Commit 16406a1cf3bebb2298a1f82e70be99e82f631bb8
1 parent
a7b291ef
Exists in
master
and in
4 other branches
Cleaning up code.
Refactoring the "connect" action.
Showing
10 changed files
with
26 additions
and
412 deletions
Show diff stats
src/objects/actions/abstract.c
... | ... | @@ -494,23 +494,6 @@ |
494 | 494 | return G_ACTION(g_object_new(PW3270_TYPE_ACTION, NULL)); |
495 | 495 | } |
496 | 496 | |
497 | - static GdkPixbuf * pixbuf_from_icon_name(GValue *value, gint width, gint G_GNUC_UNUSED(height), GtkIconLookupFlags flags) { | |
498 | - | |
499 | - const gchar * icon_name = g_value_get_string(value); | |
500 | - | |
501 | - if(!icon_name) | |
502 | - return NULL; | |
503 | - | |
504 | - return gtk_icon_theme_load_icon( | |
505 | - gtk_icon_theme_get_default(), | |
506 | - icon_name, | |
507 | - width, | |
508 | - flags, // GTK_ICON_LOOKUP_GENERIC_FALLBACK, | |
509 | - NULL | |
510 | - ); | |
511 | - | |
512 | - } | |
513 | - | |
514 | 497 | gchar * g_action_get_text(GAction *action, const gchar * property_name) { |
515 | 498 | gchar *rc = NULL; |
516 | 499 | |
... | ... | @@ -540,6 +523,23 @@ |
540 | 523 | return g_action_get_text(action, "icon-name"); |
541 | 524 | } |
542 | 525 | |
526 | + static GdkPixbuf * pixbuf_from_icon_name(GValue *value, gint width, gint G_GNUC_UNUSED(height), GtkIconLookupFlags flags) { | |
527 | + | |
528 | + const gchar * icon_name = g_value_get_string(value); | |
529 | + | |
530 | + if(!icon_name) | |
531 | + return NULL; | |
532 | + | |
533 | + return gtk_icon_theme_load_icon( | |
534 | + gtk_icon_theme_get_default(), | |
535 | + icon_name, | |
536 | + width, | |
537 | + flags, // GTK_ICON_LOOKUP_GENERIC_FALLBACK, | |
538 | + NULL | |
539 | + ); | |
540 | + | |
541 | + } | |
542 | + | |
543 | 543 | GdkPixbuf * g_action_get_pixbuf(GAction *action, GtkIconSize icon_size, GtkIconLookupFlags flags) { |
544 | 544 | |
545 | 545 | struct Properties { | ... | ... |
src/objects/actions/button.c
... | ... | @@ -88,8 +88,6 @@ |
88 | 88 | return item; |
89 | 89 | } |
90 | 90 | |
91 | - | |
92 | - /// FIXME: Get size from icon_size | |
93 | 91 | GdkPixbuf * pixbuf = g_action_get_pixbuf(action, icon_size, GTK_ICON_LOOKUP_GENERIC_FALLBACK); |
94 | 92 | |
95 | 93 | if(pixbuf) { |
... | ... | @@ -107,49 +105,7 @@ |
107 | 105 | return item; |
108 | 106 | } |
109 | 107 | |
110 | - | |
111 | 108 | return NULL; |
112 | 109 | |
113 | 110 | } |
114 | 111 | |
115 | - | |
116 | - /* | |
117 | - /// @brief Create a button associated with the action. | |
118 | - GtkWidget * pw3270_action_button_new(GAction *action, const gchar *action_name) { | |
119 | - | |
120 | - g_return_val_if_fail(PW3270_IS_ACTION(action),NULL); | |
121 | - | |
122 | - const gchar * icon_name = pw3270_action_get_icon_name(action); | |
123 | - | |
124 | - GtkWidget *image; | |
125 | - if(g_str_has_prefix(icon_name,"gtk-")) { | |
126 | - image = gtk_image_new_from_icon_name(icon_name,GTK_ICON_SIZE_BUTTON); | |
127 | - } else { | |
128 | - g_autofree gchar * symbolic_name = g_strconcat(icon_name,"-symbolic",NULL); | |
129 | - image = gtk_image_new_from_icon_name(symbolic_name,GTK_ICON_SIZE_BUTTON); | |
130 | - } | |
131 | - | |
132 | - if(!image) { | |
133 | - g_warning("Can't create button for icon \"%s\"",icon_name); | |
134 | - return NULL; | |
135 | - } | |
136 | - | |
137 | - GtkWidget * button = gtk_button_new(); | |
138 | - gtk_button_set_image(GTK_BUTTON(button), image); | |
139 | - | |
140 | - gtk_actionable_set_action_name(GTK_ACTIONABLE(button),action_name ? action_name : g_action_get_name(action)); | |
141 | - gtk_widget_set_visible(button,g_action_get_enabled(action)); | |
142 | - | |
143 | - gtk_widget_set_can_focus(button,FALSE); | |
144 | - gtk_widget_set_can_default(button,FALSE); | |
145 | - gtk_widget_set_focus_on_click(button,FALSE); | |
146 | - | |
147 | - const gchar * tooltip = pw3270_action_get_tooltip(action); | |
148 | - if(tooltip) | |
149 | - gtk_widget_set_tooltip_markup(button,tooltip); | |
150 | - | |
151 | - return button; | |
152 | - | |
153 | - } | |
154 | - */ | |
155 | - | ... | ... |
src/objects/actions/clipboard.c
... | ... | @@ -34,120 +34,3 @@ |
34 | 34 | |
35 | 35 | #include "private.h" |
36 | 36 | #include <v3270.h> |
37 | - | |
38 | - static V3270_COPY_MODE get_copy_mode_from_parameter(GVariant *parameter) { | |
39 | - | |
40 | - static const struct { | |
41 | - const gchar * name; | |
42 | - V3270_COPY_MODE value; | |
43 | - } targets[] = { | |
44 | - { "auto", V3270_COPY_DEFAULT }, | |
45 | - { "system", V3270_COPY_DEFAULT }, | |
46 | - { "default", V3270_COPY_DEFAULT }, | |
47 | - { "system default", V3270_COPY_DEFAULT }, | |
48 | - { "formatted", V3270_COPY_FORMATTED }, | |
49 | - { "text", V3270_COPY_TEXT }, | |
50 | - { "table", V3270_COPY_TABLE }, | |
51 | - { "append", V3270_COPY_APPEND } | |
52 | - | |
53 | - }; | |
54 | - | |
55 | - if(parameter) { | |
56 | - | |
57 | - const gchar * target = g_variant_get_string(parameter,NULL); | |
58 | - | |
59 | - if(target && *target) { | |
60 | - | |
61 | - size_t ix; | |
62 | - for(ix = 0; ix < G_N_ELEMENTS(targets); ix++) { | |
63 | - | |
64 | - if(!g_ascii_strcasecmp(target,targets[ix].name)) | |
65 | - return targets[ix].value; | |
66 | - | |
67 | - } | |
68 | - | |
69 | - } | |
70 | - | |
71 | - } | |
72 | - | |
73 | - return V3270_COPY_DEFAULT; | |
74 | - } | |
75 | - | |
76 | - static void activate_copy(GAction G_GNUC_UNUSED(*action), GVariant *parameter, GtkWidget *terminal) { | |
77 | - | |
78 | - debug("%s",__FUNCTION__); | |
79 | - v3270_clipboard_set(terminal,get_copy_mode_from_parameter(parameter),FALSE); | |
80 | - | |
81 | - } | |
82 | - | |
83 | - static void activate_cut(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | |
84 | - | |
85 | - debug("%s",__FUNCTION__); | |
86 | - v3270_clipboard_set(terminal,get_copy_mode_from_parameter(parameter),TRUE); | |
87 | - | |
88 | - } | |
89 | - | |
90 | - static void activate_paste(GAction G_GNUC_UNUSED(*action), GVariant *parameter, GtkWidget *terminal) { | |
91 | - | |
92 | - | |
93 | - if(!parameter) { | |
94 | - debug("%s %p",__FUNCTION__,"NULL"); | |
95 | - v3270_clipboard_get_from_url(terminal,NULL); | |
96 | - } else { | |
97 | - debug("%s \"%s\"",__FUNCTION__,g_variant_get_string(parameter,NULL)); | |
98 | - v3270_clipboard_get_from_url(terminal,g_variant_get_string(parameter,NULL)); | |
99 | - } | |
100 | - | |
101 | - } | |
102 | - | |
103 | - GAction * pw3270_action_copy_new(void) { | |
104 | - | |
105 | - pw3270SimpleAction * action = pw3270_simple_action_new(); | |
106 | - | |
107 | - action->parent.activate = activate_copy; | |
108 | - action->parent.types.parameter = G_VARIANT_TYPE_STRING; | |
109 | - | |
110 | - action->group.id = LIB3270_ACTION_GROUP_SELECTION; | |
111 | - action->parent.name = "copy"; | |
112 | - action->icon_name = "edit-copy"; | |
113 | - action->label = N_( "_Copy" ); | |
114 | - action->tooltip = N_( "Copy selected area to clipboard." ); | |
115 | - | |
116 | - return G_ACTION(action); | |
117 | - | |
118 | - } | |
119 | - | |
120 | - GAction * pw3270_action_cut_new(void) { | |
121 | - | |
122 | - pw3270SimpleAction * action = pw3270_simple_action_new(); | |
123 | - | |
124 | - action->parent.activate = activate_cut; | |
125 | - action->parent.types.parameter = G_VARIANT_TYPE_STRING; | |
126 | - | |
127 | - action->group.id = LIB3270_ACTION_GROUP_SELECTION; | |
128 | - action->parent.name = "cut"; | |
129 | - action->icon_name = "edit-cut"; | |
130 | - action->label = N_( "C_ut" ); | |
131 | - action->tooltip = N_( "Cut selected area." ); | |
132 | - | |
133 | - return G_ACTION(action); | |
134 | - | |
135 | - } | |
136 | - | |
137 | - GAction * pw3270_action_paste_new(void) { | |
138 | - | |
139 | - | |
140 | - pw3270SimpleAction * action = pw3270_simple_action_new(); | |
141 | - | |
142 | - action->parent.activate = activate_paste; | |
143 | - action->parent.types.parameter = G_VARIANT_TYPE_STRING; | |
144 | - | |
145 | - action->group.id = LIB3270_ACTION_GROUP_LOCK_STATE; | |
146 | - action->parent.name = "paste"; | |
147 | - action->icon_name = "edit-paste"; | |
148 | - action->label = N_( "_Paste" ); | |
149 | - action->tooltip = N_( "Paste text from clipboard." ); | |
150 | - | |
151 | - return G_ACTION(action); | |
152 | - | |
153 | - } | ... | ... |
src/objects/actions/connect.c
... | ... | @@ -34,24 +34,20 @@ |
34 | 34 | |
35 | 35 | #include "private.h" |
36 | 36 | |
37 | - /* | |
38 | 37 | static void activate(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { |
39 | 38 | |
40 | 39 | debug("%s",__FUNCTION__); |
41 | 40 | gtk_widget_activate(terminal); |
42 | 41 | |
43 | 42 | } |
44 | - */ | |
45 | - | |
46 | - /* | |
47 | - GAction * pw3270_action_connect_new(void) { | |
48 | 43 | |
49 | - pw3270Action * action = PW3270_ACTION(pw3270_action_new_from_lib3270(lib3270_action_get_by_name("reconnect"))); | |
44 | + GAction * pw3270_action_connect_new(void) { | |
50 | 45 | |
51 | - action->activate = activate; | |
52 | - action->name = "connect"; | |
46 | + pw3270SimpleAction * action = pw3270_simple_action_new_from_lib3270(lib3270_action_get_by_name("reconnect"),"connect"); | |
47 | + action->parent.activate = activate; | |
48 | + action->label = N_("Connect"); | |
49 | + action->tooltip = N_("Connect to host"); | |
53 | 50 | |
54 | 51 | return G_ACTION(action); |
55 | 52 | |
56 | 53 | } |
57 | - */ | ... | ... |
src/objects/actions/print.c
... | ... | @@ -36,75 +36,3 @@ |
36 | 36 | #include <v3270.h> |
37 | 37 | #include <pw3270/application.h> |
38 | 38 | |
39 | - /* | |
40 | - static void activate_print_all(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | |
41 | - debug("%s",__FUNCTION__); | |
42 | - v3270_print_all(terminal,NULL); | |
43 | - } | |
44 | - | |
45 | - static void activate_print_selected(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | |
46 | - debug("%s",__FUNCTION__); | |
47 | - v3270_print_selected(terminal,NULL); | |
48 | - } | |
49 | - | |
50 | - static void activate_print(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | |
51 | - | |
52 | - debug("%s",__FUNCTION__); | |
53 | - | |
54 | - } | |
55 | - | |
56 | - void pw3270_application_print_copy_activated(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | |
57 | - | |
58 | - debug("%s",__FUNCTION__); | |
59 | - v3270_print_copy(terminal,NULL); | |
60 | - | |
61 | - } | |
62 | - | |
63 | - GAction * pw3270_action_print_new(void) { | |
64 | - | |
65 | - pw3270SimpleAction * action = pw3270_simple_action_new(); | |
66 | - | |
67 | - action->parent.activate = activate_print; | |
68 | -// action->parent.types.parameter = G_VARIANT_TYPE_STRING; | |
69 | - | |
70 | - action->group.id = LIB3270_ACTION_GROUP_ONLINE; | |
71 | - action->parent.name = "print"; | |
72 | - action->label = N_( "Print" ); | |
73 | - action->icon_name = "printer"; | |
74 | - action->tooltip = N_( "Print terminal contents or selected area." ); | |
75 | - | |
76 | - return G_ACTION(action); | |
77 | - | |
78 | - } | |
79 | - | |
80 | - GAction * pw3270_action_print_all_new(void) { | |
81 | - | |
82 | - pw3270SimpleAction * action = pw3270_simple_action_new(); | |
83 | - | |
84 | - action->parent.activate = activate_print_all; | |
85 | - | |
86 | - action->group.id = LIB3270_ACTION_GROUP_ONLINE; | |
87 | - action->parent.name = "print.screen"; | |
88 | - action->icon_name = "printer"; | |
89 | - action->label = N_( "Print screen" ); | |
90 | - | |
91 | - return G_ACTION(action); | |
92 | - | |
93 | - } | |
94 | - | |
95 | - GAction * pw3270_action_print_selected_new(void) { | |
96 | - | |
97 | - pw3270SimpleAction * action = pw3270_simple_action_new(); | |
98 | - | |
99 | - action->parent.activate = activate_print_selected; | |
100 | - | |
101 | - action->group.id = LIB3270_ACTION_GROUP_SELECTION; | |
102 | - action->parent.name = "print.selected"; | |
103 | - action->icon_name = "printer"; | |
104 | - action->label = N_( "Print selected" ); | |
105 | - | |
106 | - return G_ACTION(action); | |
107 | - | |
108 | - } | |
109 | - */ | |
110 | - | ... | ... |
src/objects/actions/private.h
... | ... | @@ -57,19 +57,6 @@ |
57 | 57 | G_GNUC_INTERNAL void pw3270_action_notify_state(GAction *object); |
58 | 58 | |
59 | 59 | // Internal actions |
60 | -// G_GNUC_INTERNAL GAction * pw3270_action_connect_new(void); | |
61 | - G_GNUC_INTERNAL GAction * pw3270_action_copy_new(void); | |
62 | - G_GNUC_INTERNAL GAction * pw3270_action_cut_new(void); | |
63 | - G_GNUC_INTERNAL GAction * pw3270_action_paste_new(void); | |
64 | - | |
65 | - /* | |
66 | - G_GNUC_INTERNAL GAction * pw3270_action_save_new(void); | |
67 | - G_GNUC_INTERNAL GAction * pw3270_action_save_screen_new(void); | |
68 | - G_GNUC_INTERNAL GAction * pw3270_action_save_selected_new(void); | |
69 | - | |
70 | - G_GNUC_INTERNAL GAction * pw3270_action_print_new(void); | |
71 | - G_GNUC_INTERNAL GAction * pw3270_action_print_all_new(void); | |
72 | - G_GNUC_INTERNAL GAction * pw3270_action_print_selected_new(void); | |
73 | - */ | |
60 | + G_GNUC_INTERNAL GAction * pw3270_action_connect_new(void); | |
74 | 61 | |
75 | 62 | #endif // PRIVATE_H_INCLUDED | ... | ... |
src/objects/actions/save.c
... | ... | @@ -36,72 +36,3 @@ |
36 | 36 | #include <v3270.h> |
37 | 37 | #include <pw3270/application.h> |
38 | 38 | |
39 | - /* | |
40 | - static void activate_save_screen(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | |
41 | - debug("%s",__FUNCTION__); | |
42 | - v3270_save_all(terminal,NULL,NULL); | |
43 | - } | |
44 | - | |
45 | - static void activate_save_selected(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | |
46 | - debug("%s",__FUNCTION__); | |
47 | - v3270_save_selected(terminal,NULL,NULL); | |
48 | - } | |
49 | - | |
50 | - void pw3270_application_save_copy_activated(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | |
51 | - debug("%s",__FUNCTION__); | |
52 | - v3270_save_copy(terminal,NULL,NULL); | |
53 | - } | |
54 | - | |
55 | - static void activate_save(GAction G_GNUC_UNUSED(*action), GVariant G_GNUC_UNUSED(*parameter), GtkWidget *terminal) { | |
56 | - | |
57 | - debug("%s",__FUNCTION__); | |
58 | - | |
59 | - } | |
60 | - | |
61 | - GAction * pw3270_action_save_new(void) { | |
62 | - | |
63 | - pw3270SimpleAction * action = pw3270_simple_action_new(); | |
64 | - | |
65 | - action->parent.activate = activate_save; | |
66 | - action->parent.types.parameter = G_VARIANT_TYPE_STRING; | |
67 | - | |
68 | - action->group.id = LIB3270_ACTION_GROUP_ONLINE; | |
69 | - action->parent.name = "save"; | |
70 | - action->icon_name = "document-save"; | |
71 | - action->label = N_( "_Save" ); | |
72 | - action->tooltip = N_( "Save terminal contents." ); | |
73 | - | |
74 | - return G_ACTION(action); | |
75 | - | |
76 | - } | |
77 | - | |
78 | - GAction * pw3270_action_save_screen_new(void) { | |
79 | - | |
80 | - pw3270SimpleAction * action = pw3270_simple_action_new(); | |
81 | - | |
82 | - action->parent.activate = activate_save_screen; | |
83 | - | |
84 | - action->group.id = LIB3270_ACTION_GROUP_ONLINE; | |
85 | - action->parent.name = "save.screen"; | |
86 | - action->icon_name = "document-save"; | |
87 | - action->label = N_( "Save screen" ); | |
88 | - | |
89 | - return G_ACTION(action); | |
90 | - | |
91 | - } | |
92 | - | |
93 | - GAction * pw3270_action_save_selected_new(void) { | |
94 | - | |
95 | - pw3270SimpleAction * action = pw3270_simple_action_new(); | |
96 | - | |
97 | - action->parent.activate = activate_save_selected; | |
98 | - | |
99 | - action->group.id = LIB3270_ACTION_GROUP_SELECTION; | |
100 | - action->parent.name = "save.selected"; | |
101 | - action->icon_name = "document-save"; | |
102 | - action->label = N_( "Save selected" ); | |
103 | - | |
104 | - return G_ACTION(action); | |
105 | - | |
106 | - } | |
107 | -*/ | ... | ... |
src/objects/actions/window.c
... | ... | @@ -37,72 +37,3 @@ |
37 | 37 | #include <v3270/actions.h> |
38 | 38 | #include <pw3270/window.h> |
39 | 39 | |
40 | -/* | |
41 | - void pw3270_window_add_actions(GtkWidget * appwindow) { | |
42 | - | |
43 | - GActionMap * map = G_ACTION_MAP(appwindow); | |
44 | - size_t ix; | |
45 | - | |
46 | - // Map lib3270 actions | |
47 | - { | |
48 | - const LIB3270_ACTION * actions = lib3270_get_actions(); | |
49 | - for(ix = 0; actions[ix].name; ix++) { | |
50 | - | |
51 | - GAction *action = g_action_new_from_lib3270(&actions[ix]); | |
52 | - g_action_map_add_action(map,action); | |
53 | - | |
54 | - } | |
55 | - } | |
56 | - | |
57 | - // Map toggles | |
58 | - { | |
59 | - const LIB3270_TOGGLE * toggles = lib3270_get_toggles(); | |
60 | - for(ix = 0; toggles[ix].name; ix++) { | |
61 | - | |
62 | - GAction *action = g_action_new_from_toggle(&toggles[ix]); | |
63 | - g_action_map_add_action(map,action); | |
64 | - | |
65 | - } | |
66 | - } | |
67 | - | |
68 | - // Map V3270 actions | |
69 | - { | |
70 | - const V3270_ACTION * actions = v3270_get_actions(); | |
71 | - | |
72 | - for(ix = 0; actions[ix].name; ix++) { | |
73 | - GAction * action = v3270_action_new(&actions[ix]); | |
74 | - g_action_map_add_action(map,action); | |
75 | - } | |
76 | - | |
77 | - } | |
78 | - | |
79 | - // Map special actions | |
80 | - { | |
81 | - GAction * actions[] = { | |
82 | - v3270_pfkey_action_new(), | |
83 | - v3270_pakey_action_new(), | |
84 | -// pw3270_action_connect_new(), | |
85 | -// pw3270_action_copy_new(), | |
86 | -// pw3270_action_cut_new(), | |
87 | -// pw3270_action_paste_new(), | |
88 | - | |
89 | -// pw3270_action_save_new(), | |
90 | -// pw3270_action_save_screen_new(), | |
91 | -// pw3270_action_save_selected_new(), | |
92 | - | |
93 | -// pw3270_action_print_new(), | |
94 | -// pw3270_action_print_all_new(), | |
95 | -// pw3270_action_print_selected_new(), | |
96 | - | |
97 | - }; | |
98 | - | |
99 | - for(ix = 0; ix < G_N_ELEMENTS(actions); ix++) { | |
100 | - debug("Creating action %u (names=%s ptype=%s)", (unsigned int) ix, g_action_get_name(actions[ix]), (const char *) g_action_get_parameter_type(actions[ix])); | |
101 | - g_action_map_add_action(map,actions[ix]); | |
102 | - } | |
103 | - } | |
104 | - | |
105 | - debug("%s ends",__FUNCTION__); | |
106 | - | |
107 | - } | |
108 | -*/ | ... | ... |
src/objects/window/actions/setcolors.c