[gnome-disk-utility] Build against GTK+ 3



commit 387571f128ef2e9f74bed59e5ccd0a7e01427312
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Dec 12 10:31:16 2010 +1030

    Build against GTK+ 3
    
    This commit adapts the code to several GTK+ api changes, and
    drops GduSpinner in favor of GtkSpinner.
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 configure.ac                             |   12 +-
 src/gdu-gtk/Makefile.am                  |    2 -
 src/gdu-gtk/gdu-ata-smart-dialog.c       |    3 +-
 src/gdu-gtk/gdu-details-table.c          |    6 +-
 src/gdu-gtk/gdu-drive-benchmark-dialog.c |    1 -
 src/gdu-gtk/gdu-gtk.c                    |    6 +-
 src/gdu-gtk/gdu-gtk.h                    |    1 -
 src/gdu-gtk/gdu-spinner.c                |  368 ------------------------------
 src/gdu-gtk/gdu-spinner.h                |   59 -----
 src/gdu-gtk/gdu-volume-grid.c            |   78 ++++---
 src/palimpsest/gdu-section-drive.c       |    4 +-
 src/palimpsest/gdu-section-volumes.c     |    2 +-
 12 files changed, 64 insertions(+), 478 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fffacc2..bb6e926 100644
--- a/configure.ac
+++ b/configure.ac
@@ -126,8 +126,8 @@ GOBJECT2_REQUIRED=2.16
 GIO2_REQUIRED=2.22
 DBUS_GLIB_REQUIRED=0.74
 GNOME_KEYRING_REQUIRED=2.22
-GTK2_REQUIRED=2.20.0
-UNIQUE_REQUIRED=1.0
+GTK_REQUIRED=2.90.7
+UNIQUE_REQUIRED=2.90.1
 LIBNOTIFY_REQUIRED=0.6.1
 NAUTILUS_REQUIRED=2.24.0
 AVAHI_UI_REQUIRED=0.6.25
@@ -144,13 +144,13 @@ PKG_CHECK_MODULES(GIO2, [gio-2.0 >= $GIO2_REQUIRED])
 PKG_CHECK_MODULES(GIO_UNIX2, [gio-unix-2.0 >= $GIO2_REQUIRED])
 PKG_CHECK_MODULES(GTHREAD2, [gthread-2.0 >= $GLIB2_REQUIRED])
 PKG_CHECK_MODULES(DBUS_GLIB, [dbus-glib-1 >= $DBUS_GLIB_REQUIRED])
-PKG_CHECK_MODULES(GTK2, [gtk+-2.0 >= $GTK2_REQUIRED])
-PKG_CHECK_MODULES(UNIQUE, [unique-1.0 >= $UNIQUE_REQUIRED])
+PKG_CHECK_MODULES(GTK2, [gtk+-3.0 >= $GTK_REQUIRED])
+PKG_CHECK_MODULES(UNIQUE, [unique-3.0 >= $UNIQUE_REQUIRED])
 PKG_CHECK_MODULES(LIBNOTIFY, [libnotify  >= $LIBNOTIFY_REQUIRED])
 PKG_CHECK_MODULES(UDISKS, [udisks  >= $UDISKS_REQUIRED udisks < $UDISKS_NEXT_ABI_INCOMPATIBLE_VERSION])
 PKG_CHECK_MODULES(X11, [x11])
 PKG_CHECK_MODULES(LIBATASMART, [libatasmart >= 0.14])
-PKG_CHECK_MODULES(AVAHI_UI, [avahi-ui >= $AVAHI_UI_REQUIRED])
+PKG_CHECK_MODULES(AVAHI_UI, [avahi-ui-gtk3 >= $AVAHI_UI_REQUIRED])
 
 # *************
 # Remote Access
@@ -189,7 +189,7 @@ AM_CONDITIONAL(ENABLE_GNOME_KEYRING, [test "$have_gnome_keyring" = "yes"])
 
 AC_PATH_PROG(SCROLLKEEPER_CONFIG, scrollkeeper-config,no)
 if test x$SCROLLKEEPER_CONFIG = xno; then
-  AC_MSG_ERROR(Couldn't find scrollkeeper-config, please install the scrollkeeper package)
+  AC_MSG_ERROR(Could not find scrollkeeper-config, please install the scrollkeeper package)
 fi
 
 # ********************
diff --git a/src/gdu-gtk/Makefile.am b/src/gdu-gtk/Makefile.am
index a2e3db9..10745b1 100644
--- a/src/gdu-gtk/Makefile.am
+++ b/src/gdu-gtk/Makefile.am
@@ -36,7 +36,6 @@ libgdu_gtkinclude_HEADERS =              				\
 	gdu-size-widget.h						\
 	gdu-create-linux-md-dialog.h					\
 	gdu-ata-smart-dialog.h						\
-	gdu-spinner.h							\
 	gdu-volume-grid.h						\
 	gdu-details-table.h						\
 	gdu-details-element.h						\
@@ -71,7 +70,6 @@ libgdu_gtk_la_SOURCES =                 	               				\
 	gdu-size-widget.h			gdu-size-widget.c			\
 	gdu-create-linux-md-dialog.h		gdu-create-linux-md-dialog.c		\
 	gdu-ata-smart-dialog.h			gdu-ata-smart-dialog.c			\
-	gdu-spinner.h				gdu-spinner.c				\
 	gdu-volume-grid.h			gdu-volume-grid.c			\
 	gdu-details-table.h			gdu-details-table.c			\
 	gdu-details-element.h			gdu-details-element.c			\
diff --git a/src/gdu-gtk/gdu-ata-smart-dialog.c b/src/gdu-gtk/gdu-ata-smart-dialog.c
index a5e59f2..541a42d 100644
--- a/src/gdu-gtk/gdu-ata-smart-dialog.c
+++ b/src/gdu-gtk/gdu-ata-smart-dialog.c
@@ -31,7 +31,6 @@
 
 #include "gdu-time-label.h"
 #include "gdu-ata-smart-dialog.h"
-#include "gdu-spinner.h"
 #include "gdu-pool-tree-model.h"
 #include "gdu-details-table.h"
 #include "gdu-details-element.h"
@@ -1110,7 +1109,7 @@ on_self_test_button_clicked (GduButtonElement *button_element,
 
         test_dialog = gtk_dialog_new_with_buttons (NULL,
                                                    GTK_WINDOW (dialog),
-                                                   GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_NO_SEPARATOR,
+                                                   GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
                                                    NULL);
         gtk_window_set_title (GTK_WINDOW (test_dialog), "");
 
diff --git a/src/gdu-gtk/gdu-details-table.c b/src/gdu-gtk/gdu-details-table.c
index 8336d37..b11ad3f 100644
--- a/src/gdu-gtk/gdu-details-table.c
+++ b/src/gdu-gtk/gdu-details-table.c
@@ -335,11 +335,11 @@ on_details_element_changed (GduDetailsElement *element,
         }
 
         if (gdu_details_element_get_is_spinning (element)) {
-                gdu_spinner_start (GDU_SPINNER (data->spinner));
+                gtk_spinner_start (GTK_SPINNER (data->spinner));
                 gtk_widget_set_no_show_all (data->spinner, FALSE);
                 gtk_widget_show (data->spinner);
         } else {
-                gdu_spinner_stop (GDU_SPINNER (data->spinner));
+                gtk_spinner_stop (GTK_SPINNER (data->spinner));
                 gtk_widget_set_no_show_all (data->spinner, TRUE);
                 gtk_widget_hide (data->spinner);
         }
@@ -454,7 +454,7 @@ do_relayout (GduDetailsTable *table)
                                                         GTK_ICON_SIZE_MENU);
                 gtk_box_pack_start (GTK_BOX (hbox), data->image, FALSE, FALSE, 0);
 
-                data->spinner = gdu_spinner_new ();
+                data->spinner = gtk_spinner_new ();
                 gtk_box_pack_start (GTK_BOX (hbox), data->spinner, FALSE, FALSE, 0);
 
                 data->label = gtk_label_new (NULL);
diff --git a/src/gdu-gtk/gdu-drive-benchmark-dialog.c b/src/gdu-gtk/gdu-drive-benchmark-dialog.c
index 8f66abb..9f86f50 100644
--- a/src/gdu-gtk/gdu-drive-benchmark-dialog.c
+++ b/src/gdu-gtk/gdu-drive-benchmark-dialog.c
@@ -32,7 +32,6 @@
 
 #include "gdu-time-label.h"
 #include "gdu-drive-benchmark-dialog.h"
-#include "gdu-spinner.h"
 #include "gdu-details-table.h"
 #include "gdu-details-element.h"
 
diff --git a/src/gdu-gtk/gdu-gtk.c b/src/gdu-gtk/gdu-gtk.c
index 39f335c..7d7cb21 100644
--- a/src/gdu-gtk/gdu-gtk.c
+++ b/src/gdu-gtk/gdu-gtk.c
@@ -345,7 +345,7 @@ gdu_util_dialog_show_filesystem_busy (GtkWidget *parent_window,
 
         dialog = gtk_dialog_new_with_buttons (window_title,
                                               GTK_WINDOW (parent_window),
-                                              GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_NO_SEPARATOR,
+                                              GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
                                               NULL);
         content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
         action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
@@ -581,7 +581,7 @@ gdu_util_dialog_secret_internal (GtkWidget   *parent_window,
 
         dialog = gtk_dialog_new_with_buttons (window_title,
                                               GTK_WINDOW (parent_window),
-                                              GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_NO_SEPARATOR,
+                                              GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
                                               GTK_STOCK_CANCEL,
                                               GTK_RESPONSE_CANCEL,
                                               NULL);
@@ -1161,7 +1161,7 @@ gdu_util_delete_confirmation_dialog (GtkWidget   *parent_window,
 
         dialog = gtk_dialog_new_with_buttons (title,
                                               GTK_WINDOW (parent_window),
-                                              GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_NO_SEPARATOR,
+                                              GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
                                               NULL);
         content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
         action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
diff --git a/src/gdu-gtk/gdu-gtk.h b/src/gdu-gtk/gdu-gtk.h
index 11c2fd3..b0143b5 100644
--- a/src/gdu-gtk/gdu-gtk.h
+++ b/src/gdu-gtk/gdu-gtk.h
@@ -35,7 +35,6 @@
 #include <gdu-gtk/gdu-size-widget.h>
 #include <gdu-gtk/gdu-create-linux-md-dialog.h>
 #include <gdu-gtk/gdu-ata-smart-dialog.h>
-#include <gdu-gtk/gdu-spinner.h>
 #include <gdu-gtk/gdu-volume-grid.h>
 #include <gdu-gtk/gdu-details-table.h>
 #include <gdu-gtk/gdu-details-element.h>
diff --git a/src/gdu-gtk/gdu-volume-grid.c b/src/gdu-gtk/gdu-volume-grid.c
index c761adc..a5010e6 100644
--- a/src/gdu-gtk/gdu-volume-grid.c
+++ b/src/gdu-gtk/gdu-volume-grid.c
@@ -127,8 +127,8 @@ static GridElement *find_element_for_position (GduVolumeGrid *grid,
                                                guint x,
                                                guint y);
 
-static gboolean gdu_volume_grid_expose_event (GtkWidget           *widget,
-                                              GdkEventExpose      *event);
+static gboolean gdu_volume_grid_draw (GtkWidget *widget,
+                                      cairo_t   *cr);
 
 static void on_presentable_added        (GduPool        *pool,
                                          GduPresentable *p,
@@ -271,10 +271,10 @@ gdu_volume_grid_key_press_event (GtkWidget      *widget,
                 goto out;
 
         switch (event->keyval) {
-        case GDK_Left:
-        case GDK_Right:
-        case GDK_Up:
-        case GDK_Down:
+        case GDK_KEY_Left:
+        case GDK_KEY_Right:
+        case GDK_KEY_Up:
+        case GDK_KEY_Down:
                 target = NULL;
 
                 if (grid->priv->focused == NULL) {
@@ -284,25 +284,25 @@ gdu_volume_grid_key_press_event (GtkWidget      *widget,
 
                         element = grid->priv->focused;
                         if (element != NULL) {
-                                if (event->keyval == GDK_Left) {
+                                if (event->keyval == GDK_KEY_Left) {
                                         if (element->prev != NULL) {
                                                 target = element->prev;
                                         } else {
                                                 if (element->parent && element->parent->prev != NULL)
                                                         target = element->parent->prev;
                                         }
-                                } else if (event->keyval == GDK_Right) {
+                                } else if (event->keyval == GDK_KEY_Right) {
                                         if (element->next != NULL) {
                                                 target = element->next;
                                         } else {
                                                 if (element->parent && element->parent->next != NULL)
                                                         target = element->parent->next;
                                         }
-                                } else if (event->keyval == GDK_Up) {
+                                } else if (event->keyval == GDK_KEY_Up) {
                                         if (element->parent != NULL) {
                                                 target = element->parent;
                                         }
-                                } else if (event->keyval == GDK_Down) {
+                                } else if (event->keyval == GDK_KEY_Down) {
                                         if (element->embedded_elements != NULL) {
                                                 target = (GridElement *) element->embedded_elements->data;
                                         }
@@ -325,8 +325,8 @@ gdu_volume_grid_key_press_event (GtkWidget      *widget,
                 handled = TRUE;
                 break;
 
-        case GDK_Return:
-        case GDK_space:
+        case GDK_KEY_Return:
+        case GDK_KEY_space:
                 if (grid->priv->focused != grid->priv->selected &&
                     grid->priv->focused != NULL) {
                         grid->priv->selected = grid->priv->focused;
@@ -408,9 +408,8 @@ gdu_volume_grid_realize (GtkWidget *widget)
                 GDK_ENTER_NOTIFY_MASK |
                 GDK_LEAVE_NOTIFY_MASK;
         attributes.visual = gtk_widget_get_visual (widget);
-        attributes.colormap = gtk_widget_get_colormap (widget);
 
-        attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+        attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
 
         window = gtk_widget_get_parent_window (widget);
         gtk_widget_set_window (widget, window);
@@ -458,6 +457,33 @@ gdu_volume_grid_size_request (GtkWidget      *widget,
         requisition->width = num_elements * ELEMENT_MINIMUM_WIDTH;
 }
 
+
+static void
+gdu_volume_grid_get_preferred_width (GtkWidget *widget,
+                                     gint      *minimal_width,
+                                     gint      *natural_width)
+{
+  GtkRequisition requisition;
+
+  gdu_volume_grid_size_request (widget, &requisition);
+
+  *minimal_width = *natural_width = requisition.width;
+}
+
+
+static void
+gdu_volume_grid_get_preferred_height (GtkWidget *widget,
+                                      gint      *minimal_height,
+                                      gint      *natural_height)
+{
+  GtkRequisition requisition;
+
+  gdu_volume_grid_size_request (widget, &requisition);
+
+  *minimal_height = *natural_height = requisition.height;
+}
+
+
 static void
 gdu_volume_grid_class_init (GduVolumeGridClass *klass)
 {
@@ -471,11 +497,12 @@ gdu_volume_grid_class_init (GduVolumeGridClass *klass)
         object_class->constructed  = gdu_volume_grid_constructed;
         object_class->finalize     = gdu_volume_grid_finalize;
 
-        widget_class->realize            = gdu_volume_grid_realize;
-        widget_class->key_press_event    = gdu_volume_grid_key_press_event;
-        widget_class->button_press_event = gdu_volume_grid_button_press_event;
-        widget_class->size_request       = gdu_volume_grid_size_request;
-        widget_class->expose_event       = gdu_volume_grid_expose_event;
+        widget_class->realize              = gdu_volume_grid_realize;
+        widget_class->key_press_event      = gdu_volume_grid_key_press_event;
+        widget_class->button_press_event   = gdu_volume_grid_button_press_event;
+        widget_class->get_preferred_width  = gdu_volume_grid_get_preferred_width;
+        widget_class->get_preferred_height = gdu_volume_grid_get_preferred_height;
+        widget_class->draw                 = gdu_volume_grid_draw;
 
         g_object_class_install_property (object_class,
                                          PROP_DRIVE,
@@ -1455,12 +1482,11 @@ render_slice (GduVolumeGrid *grid,
 }
 
 static gboolean
-gdu_volume_grid_expose_event (GtkWidget           *widget,
-                              GdkEventExpose      *event)
+gdu_volume_grid_draw (GtkWidget *widget,
+                      cairo_t   *cr)
 {
         GduVolumeGrid *grid = GDU_VOLUME_GRID (widget);
         GtkAllocation allocation;
-        cairo_t *cr;
         gdouble width;
         gdouble height;
         gboolean need_animation_timeout;
@@ -1473,16 +1499,8 @@ gdu_volume_grid_expose_event (GtkWidget           *widget,
                         width - 1,
                         height -1);
 
-        cr = gdk_cairo_create (gtk_widget_get_window (widget));
-        cairo_rectangle (cr,
-                         event->area.x, event->area.y,
-                         event->area.width, event->area.height);
-        cairo_clip (cr);
-
         need_animation_timeout = render_slice (grid, cr, grid->priv->elements);
 
-        cairo_destroy (cr);
-
         if (need_animation_timeout) {
                 if (grid->priv->animation_timeout_id == 0) {
                         grid->priv->animation_timeout_id = g_timeout_add (80,
diff --git a/src/palimpsest/gdu-section-drive.c b/src/palimpsest/gdu-section-drive.c
index 819a33c..1dd49fc 100644
--- a/src/palimpsest/gdu-section-drive.c
+++ b/src/palimpsest/gdu-section-drive.c
@@ -397,13 +397,13 @@ gdu_section_drive_update (GduSection *_section)
         if (show_multipath_component_warning_info_bar) {
                 gtk_widget_show_all (section->priv->multipath_component_warning_info_bar);
         } else {
-                gtk_widget_hide_all (section->priv->multipath_component_warning_info_bar);
+                gtk_widget_hide (section->priv->multipath_component_warning_info_bar);
         }
 
         if (show_multipath_component_info_bar) {
                 gtk_widget_show_all (section->priv->multipath_component_info_bar);
         } else {
-                gtk_widget_hide_all (section->priv->multipath_component_info_bar);
+                gtk_widget_hide (section->priv->multipath_component_info_bar);
         }
 
         gtk_widget_set_sensitive (section->priv->drive_label, !make_insensitive);
diff --git a/src/palimpsest/gdu-section-volumes.c b/src/palimpsest/gdu-section-volumes.c
index 4f73466..34b645c 100644
--- a/src/palimpsest/gdu-section-volumes.c
+++ b/src/palimpsest/gdu-section-volumes.c
@@ -2266,7 +2266,7 @@ gdu_section_volumes_update (GduSection *_section)
         if (show_misaligned_warning_info_bar) {
                 gtk_widget_show_all (section->priv->misaligned_warning_info_bar);
         } else {
-                gtk_widget_hide_all (section->priv->misaligned_warning_info_bar);
+                gtk_widget_hide (section->priv->misaligned_warning_info_bar);
         }
 
         if (d != NULL)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]