[gnome-control-center] background: implement new UI design from Jakub Steiner



commit ce8cd977542527b22dbe42765aaa015e0db494dc
Author: Thomas Wood <thos gnome org>
Date:   Wed Aug 25 19:18:05 2010 +0100

    background: implement new UI design from Jakub Steiner

 panels/background/Makefile.am            |    4 +-
 panels/background/background.ui          |   95 ++++++++++++-----------------
 panels/background/bg-colors-source.c     |    2 +-
 panels/background/bg-flickr-source.c     |    3 +-
 panels/background/bg-pictures-source.c   |    3 +-
 panels/background/bg-source.h            |    3 +
 panels/background/bg-wallpapers-source.c |    6 +-
 panels/background/cc-background-panel.c  |   96 +++++++++++++++++++++++-------
 panels/background/display-base.png       |  Bin 0 -> 22374 bytes
 panels/background/display-overlay.png    |  Bin 0 -> 9549 bytes
 10 files changed, 128 insertions(+), 84 deletions(-)
---
diff --git a/panels/background/Makefile.am b/panels/background/Makefile.am
index 82d3c07..e1b145b 100644
--- a/panels/background/Makefile.am
+++ b/panels/background/Makefile.am
@@ -3,7 +3,9 @@ cappletname = background
 
 uidir = $(pkgdatadir)/ui/background
 dist_ui_DATA = \
-	background.ui
+	background.ui \
+	display-base.png \
+	display-overlay.png
 
 
 INCLUDES = 						\
diff --git a/panels/background/background.ui b/panels/background/background.ui
index 85a575c..b4cc7c6 100644
--- a/panels/background/background.ui
+++ b/panels/background/background.ui
@@ -58,42 +58,24 @@
       <column type="gpointer"/>
     </columns>
   </object>
-  <object class="GtkVBox" id="background-panel">
+  <object class="GtkHBox" id="background-panel">
     <property name="visible">True</property>
-    <property name="orientation">vertical</property>
     <property name="spacing">12</property>
     <child>
-      <object class="GtkHBox" id="pictures-vbox">
+      <object class="GtkVBox" id="vbox2">
         <property name="visible">True</property>
-        <property name="spacing">12</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">6</property>
         <child>
-          <object class="GtkScrolledWindow" id="scrolledwindow1">
-            <property name="width_request">150</property>
+          <object class="GtkComboBox" id="sources-combobox">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="hscrollbar_policy">automatic</property>
-            <property name="vscrollbar_policy">automatic</property>
-            <property name="shadow_type">in</property>
+            <property name="model">sources-liststore</property>
+            <property name="active">0</property>
             <child>
-              <object class="GtkTreeView" id="sources-treeview">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="model">sources-liststore</property>
-                <property name="headers_visible">False</property>
-                <property name="headers_clickable">False</property>
-                <property name="search_column">0</property>
-                <child>
-                  <object class="GtkTreeViewColumn" id="treeviewcolumn1">
-                    <property name="title">Sources</property>
-                    <child>
-                      <object class="GtkCellRendererText" id="cellrenderertext2"/>
-                      <attributes>
-                        <attribute name="text">0</attribute>
-                      </attributes>
-                    </child>
-                  </object>
-                </child>
-              </object>
+              <object class="GtkCellRendererText" id="cellrenderertext2"/>
+              <attributes>
+                <attribute name="text">0</attribute>
+              </attributes>
             </child>
           </object>
           <packing>
@@ -103,8 +85,8 @@
         </child>
         <child>
           <object class="GtkScrolledWindow" id="scrolledwindow2">
-            <property name="width_request">400</property>
-            <property name="height_request">300</property>
+            <property name="width_request">190</property>
+            <property name="height_request">380</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="hscrollbar_policy">automatic</property>
@@ -114,9 +96,9 @@
               <object class="GtkIconView" id="backgrounds-iconview">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="row_spacing">4</property>
-                <property name="column_spacing">4</property>
-                <property name="margin">4</property>
+                <property name="row_spacing">0</property>
+                <property name="column_spacing">0</property>
+                <property name="margin">0</property>
                 <child>
                   <object class="GtkCellRendererPixbuf" id="pixbuf-renderer"/>
                   <attributes>
@@ -132,29 +114,25 @@
         </child>
       </object>
       <packing>
+        <property name="expand">False</property>
         <property name="position">0</property>
       </packing>
     </child>
     <child>
-      <object class="GtkHBox" id="details-box">
-        <property name="width_request">175</property>
+      <object class="GtkVBox" id="vbox3">
         <property name="visible">True</property>
-        <property name="spacing">12</property>
+        <property name="orientation">vertical</property>
         <child>
           <object class="GtkDrawingArea" id="preview-area">
-            <property name="width_request">200</property>
             <property name="visible">True</property>
           </object>
           <packing>
-            <property name="expand">False</property>
             <property name="position">0</property>
           </packing>
         </child>
         <child>
-          <object class="GtkVBox" id="vbox1">
+          <object class="GtkHBox" id="hbox1">
             <property name="visible">True</property>
-            <property name="orientation">vertical</property>
-            <property name="spacing">12</property>
             <child>
               <object class="GtkLabel" id="background-label">
                 <property name="visible">True</property>
@@ -169,6 +147,18 @@
                 <property name="visible">True</property>
                 <property name="spacing">12</property>
                 <child>
+                  <object class="GtkColorButton" id="style-color">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="color">#000000000000</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
                   <object class="GtkComboBox" id="style-combobox">
                     <property name="visible">True</property>
                     <property name="model">style-liststore</property>
@@ -182,18 +172,6 @@
                   </object>
                   <packing>
                     <property name="expand">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkColorButton" id="style-color">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="color">#000000000000</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
                     <property name="position">1</property>
                   </packing>
                 </child>
@@ -205,14 +183,21 @@
             </child>
           </object>
           <packing>
+            <property name="expand">False</property>
             <property name="position">1</property>
           </packing>
         </child>
       </object>
       <packing>
-        <property name="expand">False</property>
         <property name="position">1</property>
       </packing>
     </child>
   </object>
+  <object class="GtkSizeGroup" id="sizegroup">
+    <property name="mode">vertical</property>
+    <widgets>
+      <widget name="background-label"/>
+      <widget name="edit-hbox"/>
+    </widgets>
+  </object>
 </interface>
diff --git a/panels/background/bg-colors-source.c b/panels/background/bg-colors-source.c
index 4c07da1..702855d 100644
--- a/panels/background/bg-colors-source.c
+++ b/panels/background/bg-colors-source.c
@@ -100,7 +100,7 @@ bg_colors_source_init (BgColorsSource *self)
       /* insert the item into the liststore */
       pixbuf = gnome_wp_item_get_thumbnail (item,
                                             thumb_factory,
-                                            100, 75);
+                                            THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);
       gtk_list_store_insert_with_values (store, NULL, 0,
                                          0, pixbuf,
                                          1, item,
diff --git a/panels/background/bg-flickr-source.c b/panels/background/bg-flickr-source.c
index 50aeb03..cd9efb9 100644
--- a/panels/background/bg-flickr-source.c
+++ b/panels/background/bg-flickr-source.c
@@ -110,7 +110,8 @@ _view_items_added_cb (SwClientItemView *item_view,
 
       /* insert the item into the liststore */
       thumb_url = sw_item_get_value (sw_item, "thumbnail");
-      pixbuf = gdk_pixbuf_new_from_file_at_scale (thumb_url, 100, 75, TRUE,
+      pixbuf = gdk_pixbuf_new_from_file_at_scale (thumb_url, THUMBNAIL_WIDTH,
+                                                  THUMBNAIL_HEIGHT, TRUE,
                                                   NULL);
       gtk_list_store_insert_with_values (store, NULL, 0,
                                          0, pixbuf,
diff --git a/panels/background/bg-pictures-source.c b/panels/background/bg-pictures-source.c
index 59632ea..43024e8 100644
--- a/panels/background/bg-pictures-source.c
+++ b/panels/background/bg-pictures-source.c
@@ -184,7 +184,8 @@ file_info_async_ready (GObject      *source,
 
 
           /* insert the item into the liststore */
-          pixbuf = gdk_pixbuf_new_from_file_at_scale (filename, 100, 75, TRUE,
+          pixbuf = gdk_pixbuf_new_from_file_at_scale (filename, THUMBNAIL_WIDTH,
+                                                      THUMBNAIL_HEIGHT, TRUE,
                                                       NULL);
           gtk_list_store_insert_with_values (store, &iter, 0,
                                              0, pixbuf,
diff --git a/panels/background/bg-source.h b/panels/background/bg-source.h
index e783136..d422544 100644
--- a/panels/background/bg-source.h
+++ b/panels/background/bg-source.h
@@ -26,6 +26,9 @@
 
 G_BEGIN_DECLS
 
+#define THUMBNAIL_WIDTH 47
+#define THUMBNAIL_HEIGHT 47
+
 #define BG_TYPE_SOURCE bg_source_get_type()
 
 #define BG_SOURCE(obj) \
diff --git a/panels/background/bg-wallpapers-source.c b/panels/background/bg-wallpapers-source.c
index 4cdb1cf..21d967f 100644
--- a/panels/background/bg-wallpapers-source.c
+++ b/panels/background/bg-wallpapers-source.c
@@ -170,7 +170,7 @@ load_wallpapers (gchar              *key,
   gtk_list_store_append (store, &iter);
 
   pixbuf = gnome_wp_item_get_thumbnail (item, priv->thumb_factory,
-                                        100, 75);
+                                        THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);
   gnome_wp_item_update_description (item);
 
   gtk_list_store_set (store, &iter,
@@ -202,8 +202,8 @@ bg_wallpapers_source_init (BgWallpapersSource *self)
   wp_xml->wp_hash = g_hash_table_new (g_str_hash, g_str_equal);
   wp_xml->client = gconf_client_get_default ();
   wp_xml->wp_model = bg_source_get_liststore (BG_SOURCE (self));
-  wp_xml->thumb_width = 100;
-  wp_xml->thumb_height = 75;
+  wp_xml->thumb_width = THUMBNAIL_WIDTH;
+  wp_xml->thumb_height = THUMBNAIL_HEIGHT;
   wp_xml->thumb_factory = priv->thumb_factory;
 
   gnome_wp_xml_load_list (wp_xml);
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index 99ffc1a..d7a1ed9 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -63,6 +63,9 @@ struct _CcBackgroundPanelPrivate
   GCancellable *copy_cancellable;
 
   GtkWidget *spinner;
+
+  GdkPixbuf *display_base;
+  GdkPixbuf *display_overlay;
 };
 
 enum
@@ -164,6 +167,18 @@ cc_background_panel_dispose (GObject *object)
       priv->thumb_factory = NULL;
     }
 
+  if (priv->display_base)
+    {
+      g_object_unref (priv->display_base);
+      priv->display_base = NULL;
+    }
+
+  if (priv->display_overlay)
+    {
+      g_object_unref (priv->display_overlay);
+      priv->display_overlay = NULL;
+    }
+
   G_OBJECT_CLASS (cc_background_panel_parent_class)->dispose (object);
 }
 
@@ -201,7 +216,7 @@ cc_background_panel_class_finalize (CcBackgroundPanelClass *klass)
 }
 
 static void
-source_changed_cb (GtkTreeSelection         *selection,
+source_changed_cb (GtkComboBox              *combo,
                    CcBackgroundPanelPrivate *priv)
 {
   GtkTreeIter iter;
@@ -210,7 +225,8 @@ source_changed_cb (GtkTreeSelection         *selection,
   guint type;
   BgSource *source;
 
-  gtk_tree_selection_get_selected (selection, &model, &iter);
+  gtk_combo_box_get_active_iter (combo, &iter);
+  model = gtk_combo_box_get_model (combo);
   gtk_tree_model_get (model, &iter,
                       1, &type,
                       3, &source, -1);
@@ -315,7 +331,6 @@ backgrounds_changed_cb (GtkIconView       *icon_view,
   GConfChangeSet *cs;
   gchar *pcolor, *scolor;
   CcBackgroundPanelPrivate *priv = panel->priv;
-  GtkTreeSelection *selection;
 
   list = gtk_icon_view_get_selected_items (icon_view);
 
@@ -324,9 +339,9 @@ backgrounds_changed_cb (GtkIconView       *icon_view,
 
   /* check if the current source is read only, i.e. the image placement and
    * color is predefined */
-  selection = gtk_tree_view_get_selection (WID ("sources-treeview"));
-  model = gtk_tree_view_get_model (WID ("sources-treeview"));
-  gtk_tree_selection_get_selected (selection, &model, &iter);
+  model = gtk_combo_box_get_model (GTK_COMBO_BOX (WID ("sources-combobox")));
+  gtk_combo_box_get_active_iter (GTK_COMBO_BOX (WID ("sources-combobox")),
+                                 &iter);
   gtk_tree_model_get (model, &iter, 2, &priv->current_source_readonly, -1);
 
 
@@ -455,6 +470,13 @@ preview_expose_cb (GtkWidget         *widget,
   GtkAllocation allocation;
   CcBackgroundPanelPrivate *priv = panel->priv;
   GdkPixbuf *pixbuf = NULL;
+  const gint preview_width = 416;
+  const gint preview_height = 248;
+  const gint preview_x = 45;
+  const gint preview_y = 84;
+  GdkPixbuf *preview, *temp;
+  gfloat scale;
+  gint size;
 
   cr = gdk_cairo_create (gtk_widget_get_window (widget));
 
@@ -464,21 +486,54 @@ preview_expose_cb (GtkWidget         *widget,
     {
       pixbuf = gnome_wp_item_get_thumbnail (priv->current_background,
                                             priv->thumb_factory,
-                                            allocation.width,
-                                            allocation.height);
+                                            preview_width,
+                                            preview_height);
     }
 
+  if (!priv->display_base)
+    return FALSE;
+
+
+  preview = gdk_pixbuf_copy (priv->display_base);
+
   if (pixbuf)
     {
-      gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
-
-      cairo_paint (cr);
+      gdk_pixbuf_composite (pixbuf, preview,
+                            preview_x, preview_y,
+                            preview_width, preview_height,
+                            preview_x, preview_y, 1, 1,
+                            GDK_INTERP_BILINEAR, 255);
 
       g_object_unref (pixbuf);
     }
 
+
+  if (priv->display_overlay)
+    {
+      gdk_pixbuf_composite (priv->display_overlay, preview,
+                            0, 0, 512, 512,
+                            0, 0, 1, 1,
+                            GDK_INTERP_BILINEAR, 255);
+    }
+
+
+  if (allocation.width < allocation.height)
+    size = allocation.width;
+  else
+    size = allocation.height;
+
+  temp = gdk_pixbuf_scale_simple (preview, size, size, GDK_INTERP_BILINEAR);
+
+  gdk_cairo_set_source_pixbuf (cr,
+                               temp,
+                               allocation.width / 2 - (size / 2),
+                               allocation.height / 2 - (size / 2));
+  cairo_paint (cr);
   cairo_destroy (cr);
 
+  g_object_unref (temp);
+  g_object_unref (preview);
+
   return TRUE;
 }
 
@@ -542,10 +597,9 @@ cc_background_panel_init (CcBackgroundPanel *self)
 {
   CcBackgroundPanelPrivate *priv;
   gchar *objects[] = { "backgrounds-liststore", "style-liststore",
-      "sources-liststore", "background-panel", NULL };
+      "sources-liststore", "background-panel", "sizegroup", NULL };
   GError *err = NULL;
   GtkWidget *widget;
-  GtkTreeSelection *selection;
   gint width, height;
   GtkListStore *store;
   gchar *filename;
@@ -613,9 +667,8 @@ cc_background_panel_init (CcBackgroundPanel *self)
   gtk_widget_show_all (GTK_WIDGET (self));
 
   /* connect to source change signal */
-  widget = WID ("sources-treeview");
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
-  g_signal_connect (selection, "changed", G_CALLBACK (source_changed_cb), priv);
+  widget = WID ("sources-combobox");
+  g_signal_connect (widget, "changed", G_CALLBACK (source_changed_cb), priv);
 
   /* connect to the background iconview change signal */
   widget = WID ("backgrounds-iconview");
@@ -628,12 +681,11 @@ cc_background_panel_init (CcBackgroundPanel *self)
   g_signal_connect (widget, "expose-event", G_CALLBACK (preview_expose_cb),
                     self);
 
-
-  width = 150;
-  height = width * ((double) gdk_screen_get_height (gdk_screen_get_default ()) /
-    (double) gdk_screen_get_width (gdk_screen_get_default ()));
-
-  gtk_widget_set_size_request (widget, width, height);
+  priv->display_base = gdk_pixbuf_new_from_file (DATADIR "/display-base.png",
+                                                 NULL);
+  priv->display_overlay = gdk_pixbuf_new_from_file (DATADIR
+                                                    "/display-overlay.png",
+                                                    NULL);
 
   g_signal_connect (WID ("style-combobox"), "changed",
                     G_CALLBACK (style_changed_cb), self);
diff --git a/panels/background/display-base.png b/panels/background/display-base.png
new file mode 100644
index 0000000..648b7ee
Binary files /dev/null and b/panels/background/display-base.png differ
diff --git a/panels/background/display-overlay.png b/panels/background/display-overlay.png
new file mode 100644
index 0000000..74113ac
Binary files /dev/null and b/panels/background/display-overlay.png differ



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