Commit 49c725e0cf91909f00d7d4ba1b428c9d7e6c2c2f

Authored by Perry Werneck
1 parent 8ef4f88a

Implementing tab-menu.

Showing 1 changed file with 18 additions and 31 deletions   Show diff stats
src/objects/window/page.c
@@ -50,13 +50,21 @@ @@ -50,13 +50,21 @@
50 50
51 G_DEFINE_TYPE(pw3270TabLabel, pw3270TabLabel, GTK_TYPE_LABEL); 51 G_DEFINE_TYPE(pw3270TabLabel, pw3270TabLabel, GTK_TYPE_LABEL);
52 52
53 -  
54 static void popup_menu_detach(GtkWidget G_GNUC_UNUSED(*label), GtkMenu *menu) { 53 static void popup_menu_detach(GtkWidget G_GNUC_UNUSED(*label), GtkMenu *menu) {
55 54
56 - debug("%s",__FUNCTION__)  
57 - gtk_widget_destroy(GTK_WIDGET(menu)); 55 + debug("%s(%p)",__FUNCTION__,menu);
  56 +
  57 + }
  58 +
  59 + static void popup_menu_deactivated(GtkMenu *menu, GtkWidget G_GNUC_UNUSED(*label)) {
  60 + gtk_menu_detach(menu);
  61 + }
58 62
  63 +#ifdef DEBUG
  64 + static void menu_destroy(GtkWidget *menu) {
  65 + debug("%s(%p)",__FUNCTION__,menu);
59 } 66 }
  67 +#endif // DEBUG
60 68
61 static gboolean tab_label_button_press(GtkWidget *label, GdkEventButton *event) { 69 static gboolean tab_label_button_press(GtkWidget *label, GdkEventButton *event) {
62 70
@@ -64,6 +72,11 @@ @@ -64,6 +72,11 @@
64 72
65 GtkWidget * menu = gtk_menu_new(); 73 GtkWidget * menu = gtk_menu_new();
66 74
  75 +#ifdef DEBUG
  76 + g_signal_connect(menu,"destroy",G_CALLBACK(menu_destroy),NULL);
  77 +#endif // DEBUG
  78 + g_signal_connect(menu,"deactivate",G_CALLBACK(popup_menu_deactivated),label);
  79 +
67 debug("menu=%p",menu); 80 debug("menu=%p",menu);
68 81
69 gtk_menu_attach_to_widget(GTK_MENU(menu), GTK_WIDGET(label), popup_menu_detach); 82 gtk_menu_attach_to_widget(GTK_MENU(menu), GTK_WIDGET(label), popup_menu_detach);
@@ -149,6 +162,7 @@ @@ -149,6 +162,7 @@
149 162
150 static gboolean on_terminal_focus(GtkWidget *terminal, GdkEvent G_GNUC_UNUSED(*event), GtkWidget * window) { 163 static gboolean on_terminal_focus(GtkWidget *terminal, GdkEvent G_GNUC_UNUSED(*event), GtkWidget * window) {
151 164
  165 + gtk_widget_grab_default(terminal);
152 pw3270_application_window_set_active_terminal(window,terminal); 166 pw3270_application_window_set_active_terminal(window,terminal);
153 167
154 /* 168 /*
@@ -246,42 +260,15 @@ @@ -246,42 +260,15 @@
246 260
247 pw3270_application_window_set_active_terminal(GTK_WIDGET(window),NULL); 261 pw3270_application_window_set_active_terminal(GTK_WIDGET(window),NULL);
248 262
249 - /*  
250 - pw3270_window_set_subtitle(GTK_WIDGET(window), _("Disconnected from host"));  
251 -  
252 - // Update actions  
253 - size_t ix;  
254 - gchar ** actions = g_action_group_list_actions(G_ACTION_GROUP(window));  
255 -  
256 - for(ix = 0; actions[ix]; ix++) {  
257 -  
258 - GAction * action = g_action_map_lookup_action(G_ACTION_MAP(window), actions[ix]);  
259 -  
260 - if(action) {  
261 -  
262 - if(PW3270_IS_ACTION(action)) {  
263 - pw3270_action_set_terminal_widget(action,NULL);  
264 - } else if(V3270_IS_ACTION(action)) {  
265 - v3270_action_set_terminal_widget(action,NULL);  
266 - }  
267 -  
268 - }  
269 -  
270 - }  
271 -  
272 - g_strfreev(actions);  
273 - */  
274 -  
275 } 263 }
276 264
277 static void close_page(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) { 265 static void close_page(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) {
278 266
279 - g_object_ref(terminal); 267 + debug("%s",__FUNCTION__);
280 268
281 GtkNotebook * notebook = GTK_NOTEBOOK(gtk_widget_get_parent(terminal)); 269 GtkNotebook * notebook = GTK_NOTEBOOK(gtk_widget_get_parent(terminal));
282 gtk_notebook_remove_page(notebook,gtk_notebook_page_num(notebook, terminal)); 270 gtk_notebook_remove_page(notebook,gtk_notebook_page_num(notebook, terminal));
283 271
284 - g_object_unref(terminal);  
285 272
286 } 273 }
287 274