diff --git a/src/include/pw3270.h b/src/include/pw3270.h index 65fdde2..9400486 100644 --- a/src/include/pw3270.h +++ b/src/include/pw3270.h @@ -89,6 +89,9 @@ LIB3270_EXPORT void pw3270_set_host_charset(GtkWidget *widget, const gchar *name); + LIB3270_EXPORT void pw3270_set_action_state(GtkAction *action, gboolean on); + + typedef enum pw3270_src { PW3270_SRC_ALL, /**< Screen contents */ diff --git a/src/plugins/rx3270/pluginmain.cc b/src/plugins/rx3270/pluginmain.cc index 9bf43bd..7e5abea 100644 --- a/src/plugins/rx3270/pluginmain.cc +++ b/src/plugins/rx3270/pluginmain.cc @@ -436,12 +436,7 @@ extern "C" return; } -#if GTK_CHECK_VERSION(3,10,0) - g_simple_action_set_enabled(G_SIMPLE_ACTION(action),FALSE); -#else - gtk_action_set_sensitive(action,FALSE); -#endif // GTK(3,10) - + pw3270_set_action_state(action,FALSE); if(filename) { @@ -484,11 +479,7 @@ extern "C" } -#if GTK_CHECK_VERSION(3,10,0) - g_simple_action_set_enabled(G_SIMPLE_ACTION(action),TRUE); -#else - gtk_action_set_sensitive(action,TRUE); -#endif // GTK(3,10) + pw3270_set_action_state(action,TRUE); #if GTK_CHECK_VERSION(2,32,0) g_mutex_unlock(&mutex); diff --git a/src/pw3270/tools.c b/src/pw3270/tools.c index 2f8c4c1..486dd81 100644 --- a/src/pw3270/tools.c +++ b/src/pw3270/tools.c @@ -223,3 +223,24 @@ LIB3270_EXPORT void pw3270_set_host_charset(GtkWidget *widget, const gchar *name gtk_widget_destroy(dialog); } + +LIB3270_EXPORT void pw3270_set_action_state(GtkAction *action, gboolean on) +{ + + if(!action) + { + return; + } +#if GTK_CHECK_VERSION(3,10,0) + else if(G_IS_SIMPLE_ACTION(action)) + { + g_simple_action_set_enabled(G_SIMPLE_ACTION(action),FALSE); + } +#endif // GTK(3,10) + else + { + gtk_action_set_sensitive(action,FALSE); + } + + } + diff --git a/src/pw3270/window.c b/src/pw3270/window.c index a2351f7..f9bc830 100644 --- a/src/pw3270/window.c +++ b/src/pw3270/window.c @@ -416,17 +416,9 @@ gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget),menu); } - static void setSensitive(GtkAction *action, gboolean on) - { - if(action) - { - gtk_action_set_sensitive(action,on); - } - } - static void pastenext(GtkWidget *widget, gboolean on, GtkAction **action) { - setSensitive(action[ACTION_PASTENEXT],on); + pw3270_set_action_state(action[ACTION_PASTENEXT],on); } static void disconnected(GtkWidget *terminal, GtkWidget * window) @@ -485,7 +477,7 @@ { GtkAction **action = (GtkAction **) g_object_get_data(G_OBJECT(widget),"named_actions"); gtk_action_group_set_sensitive(group[ACTION_GROUP_SELECTION],on); - setSensitive(action[ACTION_RESELECT],!on); + pw3270_set_action_state(action[ACTION_RESELECT],!on); } static gboolean popup_menu(GtkWidget *widget, gboolean selected, gboolean online, GdkEventButton *event, GtkWidget **popup) @@ -647,11 +639,11 @@ if(action[ACTION_PASTENEXT]) { - setSensitive(action[ACTION_PASTENEXT],FALSE); + pw3270_set_action_state(action[ACTION_PASTENEXT],FALSE); g_signal_connect(widget->terminal,"pastenext",G_CALLBACK(pastenext),action); } - setSensitive(action[ACTION_RESELECT],FALSE); + pw3270_set_action_state(action[ACTION_RESELECT],FALSE); // Connect action signals g_signal_connect(widget->terminal,"disconnected",G_CALLBACK(disconnected),widget); -- libgit2 0.21.2