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
dist_ui_DATA = \
background.ui
background.ui \
display-base.png \
display-overlay.png
INCLUDES = \

View file

@ -58,33 +58,19 @@
<column type="gpointer"/>
</columns>
</object>
<object class="GtkVBox" id="background-panel">
<object class="GtkHBox" id="background-panel">
<property name="visible">True</property>
<property name="spacing">12</property>
<child>
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<property name="spacing">6</property>
<child>
<object class="GtkHBox" id="pictures-vbox">
<object class="GtkComboBox" id="sources-combobox">
<property name="visible">True</property>
<property name="spacing">12</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="width_request">150</property>
<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>
<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>
<property name="active">0</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
@ -92,10 +78,6 @@
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
@ -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>
@ -131,30 +113,26 @@
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="details-box">
<property name="width_request">175</property>
<property name="visible">True</property>
<property name="spacing">12</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="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkDrawingArea" id="preview-area">
<property name="visible">True</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="background-label">
<property name="visible">True</property>
@ -168,6 +146,18 @@
<object class="GtkHBox" id="edit-hbox">
<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>
@ -182,15 +172,9 @@
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
<property name="position">1</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>
@ -209,10 +193,11 @@
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<object class="GtkSizeGroup" id="sizegroup">
<property name="mode">vertical</property>
<widgets>
<widget name="background-label"/>
<widget name="edit-hbox"/>
</widgets>
</object>
</interface>

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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) \

View file

@ -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);

View file

@ -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);

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB