Commit c6991dd12f82052262599347a69254bd0a5ecc9c
1 parent
fcc6a99c
Exists in
master
and in
3 other branches
Working on header bar edit dialog.
Showing
4 changed files
with
76 additions
and
60 deletions
Show diff stats
src/include/pw3270/actions.h
| ... | ... | @@ -90,13 +90,22 @@ |
| 90 | 90 | // |
| 91 | 91 | typedef GSList Pw3270ActionList; |
| 92 | 92 | |
| 93 | + typedef enum _pw3270ActionViewFlag { | |
| 94 | + PW3270_ACTION_VIEW_FLAG_FIXED = 0, ///< @brief No special options. | |
| 95 | + PW3270_ACTION_VIEW_FLAG_ALLOW_ADD = 1, ///< @brief Allow add to target widget. | |
| 96 | + PW3270_ACTION_VIEW_ALLOW_REMOVE = 2, ///< @brief Allow remove from source widget. | |
| 97 | + PW3270_ACTION_VIEW_ALLOW_MOVE = 3 ///< @brief Allow move from source to target. | |
| 98 | + } PW3270ActionViewFlag; | |
| 99 | + | |
| 100 | + | |
| 93 | 101 | GtkWidget * pw3270_action_view_new(); |
| 94 | 102 | Pw3270ActionList * pw3270_action_list_new(GtkApplication *application); |
| 95 | 103 | void pw3270_action_list_free(Pw3270ActionList *action_list); |
| 96 | 104 | void pw3270_action_view_set_actions(GtkWidget *view, Pw3270ActionList *list); |
| 97 | 105 | void pw3270_action_view_move_selected(GtkWidget *from, GtkWidget *to); |
| 98 | - void pw3270_action_view_append(GtkWidget *widget, const gchar *label, GdkPixbuf *pixbuf, const gchar *action_name, gint flags); | |
| 106 | + void pw3270_action_view_append(GtkWidget *widget, const gchar *label, GdkPixbuf *pixbuf, const gchar *action_name, const PW3270ActionViewFlag flags); | |
| 99 | 107 | gchar * pw3270_action_view_get_action_names(GtkWidget *widget); |
| 108 | + GtkWidget * pw3270_action_view_extract_button_new(GtkWidget *widget, const gchar *icon_name); | |
| 100 | 109 | |
| 101 | 110 | Pw3270ActionList * pw3270_action_list_move_action(Pw3270ActionList *action_list, const gchar *action_name, GtkWidget *view); |
| 102 | 111 | ... | ... |
src/objects/actions/view.c
| ... | ... | @@ -106,7 +106,7 @@ |
| 106 | 106 | return view; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - void pw3270_action_view_append(GtkWidget *widget, const gchar *label, GdkPixbuf *pixbuf, const gchar *action_name, gint flags) { | |
| 109 | + void pw3270_action_view_append(GtkWidget *widget, const gchar *label, GdkPixbuf *pixbuf, const gchar *action_name, PW3270ActionViewFlag flags) { | |
| 110 | 110 | |
| 111 | 111 | GtkListStore * store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget))); |
| 112 | 112 | |
| ... | ... | @@ -118,7 +118,7 @@ |
| 118 | 118 | COLUMN_PIXBUF, pixbuf, |
| 119 | 119 | COLUMN_LABEL, label, |
| 120 | 120 | COLUMN_ACTION_NAME, action_name, |
| 121 | - COLUMN_FLAGS, flags, | |
| 121 | + COLUMN_FLAGS, (gint) flags, | |
| 122 | 122 | -1 |
| 123 | 123 | ); |
| 124 | 124 | |
| ... | ... | @@ -169,10 +169,10 @@ |
| 169 | 169 | gtk_list_store_set( |
| 170 | 170 | store, |
| 171 | 171 | &iter, |
| 172 | - COLUMN_PIXBUF, element->pixbuf, | |
| 173 | - COLUMN_LABEL, (label ? label : g_action_get_name(element->action)), | |
| 172 | + COLUMN_PIXBUF, element->pixbuf, | |
| 173 | + COLUMN_LABEL, (label ? label : g_action_get_name(element->action)), | |
| 174 | 174 | COLUMN_ACTION_NAME, element->name, |
| 175 | - COLUMN_FLAGS, 3, | |
| 175 | + COLUMN_FLAGS, (gint) PW3270_ACTION_VIEW_ALLOW_MOVE, | |
| 176 | 176 | -1 |
| 177 | 177 | ); |
| 178 | 178 | |
| ... | ... | @@ -338,7 +338,7 @@ |
| 338 | 338 | gint flags = g_value_get_int(&vFlags); |
| 339 | 339 | g_value_unset(&vFlags); |
| 340 | 340 | |
| 341 | - if(flags & 1) { | |
| 341 | + if(flags & PW3270_ACTION_VIEW_FLAG_ALLOW_ADD) { | |
| 342 | 342 | |
| 343 | 343 | // Add on target widget. |
| 344 | 344 | GValue pixbuf = G_VALUE_INIT; |
| ... | ... | @@ -369,7 +369,7 @@ |
| 369 | 369 | |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - if(flags & 2) { | |
| 372 | + if(flags & PW3270_ACTION_VIEW_ALLOW_REMOVE) { | |
| 373 | 373 | |
| 374 | 374 | // Remove from source widget. |
| 375 | 375 | gtk_list_store_remove(GTK_LIST_STORE(fromModel), &iter); |
| ... | ... | @@ -411,3 +411,24 @@ |
| 411 | 411 | return g_string_free(str,FALSE); |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | + static void selection_changed(GtkTreeSelection *selection, GtkWidget *button) { | |
| 415 | + gtk_widget_set_sensitive(button,gtk_tree_selection_count_selected_rows(selection) > 0); | |
| 416 | + } | |
| 417 | + | |
| 418 | + GtkWidget * pw3270_action_view_extract_button_new(GtkWidget *widget, const gchar *icon_name) { | |
| 419 | + | |
| 420 | + GtkWidget * button = gtk_button_new_from_icon_name(icon_name,GTK_ICON_SIZE_DND); | |
| 421 | + | |
| 422 | + gtk_widget_set_focus_on_click(button,FALSE); | |
| 423 | + gtk_button_set_relief(GTK_BUTTON(button),GTK_RELIEF_NONE); | |
| 424 | + gtk_widget_set_sensitive(button,FALSE); | |
| 425 | + | |
| 426 | + g_signal_connect( | |
| 427 | + gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)), | |
| 428 | + "changed", | |
| 429 | + G_CALLBACK(selection_changed), | |
| 430 | + button | |
| 431 | + ); | |
| 432 | + | |
| 433 | + return button; | |
| 434 | + } | ... | ... |
src/objects/window/header-settings.c
| ... | ... | @@ -72,10 +72,6 @@ |
| 72 | 72 | |
| 73 | 73 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 74 | 74 | |
| 75 | - static void selection_changed(GtkTreeSelection *selection, GtkWidget *button) { | |
| 76 | - gtk_widget_set_sensitive(button,gtk_tree_selection_count_selected_rows(selection) > 0); | |
| 77 | - } | |
| 78 | - | |
| 79 | 75 | GtkWidget * pw3270_header_settings_new() { |
| 80 | 76 | |
| 81 | 77 | size_t ix; |
| ... | ... | @@ -149,53 +145,13 @@ |
| 149 | 145 | |
| 150 | 146 | // Create buttons |
| 151 | 147 | { |
| 152 | - static const gchar * icon_names[] = { | |
| 153 | - "go-next", | |
| 154 | - "go-previous", | |
| 155 | - "go-next", | |
| 156 | - "go-previous" | |
| 148 | + GtkWidget *buttons[] = { | |
| 149 | + pw3270_action_view_extract_button_new(page->views[0],"go-next"), | |
| 150 | + pw3270_action_view_extract_button_new(page->views[2],"go-previous"), | |
| 151 | + pw3270_action_view_extract_button_new(page->views[1],"go-next"), | |
| 152 | + pw3270_action_view_extract_button_new(page->views[2],"go-previous") | |
| 157 | 153 | }; |
| 158 | 154 | |
| 159 | - GtkWidget *buttons[G_N_ELEMENTS(icon_names)]; | |
| 160 | - | |
| 161 | - for(ix = 0; ix < G_N_ELEMENTS(icon_names); ix++) { | |
| 162 | - buttons[ix] = gtk_button_new_from_icon_name(icon_names[ix],GTK_ICON_SIZE_DND); | |
| 163 | - | |
| 164 | - gtk_widget_set_focus_on_click(buttons[ix],FALSE); | |
| 165 | - gtk_button_set_relief(GTK_BUTTON(buttons[ix]),GTK_RELIEF_NONE); | |
| 166 | - gtk_widget_set_sensitive(buttons[ix],FALSE); | |
| 167 | - | |
| 168 | - } | |
| 169 | - | |
| 170 | - g_signal_connect( | |
| 171 | - gtk_tree_view_get_selection(GTK_TREE_VIEW(page->views[0])), | |
| 172 | - "changed", | |
| 173 | - G_CALLBACK(selection_changed), | |
| 174 | - buttons[0] | |
| 175 | - ); | |
| 176 | - | |
| 177 | - g_signal_connect( | |
| 178 | - gtk_tree_view_get_selection(GTK_TREE_VIEW(page->views[1])), | |
| 179 | - "changed", | |
| 180 | - G_CALLBACK(selection_changed), | |
| 181 | - buttons[2] | |
| 182 | - ); | |
| 183 | - | |
| 184 | - g_signal_connect( | |
| 185 | - gtk_tree_view_get_selection(GTK_TREE_VIEW(page->views[2])), | |
| 186 | - "changed", | |
| 187 | - G_CALLBACK(selection_changed), | |
| 188 | - buttons[1] | |
| 189 | - ); | |
| 190 | - | |
| 191 | - g_signal_connect( | |
| 192 | - gtk_tree_view_get_selection(GTK_TREE_VIEW(page->views[2])), | |
| 193 | - "changed", | |
| 194 | - G_CALLBACK(selection_changed), | |
| 195 | - buttons[3] | |
| 196 | - ); | |
| 197 | - | |
| 198 | - | |
| 199 | 155 | for(ix = 0; ix < 2; ix++) { |
| 200 | 156 | GtkWidget * box = gtk_button_box_new(GTK_ORIENTATION_VERTICAL); |
| 201 | 157 | gtk_widget_set_hexpand(box,FALSE); |
| ... | ... | @@ -242,7 +198,37 @@ |
| 242 | 198 | gchar ** actions = g_strsplit(views[view],",",-1); |
| 243 | 199 | |
| 244 | 200 | for(action = 0; actions[action];action++) { |
| 245 | - action_list = pw3270_action_list_move_action(action_list,actions[action],page->views[view]); | |
| 201 | + | |
| 202 | + if(g_str_has_prefix(actions[action],"menu.")) { | |
| 203 | + | |
| 204 | + GError *error = NULL; | |
| 205 | + g_autofree gchar * icon_name = g_strconcat(actions[action]+5,"-symbolic",NULL); | |
| 206 | + | |
| 207 | + GdkPixbuf * pixbuf = gtk_icon_theme_load_icon( | |
| 208 | + gtk_icon_theme_get_default(), | |
| 209 | + icon_name, | |
| 210 | + GTK_ICON_SIZE_MENU, | |
| 211 | + GTK_ICON_LOOKUP_GENERIC_FALLBACK, | |
| 212 | + &error | |
| 213 | + ); | |
| 214 | + | |
| 215 | + if(error) { | |
| 216 | + g_warning(error->message); | |
| 217 | + g_error_free(error); | |
| 218 | + error = NULL; | |
| 219 | + } | |
| 220 | + | |
| 221 | + pw3270_action_view_append( | |
| 222 | + page->views[view], // Widget | |
| 223 | + _( "System Menu" ), // label | |
| 224 | + pixbuf, // Icon | |
| 225 | + actions[action], // Action name | |
| 226 | + PW3270_ACTION_VIEW_FLAG_FIXED // Fixed item | |
| 227 | + ); | |
| 228 | + | |
| 229 | + } else { | |
| 230 | + action_list = pw3270_action_list_move_action(action_list,actions[action],page->views[view]); | |
| 231 | + } | |
| 246 | 232 | } |
| 247 | 233 | |
| 248 | 234 | g_strfreev(actions); | ... | ... |
src/objects/window/terminal.c
| ... | ... | @@ -44,11 +44,11 @@ |
| 44 | 44 | #include <v3270/print.h> |
| 45 | 45 | #include <lib3270/os.h> |
| 46 | 46 | |
| 47 | - static void destroy(GtkWidget *terminal, gpointer GNUC_UNUSED(dunno)) { | |
| 47 | + static void destroy(GtkWidget *terminal, gpointer G_GNUC_UNUSED(dunno)) { | |
| 48 | 48 | v3270_key_file_close(terminal); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - static void toggle_changed(GtkWidget *widget, G_GNUC_UNUSED LIB3270_TOGGLE_ID toggle_id, gboolean toggle_state, const gchar *toggle_name, gpointer GNUC_UNUSED(dunno)) { | |
| 51 | + static void toggle_changed(GtkWidget *widget, LIB3270_TOGGLE_ID G_GNUC_UNUSED(toggle_id), gboolean toggle_state, const gchar *toggle_name, gpointer G_GNUC_UNUSED(dunno)) { | |
| 52 | 52 | debug("%s(%s)=%s",__FUNCTION__,toggle_name,toggle_state ? "ON" : "OFF"); |
| 53 | 53 | v3270_key_file_set_boolean(widget,"terminal",toggle_name,toggle_state); |
| 54 | 54 | } | ... | ... |