Fix GtkComboBoxEntry in 'netstatus' plugin.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Sat, 29 Nov 2014 03:18:38 +0000 (05:18 +0200)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Sat, 29 Nov 2014 03:18:38 +0000 (05:18 +0200)
It should be replaced for compatibility therefore upper version behavior needs emulation.

configure.ac
data/ui/netstatus.glade
plugins/netstat/passwd_gui.c
plugins/netstatus/netstatus-dialog.c
plugins/xkb/xkb-plugin.c
src/gtk-compat.h
src/gtk-run.c
src/input-button.c

index 64f99a6..ed4ef12 100644 (file)
@@ -34,7 +34,6 @@ AC_HELP_STRING([--enable-gtk3],[enable to use gtk-3.0 instead of gtk-2.0]),
 esac],[])
 
 if test "x$enable_gtk3" = "xyes" ; then
-  CFLAGS="$CFLAGS -DENABLE_GTK3"
   pkg_modules="$pkg_modules gtk+-3.0 libfm-gtk3 >= 1.2.0 libwnck-3.0"
 else
   pkg_modules="$pkg_modules gtk+-2.0 >= 2.18.0 libfm-gtk >= 1.2.0 libwnck-1.0"
@@ -91,8 +90,6 @@ if test x"$enable_menu_cache" = "xno"; then
        AC_WARN([No libmenu-cache found.  All menu related routines are not built.])
        AC_DEFINE(DISABLE_MENU, [1], [Disable menu related routines])
 fi
-AC_SUBST(MENU_CACHE_CFLAGS)
-AC_SUBST(MENU_CACHE_LIBS)
 AM_CONDITIONAL(ENABLE_MENU_CACHE, test x"$enable_menu_cache" = x"yes")
 
 AC_ARG_ENABLE(more_warnings,
@@ -105,7 +102,6 @@ AC_ARG_ENABLE(more_warnings,
 if test x"$enable_more_warnings" = x"yes"; then
   ADDITIONAL_FLAGS="-Wall -Werror=all -Werror=format -Werror=implicit-function-declaration -Werror=implicit-int -Werror=missing-braces -Werror=parentheses -Werror=return-type -Werror=strict-aliasing -Werror=switch -Wuninitialized -Werror=unused-label -Werror=unused-value -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Werror=missing-declarations -Wredundant-decls -Wmissing-noreturn -Wpointer-arith -Wcast-align -Wwrite-strings -Werror=inline -Werror=format-nonliteral -Wformat-nonliteral -Werror=format-security -Wformat-security -Winit-self -Werror=missing-include-dirs -Werror=undef -Werror=aggregate-return -Wmissing-format-attribute -Werror=nested-externs -fno-strict-aliasing -fmessage-length=0 -Wp,-D_FORTIFY_SOURCE=2 -DG_DISABLE_DEPRECATED -DG_DISABLE_SINGLE_INCLUDES -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_DEPRECATED -DGTK_DISABLE_SINGLE_INCLUDES"
 fi
-AC_SUBST(ADDITIONAL_FLAGS)
 
 PACKAGE_CFLAGS="$PACKAGE_CFLAGS $MENU_CACHE_CFLAGS $ADDITIONAL_FLAGS"
 PACKAGE_LIBS="$PACKAGE_LIBS $MENU_CACHE_LIBS"
index 39f7299..fc956d3 100644 (file)
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkComboBoxEntry" id="name_combo">
+                                  <object class="GtkComboBox" id="name_combo">
                                     <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="has_entry">True</property>
+                                    <child internal-child="entry">
+                                      <object class="GtkEntry" id="combobox-entry">
+                                        <property name="can_focus">True</property>
+                                      </object>
+                                    </child>
                                   </object>
                                   <packing>
                                     <property name="left_attach">1</property>
index ad9b87b..ba73150 100644 (file)
@@ -27,6 +27,7 @@
 #include "lxnm_client.h"
 #include "wireless.h"
 #include "passwd_gui.h"
+#include "gtk-compat.h"
 
 struct passwd_resp {
     ap_setting *aps;
index b6f3c9f..979d6a8 100644 (file)
@@ -592,6 +592,30 @@ netstatus_dialog_setup_configure_button (NetstatusDialogData *data)
                            !netstatus_iface_get_is_loopback (data->iface));
 }
 
+#if !GTK_CHECK_VERSION(2, 24, 0)
+static void _combo_box_entry_active_changed (GtkComboBox *combo_box,
+                                             gpointer     user_data)
+{
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  gchar *str = NULL;
+
+  if (gtk_combo_box_get_active_iter (combo_box, &iter))
+    {
+      GtkEntry *entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combo_box)));
+
+      if (entry)
+        {
+          model = gtk_combo_box_get_model (combo_box);
+
+          gtk_tree_model_get (model, &iter, 0, &str, -1);
+          gtk_entry_set_text (entry, str);
+          g_free (str);
+        }
+    }
+}
+#endif
+
 static void
 netstatus_dialog_setup_connection (NetstatusDialogData *data)
 {
@@ -616,7 +640,18 @@ netstatus_dialog_setup_connection (NetstatusDialogData *data)
 #if GTK_CHECK_VERSION(2, 24, 0)
   gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(data->name), 0);
 #else
-  gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(data->name), 0);
+  /* emulate 2.24/GtkComboBoxEntry behavior */
+  GtkCellRenderer *text_renderer = gtk_cell_renderer_text_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (data->name),
+                              text_renderer, TRUE);
+
+  gtk_combo_box_set_active (GTK_COMBO_BOX (data->name), -1);
+
+  g_signal_connect (data->name, "changed",
+                    G_CALLBACK (_combo_box_entry_active_changed), NULL);
+
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (data->name),
+                                  text_renderer, "text", 0, NULL);
 #endif
   g_object_unref(model);
 
index 52cbedf..b796124 100644 (file)
@@ -32,6 +32,7 @@
 #include <ctype.h>
 
 #include "xkb.h"
+#include "gtk-compat.h"
 
 enum
 {
index a85b58e..e7bbae6 100644 (file)
@@ -41,4 +41,8 @@
 #  define  gdk_window_get_screen        gdk_drawable_get_screen
 #endif
 
+#if GTK_CHECK_VERSION(3, 0, 0)
+#  define  GTK_DIALOG_NO_SEPARATOR      0
+#endif
+
 #endif
index a3ff9e0..0d5a635 100644 (file)
@@ -33,6 +33,8 @@
 #endif
 #include <libfm/fm-gtk.h>
 
+#include "gtk-compat.h"
+
 static GtkWidget* win = NULL; /* the run dialog */
 #ifndef DISABLE_MENU
 static MenuCache* menu_cache = NULL;
index 72d5cbe..3462ca2 100644 (file)
@@ -30,6 +30,7 @@
 #include <keybinder.h>
 
 /* generated by glib-genmarshal for BOOL:STRING */
+static
 void _marshal_BOOLEAN__STRING (GClosure     *closure,
                                GValue       *return_value G_GNUC_UNUSED,
                                guint         n_param_values,