Commit c41a63070d76a57fcdac07653c949afa77ecc40d

Authored by Perry Werneck
1 parent 5a93acd1

Working on application settings dialog.

src/objects/application/actions/preferences.c
@@ -59,6 +59,7 @@ @@ -59,6 +59,7 @@
59 dialog 59 dialog
60 ); 60 );
61 61
  62 +
62 gtk_widget_show_all(dialog); 63 gtk_widget_show_all(dialog);
63 64
64 return dialog; 65 return dialog;
src/objects/settings/dialog.c
@@ -197,6 +197,7 @@ void add(GtkContainer *container, GtkWidget *widget) { @@ -197,6 +197,7 @@ void add(GtkContainer *container, GtkWidget *widget) {
197 settings->load(widget,settings->settings); 197 settings->load(widget,settings->settings);
198 } 198 }
199 199
  200 + gtk_widget_show(widget);
200 gtk_notebook_append_page( 201 gtk_notebook_append_page(
201 GTK_PW3270_SETTINGS_DIALOG(container)->tabs, 202 GTK_PW3270_SETTINGS_DIALOG(container)->tabs,
202 widget, 203 widget,
@@ -211,14 +212,10 @@ void page_changed(GtkNotebook *notebook, GtkWidget G_GNUC_UNUSED(*child), guint @@ -211,14 +212,10 @@ void page_changed(GtkNotebook *notebook, GtkWidget G_GNUC_UNUSED(*child), guint
211 212
212 void switch_page(GtkNotebook *notebook, PW3270Settings *page, guint G_GNUC_UNUSED(page_num), PW3270SettingsDialog *dialog) { 213 void switch_page(GtkNotebook *notebook, PW3270Settings *page, guint G_GNUC_UNUSED(page_num), PW3270SettingsDialog *dialog) {
213 214
214 - if(gtk_notebook_get_n_pages(notebook) > 1) {  
215 -  
216 - GtkWidget * header_bar = gtk_dialog_get_header_bar(GTK_DIALOG(dialog));  
217 -  
218 - if(header_bar) {  
219 - gtk_header_bar_set_subtitle(GTK_HEADER_BAR(header_bar),page->title);  
220 - } 215 + GtkWidget * header_bar = gtk_dialog_get_header_bar(GTK_DIALOG(dialog));
221 216
  217 + if(header_bar) {
  218 + gtk_header_bar_set_subtitle(GTK_HEADER_BAR(header_bar),page->title);
222 } 219 }
223 220
224 } 221 }
src/objects/window/header.c
@@ -112,6 +112,15 @@ @@ -112,6 +112,15 @@
112 112
113 } 113 }
114 114
  115 + static GAction * get_action_from_name(GtkWidget *widget, const gchar *action_name) {
  116 +
  117 + if(g_str_has_prefix(action_name,"app.")) {
  118 + return g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()),action_name+4);
  119 + }
  120 +
  121 + return g_action_map_lookup_action(G_ACTION_MAP(widget),action_name+4);
  122 + }
  123 +
115 GtkWidget * pw3270_header_button_new_from_builder(GtkWidget *widget, GtkBuilder * builder, const gchar *action_name) { 124 GtkWidget * pw3270_header_button_new_from_builder(GtkWidget *widget, GtkBuilder * builder, const gchar *action_name) {
116 125
117 GtkWidget * button = NULL; 126 GtkWidget * button = NULL;
@@ -127,45 +136,28 @@ @@ -127,45 +136,28 @@
127 gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(button), G_MENU_MODEL(gtk_builder_get_object(builder, action_name+5))); 136 gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(button), G_MENU_MODEL(gtk_builder_get_object(builder, action_name+5)));
128 gtk_widget_set_visible(button,TRUE); 137 gtk_widget_set_visible(button,TRUE);
129 138
130 - } else if(g_str_has_prefix(action_name,"app.")) {  
131 -  
132 - // It's an application action  
133 -  
134 - } else if(g_str_has_prefix(action_name,"win.")) {  
135 -  
136 - // It's a window action.  
137 - GAction * action = g_action_map_lookup_action(G_ACTION_MAP(widget),action_name+4);  
138 -  
139 - if(action) {  
140 -  
141 - button = gtk_button_new_from_action(action,GTK_ICON_SIZE_BUTTON);  
142 139
143 - gtk_actionable_set_action_name(GTK_ACTIONABLE(button),action_name);  
144 - gtk_widget_set_visible(button,g_action_get_enabled(action));  
145 -  
146 -  
147 - } else { 140 + } else {
148 141
149 - g_warning("Can't find action \"%s\"",action_name+4); 142 + GAction * action = get_action_from_name(widget,action_name);
150 143
  144 + if(!action) {
  145 + g_warning("Can't find action %s",action_name);
151 } 146 }
152 147
153 - }  
154 -  
155 - if(button) { 148 + button = gtk_button_new_from_action(action,GTK_ICON_SIZE_BUTTON);
156 149
157 - g_signal_connect(button, "notify::sensitive", G_CALLBACK(on_sensitive), widget);  
158 - gtk_widget_set_focus_on_click(button,FALSE);  
159 - gtk_widget_set_can_focus(button,FALSE);  
160 - gtk_widget_set_can_default(button,FALSE);  
161 - gtk_widget_set_name(button,action_name);  
162 -  
163 - } else {  
164 -  
165 - g_warning("Can't create button for action \"%s\"",action_name); 150 + gtk_actionable_set_action_name(GTK_ACTIONABLE(button),action_name);
  151 + gtk_widget_set_visible(button,g_action_get_enabled(action));
166 152
167 } 153 }
168 154
  155 + g_signal_connect(button, "notify::sensitive", G_CALLBACK(on_sensitive), widget);
  156 + gtk_widget_set_focus_on_click(button,FALSE);
  157 + gtk_widget_set_can_focus(button,FALSE);
  158 + gtk_widget_set_can_default(button,FALSE);
  159 + gtk_widget_set_name(button,action_name);
  160 +
169 return button; 161 return button;
170 } 162 }
171 163
src/objects/window/page.c
@@ -303,30 +303,6 @@ @@ -303,30 +303,6 @@
303 // Show dialog. 303 // Show dialog.
304 gtk_widget_show_all(dialog); 304 gtk_widget_show_all(dialog);
305 305
306 -  
307 -  
308 - /*  
309 - GtkWidget * dialog = pw3270_settings_dialog_new(  
310 - _("Rename session"),  
311 - GTK_WINDOW(gtk_widget_get_toplevel(terminal))  
312 - );  
313 -  
314 - // https://developer.gnome.org/hig/stable/visual-layout.html.en  
315 - gtk_container_set_border_width(GTK_CONTAINER(content),18);  
316 -  
317 -  
318 - gtk_widget_show_all(dialog);  
319 -  
320 - if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_APPLY) {  
321 -  
322 - v3270_set_session_name(terminal, gtk_entry_get_text(GTK_ENTRY(entry)));  
323 - g_signal_emit_by_name(terminal,"save-settings");  
324 -  
325 - }  
326 -  
327 - gtk_widget_destroy(dialog);  
328 - */  
329 -  
330 } 306 }
331 307
332 static gboolean terminal_popup(GtkWidget *widget, gboolean selected, gboolean online, GdkEvent *event, pw3270ApplicationWindow * window) { 308 static gboolean terminal_popup(GtkWidget *widget, gboolean selected, gboolean online, GdkEvent *event, pw3270ApplicationWindow * window) {