Updating branch refs/heads/master to dedb40d54cc09bf9bd0635ee968db5caa047d6df (commit) from a5a57fd35316572d645587218a6f70ab01e8cddc (commit)
commit dedb40d54cc09bf9bd0635ee968db5caa047d6df Author: Fabian <timyst...@arcor.de> Date: Sun May 13 22:14:41 2012 +0200 extend menu to trim characters configure.ac.in | 4 +- panel-plugin/devices.c | 14 +++++++---- panel-plugin/mount-plugin.c | 53 +++++++++++++++++++++++++++++++++++++++++- panel-plugin/mount-plugin.h | 4 +++ 4 files changed, 66 insertions(+), 9 deletions(-) diff --git a/configure.ac.in b/configure.ac.in index a841703..3219836 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -11,12 +11,12 @@ dnl for Xfce4-panel 4.8 and higher only! m4_define([mount_version_major], [0]) m4_define([mount_version_minor], [6]) m4_define([mount_version_micro], [3]) -m4_define([mount_version_tag], []) # Leave empty for releases +m4_define([mount_version_tag], [git]) # Leave empty only for releases, but use 'git' in most cases m4_define([mount_version_build], [@REVISION@]) m4_define([mount_version], [mount_version_major().mount_version_minor().mount_version_micro()ifelse(mount_version_tag(), [], [], [mount_version_tag()-mount_version_build()])]) AC_INIT([xfce4-mount-plugin], [mount_version], - [timyst...@arcor.de]) + [timyst...@arcor.de]) MOUNT_VERSION=mount_version() AM_INIT_AUTOMAKE([xfce4-mount-plugin], [$MOUNT_VERSION]) diff --git a/panel-plugin/devices.c b/panel-plugin/devices.c index f29acda..0e436df 100644 --- a/panel-plugin/devices.c +++ b/panel-plugin/devices.c @@ -180,14 +180,18 @@ disk_print (t_disk * pdisk) } char * -shorten_disk_name (const char *dev) +shorten_disk_name (const char *dev, int len) { - char *r, *lastchars; - if (strncmp(dev, "UUID", 4)==0 && strlen(dev)>13) + char *r, *lastchars, *firstchars; + //if (strncmp(dev, "UUID", 4)==0 && + if (strlen(dev)>len) { + // we want at least 5 characters at the end so that trimmed UUIDs are still readable lastchars = (char *) (dev + strlen(dev) - 5); - r = (char *) malloc (14*sizeof(char)); - snprintf (r, 14, "UUID=...%s", lastchars); + firstchars = (char *) malloc (len-5*sizeof(char)); + snprintf(firstchars, len-5, dev); + r = (char *) malloc (len*sizeof(char)); + snprintf (r, len, "%s…%s", firstchars, lastchars); } else r = g_strdup (dev); diff --git a/panel-plugin/mount-plugin.c b/panel-plugin/mount-plugin.c index 894ebf4..036edd4 100644 --- a/panel-plugin/mount-plugin.c +++ b/panel-plugin/mount-plugin.c @@ -461,6 +461,8 @@ create_mounter_control (XfcePanelPlugin *plugin) mounter->umount_command = g_strdup(DEFAULT_UMOUNT_COMMAND); mounter->on_mount_cmd = g_strdup(""); mounter->excluded_filesystems = g_strdup(""); + mounter->trim_devicenames = TRUE; + mounter->trim_devicename_count = 14; mounter->message_dialog = FALSE; mounter->include_NFSs = FALSE; mounter->exclude_FSs = FALSE; @@ -550,6 +552,12 @@ mounter_apply_options (t_mounter_dialog *md) mt->exclude_devicenames = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(md->show_exclude_devicenames)); + + mt->trim_devicenames = gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON(md->show_trim_devicenames)); + + mt->trim_devicename_count = gtk_spin_button_get_value_as_int + (GTK_SPIN_BUTTON(md->spin_trim_devicename_count)); if (mt->include_NFSs!=incl_NFSs || mt->exclude_FSs!=excl_FSs || strlen(mt->excluded_filesystems)!=0) { @@ -641,6 +649,17 @@ exclude_devicenames_toggled (GtkWidget *widget, t_mounter_dialog *md) return TRUE; }*/ +static gboolean +trim_devicenames_toggled (GtkWidget *widget, t_mounter_dialog *md) +{ + gboolean val; + + val = gtk_check_button_get_active(GTK_CHECK_BUTTON(widget)); + gtk_widget_set_sensitive(GTK_WIDGET(md->show_trim_devicenames), !val); + + return TRUE; +} + static void mounter_create_options (XfcePanelPlugin *plugin, t_mounter *mt) { @@ -910,7 +929,36 @@ mounter_create_options (XfcePanelPlugin *plugin, t_mounter *mt) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(md->show_exclude_devicenames), mt->exclude_devicenames); - + /* Trim device names */ + _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, + _("Trim the device names to the number of characters specified in the spin button."), + NULL ); + _hbox = gtk_hbox_new (FALSE, BORDER); + gtk_widget_show (_hbox); + gtk_container_add (GTK_CONTAINER (_eventbox), _hbox ); + gtk_widget_set_sensitive(GTK_WIDGET(_hbox), !mt->exclude_devicenames); + md->show_trim_devicenames = gtk_check_button_new_with_mnemonic ( + _("Trim device names: ") ); + gtk_widget_show (md->show_trim_devicenames); + gtk_box_pack_start (GTK_BOX (_hbox), GTK_WIDGET(md->show_trim_devicenames), + FALSE, FALSE, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(md->show_trim_devicenames), + mt->trim_devicenames); + + _label = gtk_label_new(_(" characters")); + gtk_widget_show (_label); + gtk_box_pack_end (GTK_BOX (_hbox), GTK_WIDGET(_label), + FALSE, FALSE, 0); + md->spin_trim_devicename_count = gtk_spin_button_new_with_range (5.0, 99.0, 1.0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(md->spin_trim_devicename_count), (double) mt->trim_devicename_count); + gtk_widget_show (md->spin_trim_devicename_count); + gtk_box_pack_end (GTK_BOX (_hbox), GTK_WIDGET(md->spin_trim_devicename_count), + FALSE, FALSE, 0); + /* Exclude file systems */ _eventbox = gtk_event_box_new (); @@ -961,7 +1009,7 @@ mounter_show_about(XfcePanelPlugin *plugin, t_mounter *mt) GdkPixbuf *icon; const gchar *auth[] = { "Jean-Baptiste Dulong", "Fabian Nowak <timyst...@arcor.de>", - "Landry Breuil <landry at xfce.org>", NULL }; + "Landry Breuil <lan...@xfce.org>", NULL }; icon = xfce_panel_pixbuf_from_source("drive-harddisk", NULL, 32); gtk_show_about_dialog(NULL, "logo", icon, @@ -972,6 +1020,7 @@ mounter_show_about(XfcePanelPlugin *plugin, t_mounter *mt) "website", "http://goodies.xfce.org/projects/panel-plugins/xfce4-mount-plugin", "copyright", _("Copyright (c) 2005-2012\n"), "authors", auth, NULL); + // TODO: add translators. if(icon) g_object_unref(G_OBJECT(icon)); diff --git a/panel-plugin/mount-plugin.h b/panel-plugin/mount-plugin.h index 54f7181..c35a75c 100644 --- a/panel-plugin/mount-plugin.h +++ b/panel-plugin/mount-plugin.h @@ -62,6 +62,8 @@ typedef struct gboolean include_NFSs; /**< whether to also display network file systems */ gboolean exclude_FSs; gboolean exclude_devicenames; + gboolean trim_devicenames; + gint trim_devicename_count; gboolean eject_drives; gboolean showed_fstab_dialog; GtkWidget *button; @@ -106,6 +108,8 @@ typedef struct GtkWidget *show_exclude_FSs; GtkWidget *show_eject_drives; GtkWidget *show_exclude_devicenames; + GtkWidget *show_trim_devicenames; + GtkWidget *spin_trim_devicename_count; GtkWidget *string_excluded_filesystems; } t_mounter_dialog; _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits