Commit 7b2c2b0308f194e9b6f0bb923daccd5ef8ee1ba4

Authored by Perry Werneck
1 parent 390db0b4

Implementing toolbar actions edit dialog.

src/include/pw3270/actions.h
@@ -264,6 +264,7 @@ @@ -264,6 +264,7 @@
264 void pw3270_action_view_set_actions(GtkWidget *view, Pw3270ActionList *list); 264 void pw3270_action_view_set_actions(GtkWidget *view, Pw3270ActionList *list);
265 void pw3270_action_view_move_selected(GtkWidget *from, GtkWidget *to); 265 void pw3270_action_view_move_selected(GtkWidget *from, GtkWidget *to);
266 void pw3270_action_view_append(GtkWidget *widget, const gchar *label, GdkPixbuf *pixbuf, const gchar *action_name, gint flags); 266 void pw3270_action_view_append(GtkWidget *widget, const gchar *label, GdkPixbuf *pixbuf, const gchar *action_name, gint flags);
  267 + gchar * pw3270_action_view_get_action_names(GtkWidget *widget);
267 268
268 Pw3270ActionList * pw3270_action_list_move_action(Pw3270ActionList *action_list, const gchar *action_name, GtkWidget *view); 269 Pw3270ActionList * pw3270_action_list_move_action(Pw3270ActionList *action_list, const gchar *action_name, GtkWidget *view);
269 270
src/objects/actions/save.c
@@ -66,6 +66,7 @@ @@ -66,6 +66,7 @@
66 66
67 action->group.id = LIB3270_ACTION_GROUP_ONLINE; 67 action->group.id = LIB3270_ACTION_GROUP_ONLINE;
68 action->parent.name = "save"; 68 action->parent.name = "save";
  69 + action->icon_name = "document-save";
69 action->label = N_( "_Save" ); 70 action->label = N_( "_Save" );
70 action->tooltip = N_( "Save terminal contents." ); 71 action->tooltip = N_( "Save terminal contents." );
71 72
@@ -81,6 +82,7 @@ @@ -81,6 +82,7 @@
81 82
82 action->group.id = LIB3270_ACTION_GROUP_ONLINE; 83 action->group.id = LIB3270_ACTION_GROUP_ONLINE;
83 action->parent.name = "save.screen"; 84 action->parent.name = "save.screen";
  85 + action->icon_name = "document-save";
84 action->label = N_( "Save screen" ); 86 action->label = N_( "Save screen" );
85 87
86 return G_ACTION(action); 88 return G_ACTION(action);
@@ -95,6 +97,7 @@ @@ -95,6 +97,7 @@
95 97
96 action->group.id = LIB3270_ACTION_GROUP_SELECTION; 98 action->group.id = LIB3270_ACTION_GROUP_SELECTION;
97 action->parent.name = "save.selected"; 99 action->parent.name = "save.selected";
  100 + action->icon_name = "document-save";
98 action->label = N_( "Save selected" ); 101 action->label = N_( "Save selected" );
99 102
100 return G_ACTION(action); 103 return G_ACTION(action);
src/objects/actions/view.c
@@ -171,6 +171,7 @@ @@ -171,6 +171,7 @@
171 &iter, 171 &iter,
172 COLUMN_PIXBUF, element->pixbuf, 172 COLUMN_PIXBUF, element->pixbuf,
173 COLUMN_LABEL, (label ? label : g_action_get_name(element->action)), 173 COLUMN_LABEL, (label ? label : g_action_get_name(element->action)),
  174 + COLUMN_ACTION_NAME, element->name,
174 COLUMN_FLAGS, 3, 175 COLUMN_FLAGS, 3,
175 -1 176 -1
176 ); 177 );
@@ -382,5 +383,31 @@ @@ -382,5 +383,31 @@
382 383
383 } 384 }
384 385
  386 + }
  387 +
  388 + gboolean get_action_name(GtkTreeModel *model, GtkTreePath G_GNUC_UNUSED(*path), GtkTreeIter *iter, GString *str) {
  389 +
  390 + GValue value = G_VALUE_INIT;
  391 + gtk_tree_model_get_value(model,iter,COLUMN_ACTION_NAME,&value);
385 392
  393 + if(*str->str)
  394 + g_string_append(str,",");
  395 +
  396 + g_string_append(str,g_value_get_string(&value));
  397 +
  398 + g_value_unset(&value);
  399 + return FALSE;
386 } 400 }
  401 +
  402 + gchar * pw3270_action_view_get_action_names(GtkWidget *widget) {
  403 +
  404 + GString *str = g_string_new("");
  405 +
  406 + gtk_tree_model_foreach(
  407 + gtk_tree_view_get_model(GTK_TREE_VIEW(widget)),
  408 + (GtkTreeModelForeachFunc) get_action_name,
  409 + str );
  410 +
  411 + return g_string_free(str,FALSE);
  412 + }
  413 +
src/objects/actions/window.c
@@ -72,10 +72,10 @@ @@ -72,10 +72,10 @@
72 pw3270_action_copy_new(), 72 pw3270_action_copy_new(),
73 pw3270_action_cut_new(), 73 pw3270_action_cut_new(),
74 pw3270_action_paste_new(), 74 pw3270_action_paste_new(),
75 - pw3270_action_save_new(),  
76 75
77 - pw3270_action_save_screen_new(),  
78 - pw3270_action_save_selected_new(), 76 +// pw3270_action_save_new(),
  77 +// pw3270_action_save_screen_new(),
  78 +// pw3270_action_save_selected_new(),
79 79
80 pw3270_action_print_screen_new(), 80 pw3270_action_print_screen_new(),
81 pw3270_action_print_selected_new(), 81 pw3270_action_print_selected_new(),
src/objects/application/actions/preferences.c
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 GSList * pages; 40 GSList * pages;
41 } Pw3270SettingsDialog; 41 } Pw3270SettingsDialog;
42 42
43 - static void on_destroy(GtkWidget *dialog, Pw3270SettingsDialog *settings) { 43 + static void on_destroy(GtkWidget G_GNUC_UNUSED(*dialog), Pw3270SettingsDialog *settings) {
44 settings->dialog = NULL; 44 settings->dialog = NULL;
45 g_slist_free_full(settings->pages,g_free); 45 g_slist_free_full(settings->pages,g_free);
46 g_free(settings); 46 g_free(settings);
@@ -66,7 +66,7 @@ @@ -66,7 +66,7 @@
66 gtk_widget_destroy(GTK_WIDGET(dialog)); 66 gtk_widget_destroy(GTK_WIDGET(dialog));
67 } 67 }
68 68
69 - static void on_page_added(GtkNotebook *notebook, GtkWidget *widget, guint page_num, Pw3270SettingsDialog * settings) { 69 + static void on_page_added(GtkNotebook G_GNUC_UNUSED(*notebook), GtkWidget *widget, guint G_GNUC_UNUSED(page_num), Pw3270SettingsDialog G_GNUC_UNUSED(*settings)) {
70 70
71 // https://developer.gnome.org/hig/stable/visual-layout.html.en 71 // https://developer.gnome.org/hig/stable/visual-layout.html.en
72 72
@@ -83,6 +83,9 @@ @@ -83,6 +83,9 @@
83 83
84 static void on_switch_page(GtkNotebook G_GNUC_UNUSED(*notebook), GtkWidget *widget, guint G_GNUC_UNUSED(page_num), Pw3270SettingsDialog * settings) 84 static void on_switch_page(GtkNotebook G_GNUC_UNUSED(*notebook), GtkWidget *widget, guint G_GNUC_UNUSED(page_num), Pw3270SettingsDialog * settings)
85 { 85 {
  86 +
  87 + debug("%s: %p",__FUNCTION__,settings->dialog);
  88 +
86 if(!settings->dialog) 89 if(!settings->dialog)
87 return; 90 return;
88 91
@@ -92,7 +95,7 @@ @@ -92,7 +95,7 @@
92 GSList * page; 95 GSList * page;
93 for(page = settings->pages;page;page = page->next) { 96 for(page = settings->pages;page;page = page->next) {
94 Pw3270SettingsPage * pg = (Pw3270SettingsPage *) page->data; 97 Pw3270SettingsPage * pg = (Pw3270SettingsPage *) page->data;
95 - if(pg->widget == pg) { 98 + if(pg->widget == widget) {
96 if(pg->title) 99 if(pg->title)
97 gtk_header_bar_set_subtitle(GTK_HEADER_BAR(header_bar),pg->title); 100 gtk_header_bar_set_subtitle(GTK_HEADER_BAR(header_bar),pg->title);
98 return; 101 return;
src/objects/application/application.c
@@ -315,6 +315,7 @@ @@ -315,6 +315,7 @@
315 const gchar * label; 315 const gchar * label;
316 const gchar * tooltip; 316 const gchar * tooltip;
317 const gchar * action_name; 317 const gchar * action_name;
  318 + const gchar * icon_name;
318 const gchar * property_name; 319 const gchar * property_name;
319 void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal); 320 void (*activate)(GAction *action, GVariant *parameter, GtkWidget *terminal);
320 } conditional_actions[] = { 321 } conditional_actions[] = {
@@ -337,8 +338,9 @@ @@ -337,8 +338,9 @@
337 pw3270SimpleAction * action = PW3270_SIMPLE_ACTION(v3270_conditional_action_new(terminal,conditional_actions[ix].property_name)); 338 pw3270SimpleAction * action = PW3270_SIMPLE_ACTION(v3270_conditional_action_new(terminal,conditional_actions[ix].property_name));
338 339
339 action->parent.name = conditional_actions[ix].action_name; 340 action->parent.name = conditional_actions[ix].action_name;
340 - action->label = conditional_actions[ix].label; 341 + action->label = conditional_actions[ix].label;
341 action->tooltip = conditional_actions[ix].tooltip; 342 action->tooltip = conditional_actions[ix].tooltip;
  343 + action->icon_name = conditional_actions[ix].icon_name;
342 PW3270_ACTION(action)->activate = conditional_actions[ix].activate; 344 PW3270_ACTION(action)->activate = conditional_actions[ix].activate;
343 345
344 g_action_map_add_action( 346 g_action_map_add_action(
src/objects/toolbar/settings.c
@@ -79,8 +79,15 @@ @@ -79,8 +79,15 @@
79 79
80 } 80 }
81 81
82 - static void apply(Pw3270SettingsPage *pg, GtkApplication *application, GSettings *settings) { 82 + static void apply(Pw3270SettingsPage *pg, GtkApplication G_GNUC_UNUSED(*application), GSettings *settings) {
  83 +
83 debug("%s",__FUNCTION__); 84 debug("%s",__FUNCTION__);
  85 +
  86 + g_autofree gchar * action_names = pw3270_action_view_get_action_names(((ToolbarSettingsPage *) pg)->views[0]);
  87 + g_settings_set_string(settings,"toolbar-action-names",action_names);
  88 +
  89 + debug("[%s]",action_names);
  90 +
84 } 91 }
85 92
86 static void selection_changed(GtkTreeSelection *selection, GtkWidget *button) { 93 static void selection_changed(GtkTreeSelection *selection, GtkWidget *button) {
@@ -107,7 +114,7 @@ @@ -107,7 +114,7 @@
107 page->parent.load = load; 114 page->parent.load = load;
108 page->parent.apply = apply; 115 page->parent.apply = apply;
109 page->parent.label = _("Toolbar"); 116 page->parent.label = _("Toolbar");
110 - page->parent.title = _("Setup toolbar action elements"); 117 + page->parent.title = _("Setup toolbar");
111 118
112 page->parent.widget = gtk_grid_new(); 119 page->parent.widget = gtk_grid_new();
113 gtk_grid_set_row_homogeneous(GTK_GRID(page->parent.widget),FALSE); 120 gtk_grid_set_row_homogeneous(GTK_GRID(page->parent.widget),FALSE);
@@ -120,6 +127,9 @@ @@ -120,6 +127,9 @@
120 127
121 for(ix = 0; ix < G_N_ELEMENTS(page->views); ix++) { 128 for(ix = 0; ix < G_N_ELEMENTS(page->views); ix++) {
122 129
  130 + GtkWidget * label = gtk_label_new(gettext(labels[ix]));
  131 + gtk_label_set_xalign(GTK_LABEL(label),0);
  132 +
123 page->views[ix] = pw3270_action_view_new(); 133 page->views[ix] = pw3270_action_view_new();
124 134
125 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(page->views[ix])); 135 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(page->views[ix]));
@@ -127,7 +137,7 @@ @@ -127,7 +137,7 @@
127 137
128 gtk_grid_attach( 138 gtk_grid_attach(
129 GTK_GRID(page->parent.widget), 139 GTK_GRID(page->parent.widget),
130 - gtk_label_new(gettext(labels[ix])), 140 + label,
131 ix * 3,0,2,1 141 ix * 3,0,2,1
132 ); 142 );
133 143
src/objects/window/actions/sessionproperties.c
@@ -60,7 +60,7 @@ @@ -60,7 +60,7 @@
60 // Add settings pages. 60 // Add settings pages.
61 GtkWidget * elements[] = { 61 GtkWidget * elements[] = {
62 v3270_host_settings_new(), 62 v3270_host_settings_new(),
63 - v3270_color_selection_new(), 63 + v3270_color_settings_new(),
64 v3270_font_settings_new(), 64 v3270_font_settings_new(),
65 v3270_accelerator_settings_new() 65 v3270_accelerator_settings_new()
66 }; 66 };