[gnome-disk-utility] Finish GTK3 port



commit a58f325cbead303bf79026935927d83cb55c2f15
Author: David Zeuthen <davidz redhat com>
Date:   Fri Jan 21 15:44:25 2011 -0500

    Finish GTK3 port
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 configure.ac                             |    4 +-
 src/format-tool/Makefile.am              |    4 +-
 src/gdu-gtk/Makefile.am                  |    4 +-
 src/gdu-gtk/gdu-create-linux-md-dialog.c |   30 ++++----
 src/gdu-gtk/gdu-format-dialog.c          |   10 +-
 src/gdu-gtk/gdu-gtk.c                    |    8 ++
 src/gdu-gtk/gdu-volume-grid.c            |  120 ++++++++++++------------------
 src/notification/Makefile.am             |    4 +-
 src/palimpsest/Makefile.am               |    4 +-
 src/palimpsest/gdu-section-drive.c       |    2 +-
 10 files changed, 86 insertions(+), 104 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index bb6e926..f5e0261 100644
--- a/configure.ac
+++ b/configure.ac
@@ -126,7 +126,7 @@ GOBJECT2_REQUIRED=2.16
 GIO2_REQUIRED=2.22
 DBUS_GLIB_REQUIRED=0.74
 GNOME_KEYRING_REQUIRED=2.22
-GTK_REQUIRED=2.90.7
+GTK3_REQUIRED=2.90.7
 UNIQUE_REQUIRED=2.90.1
 LIBNOTIFY_REQUIRED=0.6.1
 NAUTILUS_REQUIRED=2.24.0
@@ -144,7 +144,7 @@ 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+-3.0 >= $GTK_REQUIRED])
+PKG_CHECK_MODULES(GTK3, [gtk+-3.0 >= $GTK3_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])
diff --git a/src/format-tool/Makefile.am b/src/format-tool/Makefile.am
index 0b4f92c..4573770 100644
--- a/src/format-tool/Makefile.am
+++ b/src/format-tool/Makefile.am
@@ -17,7 +17,7 @@ CORE_CFLAGS = 						\
 	$(GIO2_CFLAGS)					\
 	$(GIO_UNIX2_CFLAGS)				\
 	$(GTHREAD2_CFLAGS)				\
-	$(GTK2_CFLAGS)					\
+	$(GTK3_CFLAGS)					\
 	$(NULL)
 
 CORE_LIBADD = 						\
@@ -26,7 +26,7 @@ CORE_LIBADD = 						\
 	$(GIO2_LIBS)					\
 	$(GIO_UNIX2_LIBS)				\
 	$(GTHREAD2_LIBS)				\
-	$(GTK2_LIBS)					\
+	$(GTK3_LIBS)					\
 	$(INTLLIBS)					\
 	$(top_builddir)/src/gdu/libgdu.la		\
 	$(top_builddir)/src/gdu-gtk/libgdu-gtk.la	\
diff --git a/src/gdu-gtk/Makefile.am b/src/gdu-gtk/Makefile.am
index 10745b1..a44d452 100644
--- a/src/gdu-gtk/Makefile.am
+++ b/src/gdu-gtk/Makefile.am
@@ -111,7 +111,7 @@ libgdu_gtk_la_CFLAGS = 					\
 	$(GIO_UNIX2_CFLAGS)				\
 	$(DBUS_GLIB_CFLAGS)				\
 	$(GNOME_KEYRING_CFLAGS)				\
-	$(GTK2_CFLAGS)					\
+	$(GTK3_CFLAGS)					\
 	$(WARN_CFLAGS)					\
 	$(AM_CFLAGS)					\
 	$(LIBATASMART_CFLAGS)				\
@@ -124,7 +124,7 @@ libgdu_gtk_la_LIBADD = 					\
 	$(GIO_UNIX2_LIBS)				\
 	$(DBUS_GLIB_LIBS)				\
 	$(GNOME_KEYRING_LIBS)				\
-	$(GTK2_LIBS)					\
+	$(GTK3_LIBS)					\
 	$(INTLLIBS)					\
 	$(LIBATASMART_LIBS)				\
 	$(AVAHI_UI_LIBS)				\
diff --git a/src/gdu-gtk/gdu-create-linux-md-dialog.c b/src/gdu-gtk/gdu-create-linux-md-dialog.c
index a348391..ac0f27c 100644
--- a/src/gdu-gtk/gdu-create-linux-md-dialog.c
+++ b/src/gdu-gtk/gdu-create-linux-md-dialog.c
@@ -556,20 +556,20 @@ gdu_create_linux_md_dialog_constructed (GObject *object)
         gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), _("RAID _Level:"));
         gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
                           GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
-        combo_box = gtk_combo_box_new_text ();
+        combo_box = gtk_combo_box_text_new ();
         dialog->priv->level_combo_box = combo_box;
         /* keep in sync with on_level_combo_box_changed() */
         s = gdu_linux_md_get_raid_level_for_display ("raid0", TRUE);
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), s);
+        gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL, s);
         g_free (s);
         s = gdu_linux_md_get_raid_level_for_display ("raid1", TRUE);
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), s);
+        gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL, s);
         g_free (s);
         s = gdu_linux_md_get_raid_level_for_display ("raid5", TRUE);
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), s);
+        gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL, s);
         g_free (s);
         s = gdu_linux_md_get_raid_level_for_display ("raid6", TRUE);
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), s);
+        gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL, s);
         g_free (s);
         g_signal_connect (combo_box,
                           "changed",
@@ -620,28 +620,28 @@ gdu_create_linux_md_dialog_constructed (GObject *object)
         gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
                           GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
         /* keep in sync with on_stripe_size_combo_box_changed() */
-        combo_box = gtk_combo_box_new_text ();
+        combo_box = gtk_combo_box_text_new ();
         /* Translators: The following strings (4 KiB, 8 Kib, ..., 1 MiB) are for choosing the RAID stripe size.
          * Since the rest of gnome-disk-utility use the sane 1k=1000 conventions and RAID needs the 1k=1024
          * convenention (this is because disk block sizes are powers of two) we resort to the nerdy units.
          */
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+        gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL,
                                    _("4 KiB"));
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+        gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL,
                                    _("8 KiB"));
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+        gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL,
                                    _("16 KiB"));
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+        gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL,
                                    _("32 KiB"));
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+        gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL,
                                    _("64 KiB"));
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+        gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL,
                                    _("128 KiB"));
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+        gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL,
                                    _("256 KiB"));
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+        gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL,
                                    _("512 KiB"));
-        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+        gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL,
                                    _("1 MiB"));
         /* keep in sync with gtk_combo_box_set_active() on stripe_size_combo_box below */
         dialog->priv->stripe_size = 512 * 1024;
diff --git a/src/gdu-gtk/gdu-format-dialog.c b/src/gdu-gtk/gdu-format-dialog.c
index a718f82..e34e704 100644
--- a/src/gdu-gtk/gdu-format-dialog.c
+++ b/src/gdu-gtk/gdu-format-dialog.c
@@ -555,14 +555,14 @@ gdu_format_dialog_constructed (GObject *object)
                           GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
         if (dialog->priv->flags & GDU_FORMAT_DIALOG_FLAGS_SIMPLE) {
                 /* keep in sync with on_combo_box_changed() */
-                combo_box = gtk_combo_box_new_text ();
-                gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+                combo_box = gtk_combo_box_text_new ();
+                gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL,
                                            _("Compatible with all systems (FAT)"));
-                gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+                gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL,
                                            _("Compatible with Linux (ext2)"));
-                gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+                gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL,
                                            _("Compatible with Linux (ext4)"));
-                gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+                gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL,
                                            _("Encrypted, compatible with Linux (FAT)"));
                 gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);
                 dialog->priv->fs_type = g_strdup ("vfat");
diff --git a/src/gdu-gtk/gdu-gtk.c b/src/gdu-gtk/gdu-gtk.c
index 7d7cb21..c36ee00 100644
--- a/src/gdu-gtk/gdu-gtk.c
+++ b/src/gdu-gtk/gdu-gtk.c
@@ -1749,6 +1749,7 @@ gdu_util_get_mix_color (GtkWidget    *widget,
                         gchar        *color_buf,
                         gsize         color_buf_size)
 {
+#if 0
         GtkStyle *style;
         GdkColor color = {0};
 
@@ -1770,4 +1771,11 @@ gdu_util_get_mix_color (GtkWidget    *widget,
                   (color.red >> 8),
                   (color.green >> 8),
                   (color.blue >> 8));
+#endif
+        /* TODO: use GtkStyleContext and/or CSS etc. instead of hard-coding colors */
+        snprintf (color_buf,
+                  color_buf_size, "#%02x%02x%02x",
+                  0x80,
+                  0x80,
+                  0x80);
 }
diff --git a/src/gdu-gtk/gdu-volume-grid.c b/src/gdu-gtk/gdu-volume-grid.c
index a5010e6..d507964 100644
--- a/src/gdu-gtk/gdu-volume-grid.c
+++ b/src/gdu-gtk/gdu-volume-grid.c
@@ -223,10 +223,6 @@ gdu_volume_grid_constructed (GObject *object)
 {
         GduVolumeGrid *grid = GDU_VOLUME_GRID (object);
 
-        gtk_widget_set_size_request (GTK_WIDGET (grid),
-                                     -1,
-                                     100);
-
         g_signal_connect (grid->priv->pool,
                           "presentable-added",
                           G_CALLBACK (on_presentable_added),
@@ -390,6 +386,7 @@ gdu_volume_grid_realize (GtkWidget *widget)
         GdkWindowAttr attributes;
         gint attributes_mask;
         GtkAllocation allocation;
+        GtkStyleContext *context;
 
         gtk_widget_set_realized (widget, TRUE);
         gtk_widget_get_allocation (widget, &allocation);
@@ -421,10 +418,8 @@ gdu_volume_grid_realize (GtkWidget *widget)
         gtk_widget_set_window (widget, window);
         gdk_window_set_user_data (window, grid);
 
-        gtk_widget_style_attach (widget);
-        gtk_style_set_background (gtk_widget_get_style (widget),
-                                  window,
-                                  GTK_STATE_NORMAL);
+        context = gtk_widget_get_style_context (widget);
+        gtk_style_context_set_background (context, window);
 }
 
 static guint
@@ -445,45 +440,29 @@ get_num_elements_for_slice (GList *elements)
                 return 1;
 }
 
-
-static void
-gdu_volume_grid_size_request (GtkWidget      *widget,
-                              GtkRequisition *requisition)
-{
-        GduVolumeGrid *grid = GDU_VOLUME_GRID (widget);
-        guint num_elements;
-
-        num_elements = get_num_elements_for_slice (grid->priv->elements);
-        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;
+  GduVolumeGrid *grid = GDU_VOLUME_GRID (widget);
+  guint num_elements;
+  gint width;
 
-  gdu_volume_grid_size_request (widget, &requisition);
+  num_elements = get_num_elements_for_slice (grid->priv->elements);
+  width = num_elements * ELEMENT_MINIMUM_WIDTH;
 
-  *minimal_width = *natural_width = requisition.width;
+  *minimal_width = *natural_width = 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;
+  *minimal_height = *natural_height = 100;
 }
 
-
 static void
 gdu_volume_grid_class_init (GduVolumeGridClass *klass)
 {
@@ -1044,54 +1023,49 @@ render_element (GduVolumeGrid *grid,
         gdouble text_selected_not_focused_red;
         gdouble text_selected_not_focused_green;
         gdouble text_selected_not_focused_blue;
-        GtkStyle *style;
         PangoLayout *layout;
         PangoFontDescription *desc;
         gint width, height;
 
         need_animation_timeout = FALSE;
 
-        style = gtk_widget_get_style (GTK_WIDGET (grid));
-
-        fill_red   = style->base[GTK_STATE_NORMAL].red   / 65535.0;
-        fill_green = style->base[GTK_STATE_NORMAL].green / 65535.0;
-        fill_blue  = style->base[GTK_STATE_NORMAL].blue  / 65535.0;
-        fill_selected_red   = style->base[GTK_STATE_SELECTED].red   / 65535.0;
-        fill_selected_green = style->base[GTK_STATE_SELECTED].green / 65535.0;
-        fill_selected_blue  = style->base[GTK_STATE_SELECTED].blue  / 65535.0;
-        fill_selected_not_focused_red   = style->base[GTK_STATE_ACTIVE].red   / 65535.0;
-        fill_selected_not_focused_green = style->base[GTK_STATE_ACTIVE].green / 65535.0;
-        fill_selected_not_focused_blue  = style->base[GTK_STATE_ACTIVE].blue  / 65535.0;
-
-        stroke_red   = fill_red   * 0.75;
-        stroke_green = fill_green * 0.75;
-        stroke_blue  = fill_blue  * 0.75;
-        stroke_selected_red   = fill_selected_red   * 0.75;
-        stroke_selected_green = fill_selected_green * 0.75;
-        stroke_selected_blue  = fill_selected_blue  * 0.75;
-        stroke_selected_not_focused_red   = fill_selected_not_focused_red   * 0.75;
-        stroke_selected_not_focused_green = fill_selected_not_focused_green * 0.75;
-        stroke_selected_not_focused_blue  = fill_selected_not_focused_blue  * 0.75;
-
-        focus_rect_red   = style->text_aa[GTK_STATE_NORMAL].red   / 65535.0;
-        focus_rect_green = style->text_aa[GTK_STATE_NORMAL].green / 65535.0;
-        focus_rect_blue  = style->text_aa[GTK_STATE_NORMAL].blue  / 65535.0;
-        focus_rect_selected_red   = style->text_aa[GTK_STATE_SELECTED].red   / 65535.0;
-        focus_rect_selected_green = style->text_aa[GTK_STATE_SELECTED].green / 65535.0;
-        focus_rect_selected_blue  = style->text_aa[GTK_STATE_SELECTED].blue  / 65535.0;
-        focus_rect_selected_not_focused_red   = style->text_aa[GTK_STATE_ACTIVE].red   / 65535.0;
-        focus_rect_selected_not_focused_green = style->text_aa[GTK_STATE_ACTIVE].green / 65535.0;
-        focus_rect_selected_not_focused_blue  = style->text_aa[GTK_STATE_ACTIVE].blue  / 65535.0;
-
-        text_red   = style->fg[GTK_STATE_NORMAL].red   / 65535.0;
-        text_green = style->fg[GTK_STATE_NORMAL].green / 65535.0;
-        text_blue  = style->fg[GTK_STATE_NORMAL].blue  / 65535.0;
-        text_selected_red   = style->fg[GTK_STATE_SELECTED].red   / 65535.0;
-        text_selected_green = style->fg[GTK_STATE_SELECTED].green / 65535.0;
-        text_selected_blue  = style->fg[GTK_STATE_SELECTED].blue  / 65535.0;
-        text_selected_not_focused_red   = style->fg[GTK_STATE_ACTIVE].red   / 65535.0;
-        text_selected_not_focused_green = style->fg[GTK_STATE_ACTIVE].green / 65535.0;
-        text_selected_not_focused_blue  = style->fg[GTK_STATE_ACTIVE].blue  / 65535.0;
+        /* TODO: use GtkStyleContext and/or CSS etc. instead of hard-coding colors */
+        fill_red     = 1;
+        fill_green   = 1;
+        fill_blue    = 1;
+        fill_selected_red     = 0.40;
+        fill_selected_green   = 0.60;
+        fill_selected_blue    = 0.80;
+        fill_selected_not_focused_red     = 0.60;
+        fill_selected_not_focused_green   = 0.60;
+        fill_selected_not_focused_blue    = 0.60;
+        focus_rect_red     = 0.75;
+        focus_rect_green   = 0.75;
+        focus_rect_blue    = 0.75;
+        focus_rect_selected_red     = 0.70;
+        focus_rect_selected_green   = 0.70;
+        focus_rect_selected_blue    = 0.80;
+        focus_rect_selected_not_focused_red     = 0.70;
+        focus_rect_selected_not_focused_green   = 0.70;
+        focus_rect_selected_not_focused_blue    = 0.70;
+        stroke_red   = 0.75;
+        stroke_green = 0.75;
+        stroke_blue  = 0.75;
+        stroke_selected_red   = 0.3;
+        stroke_selected_green = 0.45;
+        stroke_selected_blue  = 0.6;
+        stroke_selected_not_focused_red   = 0.45;
+        stroke_selected_not_focused_green = 0.45;
+        stroke_selected_not_focused_blue  = 0.45;
+        text_red     = 0;
+        text_green   = 0;
+        text_blue    = 0;
+        text_selected_red     = 1;
+        text_selected_green   = 1;
+        text_selected_blue    = 1;
+        text_selected_not_focused_red     = 1;
+        text_selected_not_focused_green   = 1;
+        text_selected_not_focused_blue    = 1;
 
 #if 0
         g_debug ("rendering element: x=%d w=%d",
diff --git a/src/notification/Makefile.am b/src/notification/Makefile.am
index c1d7091..3dbdd6f 100644
--- a/src/notification/Makefile.am
+++ b/src/notification/Makefile.am
@@ -23,7 +23,7 @@ gdu_notification_daemon_CFLAGS = 			\
 	$(GOBJECT2_CFLAGS)				\
 	$(GIO2_CFLAGS)					\
 	$(GIO_UNIX2_CFLAGS)				\
-	$(GTK2_CFLAGS)					\
+	$(GTK3_CFLAGS)					\
 	$(WARN_CFLAGS)					\
 	$(LIBNOTIFY_CFLAGS)				\
 	$(AM_CFLAGS)
@@ -35,7 +35,7 @@ gdu_notification_daemon_LDADD = 			\
 	$(GLIB2_LIBS)					\
 	$(GOBJECT2_LIBS)				\
 	$(GIO2_LIBS)					\
-	$(GTK2_LIBS)					\
+	$(GTK3_LIBS)					\
 	$(LIBNOTIFY_LIBS)				\
 	$(top_builddir)/src/gdu/libgdu.la		\
 	$(top_builddir)/src/gdu-gtk/libgdu-gtk.la
diff --git a/src/palimpsest/Makefile.am b/src/palimpsest/Makefile.am
index 95baa9b..912da87 100644
--- a/src/palimpsest/Makefile.am
+++ b/src/palimpsest/Makefile.am
@@ -31,7 +31,7 @@ palimpsest_CFLAGS = 					\
 	$(GIO_UNIX2_CFLAGS)				\
 	$(DBUS_GLIB_CFLAGS)				\
 	$(GNOME_KEYRING_CFLAGS)				\
-	$(GTK2_CFLAGS)					\
+	$(GTK3_CFLAGS)					\
 	$(UNIQUE_CFLAGS)				\
 	$(X11_CFLAGS)					\
 	$(WARN_CFLAGS)					\
@@ -46,7 +46,7 @@ palimpsest_LDADD = 					\
 	$(GIO_UNIX2_LIBS)				\
 	$(DBUS_GLIB_LIBS)				\
 	$(GNOME_KEYRING_LIBS)				\
-	$(GTK2_LIBS)					\
+	$(GTK3_LIBS)					\
 	$(UNIQUE_LIBS)					\
 	$(X11_LIBS)					\
 	$(INTLLIBS)					\
diff --git a/src/palimpsest/gdu-section-drive.c b/src/palimpsest/gdu-section-drive.c
index 1dd49fc..20b5801 100644
--- a/src/palimpsest/gdu-section-drive.c
+++ b/src/palimpsest/gdu-section-drive.c
@@ -444,7 +444,7 @@ on_cddvd_button_clicked (GduButtonElement *button_element,
                 goto out;
         }
 
-        launch_context = G_APP_LAUNCH_CONTEXT (gdk_app_launch_context_new ());
+        launch_context = G_APP_LAUNCH_CONTEXT (gdk_display_get_app_launch_context (NULL));
 
         error = NULL;
         if (!g_app_info_launch (app_info,



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