background: implement new UI design from Jakub Steiner

This commit is contained in:
Thomas Wood 2010-08-25 19:18:05 +01:00
parent 45954bdeb5
commit ce8cd97754
10 changed files with 128 additions and 84 deletions

View file

@ -3,7 +3,9 @@ cappletname = background
uidir = $(pkgdatadir)/ui/background uidir = $(pkgdatadir)/ui/background
dist_ui_DATA = \ dist_ui_DATA = \
background.ui background.ui \
display-base.png \
display-overlay.png
INCLUDES = \ INCLUDES = \

View file

@ -58,42 +58,24 @@
<column type="gpointer"/> <column type="gpointer"/>
</columns> </columns>
</object> </object>
<object class="GtkVBox" id="background-panel"> <object class="GtkHBox" id="background-panel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<child> <child>
<object class="GtkHBox" id="pictures-vbox"> <object class="GtkVBox" id="vbox2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="spacing">12</property> <property name="orientation">vertical</property>
<property name="spacing">6</property>
<child> <child>
<object class="GtkScrolledWindow" id="scrolledwindow1"> <object class="GtkComboBox" id="sources-combobox">
<property name="width_request">150</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="model">sources-liststore</property>
<property name="hscrollbar_policy">automatic</property> <property name="active">0</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">in</property>
<child> <child>
<object class="GtkTreeView" id="sources-treeview"> <object class="GtkCellRendererText" id="cellrenderertext2"/>
<property name="visible">True</property> <attributes>
<property name="can_focus">True</property> <attribute name="text">0</attribute>
<property name="model">sources-liststore</property> </attributes>
<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>
</child> </child>
</object> </object>
<packing> <packing>
@ -103,8 +85,8 @@
</child> </child>
<child> <child>
<object class="GtkScrolledWindow" id="scrolledwindow2"> <object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="width_request">400</property> <property name="width_request">190</property>
<property name="height_request">300</property> <property name="height_request">380</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property> <property name="hscrollbar_policy">automatic</property>
@ -114,9 +96,9 @@
<object class="GtkIconView" id="backgrounds-iconview"> <object class="GtkIconView" id="backgrounds-iconview">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="row_spacing">4</property> <property name="row_spacing">0</property>
<property name="column_spacing">4</property> <property name="column_spacing">0</property>
<property name="margin">4</property> <property name="margin">0</property>
<child> <child>
<object class="GtkCellRendererPixbuf" id="pixbuf-renderer"/> <object class="GtkCellRendererPixbuf" id="pixbuf-renderer"/>
<attributes> <attributes>
@ -132,29 +114,25 @@
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkHBox" id="details-box"> <object class="GtkVBox" id="vbox3">
<property name="width_request">175</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="spacing">12</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkDrawingArea" id="preview-area"> <object class="GtkDrawingArea" id="preview-area">
<property name="width_request">200</property>
<property name="visible">True</property> <property name="visible">True</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkVBox" id="vbox1"> <object class="GtkHBox" id="hbox1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child> <child>
<object class="GtkLabel" id="background-label"> <object class="GtkLabel" id="background-label">
<property name="visible">True</property> <property name="visible">True</property>
@ -168,6 +146,18 @@
<object class="GtkHBox" id="edit-hbox"> <object class="GtkHBox" id="edit-hbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="spacing">12</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> <child>
<object class="GtkComboBox" id="style-combobox"> <object class="GtkComboBox" id="style-combobox">
<property name="visible">True</property> <property name="visible">True</property>
@ -180,18 +170,6 @@
</attributes> </attributes>
</child> </child>
</object> </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> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="position">1</property> <property name="position">1</property>
@ -205,14 +183,21 @@
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
</object> </object>
<object class="GtkSizeGroup" id="sizegroup">
<property name="mode">vertical</property>
<widgets>
<widget name="background-label"/>
<widget name="edit-hbox"/>
</widgets>
</object>
</interface> </interface>

View file

@ -100,7 +100,7 @@ bg_colors_source_init (BgColorsSource *self)
/* insert the item into the liststore */ /* insert the item into the liststore */
pixbuf = gnome_wp_item_get_thumbnail (item, pixbuf = gnome_wp_item_get_thumbnail (item,
thumb_factory, thumb_factory,
100, 75); THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);
gtk_list_store_insert_with_values (store, NULL, 0, gtk_list_store_insert_with_values (store, NULL, 0,
0, pixbuf, 0, pixbuf,
1, item, 1, item,

View file

@ -110,7 +110,8 @@ _view_items_added_cb (SwClientItemView *item_view,
/* insert the item into the liststore */ /* insert the item into the liststore */
thumb_url = sw_item_get_value (sw_item, "thumbnail"); 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); NULL);
gtk_list_store_insert_with_values (store, NULL, 0, gtk_list_store_insert_with_values (store, NULL, 0,
0, pixbuf, 0, pixbuf,

View file

@ -184,7 +184,8 @@ file_info_async_ready (GObject *source,
/* insert the item into the liststore */ /* 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); NULL);
gtk_list_store_insert_with_values (store, &iter, 0, gtk_list_store_insert_with_values (store, &iter, 0,
0, pixbuf, 0, pixbuf,

View file

@ -26,6 +26,9 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define THUMBNAIL_WIDTH 47
#define THUMBNAIL_HEIGHT 47
#define BG_TYPE_SOURCE bg_source_get_type() #define BG_TYPE_SOURCE bg_source_get_type()
#define BG_SOURCE(obj) \ #define BG_SOURCE(obj) \

View file

@ -170,7 +170,7 @@ load_wallpapers (gchar *key,
gtk_list_store_append (store, &iter); gtk_list_store_append (store, &iter);
pixbuf = gnome_wp_item_get_thumbnail (item, priv->thumb_factory, pixbuf = gnome_wp_item_get_thumbnail (item, priv->thumb_factory,
100, 75); THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);
gnome_wp_item_update_description (item); gnome_wp_item_update_description (item);
gtk_list_store_set (store, &iter, 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->wp_hash = g_hash_table_new (g_str_hash, g_str_equal);
wp_xml->client = gconf_client_get_default (); wp_xml->client = gconf_client_get_default ();
wp_xml->wp_model = bg_source_get_liststore (BG_SOURCE (self)); wp_xml->wp_model = bg_source_get_liststore (BG_SOURCE (self));
wp_xml->thumb_width = 100; wp_xml->thumb_width = THUMBNAIL_WIDTH;
wp_xml->thumb_height = 75; wp_xml->thumb_height = THUMBNAIL_HEIGHT;
wp_xml->thumb_factory = priv->thumb_factory; wp_xml->thumb_factory = priv->thumb_factory;
gnome_wp_xml_load_list (wp_xml); gnome_wp_xml_load_list (wp_xml);

View file

@ -63,6 +63,9 @@ struct _CcBackgroundPanelPrivate
GCancellable *copy_cancellable; GCancellable *copy_cancellable;
GtkWidget *spinner; GtkWidget *spinner;
GdkPixbuf *display_base;
GdkPixbuf *display_overlay;
}; };
enum enum
@ -164,6 +167,18 @@ cc_background_panel_dispose (GObject *object)
priv->thumb_factory = NULL; 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); G_OBJECT_CLASS (cc_background_panel_parent_class)->dispose (object);
} }
@ -201,7 +216,7 @@ cc_background_panel_class_finalize (CcBackgroundPanelClass *klass)
} }
static void static void
source_changed_cb (GtkTreeSelection *selection, source_changed_cb (GtkComboBox *combo,
CcBackgroundPanelPrivate *priv) CcBackgroundPanelPrivate *priv)
{ {
GtkTreeIter iter; GtkTreeIter iter;
@ -210,7 +225,8 @@ source_changed_cb (GtkTreeSelection *selection,
guint type; guint type;
BgSource *source; 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, gtk_tree_model_get (model, &iter,
1, &type, 1, &type,
3, &source, -1); 3, &source, -1);
@ -315,7 +331,6 @@ backgrounds_changed_cb (GtkIconView *icon_view,
GConfChangeSet *cs; GConfChangeSet *cs;
gchar *pcolor, *scolor; gchar *pcolor, *scolor;
CcBackgroundPanelPrivate *priv = panel->priv; CcBackgroundPanelPrivate *priv = panel->priv;
GtkTreeSelection *selection;
list = gtk_icon_view_get_selected_items (icon_view); 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 /* check if the current source is read only, i.e. the image placement and
* color is predefined */ * color is predefined */
selection = gtk_tree_view_get_selection (WID ("sources-treeview")); model = gtk_combo_box_get_model (GTK_COMBO_BOX (WID ("sources-combobox")));
model = gtk_tree_view_get_model (WID ("sources-treeview")); gtk_combo_box_get_active_iter (GTK_COMBO_BOX (WID ("sources-combobox")),
gtk_tree_selection_get_selected (selection, &model, &iter); &iter);
gtk_tree_model_get (model, &iter, 2, &priv->current_source_readonly, -1); gtk_tree_model_get (model, &iter, 2, &priv->current_source_readonly, -1);
@ -455,6 +470,13 @@ preview_expose_cb (GtkWidget *widget,
GtkAllocation allocation; GtkAllocation allocation;
CcBackgroundPanelPrivate *priv = panel->priv; CcBackgroundPanelPrivate *priv = panel->priv;
GdkPixbuf *pixbuf = NULL; 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)); 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, pixbuf = gnome_wp_item_get_thumbnail (priv->current_background,
priv->thumb_factory, priv->thumb_factory,
allocation.width, preview_width,
allocation.height); preview_height);
} }
if (!priv->display_base)
return FALSE;
preview = gdk_pixbuf_copy (priv->display_base);
if (pixbuf) if (pixbuf)
{ {
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); gdk_pixbuf_composite (pixbuf, preview,
preview_x, preview_y,
cairo_paint (cr); preview_width, preview_height,
preview_x, preview_y, 1, 1,
GDK_INTERP_BILINEAR, 255);
g_object_unref (pixbuf); 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); cairo_destroy (cr);
g_object_unref (temp);
g_object_unref (preview);
return TRUE; return TRUE;
} }
@ -542,10 +597,9 @@ cc_background_panel_init (CcBackgroundPanel *self)
{ {
CcBackgroundPanelPrivate *priv; CcBackgroundPanelPrivate *priv;
gchar *objects[] = { "backgrounds-liststore", "style-liststore", gchar *objects[] = { "backgrounds-liststore", "style-liststore",
"sources-liststore", "background-panel", NULL }; "sources-liststore", "background-panel", "sizegroup", NULL };
GError *err = NULL; GError *err = NULL;
GtkWidget *widget; GtkWidget *widget;
GtkTreeSelection *selection;
gint width, height; gint width, height;
GtkListStore *store; GtkListStore *store;
gchar *filename; gchar *filename;
@ -613,9 +667,8 @@ cc_background_panel_init (CcBackgroundPanel *self)
gtk_widget_show_all (GTK_WIDGET (self)); gtk_widget_show_all (GTK_WIDGET (self));
/* connect to source change signal */ /* connect to source change signal */
widget = WID ("sources-treeview"); widget = WID ("sources-combobox");
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)); g_signal_connect (widget, "changed", G_CALLBACK (source_changed_cb), priv);
g_signal_connect (selection, "changed", G_CALLBACK (source_changed_cb), priv);
/* connect to the background iconview change signal */ /* connect to the background iconview change signal */
widget = WID ("backgrounds-iconview"); 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), g_signal_connect (widget, "expose-event", G_CALLBACK (preview_expose_cb),
self); self);
priv->display_base = gdk_pixbuf_new_from_file (DATADIR "/display-base.png",
width = 150; NULL);
height = width * ((double) gdk_screen_get_height (gdk_screen_get_default ()) / priv->display_overlay = gdk_pixbuf_new_from_file (DATADIR
(double) gdk_screen_get_width (gdk_screen_get_default ())); "/display-overlay.png",
NULL);
gtk_widget_set_size_request (widget, width, height);
g_signal_connect (WID ("style-combobox"), "changed", g_signal_connect (WID ("style-combobox"), "changed",
G_CALLBACK (style_changed_cb), self); G_CALLBACK (style_changed_cb), self);

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB