Author: cazfi
Date: Fri Jan  1 23:04:41 2016
New Revision: 31290

URL: http://svn.gna.org/viewcvs/freeciv?rev=31290&view=rev
Log:
Replaced deprecated gtk_widget_reparent() usages with modern solutions in 
gtk3x-client

See patch #6733

Modified:
    trunk/client/gui-gtk-3.x/chatline.c
    trunk/client/gui-gtk-3.x/gui_main.c
    trunk/m4/gtk3x-client.m4

Modified: trunk/client/gui-gtk-3.x/chatline.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/chatline.c?rev=31290&r1=31289&r2=31290&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.x/chatline.c (original)
+++ trunk/client/gui-gtk-3.x/chatline.c Fri Jan  1 23:04:41 2016
@@ -1178,7 +1178,11 @@
     if (ptoolkit->toolbar_displayed) {
       gtk_widget_hide(ptoolkit->toolbar);
     }
-    gtk_widget_reparent(ptoolkit->main_widget, toolkit_view);
+    g_object_ref(ptoolkit->main_widget); /* Make sure reference count stays 
above 0
+                                          * during the transition to new 
parent. */
+    gtk_container_remove(GTK_CONTAINER(parent), ptoolkit->main_widget);
+    gtk_container_add(GTK_CONTAINER(toolkit_view), ptoolkit->main_widget);
+    g_object_unref(ptoolkit->main_widget);
     if (ptoolkit->toolbar_displayed) {
       gtk_widget_show(ptoolkit->toolbar);
     }

Modified: trunk/client/gui-gtk-3.x/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/gui_main.c?rev=31290&r1=31289&r2=31290&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.x/gui_main.c (original)
+++ trunk/client/gui-gtk-3.x/gui_main.c Fri Jan  1 23:04:41 2016
@@ -746,19 +746,26 @@
 }
 
 /**************************************************************************
- reattaches the detached widget when the user destroys it.
+  Reattaches the detached widget when the user destroys it.
 **************************************************************************/
 static void tearoff_destroy(GtkWidget *w, gpointer data)
 {
   GtkWidget *p, *b, *box;
+  GtkWidget *old_parent;
 
   box = GTK_WIDGET(data);
+  old_parent = gtk_widget_get_parent(box);
   p = g_object_get_data(G_OBJECT(w), "parent");
   b = g_object_get_data(G_OBJECT(w), "toggle");
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b), FALSE);
 
   gtk_widget_hide(w);
-  gtk_widget_reparent(box, p);
+
+  g_object_ref(box); /* Make sure reference count stays above 0
+                      * during the transition to new parent. */
+  gtk_container_remove(GTK_CONTAINER(old_parent), box);
+  gtk_container_add(GTK_CONTAINER(p), box);
+  g_object_unref(box);
 }
 
 /**************************************************************************
@@ -777,9 +784,12 @@
 static void tearoff_callback(GtkWidget *b, gpointer data)
 {
   GtkWidget *box = GTK_WIDGET(data);
-  GtkWidget *w;
 
   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b))) {
+    GtkWidget *old_parent;
+    GtkWidget *w;
+
+    old_parent = gtk_widget_get_parent(box);
     w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     setup_dialog(w, toplevel);
     gtk_widget_set_name(w, "Freeciv");
@@ -789,10 +799,14 @@
     g_signal_connect(w, "key_press_event",
        G_CALLBACK(propagate_keypress), NULL);
 
-
     g_object_set_data(G_OBJECT(w), "parent", gtk_widget_get_parent(box));
     g_object_set_data(G_OBJECT(w), "toggle", b);
-    gtk_widget_reparent(box, w);
+
+    g_object_ref(box); /* Make sure reference count stays above 0
+                        * during the transition to new parent. */
+    gtk_container_remove(GTK_CONTAINER(old_parent), box);
+    gtk_container_add(GTK_CONTAINER(w), box);
+    g_object_unref(box);
     gtk_widget_show(w);
   } else {
     gtk_widget_destroy(gtk_widget_get_parent(box));

Modified: trunk/m4/gtk3x-client.m4
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/m4/gtk3x-client.m4?rev=31290&r1=31289&r2=31290&view=diff
==============================================================================
--- trunk/m4/gtk3x-client.m4    (original)
+++ trunk/m4/gtk3x-client.m4    Fri Jan  1 23:04:41 2016
@@ -8,7 +8,7 @@
   # Add check "x$client" = "xauto"  when this becomes supported client
   if test "x$gui_gtk3x" = "xyes" ||
      test "x$client" = "xall" ; then
-    PKG_CHECK_MODULES([GTK3X], [gtk+-3.0 >= 3.12.0],
+    PKG_CHECK_MODULES([GTK3X], [gtk+-3.0 >= 3.14.0],
       [
         GTK3X_CFLAGS="$GTK3X_CFLAGS 
-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_12"
         GTK3X_CFLAGS="$GTK3X_CFLAGS 
-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_44"


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to