[Goodies-commits] r2492 - in xfce4-mount-plugin/trunk: . panel-plugin
Fabian Nowak
timystery at xfce.org
Sun Feb 11 10:00:42 CET 2007
Author: timystery
Date: 2007-02-11 09:00:42 +0000 (Sun, 11 Feb 2007)
New Revision: 2492
Modified:
xfce4-mount-plugin/trunk/configure.ac
xfce4-mount-plugin/trunk/panel-plugin/devices.c
xfce4-mount-plugin/trunk/panel-plugin/devices.h
xfce4-mount-plugin/trunk/panel-plugin/mount-plugin.c
xfce4-mount-plugin/trunk/panel-plugin/mount-plugin.h
Log:
Beginning implementation of excluding file systems,
new options structure, eject option
Modified: xfce4-mount-plugin/trunk/configure.ac
===================================================================
--- xfce4-mount-plugin/trunk/configure.ac 2007-02-08 09:50:37 UTC (rev 2491)
+++ xfce4-mount-plugin/trunk/configure.ac 2007-02-11 09:00:42 UTC (rev 2492)
@@ -2,8 +2,8 @@
dnl
dnl xfce4-mount-plugin - Mount plugin for xfce4-panel
dnl
-dnl 2003,2004 Benedikt Meurer <benny at xfce.org>
-dnl 2005 Fabian Nowak <timystery at arcor.de>
+dnl 2003, 2004 Benedikt Meurer <benny at xfce.org>
+dnl 2005-2007 Fabian Nowak <timystery at arcor.de>
dnl
dnl for Xfce4-panel 4.3 and higher only!
Modified: xfce4-mount-plugin/trunk/panel-plugin/devices.c
===================================================================
--- xfce4-mount-plugin/trunk/panel-plugin/devices.c 2007-02-08 09:50:37 UTC (rev 2491)
+++ xfce4-mount-plugin/trunk/panel-plugin/devices.c 2007-02-11 09:00:42 UTC (rev 2492)
@@ -4,10 +4,10 @@
Copyright (C) 2005 Jean-Baptiste jb_dul at yahoo.com
Copyright (C) 2005, 2006 Fabian Nowak timystery at arcor.de.
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful,
@@ -40,13 +40,13 @@
#define MTAB "/etc/mtab"
/*-------------------- get_size_human_readable --------------------*/
-/* Return a string containing a size expressed in KB, MB or GB and the unit
+/* Return a string containing a size expressed in KB, MB or GB and the unit
* it is expressed in.
- *
+ *
* @params size: Size in bytes
* @return Formatted output, e.g. "1.5 GB"
*/
-char *
+char *
get_size_human_readable (float size)
{
if (size < KB) return g_strdup_printf (_("%.1f B"), size);
@@ -57,7 +57,7 @@
/*--------------------------------------------------------------------*/
/*-------------------------- mount_info_print --------------------------*/
-void
+void
mount_info_print(t_mount_info * mount_info)
{
if (mount_info != NULL)
@@ -74,8 +74,8 @@
/*-----------------------------------------------*/
/*------------------------- mount_info_new --------------------*/
-t_mount_info *
-mount_info_new (float size, float used, float avail,
+t_mount_info *
+mount_info_new (float size, float used, float avail,
unsigned int percent, char * type, char * mounted_on)
{
if ( type != NULL && mounted_on != NULL /* && size != 0 */ )
@@ -98,8 +98,8 @@
/* Creates a new struct t_mount_info from a struct statfs data.
*
*/
-t_mount_info *
-mount_info_new_from_stat (struct statfs * pstatfs,
+t_mount_info *
+mount_info_new_from_stat (struct statfs * pstatfs,
char * mnt_type,
char * mnt_dir)
{
@@ -110,28 +110,28 @@
float used; /* used size of device */
float avail; /* Available size of device */
unsigned int percent ; /* percentage used */
-
+
/* compute sizes in bytes */
size = (float)pstatfs->f_bsize * (float)pstatfs->f_blocks;
used = (float)pstatfs->f_bsize
* ((float)pstatfs->f_blocks - (float)pstatfs->f_bfree);
avail = (float)pstatfs->f_bsize * (float)pstatfs->f_bavail;
- percent = ((float)pstatfs->f_blocks - (float)pstatfs->f_bavail) * 100
+ percent = ((float)pstatfs->f_blocks - (float)pstatfs->f_bavail) * 100
/ (float)pstatfs->f_blocks;
-
+
/* create new t_mount_info */
- mount_info = mount_info_new (size, used, avail, percent,
+ mount_info = mount_info_new (size, used, avail, percent,
mnt_type, mnt_dir);
return mount_info;
}
return NULL;
-
+
}
/*---------------------------------------------------------*/
/*-------- free a struct t_mount_info -------------------*/
-void
+void
mount_info_free(t_mount_info * * mount_info)
{
if (*mount_info != NULL)
@@ -149,16 +149,16 @@
/*------- print a t_disk struct using printf -------------*/
-void
+void
disk_print (t_disk * pdisk)
{
if (pdisk != NULL)
{
printf (_("disk : %s\n"),pdisk->device);
printf (_("mount point : %s\n"), pdisk->mount_point);
-
+
if (pdisk->mount_info != NULL)
- mount_info_print (pdisk->mount_info);
+ mount_info_print (pdisk->mount_info);
else printf (_("not mounted\n"));
}
return;
@@ -166,7 +166,7 @@
/*----------------------------------------*/
/* create a new t_disk struct */
-t_disk *
+t_disk *
disk_new (const char * dev, const char * mp)
{
if ( dev != NULL && mp != NULL)
@@ -176,7 +176,7 @@
pdisk->device = g_strdup(dev);
pdisk->mount_point = g_strdup(mp);
pdisk->mount_info = NULL;
-
+
return pdisk ;
}
return NULL;
@@ -199,31 +199,59 @@
}
/* ----------------------------------------*/
+gchar *
+replace_placeholder (char *source, char *replacement) {
+ gchar *retval = "", *duplicate;
+ duplicate = g_strdup (source);
+ int i;
+ for (i = strlen(duplicate)-1; i >0; i--) {
+ if (duplicate[i-1]=='%' && duplicate[i]=='d')
+ {
+ duplicate[i-1]='\0';
+ retval = g_strconcat (duplicate+i+1, retval, NULL);
+ i--;
+ }
+
+ }
+ retval = g_strconcat (duplicate+i, retval, NULL);
+
+ return retval;
+}
+
/*------------ mount a t_disk ---------------*/
/* return exit status of the mount command*/
-void
-disk_mount (t_disk *pdisk, char *on_mount_cmd, char* mount_command)
+void
+disk_mount (t_disk *pdisk, char *on_mount_cmd, char* mount_command, gboolean eject)
{
+ gchar *tmp;
if (pdisk != NULL)
{
- char * cmd ;
+ gchar * cmd ;
- cmd = g_strconcat ("sh -c '", mount_command, " ",
+ tmp = replace_placeholder (mount_command, pdisk->mount_point);
+ if (eject)
+ cmd = g_strconcat ("sh -c ' eject -t ", pdisk->mount_point, " && ", tmp, " ",
pdisk->mount_point, NULL);
- if (on_mount_cmd != NULL)
- cmd = g_strconcat (cmd, " && ", on_mount_cmd, " ",
+ else
+ cmd = g_strconcat ("sh -c ' ", tmp, " ",
+ pdisk->mount_point, NULL);
+
+ if (on_mount_cmd != NULL) {
+ tmp = replace_placeholder (on_mount_cmd, pdisk->mount_point);
+ cmd = g_strconcat (cmd, " && ", tmp, " ",
pdisk->mount_point, " ' ", NULL);
+ }
else
cmd = g_strconcat (cmd, " ' ", NULL);
DBG("cmd :%s \n",cmd);
-
+
GError *error = NULL;
-
+
gboolean val = xfce_exec (cmd, FALSE, FALSE, &error);
if (!val)
xfce_err (_("Mount Plugin: Error executing command."));
-
+
g_free(cmd);
}
}
@@ -231,11 +259,12 @@
/* --------------unmount a t_disk ----------------*/
/* return exit status of the mount command*/
-int
-disk_umount (t_disk *pdisk, char* umount_command, gboolean synchronous)
+int
+disk_umount (t_disk *pdisk, char* umount_command, gboolean synchronous, gboolean eject)
{
int retval = NONE;
-
+ gchar *tmp;
+
if (pdisk != NULL)
{
GError *error = NULL;
@@ -246,24 +275,26 @@
gboolean val;
if (synchronous) {
gint filehandle = g_file_open_tmp (NULL, &tmpfile, &error);
-
+
if (filehandle==-1) {
close (filehandle);
return ERROR;
}
close (filehandle);
-
+
g_return_val_if_fail (tmpfile!=NULL, ERROR);
error = NULL;
-
+
/* changed from pdisk->device to pdisk->mount_point */
- cmd = g_strconcat ("sh -c '", umount_command, " ",
+ tmp = replace_placeholder (umount_command, pdisk->mount_point);
+ cmd = g_strconcat ("sh -c '", tmp, " ",
pdisk->mount_point, " 2>", tmpfile, " ' ", NULL);
val = xfce_exec_sync (cmd, FALSE, FALSE, &error);
}
else {
/* changed from pdisk->device to pdisk->mount_point */
- cmd = g_strconcat ("sh -c '", umount_command, " ",
+ tmp = replace_placeholder (umount_command, pdisk->mount_point);
+ cmd = g_strconcat ("sh -c '", tmp, " ",
pdisk->mount_point, " ' ", NULL);
val = xfce_exec (cmd, FALSE, FALSE, &error);
}
@@ -272,32 +303,32 @@
xfce_err (_("Mount Plugin: Error executing command."));
retval = ERROR;
}
-
+
if (!synchronous) /* already return from this function at this stage */
{
return retval;
}
-
+
/* synchronous only */
gchar *contents;
error = NULL;
g_file_get_contents (tmpfile, &contents, NULL, &error);
g_unlink (tmpfile);
g_free (tmpfile);
-
+
if (strlen( (const char*)contents )!=0)
retval = ERROR;
-
+
g_free (cmd);
g_free (contents);
}
-
+
return retval;
}
/*------------------------------------------------*/
/*------------------------- disks_new ----------------*/
-/* Fill a GPtrArray with pointers on struct t_disk containing infos on devices
+/* Fill a GPtrArray with pointers on struct t_disk containing infos on devices
* and theoretical mount point. used setfsent() and getfsent(),
* now uses setmntent() and getmntent() and enmntent().
*
@@ -305,37 +336,37 @@
*
* @return GPtrArray *pdisks containing elements to be displayed
*/
-GPtrArray *
+GPtrArray *
disks_new (gboolean include_NFSs)
{
GPtrArray * pdisks; /* to be returned */
t_disk * pdisk;
struct fstab *pfstab;
-
+
/* open fstab */
if (setfsent()!=1)
return NULL; /* on error return NULL */
-
+
pdisks = g_ptr_array_new();
-
+
for (pfstab = getfsent(); pfstab!=NULL; pfstab = getfsent()) {
/*
pfstab = getfsent(); //read a line in fstab
if (pfstab == NULL) break ; // on EOF exit loop
*/
-
+
gboolean has_valid_mount_device =
g_str_has_prefix(pfstab->fs_spec, "/dev/");
if (include_NFSs)
has_valid_mount_device = has_valid_mount_device |
- g_str_has_prefix(pfstab->fs_vfstype, "fuse") |
+ g_str_has_prefix(pfstab->fs_vfstype, "fuse") |
g_str_has_prefix(pfstab->fs_vfstype, "shfs") |
g_str_has_prefix(pfstab->fs_vfstype, "nfs") |
g_str_has_prefix(pfstab->fs_vfstype, "smbfs");
-
- if ( has_valid_mount_device &&
+
+ if ( has_valid_mount_device &&
g_str_has_prefix(pfstab->fs_file, "/") ) {
pdisk = disk_new (pfstab->fs_spec, pfstab->fs_file);
g_ptr_array_add (pdisks , pdisk);
@@ -343,7 +374,7 @@
}
} /* end for */
-
+
endfsent(); /* close file */
return pdisks;
@@ -351,7 +382,7 @@
/*--------------------- disks_free --------------------------*/
/* free a GPtrArray containing pointer on struct t_disk elements */
-void
+void
disks_free (GPtrArray ** pdisks)
{
if (*pdisks != NULL)
@@ -370,7 +401,7 @@
/*----------------------- disks_print----------------------*/
/* print a GPtrArray containing pointer on struct t_disk elements */
-void
+void
disks_print (GPtrArray * pdisks)
{
int i ;
@@ -382,18 +413,56 @@
}
+/*--------------------disks_remove_device ----------------------------*/
+/* Removes specfied device from array.
+ * Returns true on success, else false.
+ */
+gboolean
+disks_remove_device (GPtrArray * pdisks, char *device)
+{
+ int i;
+ for (i=0; i < pdisks->len ; i++)
+ {
+ if (strcmp (((t_disk *) g_ptr_array_index(pdisks, i))->device,
+ device)==0)
+ g_ptr_array_remove_index(pdisks, i);
+ }
+
+ return FALSE;
+}
+
+
+/*--------------------disks_remove_mountpoint ----------------------------*/
+/* Removes specfied mount point from array.
+ * Returns true on success, else false.
+ */
+gboolean
+disks_remove_mountpoint (GPtrArray * pdisks, char *mountp)
+{
+ int i;
+ for (i=0; i < pdisks->len ; i++)
+ {
+ if (strcmp ( ((t_disk *) g_ptr_array_index(pdisks, i))->mount_point,
+ mountp)==0)
+ g_ptr_array_remove_index(pdisks, i);
+ }
+
+ return FALSE;
+}
+
+
/*-------------------- disks_search -------------------------*/
/* CHANGE !!!!!! search on mount directory rather than device name */
-/* Returns a pointer on FIRST struct t_disk containing char * device as
+/* Returns a pointer on FIRST struct t_disk containing char * device as
* device field; if not found return NULL.
*/
-t_disk *
+t_disk *
disks_search (GPtrArray * pdisks, char * mount_point)
{
int i ;
for (i=0; i < pdisks->len ; i++)
{
- if (g_ascii_strcasecmp (
+ if (g_ascii_strcasecmp (
((t_disk *) g_ptr_array_index(pdisks, i))->mount_point,
mount_point
)==0 ) return g_ptr_array_index (pdisks, i);
@@ -402,10 +471,10 @@
}
/* -------- disks_free_mount_info ----------------*/
-/* Remove struct t_mount_info from a GPtrArray containing
+/* Remove struct t_mount_info from a GPtrArray containing
* struct t_disk * elements.
*/
-void
+void
disks_free_mount_info(GPtrArray * pdisks)
{
int i ;
@@ -419,41 +488,41 @@
/* --------------- disks_refresh ----------------------*/
-/* Refreshes t_mount_info infos in a GPtrArray containing
+/* Refreshes t_mount_info infos in a GPtrArray containing
* struct t_disk * elements.
*/
void
disks_refresh(GPtrArray * pdisks)
{
/* using getmntent to get filesystems mount information */
-
+
FILE * fmtab = NULL; /* file /etc/mtab */
struct mntent * pmntent = NULL; /* struct for mnt info */
struct statfs * pstatfs = NULL;
-
+
t_mount_info * mount_info;
t_disk * pdisk ;
-
+
/* remove t_mount_info for all devices */
disks_free_mount_info (pdisks);
-
+
/* allocate new struct statfs */
pstatfs = g_new0 (struct statfs, 1);
-
+
/* open file */
fmtab = setmntent (MTAB, "r"); /* mtab file */
-
+
/* start looking for mounted devices */
for (pmntent=getmntent(fmtab); pmntent!=NULL; pmntent=getmntent(fmtab)) {
DBG (" have entry: %s on %s \n", pmntent->mnt_fsname, pmntent->mnt_dir );
-
+
/* getstat on disk */
/* if (statfs(pmntent->mnt_dir, pstatfs)==0 && (pstatfs->f_blocks != 0)) { */
statfs(pmntent->mnt_dir, pstatfs);
-
+
/* if we got the stat and the block number is non-zero */
-
+
/* get pointer on disk from pdisks */
/* CHANGED to reflect change in disk_search */
pdisk = disks_search (pdisks, pmntent->mnt_dir);
@@ -462,9 +531,9 @@
/* create a new struct t_disk and add it to pdisks */
/* test for mnt_dir!=none or neither block device nor NFS */
if ( (g_ascii_strcasecmp(pmntent->mnt_dir, "none") == 0) ||
- !(g_str_has_prefix(pmntent->mnt_fsname, "/dev/") ||
+ !(g_str_has_prefix(pmntent->mnt_fsname, "/dev/") ||
g_str_has_prefix(pmntent->mnt_type, "fuse") ||
- g_str_has_prefix(pmntent->mnt_type, "nfs") ||
+ g_str_has_prefix(pmntent->mnt_type, "nfs") ||
g_str_has_prefix(pmntent->mnt_type, "smbfs") ||
g_str_has_prefix(pmntent->mnt_type, "shfs") )
) continue;
@@ -473,16 +542,16 @@
pdisk = disk_new (pmntent->mnt_fsname, pmntent->mnt_dir);
g_ptr_array_add (pdisks, pdisk);
}
-
- /* create new t_mount_info */
+
+ /* create new t_mount_info */
mount_info = mount_info_new_from_stat (pstatfs, pmntent->mnt_type,
pmntent->mnt_dir);
/* add it to pdisk */
pdisk->mount_info = mount_info ;
-
+
/* } */ /* if statfs */
} /* end for */
-
+
g_free (pstatfs);
endmntent (fmtab); // close file
return;
Modified: xfce4-mount-plugin/trunk/panel-plugin/devices.h
===================================================================
--- xfce4-mount-plugin/trunk/panel-plugin/devices.h 2007-02-08 09:50:37 UTC (rev 2491)
+++ xfce4-mount-plugin/trunk/panel-plugin/devices.h 2007-02-11 09:00:42 UTC (rev 2492)
@@ -2,10 +2,10 @@
/*
Copyright (C) 2005 Jean-Baptiste jb_dul at yahoo.com
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful,
@@ -49,44 +49,49 @@
/*----------------------------------------------*/
/*-------------------- get_size_human_readable --------------------*/
-/* return a string containing a size expressed in KB,MB or GB and the unit it
+/* return a string containing a size expressed in KB,MB or GB and the unit it
* is expressed in
*/
char * get_size_human_readable(float size);
-
/*------------ mount a t_disk ---------------*/
/* return exit status of the mount command
*/
-void disk_mount (t_disk *pdisk, char *on_mount_cmd, char* mount_command);
+void disk_mount (t_disk *pdisk, char *on_mount_cmd, char* mount_command, gboolean eject);
/* --------------unmount a t_disk ----------------*/
-int disk_umount (t_disk *pdisk, char* umount_command, gboolean synchronous);
+int disk_umount (t_disk *pdisk, char* umount_command, gboolean synchronous, gboolean eject);
/*------------------------- disks_new ----------------*/
-/* fill a GPtrArray with pointers on struct t_disk containing infos on devices
- * and theoretical mount point. use setfsent() and getfsent().
+/* fill a GPtrArray with pointers on struct t_disk containing infos on devices
+ * and theoretical mount point. use setfsent() and getfsent().
*/
GPtrArray * disks_new (gboolean include_NFSs) ;
/*--------------------- disks_free --------------------------*/
-/* free a GPtrArray containing pointer on struct t_disk elements
+/* free a GPtrArray containing pointer on struct t_disk elements
*/
void disks_free (GPtrArray * * pdisks);
/*----------------------- disks_print----------------------*/
-/* print a GPtrArray containing pointer on struct t_disk elements
+/* print a GPtrArray containing pointer on struct t_disk elements
*/
void disks_print (GPtrArray * pdisks);
+/* Removes specfied device from array. */
+gboolean disks_remove_device (GPtrArray * pdisks, char *device);
+
+/* Removes specfied mount point from array. */
+gboolean disks_remove_mountpoint (GPtrArray * pdisks, char *device);
+
/*-------------------- disks_search -------------------------*/
-/* return a pointer on FIRST struct t_disk containing char * device as device
+/* return a pointer on FIRST struct t_disk containing char * device as device
* field; if not found return NULL
*/
t_disk * disks_search (GPtrArray * pdisks, char * device);
/* --------------- disks_refresh ----------------------*/
-/* refresh t_mount_info infos in a GPtrArray containing
+/* refresh t_mount_info infos in a GPtrArray containing
* struct t_disk * elements
*/
void disks_refresh (GPtrArray * pdisks);
Modified: xfce4-mount-plugin/trunk/panel-plugin/mount-plugin.c
===================================================================
--- xfce4-mount-plugin/trunk/panel-plugin/mount-plugin.c 2007-02-08 09:50:37 UTC (rev 2491)
+++ xfce4-mount-plugin/trunk/panel-plugin/mount-plugin.c 2007-02-11 09:00:42 UTC (rev 2492)
@@ -4,10 +4,10 @@
Copyright (C) 2005 Jean-Baptiste jb_dul at yahoo.com
Copyright (C) 2005, 2006 Fabian Nowak timystery at arcor.de.
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful,
@@ -30,21 +30,21 @@
/*---------------- on_activate_disk_display ---------------*/
-static void
+static void
on_activate_disk_display (GtkWidget *widget, t_disk * disk)
{
TRACE ("enters on_activate_disk_display");
-
+
t_mounter * mt;
mt = (t_mounter *) g_object_get_data (G_OBJECT(widget), "mounter");
-
+
if (disk != NULL) {
if (disk->mount_info != NULL) { /* disk is mounted */
- int result = disk_umount (disk, mt->umount_command,
- mt->message_dialog);
-
+ int result = disk_umount (disk, mt->umount_command,
+ mt->message_dialog, mt->eject_drives);
+
if (mt->message_dialog) { /* popup dialog */
-
+
gchar *msg = (gchar *) g_malloc (1024*sizeof(gchar));
if (result==NONE)
msg = _("The device \"%s\" should be removable safely "
@@ -52,15 +52,15 @@
else
msg = _("An error occured. The device should not be "
"removed!");
-
+
GtkWidget *my_dlg;
- my_dlg = gtk_message_dialog_new (NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
+ my_dlg = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
msg,
disk->mount_point);
-
+
g_signal_connect (my_dlg, "response",
G_CALLBACK (on_message_dialog_response), my_dlg);
gtk_widget_show (my_dlg);
@@ -68,7 +68,7 @@
}
}
else { /* disk is not mounted */
- disk_mount (disk, mt->on_mount_cmd, mt->mount_command);
+ disk_mount (disk, mt->on_mount_cmd, mt->mount_command, mt->eject_drives);
}
}
@@ -83,62 +83,64 @@
{
/* schrink the gtk button's image to new size - */
gtk_widget_set_size_request (GTK_WIDGET(mt->button), size - 4, size - 4);
-
+
}
/*---------------------------------------------------------*/
/*-------------------- disk_display_new -----------------*/
/*create a new t_disk_display from t_disk infos */
-static t_disk_display*
+static t_disk_display*
disk_display_new (t_disk *disk, t_mounter *mounter)
{
TRACE ("enters disk_display_new");
- if (disk!=NULL)
+ if (disk!=NULL)
{
t_disk_display * dd ;
dd = g_new0 (t_disk_display, 1) ;
dd->menu_item = gtk_menu_item_new();
g_signal_connect (G_OBJECT(dd->menu_item), "activate",
G_CALLBACK(on_activate_disk_display), disk);
- g_object_set_data (G_OBJECT(dd->menu_item), "mounter",
+ g_object_set_data (G_OBJECT(dd->menu_item), "mounter",
(gpointer)mounter);
-
+
dd->hbox = gtk_hbox_new (FALSE, 10);
gtk_container_add (GTK_CONTAINER(dd->menu_item), dd->hbox);
-
+
dd->label_disk = gtk_label_new (g_strconcat(disk->device, " -> ",
disk->mount_point, NULL));
/*change to uniform label size*/
gtk_label_set_width_chars(GTK_LABEL(dd->label_disk),28);
- gtk_label_set_justify(GTK_LABEL(dd->label_disk),GTK_JUSTIFY_LEFT);
+ /* gtk_label_set_justify(GTK_LABEL(dd->label_disk),GTK_JUSTIFY_LEFT); */
+ gtk_misc_set_alignment(GTK_MISC(dd->label_disk),0.5, 0.5);
gtk_box_pack_start(GTK_BOX(dd->hbox),dd->label_disk,FALSE,TRUE,0);
-
+
dd->label_mount_info = gtk_label_new("");
/*change to uniform label size*/
gtk_label_set_width_chars(GTK_LABEL(dd->label_mount_info),25);
gtk_label_set_use_markup(GTK_LABEL(dd->label_mount_info),TRUE);
- gtk_label_set_justify (GTK_LABEL(dd->label_mount_info),
- GTK_JUSTIFY_RIGHT);
+ /* gtk_label_set_justify (GTK_LABEL(dd->label_mount_info),
+ GTK_JUSTIFY_RIGHT); */
+ gtk_misc_set_alignment(GTK_MISC(dd->label_mount_info),0.5, 0.5);
gtk_box_pack_start(GTK_BOX(dd->hbox),dd->label_mount_info,TRUE,TRUE,0);
-
+
dd->progress_bar = gtk_progress_bar_new();
gtk_box_pack_start(GTK_BOX(dd->hbox),dd->progress_bar,TRUE,TRUE,0);
-
+
return dd ;
}
-
+
TRACE ("leaves disk_display_new");
-
+
return NULL ;
}
/*-----------------------------------------------------------*/
/*-------------------- disk_display_refresh -----------------*/
-static void
-disk_display_refresh(t_disk_display * disk_display,
+static void
+disk_display_refresh(t_disk_display * disk_display,
t_mount_info * mount_info)
{
TRACE("enters disk_display_refresh");
@@ -155,15 +157,15 @@
DBG("avail is now : %s",size);
text = g_strdup_printf ("[%s/%s] %s free", used, size, avail);
DBG("text is now : %s",text);
-
+
g_free(used);
g_free(size);
g_free(avail);
/* text = g_strdup_printf("mounted on : %s\t[%g Mb/%g Mb] %g Mb free",mount_info->mounted_on, mount_info->used, mount_info->size, mount_info->avail); */
gtk_label_set_text(GTK_LABEL(disk_display->label_mount_info), text);
-
+
gtk_progress_bar_set_fraction (
- GTK_PROGRESS_BAR(disk_display->progress_bar),
+ GTK_PROGRESS_BAR(disk_display->progress_bar),
((gdouble)mount_info->percent / 100) );
gtk_progress_bar_set_text (
GTK_PROGRESS_BAR(disk_display->progress_bar),
@@ -173,7 +175,7 @@
else /* mount_info == NULL */
{
/*remove mount info */
- gtk_label_set_markup (GTK_LABEL(disk_display->label_mount_info),
+ gtk_label_set_markup (GTK_LABEL(disk_display->label_mount_info),
_("<span foreground=\"#FF0000\">not mounted</span>"));
gtk_widget_hide (GTK_WIDGET(disk_display->progress_bar));
@@ -185,37 +187,37 @@
/*--------------- mounter_data_free -----------------*/
-static void
+static void
mounter_data_free (t_mounter * mt)
{
TRACE ("enters mounter_data_free");
-
+
disks_free (&(mt->pdisks));
gtk_widget_destroy (GTK_WIDGET(mt->menu));
mt->menu = NULL;
-
+
TRACE ("leaves mounter_data_free");
}
/*----------------------------------------------*/
/*--------------- mounter_free -----------------*/
-static void
+static void
mounter_free (XfcePanelPlugin *plugin, t_mounter *mounter)
{
TRACE ("enters mounter_free");
-
+
mounter_data_free (mounter);
-
+
g_free (mounter);
-
+
TRACE ("leaves mounter_free");
}
/*----------------------------------------------*/
/*---------------- mounter_data_new --------------------------*/
-static void
+static void
mounter_data_new (t_mounter *mt)
{
TRACE ("enters mounter_data_new");
@@ -223,81 +225,93 @@
int i ;
t_disk * disk ;
t_disk_display * disk_display ;
-
+
/*get static infos from /etc/fstab */
mt->pdisks = disks_new (mt->include_NFSs);
-
+
/* get dynamic infos on mounts */
disks_refresh (mt->pdisks);
-
+
/* menu with menu_item */
mt->menu = gtk_menu_new ();
-
+
for(i=0;i < mt->pdisks->len;i++)
{
disk = g_ptr_array_index (mt->pdisks,i); /* get the disk */
disk_display = disk_display_new (disk,mt); /* creates a disk_display */
-
+
/* fill in mount infos */
- disk_display_refresh (disk_display,disk->mount_info);
-
+ disk_display_refresh (disk_display,disk->mount_info);
+
/* add the menu_item to the menu */
- gtk_menu_shell_append (GTK_MENU_SHELL(mt->menu),
- disk_display->menu_item);
+ gtk_menu_shell_append (GTK_MENU_SHELL(mt->menu),
+ disk_display->menu_item);
}
gtk_widget_show_all(mt->menu);
-
+
mt->icon = PACKAGE_DATA_DIR"/icons/hicolor/scalable/apps/xfce-mount.svg";
mt->mount_command = DEFAULT_MOUNT_COMMAND;
mt->umount_command = DEFAULT_UMOUNT_COMMAND;
-
+
+ mt->excluded_filesystems = "";
+
mt->message_dialog = FALSE;
-
+
mt->include_NFSs = FALSE;
-
+
+ mt->exclude_FSs = FALSE;
+
+ mt->eject_drives = FALSE;
+
TRACE ("leaves mounter_data_new");
-
+
return ;
}
/*------------------------------------------------------*/
/*---------------------- mounter_refresh ---------------*/
-static void
+static void
mounter_refresh (t_mounter * mt)
{
TRACE ("enters mounter_refresh");
-
+
mounter_data_free (mt);
gchar *mount = g_strdup (mt->mount_command);
gchar *umount = g_strdup (mt->umount_command);
gchar *icon = g_strdup (mt->icon);
+ gchar *excl_filesystems = g_strdup (mt->excluded_filesystems);
DBG ("Changed icon value from '%s' to '%s'.\n", mt->icon, icon);
gboolean msg_dlg = mt->message_dialog;
gboolean incl_NFSs = mt->include_NFSs;
-
+ gboolean excl_FSs = mt->exclude_FSs;
+ gboolean eject = mt->eject_drives;
+
mounter_data_new (mt);
mt->icon = g_strdup (icon);
DBG ("Changed icon value from '%s' to '%s'.\n", icon, mt->icon);
mt->mount_command = g_strdup (mount);
mt->umount_command = g_strdup (umount);
+ mt->excluded_filesystems = g_strdup (excl_filesystems);
mt->message_dialog = msg_dlg;
mt->include_NFSs = incl_NFSs;
+ mt->exclude_FSs = excl_FSs;
+ mt->eject_drives = eject;
TRACE ("leaves mounter_refresh");
-
+
}
/*---------------------------------------------------------*/
/* --------------plugin event --------------------------------*/
-static gboolean
+static gboolean
on_button_press (GtkWidget *widget, GdkEventButton *event, t_mounter *mounter)
{
TRACE ("enters on_button_press");
if (mounter != NULL && event->button == 1) /* left click only */
{
-
+
mounter_refresh (mounter); /* refreshs infos regarding mounts data */
gtk_menu_popup (GTK_MENU(mounter->menu), NULL, NULL, NULL, NULL, 0,
event->time);
@@ -314,41 +328,52 @@
mounter_read_config (XfcePanelPlugin *plugin, t_mounter *mt)
{
TRACE ("enter read_config");
-
+
const char *value;
char *file;
XfceRc *rc;
-
+
if ( !( file = xfce_panel_plugin_lookup_rc_file (plugin) ) )
return;
-
+
rc = xfce_rc_simple_open (file, TRUE);
g_free (file);
-
+
if ( value = xfce_rc_read_entry(rc, "on_mount_cmd", NULL) )
mt->on_mount_cmd = g_strdup (value);
-
+
if ( value = xfce_rc_read_entry(rc, "icon", NULL) )
mt->icon = g_strdup (value);
else
asprintf (&(mt->icon), "%s/icons/hicolor/scalable/apps/xfce-mount.svg", PACKAGE_DATA_DIR);
-
+
if ( value = xfce_rc_read_entry (rc, "mount_command", NULL) )
mt->mount_command = g_strdup (value);
else
mt->mount_command = g_strdup (DEFAULT_MOUNT_COMMAND);
-
+
if ( value = xfce_rc_read_entry (rc, "umount_command", NULL) )
mt->umount_command = g_strdup (value);
else
mt->umount_command = g_strdup (DEFAULT_UMOUNT_COMMAND);
-
+
+ if ( value = xfce_rc_read_entry (rc, "excluded_filesystems", NULL) )
+ mt->excluded_filesystems = g_strdup (value);
+ else
+ mt->excluded_filesystems = g_strdup ("");
+
if ( value = xfce_rc_read_entry(rc, "message_dialog", NULL) )
- mt->message_dialog = atoi (value);
-
+ mt->message_dialog = atoi (value);
+
if ( value = xfce_rc_read_entry(rc, "include_NFSs", NULL) )
- mt->include_NFSs= atoi (value);
-
+ mt->include_NFSs= atoi (value);
+
+ if ( value = xfce_rc_read_entry(rc, "exclude_FSs", NULL) )
+ mt->exclude_FSs= atoi (value);
+
+ if ( value = xfce_rc_read_entry(rc, "eject_drives", NULL) )
+ mt->eject_drives= atoi (value);
+
xfce_rc_close (rc);
TRACE ("leaves read_config");
@@ -361,38 +386,47 @@
mounter_write_config (XfcePanelPlugin *plugin, t_mounter *mt)
{
TRACE ("enter write_config");
-
+
XfceRc *rc;
char *file;
if (!(file = xfce_panel_plugin_save_location (plugin, TRUE)))
return;
-
+
/* int res = */ unlink (file);
-
+
rc = xfce_rc_simple_open (file, FALSE);
g_free (file);
if (!rc)
return;
- xfce_rc_write_entry (rc, "on_mount_cmd",
+ xfce_rc_write_entry (rc, "on_mount_cmd",
mt->on_mount_cmd ? mt->on_mount_cmd : "");
-
+
if ( strcmp(mt->mount_command, DEFAULT_MOUNT_COMMAND)!=0 )
xfce_rc_write_entry (rc, "mount_command", mt->mount_command);
-
- if ( strcmp(mt->umount_command, DEFAULT_UMOUNT_COMMAND)!=0 )
- xfce_rc_write_entry (rc, "umount_command", mt->umount_command);
-
- if ( mt->message_dialog==1 )
+
+ if ( strcmp(mt->umount_command, DEFAULT_UMOUNT_COMMAND)!=0 )
+ xfce_rc_write_entry (rc, "umount_command", mt->umount_command);
+
+ if ( strlen(mt->excluded_filesystems)!=0 )
+ xfce_rc_write_entry (rc, "excluded_filesystems", mt->excluded_filesystems);
+
+ if ( mt->message_dialog==1 )
xfce_rc_write_entry (rc, "message_dialog", "1");
-
- if ( mt->include_NFSs==1 )
+
+ if ( mt->include_NFSs==1 )
xfce_rc_write_entry (rc, "include_NFSs", "1");
-
+
+ if ( mt->exclude_FSs==1 )
+ xfce_rc_write_entry (rc, "exclude_FSs", "1");
+
+ if ( mt->eject_drives==1 )
+ xfce_rc_write_entry (rc, "eject_drives", "1");
+
xfce_rc_write_entry (rc, "icon", mt->icon);
-
+
xfce_rc_close (rc);
TRACE ("leaves write config");
@@ -407,37 +441,37 @@
TRACE ("enters create_mounter_control");
t_mounter *mounter;
-
+
mounter = g_new0(t_mounter,1);
/* default mount command */
mounter->on_mount_cmd = NULL;
-
+
mounter->icon = NULL;
-
+
mounter->plugin = plugin;
-
- if (!tooltips)
+
+ if (!tooltips)
{
tooltips = gtk_tooltips_new();
}
/*plugin button */
-
+
/* GdkPixbuf * pb;
- pb = gdk_pixbuf_new_from_inline (sizeof(icon_plugin), icon_plugin, FALSE,
+ pb = gdk_pixbuf_new_from_inline (sizeof(icon_plugin), icon_plugin, FALSE,
NULL); */
- /*get the data*/
+ /*get the data*/
mounter_data_new (mounter);
g_assert (mounter->icon!=NULL);
-
+
mounter->button_pb = gdk_pixbuf_new_from_file (mounter->icon, NULL);
mounter->button = xfce_iconbutton_new_from_pixbuf (mounter->button_pb);
gtk_button_set_relief (GTK_BUTTON(mounter->button), GTK_RELIEF_NONE);
- gtk_tooltips_set_tip (tooltips, GTK_WIDGET(mounter->button), _("devices"),
+ gtk_tooltips_set_tip (tooltips, GTK_WIDGET(mounter->button), _("devices"),
NULL);
g_signal_connect (G_OBJECT(mounter->button), "button_press_event",
@@ -451,7 +485,7 @@
/*---------- free_mounter_dialog ---------------------*/
-static void
+static void
free_mounter_dialog(GtkWidget * widget, t_mounter_dialog * md)
{
g_free(md);
@@ -461,7 +495,7 @@
/*---------------- mounter_apply_options ---------------*/
static void
-mounter_apply_options (t_mounter_dialog *md)
+mounter_apply_options (t_mounter_dialog *md)
{
TRACE ("enters mounter_apply_options");
@@ -469,75 +503,86 @@
const char * tmp;
tmp = gtk_entry_get_text (GTK_ENTRY(md->string_cmd));
-
+
gboolean incl_NFSs = mt->include_NFSs;
-
+ gboolean excl_FSs = mt->exclude_FSs;
+
g_free (mt->on_mount_cmd);
if (tmp && *tmp)
mt->on_mount_cmd = g_strdup (tmp);
else
mt->on_mount_cmd = NULL;
- if ( gtk_toggle_button_get_active
+ if ( gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON(md->specify_commands)) ) {
- mt->mount_command = g_strdup ( gtk_entry_get_text
+ mt->mount_command = g_strdup ( gtk_entry_get_text
(GTK_ENTRY(md->string_mount_command)) );
- mt->umount_command = g_strdup ( gtk_entry_get_text
- (GTK_ENTRY(md->string_umount_command)) );
+ mt->umount_command = g_strdup ( gtk_entry_get_text
+ (GTK_ENTRY(md->string_umount_command)) );
}
else {
- mt->mount_command = g_strdup ( DEFAULT_MOUNT_COMMAND );
+ mt->mount_command = g_strdup ( DEFAULT_MOUNT_COMMAND );
mt->umount_command = g_strdup ( DEFAULT_UMOUNT_COMMAND );
}
-
- mt->message_dialog = gtk_toggle_button_get_active
+
+ mt->excluded_filesystems = g_strdup ( gtk_entry_get_text
+ (GTK_ENTRY(md->string_excluded_filesystems)) );
+
+ mt->message_dialog = gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON(md->show_message_dialog));
-
- mt->include_NFSs = gtk_toggle_button_get_active
+
+ mt->include_NFSs = gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON(md->show_include_NFSs));
-
- if (mt->include_NFSs!=incl_NFSs) {
+
+ mt->eject_drives = gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(md->show_eject_drives));
+
+ mt->exclude_FSs = gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON(md->show_exclude_FSs));
+
+ if (mt->include_NFSs!=incl_NFSs || mt->exclude_FSs!=excl_FSs
+ || !strlen(mt->excluded_filesystems)==0) {
/* re-read disk information */
mounter_refresh (mt);
}
-
+
if ( gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(md->string_icon))
!=NULL )
mt->icon = g_strdup( gtk_file_chooser_get_filename (
GTK_FILE_CHOOSER(md->string_icon)) );
else
- asprintf (&(mt->icon),
+ asprintf (&(mt->icon),
"%s/icons/hicolor/scalable/apps/xfce-mount.svg",
PACKAGE_DATA_DIR);
mt->button_pb = gdk_pixbuf_new_from_file (mt->icon, NULL);
xfce_iconbutton_set_pixbuf (XFCE_ICONBUTTON(mt->button), mt->button_pb);
-
+
TRACE ("leaves mounter_apply_options");
}
/*-------------------- on_options_dialog_response --------------------- */
-static void
+static void
on_optionsDialog_response (GtkWidget *dlg, int response, t_mounter_dialog * md)
{
TRACE ("enters on_optionsDialog_response");
-
+
mounter_apply_options (md);
gtk_widget_destroy (md->dialog);
-
+
xfce_panel_plugin_unblock_menu (md->mt->plugin);
-
+
mounter_write_config (md->mt->plugin, md->mt);
-
+
TRACE ("leaves on_optionsDialog_response");
}
/*------------------------------------------------------*/
/*-------------- entry_lost_focus -----------------------*/
-/* This shows a way to update plugin settings when the user leaves a text
+/* This shows a way to update plugin settings when the user leaves a text
* entry, by connecting to the "focus-out" event on the entry.
*/
static gboolean
@@ -552,18 +597,36 @@
static gboolean
-specify_command_toggled (GtkWidget *widget, t_mounter_dialog *md) {
-
- gboolean is_active = gtk_toggle_button_get_active
+specify_command_toggled (GtkWidget *widget, t_mounter_dialog *md)
+{
+ gboolean is_active = gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (widget));
gtk_widget_set_sensitive ( md->box_mount_commands, is_active );
return TRUE;
}
+static gboolean
+exlude_FSs_toggled (GtkWidget *widget, t_mounter_dialog *md)
+{
+ gboolean is_active = gtk_toggle_button_get_active
+ (GTK_TOGGLE_BUTTON (widget));
+ gtk_widget_set_sensitive ( md->string_excluded_filesystems, is_active );
+ return TRUE;
+}
+
+/*
+static gboolean
+on_iconLabel_activated (GtkWidget *widget, t_mounter_dialog *md)
+{
+ gtk_widget_grab_focus (md->string_icon);
+ return TRUE;
+}
+*/
+
/*----------------- mounter_create_options -------------*/
-static void
+static void
mounter_create_options (XfcePanelPlugin *plugin, t_mounter *mt)
{
@@ -572,18 +635,18 @@
xfce_panel_plugin_block_menu (plugin);
GtkWidget *dlg, *header;
- dlg = gtk_dialog_new_with_buttons (_("Edit Properties"),
+ dlg = gtk_dialog_new_with_buttons (_("Edit Properties"),
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))),
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL);
-
+
gtk_container_set_border_width (GTK_CONTAINER (dlg), 2);
header = xfce_create_header (NULL, _("Mount devices"));
gtk_widget_set_size_request (GTK_BIN (header)->child, -1, 32);
gtk_container_set_border_width (GTK_CONTAINER (header), BORDER - 2);
gtk_widget_show (header);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), header, FALSE,
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), header, FALSE,
TRUE, 0);
GtkWidget *vbox, *label;
@@ -599,117 +662,169 @@
vbox = GTK_DIALOG (dlg)->vbox; /* gtk_vbox_new (FALSE, BORDER); */
/* gtk_widget_show (vbox);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), GTK_WIDGET (vbox),
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), GTK_WIDGET (vbox),
TRUE, TRUE, 0); */
- /* "local" variables */
+ /* "local" variables */
GtkWidget *_eventbox;
- GtkWidget *_frame;
GtkWidget *_label;
- GtkWidget *_vbox2;
+ GtkWidget *_vbox, *_vbox2;
GtkWidget *_hbox;
GtkTooltips *tip;
- GtkWidget *_innervbox;
+ GtkWidget *_notebook;
+
+ _notebook = gtk_notebook_new ();
+ gtk_widget_show (_notebook);
+ gtk_container_border_width (GTK_CONTAINER(_notebook), BORDER);
+ gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET(_notebook),
+ TRUE, TRUE, BORDER);
+
+ tip = gtk_tooltips_new ();
+ gtk_tooltips_enable (tip);
+
+ /* --------------- General tab page ----------------------*/
+ _vbox = gtk_vbox_new (FALSE, BORDER);
+ gtk_container_border_width (GTK_CONTAINER(_vbox), BORDER);
+ gtk_widget_show (_vbox);
+
+ /* Show "unmounted" message */
_eventbox = gtk_event_box_new ();
- _frame = gtk_frame_new (_("Commands"));
- _label = gtk_label_new ("");
- _vbox2 = gtk_vbox_new (FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER(_vbox2), BORDER<<1);
+ gtk_box_pack_start (GTK_BOX (_vbox), GTK_WIDGET(_eventbox),
+ FALSE, FALSE, 0);
+ gtk_widget_show (_eventbox);
+ gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
+ _("This is only useful and recommended if you specify \"sync\" as part "
+ "of the \"unmount\" command string."),
+ NULL );
- gtk_box_pack_start (GTK_BOX (_vbox2), GTK_WIDGET(_eventbox),
+ md->show_message_dialog = gtk_check_button_new_with_mnemonic (
+ _("Show _message after unmount") );
+ gtk_widget_show (md->show_message_dialog);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(md->show_message_dialog),
+ mt->message_dialog);
+ gtk_container_add (GTK_CONTAINER (_eventbox), md->show_message_dialog );
+
+ /* Symbol chooser */
+ _eventbox = gtk_event_box_new ();
+ gtk_box_pack_start (GTK_BOX (_vbox), GTK_WIDGET(_eventbox),
FALSE, FALSE, 0);
gtk_widget_show (_eventbox);
+ gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
+ _("You can specify a distinct icon to be displayed in the panel."),
+ NULL );
+ _hbox = gtk_hbox_new (FALSE, BORDER);
+ gtk_widget_show (_hbox);
+ gtk_container_add (GTK_CONTAINER(_eventbox), _hbox );
+
+ _label = gtk_label_new_with_mnemonic (_("Icon:"));
+ /* g_signal_connect(_label, "mnemonic-activate", G_CALLBACK(on_iconLabel_activated), md); */
gtk_widget_show (_label);
+ gtk_box_pack_start (GTK_BOX(_hbox), _label, FALSE, FALSE, 0);
- gtk_widget_show (_vbox2);
- gtk_container_add(GTK_CONTAINER(_frame), _vbox2);
+ md->string_icon = gtk_file_chooser_button_new (_("Select an image"),
+ GTK_FILE_CHOOSER_ACTION_OPEN);
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER(md->string_icon),
+ mt->icon);
+ gtk_widget_show (md->string_icon);
+ gtk_box_pack_start (GTK_BOX(_hbox), md->string_icon, TRUE, TRUE, 0);
- gtk_label_set_markup (GTK_LABEL(_label), _("<b>Commands</b>"));
- gtk_frame_set_label_widget (GTK_FRAME(_frame), _label);
+ _label = gtk_label_new_with_mnemonic ("_General");
+ gtk_widget_show (_label);
+ gtk_notebook_append_page (GTK_NOTEBOOK(_notebook), _vbox, _label);
- gtk_frame_set_shadow_type (GTK_FRAME(_frame), GTK_SHADOW_NONE);
- gtk_widget_show (_frame);
- gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET(_frame),
- FALSE, FALSE, BORDER);
+ /* --------------- Commands tab page ----------------------*/
+ _vbox = gtk_vbox_new (FALSE, BORDER);
+ gtk_container_border_width (GTK_CONTAINER(_vbox), BORDER);
+ gtk_widget_show (_vbox);
- _hbox = gtk_hbox_new (FALSE, 0);
+ /* After-mount command */
+ _eventbox = gtk_event_box_new ();
+ gtk_box_pack_start (GTK_BOX (_vbox), GTK_WIDGET(_eventbox),
+ FALSE, FALSE, 0);
+ gtk_widget_show (_eventbox);
+ gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
+ _("This command will be executed after mounting the device with the "
+ "mount point of the device as argument.\n"
+ "If you are unsure what to insert, try \"thunar\".\n"
+ "'\%d' can be used to specify the device."),
+ NULL);
+
+ _hbox = gtk_hbox_new (FALSE, BORDER);
gtk_widget_show (_hbox);
gtk_container_add (GTK_CONTAINER (_eventbox), _hbox);
- _label = gtk_label_new (_("Execute after mounting:"));
+ _label = gtk_label_new_with_mnemonic (_("_Execute after mounting:"));
gtk_widget_show (_label);
gtk_box_pack_start (GTK_BOX (_hbox), _label, FALSE, FALSE, 0);
- tip = gtk_tooltips_new ();
- gtk_tooltips_enable (tip);
- gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
- _("This command will be executed after mounting the device with the "
- "mount point of the device as argument.\n"
- "If you are unsure what to insert, try \"xffm\" or \"rox\" or "
- "\"thunar\"."),
- NULL);
-
md->string_cmd = gtk_entry_new ();
if (mt->on_mount_cmd != NULL)
- gtk_entry_set_text (GTK_ENTRY(md->string_cmd),
+ gtk_entry_set_text (GTK_ENTRY(md->string_cmd),
g_strdup(mt->on_mount_cmd));
gtk_entry_set_width_chars (GTK_ENTRY(md->string_cmd), 15);
gtk_widget_show (md->string_cmd);
- gtk_box_pack_start (GTK_BOX(_hbox), md->string_cmd, TRUE, TRUE, BORDER);
+ gtk_box_pack_start (GTK_BOX(_hbox), md->string_cmd, TRUE, TRUE, 0);
- _innervbox = gtk_vbox_new (FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (_innervbox), 0);
- gtk_widget_show (_innervbox);
- gtk_box_pack_start (GTK_BOX (_vbox2), GTK_WIDGET (_innervbox), FALSE, FALSE,
- BORDER);
+ /* Specify custom commands */
+ _vbox2 = gtk_vbox_new (FALSE, BORDER);
+ gtk_box_pack_start (GTK_BOX (_vbox), GTK_WIDGET (_vbox2), FALSE, FALSE,
+ 0);
+ gtk_widget_show (_vbox2);
_eventbox = gtk_event_box_new ();
+ gtk_box_pack_start (GTK_BOX (_vbox2), GTK_WIDGET (_eventbox), FALSE,
+ FALSE, 0);
gtk_widget_show (_eventbox);
- gtk_box_pack_start (GTK_BOX (_innervbox), GTK_WIDGET (_eventbox), FALSE,
- FALSE, 0);
+ gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
+ _("WARNING: These options are for experts only! If you do not know "
+ "what they may be good for, keep your hands off!"),
+ NULL );
- md->specify_commands = gtk_check_button_new_with_label (
- _("Specify own commands") );
-
- gboolean set_active =
- ( strcmp(mt->mount_command, DEFAULT_MOUNT_COMMAND)!=0 ||
- strcmp(mt->umount_command, DEFAULT_UMOUNT_COMMAND)!=0 ) ?
+ md->specify_commands = gtk_check_button_new_with_mnemonic (
+ _("_Custom commands") );
+ gboolean set_active =
+ ( strcmp(mt->mount_command, DEFAULT_MOUNT_COMMAND)!=0 ||
+ strcmp(mt->umount_command, DEFAULT_UMOUNT_COMMAND)!=0 ) ?
TRUE : FALSE;
-
+
gtk_widget_show (md->specify_commands);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(md->specify_commands),
+ set_active);
+ g_signal_connect ( G_OBJECT(md->specify_commands), "toggled",
+ G_CALLBACK(specify_command_toggled), md);
gtk_container_add (GTK_CONTAINER (_eventbox), md->specify_commands );
- gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
- _("WARNING: These options are for experts only! If you do not know "
- "what they may be good for, keep your hands off!"),
- NULL );
-
+ /* Custom commands */
_eventbox = gtk_event_box_new ();
+ gtk_box_pack_start (GTK_BOX (_vbox2), GTK_WIDGET (_eventbox), FALSE,
+ FALSE, 0);
gtk_widget_show (_eventbox);
- gtk_box_pack_start (GTK_BOX (_innervbox), GTK_WIDGET (_eventbox), FALSE,
- FALSE, 0);
+ gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
+ _("Most users will only want to prepend \"sudo\" to both "
+ "commands or prepend \"sync \%d &&\" to the \"unmount\" command.\n"
+ "'\%d' can be used to specify the device."),
+ NULL );
md->box_mount_commands = gtk_table_new (2, 2, FALSE);
+ gtk_container_add (GTK_CONTAINER (_eventbox), md->box_mount_commands);
gtk_widget_show (md->box_mount_commands);
- gtk_container_add (GTK_CONTAINER (_eventbox), md->box_mount_commands);
- _label = gtk_label_new (_("Mount command:"));
+ _label = gtk_label_new_with_mnemonic (_("_Mount command:"));
gtk_misc_set_alignment (GTK_MISC(_label), 0.0, 0.5);
gtk_widget_show (_label);
- gtk_table_attach (GTK_TABLE(md->box_mount_commands), _label, 0, 1, 0, 1,
+ gtk_table_attach (GTK_TABLE(md->box_mount_commands), _label, 0, 1, 0, 1,
GTK_FILL, GTK_SHRINK, 0, 0);
-
- _label = gtk_label_new (_("Unmount command:"));
+ _label = gtk_label_new_with_mnemonic (_("_Unmount command:"));
gtk_misc_set_alignment (GTK_MISC(_label), 0.0, 0.5);
gtk_widget_show (_label);
- gtk_table_attach (GTK_TABLE(md->box_mount_commands), _label, 0, 1, 1, 2,
+ gtk_table_attach (GTK_TABLE(md->box_mount_commands), _label, 0, 1, 1, 2,
GTK_FILL, GTK_SHRINK, 0, 0);
-
+
md->string_mount_command = gtk_entry_new ();
- gtk_entry_set_text (GTK_ENTRY(md->string_mount_command ),
+ gtk_entry_set_text (GTK_ENTRY(md->string_mount_command ),
g_strdup(mt->mount_command ));
gtk_widget_show (md->string_mount_command );
gtk_table_attach (GTK_TABLE(md->box_mount_commands),
@@ -717,122 +832,111 @@
0, 1, GTK_EXPAND|GTK_FILL, GTK_SHRINK, BORDER, 0);
md->string_umount_command = gtk_entry_new ();
- gtk_entry_set_text (GTK_ENTRY(md->string_umount_command ),
+ gtk_entry_set_text (GTK_ENTRY(md->string_umount_command ),
g_strdup(mt->umount_command ));
gtk_widget_show (md->string_umount_command );
- gtk_table_attach (GTK_TABLE(md->box_mount_commands),
+ gtk_table_attach (GTK_TABLE(md->box_mount_commands),
md->string_umount_command , 1, 2,
1, 2, GTK_EXPAND|GTK_FILL, GTK_SHRINK, BORDER, 0);
- gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
- _("Most users will only want to prepend \"sudo\" to both "
- "commands or prepend \"sync &&\" to the \"unmount\" command."),
- NULL );
-
- /* g_signal_connect_swapped (md->string_cmd, "focus-out-event",
- G_CALLBACK(entry_lost_focus), md); */
-
- g_signal_connect ( G_OBJECT(md->specify_commands), "toggled",
- G_CALLBACK(specify_command_toggled), md);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(md->specify_commands),
- set_active);
if (!set_active) /* following command wasn't executed by signal handler! */
gtk_widget_set_sensitive ( md->box_mount_commands, FALSE );
-
-
- /* show message-dialog stuff */
- _label = gtk_label_new("");
- gtk_label_set_markup (GTK_LABEL(_label), _("<b>General</b>"));
- gtk_widget_show(_label);
- _frame = gtk_frame_new (_("General"));
- gtk_frame_set_label_widget (GTK_FRAME(_frame), _label);
- gtk_frame_set_shadow_type (GTK_FRAME(_frame), GTK_SHADOW_NONE);
- gtk_widget_show(_frame);
- gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (_frame),
- FALSE, FALSE, BORDER);
+ _label = gtk_label_new_with_mnemonic ("_Commands");
+ gtk_widget_show (_label);
+ gtk_notebook_append_page (GTK_NOTEBOOK(_notebook), _vbox, _label);
- _vbox2 = gtk_vbox_new (FALSE, 0);
- gtk_widget_show (_vbox2);
- gtk_container_set_border_width (GTK_CONTAINER (_vbox2), BORDER<<1);
- gtk_container_add (GTK_CONTAINER(_frame), GTK_WIDGET(_vbox2));
+ /* File systems tab page */
+ _vbox = gtk_vbox_new (FALSE, BORDER);
+ gtk_container_border_width (GTK_CONTAINER(_vbox), BORDER);
+ gtk_widget_show (_vbox);
+ /* show include_NFSs */
_eventbox = gtk_event_box_new ();
+ gtk_box_pack_start (GTK_BOX (_vbox), GTK_WIDGET(_eventbox),
+ FALSE, FALSE, 0);
gtk_widget_show (_eventbox);
- gtk_box_pack_start(GTK_BOX(_vbox2), GTK_WIDGET(_eventbox), FALSE, FALSE, 0);
+ gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
+ _("Activate this option to also display network file systems like "
+ "NFS, SMBFS, SHFS and SSHFS."),
+ NULL );
- md->show_message_dialog = gtk_check_button_new_with_label (
- _("Show message after unmount") );
- gtk_widget_show (md->show_message_dialog);
- gtk_container_add (GTK_CONTAINER (_eventbox), md->show_message_dialog );
+ md->show_include_NFSs = gtk_check_button_new_with_mnemonic (
+ _("Display _network file systems") );
- gtk_widget_show (md->show_message_dialog);
- gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
- _("This is only useful and recommended if you specify \"sync\" as part "
- "of the \"unmount\" command string."),
- NULL );
+ gtk_widget_show (md->show_include_NFSs);
+ gtk_container_add (GTK_CONTAINER (_eventbox), md->show_include_NFSs );
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(md->show_include_NFSs),
+ mt->include_NFSs);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(md->show_message_dialog),
- mt->message_dialog);
-
- /* show include_NFSs */
+ /* eject CD-drives */
_eventbox = gtk_event_box_new ();
+ gtk_box_pack_start (GTK_BOX (_vbox), GTK_WIDGET(_eventbox),
+ FALSE, FALSE, 0);
gtk_widget_show (_eventbox);
- gtk_box_pack_start (GTK_BOX (_vbox2), GTK_WIDGET (_eventbox),
- FALSE, FALSE, 0);
- md->show_include_NFSs = gtk_check_button_new_with_label (
- _("Also display network file systems") );
- gtk_widget_show (md->show_message_dialog);
- gtk_container_add (GTK_CONTAINER (_eventbox), md->show_include_NFSs );
+ gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
+ _("Activate this option to also eject a CD-drive after unmounting"
+ " and to insert before mounting."),
+ NULL );
- gtk_widget_show (md->show_include_NFSs);
- gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
- _("Activate this option to also display network file systems like "
- "NFS, SMBFS, SHFS and SSHFS."),
- NULL );
+ md->show_eject_drives = gtk_check_button_new_with_mnemonic (
+ _("_Eject CD-drives") );
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(md->show_include_NFSs),
- mt->include_NFSs);
+ gtk_widget_show (md->show_eject_drives);
+ gtk_container_add (GTK_CONTAINER (_eventbox), md->show_eject_drives );
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(md->show_eject_drives),
+ mt->eject_drives);
- /* Icon */
+ /* Exclude file systems */
_eventbox = gtk_event_box_new ();
+ gtk_box_pack_start (GTK_BOX (_vbox), GTK_WIDGET(_eventbox),
+ FALSE, FALSE, 0);
gtk_widget_show (_eventbox);
- gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
- _("You can specify a distinct icon to be displayed in the panel."),
+ gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
+ _("Exclude the following file systems from the menu.\n"
+ "The list is separated by simple spaces.\n"
+ "It is up to you to specify correct devices or mount points."),
NULL );
-
- _hbox = gtk_hbox_new (FALSE, 0);
- gtk_widget_show (_hbox);
- gtk_box_pack_start (GTK_BOX (_vbox2), GTK_WIDGET (_hbox), FALSE, FALSE, 0);
-
- _label = gtk_label_new (_("Icon:"));
- gtk_widget_show (_label);
- gtk_box_pack_start (GTK_BOX (_hbox), _label, FALSE, FALSE, 0);
- md->string_icon = gtk_file_chooser_button_new (_("Select an image"),
- GTK_FILE_CHOOSER_ACTION_OPEN);
- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER(md->string_icon),
- mt->icon);
- gtk_widget_show (md->string_icon);
- gtk_container_add (GTK_CONTAINER (_eventbox), GTK_WIDGET(md->string_icon) );
- gtk_box_pack_start (GTK_BOX(_hbox), _eventbox, TRUE, TRUE, BORDER);
-
+ _vbox2 = gtk_vbox_new (FALSE, BORDER);
+ gtk_widget_show (_vbox2);
+ gtk_container_add (GTK_CONTAINER (_eventbox), _vbox2 );
+
+ md->show_exclude_FSs = gtk_check_button_new_with_mnemonic (
+ _("E_xclude specified file systems") );
+ gtk_widget_show (md->show_exclude_FSs);
+ gtk_box_pack_start (GTK_BOX(_vbox2), md->show_exclude_FSs, FALSE, FALSE, 0);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(md->show_exclude_FSs),
+ mt->exclude_FSs);
+ g_signal_connect ( G_OBJECT(md->show_exclude_FSs), "toggled",
+ G_CALLBACK(exlude_FSs_toggled), md);
+
+ md->string_excluded_filesystems = gtk_entry_new ();
+ if (!mt->exclude_FSs)
+ gtk_widget_set_sensitive (md->string_excluded_filesystems, FALSE);
+ gtk_entry_set_text (GTK_ENTRY(md->string_excluded_filesystems), mt->excluded_filesystems);
+ gtk_widget_show(md->string_excluded_filesystems);
+ gtk_box_pack_start (GTK_BOX(_vbox2), md->string_excluded_filesystems, TRUE, TRUE, 0);
+
+ _label = gtk_label_new_with_mnemonic ("_File sytems");
+ gtk_widget_show(_label);
+ gtk_notebook_append_page (GTK_NOTEBOOK(_notebook), _vbox, _label);
+
g_signal_connect (dlg, "response",
G_CALLBACK(on_optionsDialog_response), md);
gtk_widget_show (dlg);
- TRACE ("enters mounter_create_options");
+ TRACE ("leaves mounter_create_options");
}
/*----------------------------------------------------*/
/* extensions for panel 4.4 */
-static void
+static void
mount_construct (XfcePanelPlugin *plugin)
-{
+{
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
t_mounter *mounter;
@@ -840,30 +944,30 @@
mounter = create_mounter_control (plugin);
mounter_read_config (plugin, mounter);
-
+
mounter->button_pb = gdk_pixbuf_new_from_file (mounter->icon, NULL);
- xfce_iconbutton_set_pixbuf (XFCE_ICONBUTTON(mounter->button),
+ xfce_iconbutton_set_pixbuf (XFCE_ICONBUTTON(mounter->button),
mounter->button_pb);
-
+
g_signal_connect (plugin, "free-data", G_CALLBACK (mounter_free), mounter);
-
+
g_signal_connect (plugin, "save", G_CALLBACK (mounter_write_config),
mounter);
-
+
xfce_panel_plugin_menu_show_configure (plugin);
- g_signal_connect (plugin, "configure-plugin",
+ g_signal_connect (plugin, "configure-plugin",
G_CALLBACK (mounter_create_options), mounter);
-
- g_signal_connect (plugin, "size-changed", G_CALLBACK (mounter_set_size),
+
+ g_signal_connect (plugin, "size-changed", G_CALLBACK (mounter_set_size),
mounter);
-
- /* g_signal_connect (plugin, "orientation-changed",
+
+ /* g_signal_connect (plugin, "orientation-changed",
G_CALLBACK (monitor_set_orientation), mounter); */
-
+
gtk_container_add (GTK_CONTAINER(plugin), mounter->button);
xfce_panel_plugin_add_action_widget (plugin, mounter->button);
-
+
}
XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (mount_construct);
Modified: xfce4-mount-plugin/trunk/panel-plugin/mount-plugin.h
===================================================================
--- xfce4-mount-plugin/trunk/panel-plugin/mount-plugin.h 2007-02-08 09:50:37 UTC (rev 2491)
+++ xfce4-mount-plugin/trunk/panel-plugin/mount-plugin.h 2007-02-11 09:00:42 UTC (rev 2492)
@@ -4,10 +4,10 @@
Copyright (C) 2005 Jean-Baptiste jb_dul at yahoo.com
Copyright (C) 2005, 2006 Fabian Nowak timystery at arcor.de.
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful,
@@ -27,11 +27,11 @@
#include <config.h>
#endif
-/*
+
#define DEBUG 1
#define DEBUG_TRACE 1
-*/
+
#include <gtk/gtk.h>
#include <libxfce4panel/xfce-panel-plugin.h>
#include <libxfce4util/libxfce4util.h>
@@ -54,15 +54,18 @@
static GtkTooltips *tooltips = NULL;
/*--------- graphical interface ----------*/
-typedef struct
+typedef struct
{
XfcePanelPlugin *plugin;
char *on_mount_cmd;
gchar *mount_command;
gchar *umount_command;
gchar *icon;
+ gchar *excluded_filesystems;
gboolean message_dialog; /* whether to show (un)success after umount */
gboolean include_NFSs; /* whether to also display network file systems */
+ gboolean exclude_FSs;
+ gboolean eject_drives;
GtkWidget *button;
GdkPixbuf *button_pb;
GtkWidget *menu;
@@ -95,6 +98,9 @@
GtkWidget *string_umount_command;
GtkWidget *show_message_dialog;
GtkWidget *show_include_NFSs;
+ GtkWidget *show_exclude_FSs;
+ GtkWidget *show_eject_drives;
+ GtkWidget *string_excluded_filesystems;
}
t_mounter_dialog;
/*------------------------------------------------------*/
More information about the Goodies-commits
mailing list