Commit 818e87e6f91e43209446d407476304b898c82c23
1 parent
2bb408b2
Exists in
script-support
Working on script dialog.
Showing
1 changed file
with
59 additions
and
0 deletions
Show diff stats
src/objects/application/actions/script.c
... | ... | @@ -28,6 +28,7 @@ |
28 | 28 | |
29 | 29 | static GtkWidget * factory(V3270SimpleAction *action, GtkWidget *terminal); |
30 | 30 | static void response(GtkWidget *dialog, gint response_id, GtkWidget *input); |
31 | +static void icon_press(GtkWidget *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_pos, G_GNUC_UNUSED GdkEvent *event, const void *dunno); | |
31 | 32 | |
32 | 33 | GAction * pw3270_script_action_new() { |
33 | 34 | |
... | ... | @@ -75,6 +76,14 @@ GtkWidget * factory(V3270SimpleAction * action, GtkWidget *terminal) { |
75 | 76 | gtk_widget_set_vexpand(input,FALSE); |
76 | 77 | gtk_entry_set_width_chars(GTK_ENTRY(input),60); |
77 | 78 | |
79 | + gtk_entry_set_icon_from_icon_name( | |
80 | + GTK_ENTRY(input), | |
81 | + GTK_ENTRY_ICON_SECONDARY, | |
82 | + "document-open" | |
83 | + ); | |
84 | + | |
85 | + g_signal_connect(input,"icon_press",G_CALLBACK(icon_press),NULL); | |
86 | + | |
78 | 87 | gtk_grid_attach(grid,input,1,0,10,1); |
79 | 88 | |
80 | 89 | // Setup window |
... | ... | @@ -89,6 +98,8 @@ GtkWidget * factory(V3270SimpleAction * action, GtkWidget *terminal) { |
89 | 98 | NULL |
90 | 99 | ); |
91 | 100 | |
101 | + /* | |
102 | + // Cant use gtk_entry_bind_to_filechooser due to plugin interaction | |
92 | 103 | gtk_entry_bind_to_filechooser( |
93 | 104 | input, |
94 | 105 | GTK_FILE_CHOOSER_ACTION_OPEN, |
... | ... | @@ -97,6 +108,7 @@ GtkWidget * factory(V3270SimpleAction * action, GtkWidget *terminal) { |
97 | 108 | "*.*", |
98 | 109 | _("All files") |
99 | 110 | ); |
111 | + */ | |
100 | 112 | |
101 | 113 | g_signal_connect(dialog,"response",G_CALLBACK(response),input); |
102 | 114 | |
... | ... | @@ -105,6 +117,53 @@ GtkWidget * factory(V3270SimpleAction * action, GtkWidget *terminal) { |
105 | 117 | |
106 | 118 | } |
107 | 119 | |
120 | +void icon_press(GtkWidget *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_pos, G_GNUC_UNUSED GdkEvent *event, const void *dunno) { | |
121 | + | |
122 | + GtkWidget * dialog = | |
123 | + gtk_file_chooser_dialog_new( | |
124 | + _("Select script to run"), | |
125 | + GTK_WINDOW(gtk_widget_get_toplevel(entry)), | |
126 | + GTK_FILE_CHOOSER_ACTION_OPEN, | |
127 | + _("Cancel"), GTK_RESPONSE_CANCEL, | |
128 | + _("Run"), GTK_RESPONSE_ACCEPT, | |
129 | + NULL | |
130 | + ); | |
131 | + | |
132 | + gtk_window_set_modal(GTK_WINDOW(dialog),TRUE); | |
133 | + gtk_window_set_deletable(GTK_WINDOW(dialog),FALSE); | |
134 | + | |
135 | + const gchar *filename = gtk_entry_get_text(GTK_ENTRY(entry)); | |
136 | + | |
137 | + pw3270_application_plugin_call( | |
138 | + g_application_get_default(), | |
139 | + "pw3270_plugin_set_script_chooser", | |
140 | + dialog | |
141 | + ); | |
142 | + | |
143 | + /* | |
144 | + g_autoptr(GSList) filters = gtk_file_chooser_list_filters(GTK_FILE_CHOOSER(dialog)); | |
145 | + | |
146 | + if(g_slist_length(filters) == 0) { | |
147 | + gtk_widget_destroy(dialog); | |
148 | + } | |
149 | + */ | |
150 | + | |
151 | + if(filename && *filename) | |
152 | + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),filename); | |
153 | + | |
154 | + gtk_widget_show_all(dialog); | |
155 | + | |
156 | + if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { | |
157 | + | |
158 | + g_autofree gchar * filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | |
159 | + gtk_entry_set_text(GTK_ENTRY(entry),filename); | |
160 | + | |
161 | + } | |
162 | + | |
163 | + gtk_widget_destroy(dialog); | |
164 | + | |
165 | +} | |
166 | + | |
108 | 167 | void response(GtkWidget *dialog, gint response_id, GtkWidget *input) { |
109 | 168 | |
110 | 169 | if(response_id == GTK_RESPONSE_APPLY) { | ... | ... |