--- xfce4-panel-4.13.4/plugins/actions/actions.c.orig 2018-12-22 23:15:40.000000000 +0100 +++ xfce4-panel-4.13.4/plugins/actions/actions.c 2019-03-16 12:10:56.211878484 +0100 @@ -37,6 +37,7 @@ +#define DEFAULT_TITLE _("Session Menu") #define DEFAULT_ICON_SIZE (16) #define DEFAULT_TIMEOUT (30) @@ -71,11 +72,22 @@ } AppearanceType; +typedef enum +{ + BUTTON_TITLE_TYPE_FULLNAME, + BUTTON_TITLE_TYPE_USERNAME, + BUTTON_TITLE_TYPE_USERID, + BUTTON_TITLE_TYPE_CUSTOM +} +ButtonTitleType; + enum { PROP_0, PROP_ITEMS, PROP_APPEARANCE, + PROP_BUTTON_TITLE, + PROP_CUSTOM_TITLE, PROP_INVERT_ORIENTATION, PROP_ASK_CONFIRMATION }; @@ -98,6 +110,8 @@ XfcePanelPlugin __parent__; AppearanceType type; + ButtonTitleType button_title; + gchar *custom_title; GPtrArray *items; GtkWidget *menu; guint invert_orientation : 1; @@ -263,6 +277,22 @@ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, + PROP_BUTTON_TITLE, + g_param_spec_uint ("button-title", + NULL, NULL, + BUTTON_TITLE_TYPE_FULLNAME, + BUTTON_TITLE_TYPE_CUSTOM, + BUTTON_TITLE_TYPE_FULLNAME, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (gobject_class, + PROP_CUSTOM_TITLE, + g_param_spec_string ("custom-title", + NULL, NULL, + DEFAULT_TITLE, + G_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, PROP_INVERT_ORIENTATION, g_param_spec_boolean ("invert-orientation", NULL, NULL, @@ -285,6 +315,7 @@ actions_plugin_init (ActionsPlugin *plugin) { plugin->type = APPEARANCE_TYPE_MENU; + plugin->button_title = BUTTON_TITLE_TYPE_FULLNAME; plugin->invert_orientation = FALSE; plugin->ask_confirmation = TRUE; } @@ -320,6 +351,15 @@ g_value_set_uint (value, plugin->type); break; + case PROP_BUTTON_TITLE: + g_value_set_uint (value, plugin->button_title); + break; + + case PROP_CUSTOM_TITLE: + g_value_set_string (value, plugin->custom_title == NULL ? + DEFAULT_TITLE : plugin->custom_title); + break; + case PROP_INVERT_ORIENTATION: g_value_set_boolean (value, plugin->invert_orientation); break; @@ -359,6 +399,17 @@ actions_plugin_pack (plugin); break; + case PROP_BUTTON_TITLE: + plugin->button_title = g_value_get_uint (value); + actions_plugin_pack (plugin); + break; + + case PROP_CUSTOM_TITLE: + g_free (plugin->custom_title); + plugin->custom_title = g_value_dup_string (value); + actions_plugin_pack (plugin); + break; + case PROP_INVERT_ORIENTATION: plugin->invert_orientation = g_value_get_boolean (value); actions_plugin_pack (plugin); @@ -384,6 +435,8 @@ { { "items", G_TYPE_PTR_ARRAY }, { "appearance", G_TYPE_UINT }, + { "button-title", G_TYPE_UINT }, + { "custom-title", G_TYPE_STRING }, { "invert-orientation", G_TYPE_BOOLEAN }, { "ask-confirmation", G_TYPE_BOOLEAN }, { NULL } @@ -564,6 +617,8 @@ GObject *dialog; GObject *object; GObject *combo; + GObject *combo2; + GObject *text; ActionEntry *entry; guint i; const GValue *val; @@ -598,6 +654,16 @@ G_OBJECT (object), "sensitive", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL | G_BINDING_INVERT_BOOLEAN); + combo2 = gtk_builder_get_object (builder, "combo-title"); + g_object_bind_property (G_OBJECT (plugin), "button-title", + G_OBJECT (combo2), "active", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); + + text = gtk_builder_get_object (builder, "entry-cust-title"); + g_object_bind_property (G_OBJECT (plugin), "custom-title", + G_OBJECT (text), "text", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); + object = gtk_builder_get_object (builder, "confirmation-dialog"); g_object_bind_property (G_OBJECT (plugin), "ask-confirmation", G_OBJECT (object), "active", @@ -1128,7 +1204,7 @@ GtkWidget *label; GtkWidget *button; GtkWidget *widget; - const gchar *username; + const gchar *button_title; GtkWidget *child; GtkWidget *box; guint i; @@ -1192,15 +1268,40 @@ } else { + switch (plugin->button_title) + { + case BUTTON_TITLE_TYPE_FULLNAME: /* get a decent username, not the glib defaults */ - username = g_get_real_name (); - if (panel_str_is_empty (username) - || strcmp (username, "Unknown") == 0) - { - username = g_get_user_name (); - if (panel_str_is_empty (username) - || strcmp (username, "somebody") == 0) - username = _("John Doe"); + button_title = g_get_real_name (); + if (panel_str_is_empty (button_title) + || strcmp (button_title, "Unknown") == 0) + { + button_title = g_get_user_name (); + if (panel_str_is_empty (button_title) + || strcmp (button_title, "somebody") == 0) + button_title = _("John Doe"); + } + break; + + case BUTTON_TITLE_TYPE_USERNAME: + button_title = g_get_user_name (); + if (panel_str_is_empty (button_title)) + button_title = "somebody"; + break; + + case BUTTON_TITLE_TYPE_USERID: + { + char buf[16]; + snprintf(buf, sizeof(buf), "%u", (unsigned)getuid()); + button_title = buf; + } + break; + + default: + case BUTTON_TITLE_TYPE_CUSTOM: + button_title = (plugin->custom_title == NULL? + DEFAULT_TITLE : plugin->custom_title); + break; } button = xfce_arrow_button_new (GTK_ARROW_NONE); @@ -1212,7 +1313,7 @@ G_CALLBACK (actions_plugin_menu), plugin); gtk_widget_show (button); - label = gtk_label_new (username); + label = gtk_label_new (button_title); gtk_container_add (GTK_CONTAINER (button), label); mode = xfce_panel_plugin_get_mode (XFCE_PANEL_PLUGIN (plugin)); gtk_label_set_angle (GTK_LABEL (label), --- xfce4-panel-4.13.4/plugins/actions/actions-dialog.glade.orig 2018-11-26 21:38:09.000000000 +0100 +++ xfce4-panel-4.13.4/plugins/actions/actions-dialog.glade 2019-03-16 12:34:24.749042266 +0100 @@ -135,6 +135,34 @@ + + True + False + 0 + Session Menu _title: + True + combo-title + + + 0 + 1 + + + + + True + False + 0 + Custo_m title: + True + entry-cust-title + + + 0 + 2 + + + Invert buttons _orientation False @@ -146,11 +175,39 @@ 0 - 1 + 3 2 + + True + False + title-store + + + + 0 + + + + + 1 + 1 + + + + + True + True + + + + 1 + 2 + + + _Show confirmation dialog False @@ -163,7 +220,7 @@ 0 - 2 + 4 2 @@ -288,4 +345,24 @@ help-button + + + + + + + + Full Name + + + Username + + + User ID (numeric) + + + Custom + + +