Commit 56f786372924e2cf745c4fc2ed6983a775867e0f

Authored by Perry Werneck
1 parent 122c9194

Ajustando comportamento das "actions" que parece ter mudado num dos últimos updates do gtk.

src/include/pw3270.h
... ... @@ -89,6 +89,9 @@
89 89  
90 90 LIB3270_EXPORT void pw3270_set_host_charset(GtkWidget *widget, const gchar *name);
91 91  
  92 + LIB3270_EXPORT void pw3270_set_action_state(GtkAction *action, gboolean on);
  93 +
  94 +
92 95 typedef enum pw3270_src
93 96 {
94 97 PW3270_SRC_ALL, /**< Screen contents */
... ...
src/plugins/rx3270/pluginmain.cc
... ... @@ -436,12 +436,7 @@ extern &quot;C&quot;
436 436 return;
437 437 }
438 438  
439   -#if GTK_CHECK_VERSION(3,10,0)
440   - g_simple_action_set_enabled(G_SIMPLE_ACTION(action),FALSE);
441   -#else
442   - gtk_action_set_sensitive(action,FALSE);
443   -#endif // GTK(3,10)
444   -
  439 + pw3270_set_action_state(action,FALSE);
445 440  
446 441 if(filename)
447 442 {
... ... @@ -484,11 +479,7 @@ extern &quot;C&quot;
484 479  
485 480 }
486 481  
487   -#if GTK_CHECK_VERSION(3,10,0)
488   - g_simple_action_set_enabled(G_SIMPLE_ACTION(action),TRUE);
489   -#else
490   - gtk_action_set_sensitive(action,TRUE);
491   -#endif // GTK(3,10)
  482 + pw3270_set_action_state(action,TRUE);
492 483  
493 484 #if GTK_CHECK_VERSION(2,32,0)
494 485 g_mutex_unlock(&mutex);
... ...
src/pw3270/tools.c
... ... @@ -223,3 +223,24 @@ LIB3270_EXPORT void pw3270_set_host_charset(GtkWidget *widget, const gchar *name
223 223 gtk_widget_destroy(dialog);
224 224  
225 225 }
  226 +
  227 +LIB3270_EXPORT void pw3270_set_action_state(GtkAction *action, gboolean on)
  228 +{
  229 +
  230 + if(!action)
  231 + {
  232 + return;
  233 + }
  234 +#if GTK_CHECK_VERSION(3,10,0)
  235 + else if(G_IS_SIMPLE_ACTION(action))
  236 + {
  237 + g_simple_action_set_enabled(G_SIMPLE_ACTION(action),FALSE);
  238 + }
  239 +#endif // GTK(3,10)
  240 + else
  241 + {
  242 + gtk_action_set_sensitive(action,FALSE);
  243 + }
  244 +
  245 + }
  246 +
... ...
src/pw3270/window.c
... ... @@ -416,17 +416,9 @@
416 416 gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget),menu);
417 417 }
418 418  
419   - static void setSensitive(GtkAction *action, gboolean on)
420   - {
421   - if(action)
422   - {
423   - gtk_action_set_sensitive(action,on);
424   - }
425   - }
426   -
427 419 static void pastenext(GtkWidget *widget, gboolean on, GtkAction **action)
428 420 {
429   - setSensitive(action[ACTION_PASTENEXT],on);
  421 + pw3270_set_action_state(action[ACTION_PASTENEXT],on);
430 422 }
431 423  
432 424 static void disconnected(GtkWidget *terminal, GtkWidget * window)
... ... @@ -485,7 +477,7 @@
485 477 {
486 478 GtkAction **action = (GtkAction **) g_object_get_data(G_OBJECT(widget),"named_actions");
487 479 gtk_action_group_set_sensitive(group[ACTION_GROUP_SELECTION],on);
488   - setSensitive(action[ACTION_RESELECT],!on);
  480 + pw3270_set_action_state(action[ACTION_RESELECT],!on);
489 481 }
490 482  
491 483 static gboolean popup_menu(GtkWidget *widget, gboolean selected, gboolean online, GdkEventButton *event, GtkWidget **popup)
... ... @@ -647,11 +639,11 @@
647 639  
648 640 if(action[ACTION_PASTENEXT])
649 641 {
650   - setSensitive(action[ACTION_PASTENEXT],FALSE);
  642 + pw3270_set_action_state(action[ACTION_PASTENEXT],FALSE);
651 643 g_signal_connect(widget->terminal,"pastenext",G_CALLBACK(pastenext),action);
652 644 }
653 645  
654   - setSensitive(action[ACTION_RESELECT],FALSE);
  646 + pw3270_set_action_state(action[ACTION_RESELECT],FALSE);
655 647  
656 648 // Connect action signals
657 649 g_signal_connect(widget->terminal,"disconnected",G_CALLBACK(disconnected),widget);
... ...