Commit b0c918c602767ad95ee02cf6a4233e3099220c11
1 parent
c6991dd1
Exists in
master
and in
3 other branches
Implementing add/remove from header bar blocks.
Showing
3 changed files
with
75 additions
and
21 deletions
Show diff stats
src/objects/actions/view.c
| ... | ... | @@ -411,8 +411,31 @@ |
| 411 | 411 | return g_string_free(str,FALSE); |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | + static void check_4_sensitive(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gboolean *sensitive) { | |
| 415 | + | |
| 416 | + GValue value = { 0, }; | |
| 417 | + gtk_tree_model_get_value(model,iter,COLUMN_FLAGS,&value); | |
| 418 | + | |
| 419 | + if(!(g_value_get_int(&value) & PW3270_ACTION_VIEW_FLAG_ALLOW_ADD)) | |
| 420 | + *sensitive = FALSE; | |
| 421 | + | |
| 422 | + g_value_unset(&value); | |
| 423 | + | |
| 424 | + } | |
| 425 | + | |
| 414 | 426 | static void selection_changed(GtkTreeSelection *selection, GtkWidget *button) { |
| 415 | - gtk_widget_set_sensitive(button,gtk_tree_selection_count_selected_rows(selection) > 0); | |
| 427 | + | |
| 428 | + if(!gtk_tree_selection_count_selected_rows(selection)) { | |
| 429 | + gtk_widget_set_sensitive(button,FALSE); | |
| 430 | + return; | |
| 431 | + } | |
| 432 | + | |
| 433 | + gboolean sensitive = TRUE; | |
| 434 | + | |
| 435 | + // Scan selected rows | |
| 436 | + gtk_tree_selection_selected_foreach(selection,(GtkTreeSelectionForeachFunc) check_4_sensitive,&sensitive); | |
| 437 | + gtk_widget_set_sensitive(button,sensitive); | |
| 438 | + | |
| 416 | 439 | } |
| 417 | 440 | |
| 418 | 441 | GtkWidget * pw3270_action_view_extract_button_new(GtkWidget *widget, const gchar *icon_name) { | ... | ... |
src/objects/toolbar/settings.c
| ... | ... | @@ -146,30 +146,12 @@ |
| 146 | 146 | gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(gtk_tree_view_get_model(GTK_TREE_VIEW(page->views[1]))), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING); |
| 147 | 147 | |
| 148 | 148 | // Create buttons |
| 149 | - static const gchar * icon_names[G_N_ELEMENTS(page->buttons)] = { | |
| 150 | - "go-next", | |
| 151 | - "go-previous" | |
| 152 | - }; | |
| 153 | - | |
| 154 | 149 | GtkWidget * box = gtk_button_box_new(GTK_ORIENTATION_VERTICAL); |
| 155 | 150 | gtk_widget_set_hexpand(box,FALSE); |
| 156 | 151 | gtk_widget_set_vexpand(box,FALSE); |
| 157 | 152 | |
| 158 | - for(ix = 0; ix < G_N_ELEMENTS(icon_names); ix++) { | |
| 159 | - page->buttons[ix] = gtk_button_new_from_icon_name(icon_names[ix],GTK_ICON_SIZE_DND); | |
| 160 | - | |
| 161 | - gtk_widget_set_focus_on_click(page->buttons[ix],FALSE); | |
| 162 | - gtk_button_set_relief(GTK_BUTTON(page->buttons[ix]),GTK_RELIEF_NONE); | |
| 163 | - gtk_widget_set_sensitive(page->buttons[ix],FALSE); | |
| 164 | - | |
| 165 | - g_signal_connect( | |
| 166 | - gtk_tree_view_get_selection(GTK_TREE_VIEW(page->views[ix])), | |
| 167 | - "changed", | |
| 168 | - G_CALLBACK(selection_changed), | |
| 169 | - page->buttons[ix] | |
| 170 | - ); | |
| 171 | - | |
| 172 | - } | |
| 153 | + page->buttons[0] = pw3270_action_view_extract_button_new(page->views[0],"go-next"), | |
| 154 | + page->buttons[1] = pw3270_action_view_extract_button_new(page->views[1],"go-previous"), | |
| 173 | 155 | |
| 174 | 156 | gtk_box_pack_start(GTK_BOX(box),page->buttons[0],FALSE,FALSE,0); |
| 175 | 157 | gtk_box_pack_end(GTK_BOX(box),page->buttons[1],FALSE,FALSE,0); | ... | ... |
src/objects/window/header-settings.c
| ... | ... | @@ -72,6 +72,26 @@ |
| 72 | 72 | |
| 73 | 73 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 74 | 74 | |
| 75 | + static void remove_from_left(GtkButton G_GNUC_UNUSED(*button), PW3270SettingsPrivate *settings) { | |
| 76 | + debug("%s(%p)",__FUNCTION__,settings); | |
| 77 | + pw3270_action_view_move_selected(settings->views[0],settings->views[2]); | |
| 78 | + } | |
| 79 | + | |
| 80 | + static void add_to_left(GtkButton G_GNUC_UNUSED(*button), PW3270SettingsPrivate *settings) { | |
| 81 | + debug("%s(%p)",__FUNCTION__,settings); | |
| 82 | + pw3270_action_view_move_selected(settings->views[2],settings->views[0]); | |
| 83 | + } | |
| 84 | + | |
| 85 | + static void remove_from_right(GtkButton G_GNUC_UNUSED(*button), PW3270SettingsPrivate *settings) { | |
| 86 | + debug("%s(%p)",__FUNCTION__,settings); | |
| 87 | + pw3270_action_view_move_selected(settings->views[1],settings->views[2]); | |
| 88 | + } | |
| 89 | + | |
| 90 | + static void add_to_right(GtkButton G_GNUC_UNUSED(*button), PW3270SettingsPrivate *settings) { | |
| 91 | + debug("%s(%p)",__FUNCTION__,settings); | |
| 92 | + pw3270_action_view_move_selected(settings->views[2],settings->views[1]); | |
| 93 | + } | |
| 94 | + | |
| 75 | 95 | GtkWidget * pw3270_header_settings_new() { |
| 76 | 96 | |
| 77 | 97 | size_t ix; |
| ... | ... | @@ -152,6 +172,35 @@ |
| 152 | 172 | pw3270_action_view_extract_button_new(page->views[2],"go-previous") |
| 153 | 173 | }; |
| 154 | 174 | |
| 175 | + g_signal_connect( | |
| 176 | + buttons[0], | |
| 177 | + "clicked", | |
| 178 | + G_CALLBACK(remove_from_left), | |
| 179 | + page | |
| 180 | + ); | |
| 181 | + | |
| 182 | + g_signal_connect( | |
| 183 | + buttons[1], | |
| 184 | + "clicked", | |
| 185 | + G_CALLBACK(add_to_left), | |
| 186 | + page | |
| 187 | + ); | |
| 188 | + | |
| 189 | + g_signal_connect( | |
| 190 | + buttons[2], | |
| 191 | + "clicked", | |
| 192 | + G_CALLBACK(remove_from_right), | |
| 193 | + page | |
| 194 | + ); | |
| 195 | + | |
| 196 | + g_signal_connect( | |
| 197 | + buttons[3], | |
| 198 | + "clicked", | |
| 199 | + G_CALLBACK(add_to_right), | |
| 200 | + page | |
| 201 | + ); | |
| 202 | + | |
| 203 | + | |
| 155 | 204 | for(ix = 0; ix < 2; ix++) { |
| 156 | 205 | GtkWidget * box = gtk_button_box_new(GTK_ORIENTATION_VERTICAL); |
| 157 | 206 | gtk_widget_set_hexpand(box,FALSE); | ... | ... |