[Xfce4-commits] <ristretto:master> Change looks of the thumbnailbar
Stephan Arts
noreply at xfce.org
Mon Oct 12 00:18:01 CEST 2009
Updating branch refs/heads/master
to ac5848324c73cf6d220a20fdb66390ff557836f0 (commit)
from 90722c427ac74f24eeaa67a9e0b6b5c526e8ca9f (commit)
commit ac5848324c73cf6d220a20fdb66390ff557836f0
Author: Stephan Arts <stephan at xfce.org>
Date: Mon Oct 12 00:11:39 2009 +0200
Change looks of the thumbnailbar
ChangeLog | 5 ++
src/thumbnail_bar.c | 107 +++++++++++++++++++++++++++++++++++++++++++++------
src/thumbnail_bar.h | 1 +
3 files changed, 101 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e939b92..2d7108b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2009-10-08 Stephan Arts <stephan at xfce.org>
+ * src/thumbnail_bar.c,
+ src/thumbnail_bar.h: Change looks of the thumbnailbar
+
+2009-10-08 Stephan Arts <stephan at xfce.org>
+
* src/app_menu_item.c: Add application-icon to application-menu-item, used
in the open-with menu.
diff --git a/src/thumbnail_bar.c b/src/thumbnail_bar.c
index 8711604..1d871bc 100644
--- a/src/thumbnail_bar.c
+++ b/src/thumbnail_bar.c
@@ -184,22 +184,32 @@ rstto_thumbnail_bar_class_init(RsttoThumbnailBarClass *bar_class)
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
- g_param_spec_int ("border_width",
- _("Border Width"),
- _("The border width of the thumbnail-bar"),
- 0, G_MAXINT, 3,
+ g_param_spec_int ("border-width",
+ _("border width"),
+ _("the border width of the thumbnail-bar"),
+ 0, G_MAXINT, 0,
+ G_PARAM_READABLE));
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("film-border-width",
+ _("border width"),
+ _("the border width of the thumbnail-bar"),
+ 0, G_MAXINT, 8,
G_PARAM_READABLE));
+
}
static void
rstto_thumbnail_bar_size_request(GtkWidget *widget, GtkRequisition *requisition)
{
RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(widget);
- gint border_width = GTK_CONTAINER(bar)->border_width;
+ gint border_width;
+ gint film_border_width = bar->film_border_width;
GList *iter;
GtkRequisition child_requisition;
- gtk_widget_style_get(widget, "border-width", &border_width, NULL);
+ gtk_widget_style_get (widget, "border-width", &border_width, NULL);
+ gtk_widget_style_get (widget, "film-border-width", &film_border_width, NULL);
requisition->height = 70;
requisition->width = 70;
@@ -211,11 +221,21 @@ rstto_thumbnail_bar_size_request(GtkWidget *widget, GtkRequisition *requisition)
requisition->height = MAX(child_requisition.height, requisition->height);
}
- requisition->height += (border_width * 2);
- requisition->width += (border_width * 2);
+ switch (bar->priv->orientation)
+ {
+ case GTK_ORIENTATION_HORIZONTAL:
+ requisition->height += ((border_width * 2) + (film_border_width * 2));
+ requisition->width += (border_width * 2);
+ break;
+ case GTK_ORIENTATION_VERTICAL:
+ requisition->height += (border_width * 2);
+ requisition->width += ((border_width * 2) + (film_border_width * 2));
+ break;
+ }
widget->requisition = *requisition;
GTK_CONTAINER(bar)->border_width = border_width;
+ bar->film_border_width = film_border_width;
}
static void
@@ -223,6 +243,7 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(widget);
gint border_width = GTK_CONTAINER(bar)->border_width;
+ gint film_border_width = bar->film_border_width;
gint spacing = 0;
GtkAllocation child_allocation;
GtkRequisition child_requisition;
@@ -250,6 +271,7 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
switch(bar->priv->orientation)
{
case GTK_ORIENTATION_HORIZONTAL:
+ child_allocation.y += film_border_width;
if (bar->priv->auto_center == TRUE)
{
bar->priv->offset = 0 - (allocation->width / 2);
@@ -257,7 +279,7 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
while(iter)
{
gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
- allocation->height = MAX(child_requisition.height + (border_width * 2), allocation->height);
+ allocation->height = MAX(child_requisition.height + (border_width * 2) + (film_border_width * 2), allocation->height);
if (bar->priv->auto_center == TRUE)
{
@@ -273,7 +295,7 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
while(iter)
{
gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
- child_allocation.height = allocation->height - (border_width * 2);
+ child_allocation.height = allocation->height - (border_width * 2) - (film_border_width * 2);
child_allocation.width = child_allocation.height;
if ((child_allocation.x < (allocation->x + allocation->width)) &&
@@ -290,6 +312,7 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
}
break;
case GTK_ORIENTATION_VERTICAL:
+ child_allocation.x += film_border_width;
if (bar->priv->auto_center == TRUE)
{
bar->priv->offset = 0 - (allocation->height / 2);
@@ -297,7 +320,7 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
while(iter)
{
gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
- allocation->width = MAX(child_requisition.width + (border_width * 2), allocation->width);
+ allocation->width = MAX(child_requisition.width + (border_width * 2) + (film_border_width * 2), allocation->width);
if (bar->priv->auto_center == TRUE)
{
@@ -314,7 +337,7 @@ rstto_thumbnail_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
- child_allocation.width = allocation->width - (border_width * 2);
+ child_allocation.width = allocation->width - (border_width * 2) - (film_border_width * 2);
child_allocation.height = child_allocation.width;
if (child_allocation.y < (allocation->y + allocation->height))
@@ -340,6 +363,18 @@ rstto_thumbnail_bar_expose(GtkWidget *widget, GdkEventExpose *ex)
GdkEventExpose *n_ex = g_new0(GdkEventExpose, 1);
gint border_width = GTK_CONTAINER(bar)->border_width;
+ gint film_border_width = bar->film_border_width;
+ gint i = 0;
+ GdkColor color, dot_color, bar_color;
+ color.red= 0;
+ color.green= 0;
+ color.blue= 0;
+ dot_color.red = 0xffff;
+ dot_color.green = 0xffff;
+ dot_color.blue = 0xffff;
+ bar_color.red = 0x4444;
+ bar_color.green = 0x4444;
+ bar_color.blue = 0x4444;
n_ex->type = ex->type;
n_ex->window = ex->window;
@@ -350,6 +385,50 @@ rstto_thumbnail_bar_expose(GtkWidget *widget, GdkEventExpose *ex)
n_ex->area.height = ex->area.height;
n_ex->count = ex->count;
+ GdkGC *gc = gdk_gc_new(GDK_DRAWABLE(widget->window));
+ gdk_colormap_alloc_color (gdk_gc_get_colormap (gc), &color, FALSE, TRUE);
+ gdk_colormap_alloc_color (gdk_gc_get_colormap (gc), &dot_color, FALSE, TRUE);
+ gdk_colormap_alloc_color (gdk_gc_get_colormap (gc), &bar_color, FALSE, TRUE);
+ gdk_gc_set_rgb_fg_color (gc, &color);
+
+ switch (bar->priv->orientation)
+ {
+ case GTK_ORIENTATION_HORIZONTAL:
+ n_ex->area.y += film_border_width;
+
+ gdk_draw_rectangle(GDK_DRAWABLE(widget->window), gc, TRUE, 0, 0, widget->allocation.width, film_border_width);
+ gdk_draw_rectangle(GDK_DRAWABLE(widget->window), gc, TRUE, 0, widget->allocation.height - film_border_width, widget->allocation.width, film_border_width);
+ gdk_gc_set_rgb_fg_color (gc, &dot_color);
+ for (; i < widget->allocation.width; i+=film_border_width)
+ {
+ gdk_draw_rectangle (GDK_DRAWABLE (widget->window), gc, TRUE, 2+i, 2, (gint)((gdouble)film_border_width / 2.0), (gint)((gdouble)film_border_width / 2.0));
+ gdk_draw_rectangle (GDK_DRAWABLE (widget->window), gc, TRUE, 2+i,
+ widget->allocation.height - (gint)((gdouble)film_border_width / 4.0 * 3.0),
+ film_border_width/2, film_border_width/2);
+ }
+ gdk_gc_set_rgb_fg_color (gc, &bar_color);
+ gdk_draw_rectangle(GDK_DRAWABLE(widget->window), gc, TRUE, 0, film_border_width, widget->allocation.width, widget->allocation.height - film_border_width * 2);
+ break;
+
+ case GTK_ORIENTATION_VERTICAL:
+
+ n_ex->area.x += film_border_width;
+ gdk_draw_rectangle(GDK_DRAWABLE(widget->window), gc, TRUE, 0, 0, film_border_width, widget->allocation.height);
+ gdk_draw_rectangle(GDK_DRAWABLE(widget->window), gc, TRUE, widget->allocation.width - film_border_width, 0, film_border_width, widget->allocation.height);
+ gdk_gc_set_rgb_fg_color (gc, &dot_color);
+ for (; i < widget->allocation.height; i+=film_border_width)
+ {
+ gdk_draw_rectangle (GDK_DRAWABLE (widget->window), gc, TRUE, 2, 2+i, film_border_width / 2, film_border_width / 2);
+ gdk_draw_rectangle (GDK_DRAWABLE (widget->window), gc, TRUE,
+ widget->allocation.width - (gint)((gdouble)film_border_width / 4.0 * 3.0),
+ 2+i,
+ film_border_width/2, film_border_width/2);
+ }
+ gdk_gc_set_rgb_fg_color (gc, &bar_color);
+ gdk_draw_rectangle(GDK_DRAWABLE(widget->window), gc, TRUE, film_border_width, 0, widget->allocation.width - film_border_width * 2, widget->allocation.height);
+ break;
+ }
+
while(iter)
{
@@ -661,6 +740,9 @@ cb_rstto_thumbnail_bar_thumbnail_motion_notify_event (GtkWidget *thumb,
{
bar->priv->offset = bar->priv->motion.offset + (bar->priv->motion.current_y - y);
}
+ bar->priv->motion.offset = bar->priv->offset;
+ bar->priv->motion.current_x = x;
+ bar->priv->motion.current_y = y;
gtk_widget_queue_resize(GTK_WIDGET(bar));
}
return FALSE;
@@ -766,6 +848,7 @@ cb_rstto_thumbnail_bar_image_list_iter_changed (RsttoImageListIter *iter, gpoint
RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR (user_data);
bar->priv->thumbs = g_list_sort_with_data (bar->priv->thumbs, (GCompareDataFunc)cb_rstto_thumbnail_bar_compare, bar);
+ bar->priv->auto_center = TRUE;
gtk_widget_queue_resize(GTK_WIDGET(bar));
/* useless, but keepsthe compiler silent */
diff --git a/src/thumbnail_bar.h b/src/thumbnail_bar.h
index e5cb3cb..11e847b 100644
--- a/src/thumbnail_bar.h
+++ b/src/thumbnail_bar.h
@@ -47,6 +47,7 @@ struct _RsttoThumbnailBar
{
GtkContainer parent;
RsttoThumbnailBarPriv *priv;
+ gint film_border_width;
};
typedef struct _RsttoThumbnailBarClass RsttoThumbnailBarClass;
More information about the Xfce4-commits
mailing list