[Xfce4-commits] <thunar:nick/gtk3> Port to gtk3.

Nick Schermer noreply at xfce.org
Sat May 5 13:36:02 CEST 2012


Updating branch refs/heads/nick/gtk3
         to c0e3e85dadd1930f2c3339b6d0a6d05805790795 (commit)
       from 014dc8f3bddc4602ca2f813652209f36cebada53 (commit)

commit c0e3e85dadd1930f2c3339b6d0a6d05805790795
Author: Nick Schermer <nick at xfce.org>
Date:   Sat May 5 13:35:10 2012 +0200

    Port to gtk3.

 configure.in.in                                |   18 ++--
 examples/tex-open-terminal/Makefile.am         |    2 +
 examples/tex-open-terminal/tex-open-terminal.c |   15 +---
 plugins/thunar-tpa/thunar-tpa.c                |    5 +-
 thunarx/thunarx-property-page.c                |  121 +++++++++++++++---------
 5 files changed, 93 insertions(+), 68 deletions(-)

diff --git a/configure.in.in b/configure.in.in
index aebe4f7..6f6a3be 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -154,14 +154,14 @@ dnl ***********************************
 dnl *** Check for required packages ***
 dnl ***********************************
 XDT_CHECK_PACKAGE([EXO], [exo-1], [0.6.0])
-XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.24.0])
-XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.24.0])
-XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.24.0])
-XDT_CHECK_PACKAGE([GMODULE], [gmodule-2.0], [2.24.0])
-XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.20.0])
-XDT_CHECK_PACKAGE([GDK_PIXBUF], [gdk-pixbuf-2.0], [2.14.0])
-XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.9.0])
-XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.9.0])
+XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.30.0])
+XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.30.0])
+XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.30.0])
+XDT_CHECK_PACKAGE([GMODULE], [gmodule-2.0], [2.30.0])
+XDT_CHECK_PACKAGE([GTK], [gtk+-3.0], [3.2.0])
+XDT_CHECK_PACKAGE([GDK_PIXBUF], [gdk-pixbuf-2.0], [2.24.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.10.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.10.0])
 
 dnl ********************************************
 dnl *** Check for session management support ***
@@ -172,7 +172,7 @@ dnl **********************************
 dnl *** Optional GIO UNIX features ***
 dnl **********************************
 XDT_CHECK_OPTIONAL_PACKAGE([GIO_UNIX], [gio-unix-2.0],
-                           [2.24.0], [gio-unix], [GIO UNIX features])
+                           [2.30.0], [gio-unix], [GIO UNIX features])
 
 dnl **********************************
 dnl *** Optional support for D-BUS ***
diff --git a/examples/tex-open-terminal/Makefile.am b/examples/tex-open-terminal/Makefile.am
index e71996e..a8cf3ce 100644
--- a/examples/tex-open-terminal/Makefile.am
+++ b/examples/tex-open-terminal/Makefile.am
@@ -18,6 +18,7 @@ tex_open_terminal_la_SOURCES =						\
 
 tex_open_terminal_la_CFLAGS =						\
 	$(GTK_CFLAGS)							\
+	$(LIBXFCE4UI_CFLAGS)						\
 	$(PLATFORM_CFLAGS)
 
 tex_open_terminal_la_DEPENDENCIES =					\
@@ -25,6 +26,7 @@ tex_open_terminal_la_DEPENDENCIES =					\
 
 tex_open_terminal_la_LIBADD =						\
 	$(top_builddir)/thunarx/libthunarx-$(THUNARX_VERSION_API).la	\
+	$(LIBXFCE4UI_LIBS)						\
 	$(GTK_LIBS)
 
 tex_open_terminal_la_LDFLAGS =						\
diff --git a/examples/tex-open-terminal/tex-open-terminal.c b/examples/tex-open-terminal/tex-open-terminal.c
index 331b70f..297ab9b 100644
--- a/examples/tex-open-terminal/tex-open-terminal.c
+++ b/examples/tex-open-terminal/tex-open-terminal.c
@@ -29,6 +29,7 @@
 #include <string.h>
 #endif
 
+#include <libxfce4ui/libxfce4ui.h>
 #include <tex-open-terminal/tex-open-terminal.h>
 
 
@@ -143,7 +144,6 @@ tex_open_terminal_activated (GtkAction *action,
                              GtkWidget *window)
 {
   const gchar *path;
-  GtkWidget   *dialog;
   GError      *error = NULL;
   gchar       *command;
 
@@ -156,18 +156,9 @@ tex_open_terminal_activated (GtkAction *action,
   command = g_strdup_printf ("Terminal --working-directory \"%s\"", path);
 
   /* try to run the terminal command */
-  if (!gdk_spawn_command_line_on_screen (gtk_widget_get_screen (window), command, &error))
+  if (!xfce_spawn_command_line_on_screen (gtk_widget_get_screen (window), command, FALSE, FALSE, &error))
     {
-      /* display an error dialog */
-      dialog = gtk_message_dialog_new (GTK_WINDOW (window),
-                                       GTK_DIALOG_DESTROY_WITH_PARENT,
-                                       GTK_MESSAGE_ERROR,
-                                       GTK_BUTTONS_CLOSE,
-                                       "Failed to open terminal in folder %s.",
-                                       path);
-      gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s.", error->message);
-      gtk_dialog_run (GTK_DIALOG (dialog));
-      gtk_widget_destroy (dialog);
+      xfce_dialog_show_error (GTK_WINDOW (window), error, "Failed to open terminal in folder %s.", path);
       g_error_free (error);
     }
 
diff --git a/plugins/thunar-tpa/thunar-tpa.c b/plugins/thunar-tpa/thunar-tpa.c
index 3af9472..5905dfc 100644
--- a/plugins/thunar-tpa/thunar-tpa.c
+++ b/plugins/thunar-tpa/thunar-tpa.c
@@ -441,10 +441,11 @@ thunar_tpa_drag_data_received (GtkWidget        *button,
   if (G_LIKELY (info == TARGET_TEXT_URI_LIST))
     {
       /* check if the data is valid for text/uri-list */
-      if (G_LIKELY (selection_data->length >= 0 && selection_data->format == 8))
+      if (G_LIKELY (gtk_selection_data_get_length (selection_data) >= 0
+          && gtk_selection_data_get_format (selection_data) == 8))
         {
           /* parse the URI list according to RFC 2483 */
-          uri_list = g_uri_list_extract_uris ((const gchar *) selection_data->data);
+          uri_list = gtk_selection_data_get_uris (selection_data);
           succeed = thunar_tpa_move_to_trash (plugin, (const gchar **) uri_list);
           g_strfreev (uri_list);
         }
diff --git a/thunarx/thunarx-property-page.c b/thunarx/thunarx-property-page.c
index 68bae2b..0299bdc 100644
--- a/thunarx/thunarx-property-page.c
+++ b/thunarx/thunarx-property-page.c
@@ -43,19 +43,23 @@ enum
 
 
 
-static void thunarx_property_page_get_property  (GObject                  *object,
-                                                 guint                     prop_id,
-                                                 GValue                   *value,
-                                                 GParamSpec               *pspec);
-static void thunarx_property_page_set_property  (GObject                  *object,
-                                                 guint                     prop_id,
-                                                 const GValue             *value,
-                                                 GParamSpec               *pspec);
-static void thunarx_property_page_destroy       (GtkObject                *object);
-static void thunarx_property_page_size_request  (GtkWidget                *widget,
-                                                 GtkRequisition           *requisition);
-static void thunarx_property_page_size_allocate (GtkWidget                *widget,
-                                                 GtkAllocation            *allocation);
+static void thunarx_property_page_get_property        (GObject                  *object,
+                                                        guint                     prop_id,
+                                                        GValue                   *value,
+                                                        GParamSpec               *pspec);
+static void thunarx_property_page_set_property         (GObject                  *object,
+                                                        guint                     prop_id,
+                                                        const GValue             *value,
+                                                        GParamSpec               *pspec);
+static void thunarx_property_page_destroy              (GtkWidget                *widget);
+static void thunarx_property_page_get_preferred_width  (GtkWidget                *widget,
+                                                        gint                     *minimal_width,
+                                                        gint                     *natural_width);
+static void thunarx_property_page_get_preferred_height (GtkWidget                *widget,
+                                                        gint                     *minimal_height,
+                                                        gint                     *natural_height);
+static void thunarx_property_page_size_allocate        (GtkWidget                *widget,
+                                                        GtkAllocation            *allocation);
 
 
 
@@ -73,7 +77,6 @@ G_DEFINE_TYPE (ThunarxPropertyPage, thunarx_property_page, GTK_TYPE_BIN)
 static void
 thunarx_property_page_class_init (ThunarxPropertyPageClass *klass)
 {
-  GtkObjectClass *gtkobject_class;
   GtkWidgetClass *gtkwidget_class;
   GObjectClass   *gobject_class;
 
@@ -84,12 +87,11 @@ thunarx_property_page_class_init (ThunarxPropertyPageClass *klass)
   gobject_class->get_property = thunarx_property_page_get_property;
   gobject_class->set_property = thunarx_property_page_set_property;
 
-  gtkobject_class = GTK_OBJECT_CLASS (klass);
-  gtkobject_class->destroy = thunarx_property_page_destroy;
-
   gtkwidget_class = GTK_WIDGET_CLASS (klass);
-  gtkwidget_class->size_request = thunarx_property_page_size_request;
+  gtkwidget_class->get_preferred_width  = thunarx_property_page_get_preferred_width;
+  gtkwidget_class->get_preferred_height = thunarx_property_page_get_preferred_height;
   gtkwidget_class->size_allocate = thunarx_property_page_size_allocate;
+  gtkwidget_class->destroy = thunarx_property_page_destroy;
 
   /**
    * ThunarxPropertyPage::label:
@@ -181,41 +183,65 @@ thunarx_property_page_set_property (GObject      *object,
 
 
 static void
-thunarx_property_page_destroy (GtkObject *object)
+thunarx_property_page_destroy (GtkWidget *object)
 {
   ThunarxPropertyPage *property_page = THUNARX_PROPERTY_PAGE (object);
 
   /* destroy the label widget (if any) */
   if (G_LIKELY (property_page->priv->label_widget != NULL))
     {
-      gtk_object_destroy (GTK_OBJECT (property_page->priv->label_widget));
+      gtk_widget_destroy (property_page->priv->label_widget);
       g_object_unref (G_OBJECT (property_page->priv->label_widget));
       property_page->priv->label_widget = NULL;
     }
 
-  (*GTK_OBJECT_CLASS (thunarx_property_page_parent_class)->destroy) (object);
+  (*GTK_WIDGET_CLASS (thunarx_property_page_parent_class)->destroy) (object);
 }
 
 
 
 static void
-thunarx_property_page_size_request (GtkWidget      *widget,
-                                    GtkRequisition *requisition)
+thunarx_property_page_get_preferred_width (GtkWidget *widget,
+                                           gint      *minimal_width,
+                                           gint      *natural_width)
 {
-  GtkBin *bin = GTK_BIN (widget);
+  GtkWidget *child;
+  gint       minimal = 0;
+  gint       natural = 0;
+  gint       border;
 
-  if (G_LIKELY (bin->child != NULL && GTK_WIDGET_VISIBLE (bin->child)))
-    {
-      gtk_widget_size_request (bin->child, requisition);
-    }
-  else
-    {
-      requisition->width = 0;
-      requisition->height = 0;
-    }
+  child = gtk_bin_get_child (GTK_BIN (widget));
+  if (G_LIKELY (child != NULL))
+    gtk_widget_get_preferred_width (child, &minimal, &natural);
+
+  /* TODO, we previously also added widget->style->[xy]thickness */
+  border = 2 * gtk_container_get_border_width (GTK_CONTAINER (widget));
 
-  requisition->width += 2 * (GTK_CONTAINER (bin)->border_width + widget->style->xthickness);
-  requisition->height += 2 * (GTK_CONTAINER (bin)->border_width + widget->style->ythickness);
+  *minimal_width = minimal + border;
+  *natural_width = natural + border;
+}
+
+
+
+static void
+thunarx_property_page_get_preferred_height (GtkWidget *widget,
+                                            gint      *minimal_height,
+                                            gint      *natural_height)
+{
+  GtkWidget *child;
+  gint       minimal = 0;
+  gint       natural = 0;
+  gint       border;
+
+  child = gtk_bin_get_child (GTK_BIN (widget));
+  if (G_LIKELY (child != NULL))
+    gtk_widget_get_preferred_height (child, &minimal, &natural);
+
+  /* TODO, we previously also added widget->style->[xy]thickness */
+  border = 2 * gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+  *minimal_height = minimal + border;
+  *natural_height = natural + border;
 }
 
 
@@ -224,23 +250,28 @@ static void
 thunarx_property_page_size_allocate (GtkWidget     *widget,
                                      GtkAllocation *allocation)
 {
-  GtkAllocation child_allocation;
-  GtkBin       *bin = GTK_BIN (widget);
+  GtkAllocation  child_allocation;
+  gint           border_width;
+  GtkWidget     *child;
 
   /* apply the allocation to the property page */
-  widget->allocation = *allocation;
+  gtk_widget_set_allocation (widget, allocation);
 
   /* apply the child allocation if we have a child */
-  if (G_LIKELY (bin->child != NULL && GTK_WIDGET_VISIBLE (bin->child)))
+  child = gtk_bin_get_child (GTK_BIN (widget));
+  if (child != NULL
+      && gtk_widget_get_visible (child))
     {
+      border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
       /* calculate the allocation for the child widget */
-      child_allocation.x = allocation->x + GTK_CONTAINER (bin)->border_width + widget->style->xthickness;
-      child_allocation.y = allocation->y + GTK_CONTAINER (bin)->border_width + widget->style->ythickness;
-      child_allocation.width = allocation->width - 2 * (GTK_CONTAINER (bin)->border_width + widget->style->xthickness);
-      child_allocation.height = allocation->height - 2 * (GTK_CONTAINER (bin)->border_width + widget->style->ythickness);
+      child_allocation.x = allocation->x + border_width;
+      child_allocation.y = allocation->y + border_width;
+      child_allocation.width = allocation->width - 2 * border_width;
+      child_allocation.height = allocation->height - 2 * border_width;
 
       /* apply the child allocation */
-      gtk_widget_size_allocate (bin->child, &child_allocation);
+      gtk_widget_size_allocate (child, &child_allocation);
     }
 }
 
@@ -367,7 +398,7 @@ thunarx_property_page_set_label_widget (ThunarxPropertyPage *property_page,
                                         GtkWidget           *label_widget)
 {
   g_return_if_fail (THUNARX_IS_PROPERTY_PAGE (property_page));
-  g_return_if_fail (label_widget == NULL || (GTK_IS_WIDGET (label_widget) && label_widget->parent == NULL));
+  g_return_if_fail (label_widget == NULL || (GTK_IS_WIDGET (label_widget)));
 
   if (G_UNLIKELY (label_widget == property_page->priv->label_widget))
     return;


More information about the Xfce4-commits mailing list