From 6f18dd3df0f3d5f32b4e6c8a70a0e5ce7eabc92e Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Mon, 16 Dec 2019 09:50:47 -0300 Subject: [PATCH] Buttons on the header bar are now configurable. --- schemas/linux/application.gschema.xml.in | 12 ++++++++++++ schemas/windows/application.gschema.xml.in | 12 ++++++++++++ src/objects/actions/button.c | 6 ------ src/objects/window/header.c | 17 ----------------- src/objects/window/window.c | 23 +++++++++++++++++++++++ 5 files changed, 47 insertions(+), 23 deletions(-) diff --git a/schemas/linux/application.gschema.xml.in b/schemas/linux/application.gschema.xml.in index ec244a8..9675f05 100644 --- a/schemas/linux/application.gschema.xml.in +++ b/schemas/linux/application.gschema.xml.in @@ -74,6 +74,18 @@ + + 'win.disconnect,win.reconnect,win.file.transfer,win.print' + The actions in the first block of the header bar + + + + + 'menu.open-menu' + The actions in the last block of the header bar + + + diff --git a/schemas/windows/application.gschema.xml.in b/schemas/windows/application.gschema.xml.in index ec244a8..9675f05 100644 --- a/schemas/windows/application.gschema.xml.in +++ b/schemas/windows/application.gschema.xml.in @@ -74,6 +74,18 @@ + + 'win.disconnect,win.reconnect,win.file.transfer,win.print' + The actions in the first block of the header bar + + + + + 'menu.open-menu' + The actions in the last block of the header bar + + + diff --git a/src/objects/actions/button.c b/src/objects/actions/button.c index 876d3ee..e4139cc 100644 --- a/src/objects/actions/button.c +++ b/src/objects/actions/button.c @@ -50,12 +50,6 @@ image = gtk_image_new_from_icon_name(symbolic_name,GTK_ICON_SIZE_BUTTON); } - - // If fails, use the regular icon. - if(!image) { - debug("***************** %s",icon_name); - } - if(!image) { g_warning("Can't create button for icon \"%s\"",icon_name); return NULL; diff --git a/src/objects/window/header.c b/src/objects/window/header.c index 815707e..dc9efd0 100644 --- a/src/objects/window/header.c +++ b/src/objects/window/header.c @@ -41,22 +41,6 @@ } - /* - static gboolean bg_deactivate_button(GtkWidget *button) { - debug("******************** %s %p",__FUNCTION__,button) - return FALSE; - } - - static void on_state_flags_changed(GtkWidget *button, GtkStateFlags flags, gpointer user_data) { - - debug("%s(%p,%d)",__FUNCTION__,button,flags & GTK_STATE_FLAG_ACTIVE); - - if(flags & GTK_STATE_FLAG_ACTIVE) - g_idle_add((GSourceFunc) bg_deactivate_button, button); - - } - */ - GtkWidget * pw3270_header_button_new_from_builder(GtkWidget *widget, GtkBuilder * builder, const gchar *action_name) { GtkWidget * button = NULL; @@ -86,7 +70,6 @@ if(button) { g_signal_connect(button, "notify::sensitive", G_CALLBACK(on_sensitive), widget); - // g_signal_connect(button,"state-flags-changed",G_CALLBACK(on_state_flags_changed), widget); gtk_widget_set_focus_on_click(button,FALSE); gtk_widget_set_can_focus(button,FALSE); gtk_widget_set_can_default(button,FALSE); diff --git a/src/objects/window/window.c b/src/objects/window/window.c index b2227a9..c044730 100644 --- a/src/objects/window/window.c +++ b/src/objects/window/window.c @@ -220,7 +220,29 @@ // Create header's action buttons // https://wiki.gnome.org/Initiatives/GnomeGoals/GearIcons + { + g_autofree gchar * left = g_settings_get_string(settings, "header-start-action-names"); + g_autofree gchar * right = g_settings_get_string(settings, "header-end-action-names"); + + gchar ** elements; + + // First the left side actions. + elements = g_strsplit(left,",",-1); + for(ix=0;elements[ix];ix++) { + gtk_header_bar_pack_start(header, pw3270_header_button_new_from_builder(GTK_WIDGET(window),builder,elements[ix])); + } + g_strfreev(elements); + + // And then, the right side actions; + elements = g_strsplit(right,",",-1); + for(ix=0;elements[ix];ix++) { + gtk_header_bar_pack_end(header, pw3270_header_button_new_from_builder(GTK_WIDGET(window),builder,elements[ix])); + } + g_strfreev(elements); + } + + /* static const gchar * end_actions[] = { "menu.open-menu", }; @@ -240,6 +262,7 @@ for(ix = 0; ix < G_N_ELEMENTS(start_actions); ix++) { gtk_header_bar_pack_start(header, pw3270_header_button_new_from_builder(GTK_WIDGET(window),builder,start_actions[ix])); } + */ /* -- libgit2 0.21.2