Commit 7abe674b07a336c9c317c30baccb6a481cb75b92
1 parent
4b6f991f
Exists in
master
and in
5 other branches
Reincluindo dialogo para salvar o bloco selecionado
Showing
5 changed files
with
68 additions
and
44 deletions
Show diff stats
src/gtk/actions.c
... | ... | @@ -97,13 +97,13 @@ static void reload_action(GtkAction *action, GtkWidget *widget) |
97 | 97 | static void copy_action(GtkAction *action, GtkWidget *widget) |
98 | 98 | { |
99 | 99 | trace("Action %s activated on widget %p",gtk_action_get_name(action),widget); |
100 | - v3270_copy_clipboard(GTK_V3270(widget)); | |
100 | + v3270_copy_clipboard(widget); | |
101 | 101 | } |
102 | 102 | |
103 | 103 | static void paste_clipboard_action(GtkAction *action, GtkWidget *widget) |
104 | 104 | { |
105 | 105 | trace("Action %s activated on widget %p",gtk_action_get_name(action),widget); |
106 | - v3270_paste_clipboard(GTK_V3270(widget)); | |
106 | + v3270_paste_clipboard(widget); | |
107 | 107 | } |
108 | 108 | |
109 | 109 | static void paste_next_action(GtkAction *action, GtkWidget *widget) |
... | ... | @@ -189,7 +189,7 @@ static void lib3270_toggle_action(GtkToggleAction *action,GtkWidget *widget) |
189 | 189 | |
190 | 190 | if(toggle == TOGGLE_GDKDEBUG) |
191 | 191 | gdk_window_set_debug_updates(gtk_toggle_action_get_active(action)); |
192 | - else | |
192 | + else if(toggle < LIB3270_TOGGLE_COUNT) | |
193 | 193 | lib3270_set_toggle(GTK_V3270(widget)->host,toggle,gtk_toggle_action_get_active(action)); |
194 | 194 | } |
195 | 195 | |
... | ... | @@ -511,7 +511,8 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash |
511 | 511 | |
512 | 512 | case ACTION_TYPE_TOGGLE: |
513 | 513 | action = GTK_ACTION(gtk_toggle_action_new(nm,NULL,NULL,NULL)); |
514 | - toggle_action[id] = action; | |
514 | + if(id < LIB3270_TOGGLE_COUNT) | |
515 | + toggle_action[id] = action; | |
515 | 516 | g_object_set_data(G_OBJECT(action),"toggle_id",(gpointer) id); |
516 | 517 | gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action),(lib3270_get_toggle(GTK_V3270(widget)->host,id) != 0)); |
517 | 518 | g_signal_connect(action,"toggled",G_CALLBACK(lib3270_toggle_action),widget); | ... | ... |
src/gtk/dialog.c
... | ... | @@ -34,17 +34,22 @@ |
34 | 34 | |
35 | 35 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
36 | 36 | |
37 | - static int save_dialog(GtkAction *action, GtkWidget *widget, const gchar *title, const gchar *errmsg, gchar *text) | |
37 | + static int save_dialog(GtkAction *action, GtkWidget *widget, const gchar *title, const gchar *errmsg, const gchar *text) | |
38 | 38 | { |
39 | 39 | GtkWindow * toplevel = GTK_WINDOW(gtk_widget_get_toplevel(widget)); |
40 | 40 | const gchar * user_title = g_object_get_data(G_OBJECT(action),"title"); |
41 | + GtkWidget * dialog; | |
41 | 42 | |
42 | - GtkWidget *dialog = gtk_file_chooser_dialog_new( gettext(user_title ? user_title : title), | |
43 | - toplevel, | |
44 | - GTK_FILE_CHOOSER_ACTION_SAVE, | |
45 | - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
46 | - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, | |
47 | - NULL ); | |
43 | + | |
44 | + if(!text) | |
45 | + return; | |
46 | + | |
47 | + dialog = gtk_file_chooser_dialog_new( gettext(user_title ? user_title : title), | |
48 | + toplevel, | |
49 | + GTK_FILE_CHOOSER_ACTION_SAVE, | |
50 | + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
51 | + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, | |
52 | + NULL ); | |
48 | 53 | |
49 | 54 | |
50 | 55 | if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
... | ... | @@ -95,7 +100,7 @@ |
95 | 100 | GtkEntry * host = GTK_ENTRY(gtk_entry_new()); |
96 | 101 | GtkEntry * port = GTK_ENTRY(gtk_entry_new()); |
97 | 102 | GtkToggleButton * checkbox = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_label( _( "Secure connection" ) )); |
98 | - GtkWidget * dialog = gtk_dialog_new_with_buttons( gettext(title ? title : "Select hostname"), | |
103 | + GtkWidget * dialog = gtk_dialog_new_with_buttons( gettext(title ? title : N_( "Select hostname" )), | |
99 | 104 | GTK_WINDOW(gtk_widget_get_toplevel(widget)), |
100 | 105 | GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, |
101 | 106 | GTK_STOCK_CONNECT, GTK_RESPONSE_ACCEPT, |
... | ... | @@ -104,7 +109,7 @@ |
104 | 109 | |
105 | 110 | gtk_window_set_icon_name(GTK_WINDOW(dialog),GTK_STOCK_HOME); |
106 | 111 | gtk_entry_set_max_length(host,0xFF); |
107 | - gtk_entry_set_width_chars(host,60); | |
112 | + gtk_entry_set_width_chars(host,50); | |
108 | 113 | |
109 | 114 | gtk_entry_set_max_length(port,6); |
110 | 115 | gtk_entry_set_width_chars(port,7); |
... | ... | @@ -119,7 +124,7 @@ |
119 | 124 | |
120 | 125 | gtk_container_set_border_width(GTK_CONTAINER(table),5); |
121 | 126 | |
122 | - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),GTK_WIDGET(table),FALSE,FALSE,2); | |
127 | + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(table),FALSE,FALSE,2); | |
123 | 128 | |
124 | 129 | hostname = cfghost; |
125 | 130 | |
... | ... | @@ -157,29 +162,23 @@ |
157 | 162 | switch(gtk_dialog_run(GTK_DIALOG(dialog))) |
158 | 163 | { |
159 | 164 | case GTK_RESPONSE_ACCEPT: |
160 | - | |
161 | - #warning Work in progress | |
162 | - | |
163 | -/* | |
164 | 165 | gtk_widget_set_sensitive(dialog,FALSE); |
165 | 166 | |
166 | - if(gtk_toggle_button_get_active(checkbox)) | |
167 | - strcpy(buffer,"L:"); | |
168 | - else | |
169 | - *buffer = 0; | |
170 | - | |
171 | - strncat(buffer,gtk_entry_get_text(host),1023); | |
172 | - strncat(buffer,":",1023); | |
173 | - strncat(buffer,gtk_entry_get_text(port),1023); | |
167 | + hostname = g_strconcat( gtk_toggle_button_get_active(checkbox) ? "L:" : "", | |
168 | + gtk_entry_get_text(host), | |
169 | + ":", | |
170 | + gtk_entry_get_text(port), | |
171 | + NULL | |
172 | + ); | |
174 | 173 | |
175 | - if(!lib3270_connect(GTK_V3270(widget)->host,host,1)) | |
174 | + if(!lib3270_connect(v3270_get_session(widget),hostname,1)) | |
176 | 175 | { |
177 | 176 | // Connection OK |
177 | + set_string_to_config("host","uri","%s",hostname); | |
178 | 178 | again = FALSE; |
179 | - set_string_to_config("host","uri","%s",buffer); | |
180 | - SetString("Network","Hostname",buffer); | |
181 | 179 | } |
182 | -*/ | |
180 | + | |
181 | + g_free(hostname); | |
183 | 182 | break; |
184 | 183 | |
185 | 184 | case GTK_RESPONSE_REJECT: |
... | ... | @@ -203,6 +202,11 @@ |
203 | 202 | { |
204 | 203 | trace("Action %s activated on widget %p",gtk_action_get_name(action),widget); |
205 | 204 | |
205 | + save_dialog( action, | |
206 | + widget, | |
207 | + N_( "Save selection to file" ), | |
208 | + N_( "Can't save selection to file \n%s" ), | |
209 | + v3270_get_selected_text(widget)); | |
206 | 210 | } |
207 | 211 | |
208 | 212 | void save_copy_action(GtkAction *action, GtkWidget *widget) | ... | ... |
src/gtk/v3270/clipboard.c
... | ... | @@ -75,30 +75,45 @@ static void clipboard_get(GtkClipboard *clipboard, GtkSelectionData *selection, |
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | -void v3270_copy_clipboard(v3270 *widget) | |
78 | +const gchar * v3270_get_selected_text(GtkWidget *widget) | |
79 | 79 | { |
80 | - char *text; | |
81 | - GtkClipboard * clipboard = gtk_widget_get_clipboard(GTK_WIDGET(widget),GDK_SELECTION_CLIPBOARD); | |
80 | + v3270 *terminal; | |
81 | + gchar *text; | |
82 | 82 | |
83 | - if(widget->clipboard) | |
83 | + g_return_val_if_fail(GTK_IS_V3270(widget),NULL); | |
84 | + | |
85 | + terminal = GTK_V3270(widget); | |
86 | + | |
87 | + if(terminal->clipboard) | |
84 | 88 | { |
85 | - g_free(widget->clipboard); | |
86 | - widget->clipboard = NULL; | |
89 | + g_free(terminal->clipboard); | |
90 | + terminal->clipboard = NULL; | |
87 | 91 | } |
88 | 92 | |
89 | - text = lib3270_get_selected(widget->host); | |
93 | + text = lib3270_get_selected(terminal->host); | |
90 | 94 | |
91 | 95 | if(!text) |
92 | 96 | { |
93 | 97 | g_signal_emit(widget,v3270_widget_signal[SIGNAL_CLIPBOARD], 0, FALSE); |
94 | - lib3270_ring_bell(widget->host); | |
95 | - return; | |
98 | + lib3270_ring_bell(terminal->host); | |
99 | + return NULL; | |
96 | 100 | } |
97 | 101 | |
98 | - widget->clipboard = g_convert(text, -1, "UTF-8", lib3270_get_charset(widget->host), NULL, NULL, NULL); | |
102 | + terminal->clipboard = g_convert(text, -1, "UTF-8", lib3270_get_charset(terminal->host), NULL, NULL, NULL); | |
99 | 103 | |
100 | 104 | free(text); |
101 | 105 | |
106 | + return terminal->clipboard; | |
107 | +} | |
108 | + | |
109 | +void v3270_copy_clipboard(GtkWidget *widget) | |
110 | +{ | |
111 | + const gchar * text = v3270_get_selected_text(widget); | |
112 | + GtkClipboard * clipboard = gtk_widget_get_clipboard(widget,GDK_SELECTION_CLIPBOARD); | |
113 | + | |
114 | + if(!text) | |
115 | + return; | |
116 | + | |
102 | 117 | if(gtk_clipboard_set_with_owner( clipboard, |
103 | 118 | targets, |
104 | 119 | G_N_ELEMENTS(targets), |
... | ... | @@ -245,8 +260,8 @@ static void text_received(GtkClipboard *clipboard, const gchar *text, GtkWidget |
245 | 260 | v3270_paste_string(widget,text,"UTF-8"); |
246 | 261 | } |
247 | 262 | |
248 | -void v3270_paste_clipboard(v3270 *widget) | |
263 | +void v3270_paste_clipboard(GtkWidget *widget) | |
249 | 264 | { |
250 | - gtk_clipboard_request_text(gtk_widget_get_clipboard(GTK_WIDGET(widget),GDK_SELECTION_CLIPBOARD),(GtkClipboardTextReceivedFunc) text_received,(gpointer) widget); | |
265 | + gtk_clipboard_request_text(gtk_widget_get_clipboard(widget,GDK_SELECTION_CLIPBOARD),(GtkClipboardTextReceivedFunc) text_received,(gpointer) widget); | |
251 | 266 | } |
252 | 267 | ... | ... |
src/gtk/v3270/v3270.h
... | ... | @@ -201,9 +201,10 @@ |
201 | 201 | void v3270_disconnect(GtkWidget *widget); |
202 | 202 | |
203 | 203 | // Clipboard |
204 | - void v3270_copy_clipboard(v3270 *widget); | |
204 | + const gchar * v3270_get_selected_text(GtkWidget *widget); | |
205 | + void v3270_copy_clipboard(GtkWidget *widget); | |
205 | 206 | void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encoding); |
206 | - void v3270_paste_clipboard(v3270 *widget); | |
207 | + void v3270_paste_clipboard(GtkWidget *widget); | |
207 | 208 | |
208 | 209 | G_END_DECLS |
209 | 210 | ... | ... |