[Xfce4-commits] <ristretto:stephan/icon-bar> Replace text-column with file-column
Stephan Arts
noreply at xfce.org
Sun Feb 5 11:04:03 CET 2012
Updating branch refs/heads/stephan/icon-bar
to a05f89d523b765e688ac955e79e1ec65df70d53a (commit)
from 1127e89f339a2e5722c97b85a7084574b400c1a8 (commit)
commit a05f89d523b765e688ac955e79e1ec65df70d53a
Author: Stephan Arts <stephan at xfce.org>
Date: Sat Feb 4 13:07:56 2012 +0100
Replace text-column with file-column
src/icon_bar.c | 223 +++++++++++------------------------------------------
src/icon_bar.h | 4 +-
src/image_list.c | 10 +--
src/main_window.c | 2 +-
4 files changed, 53 insertions(+), 186 deletions(-)
diff --git a/src/icon_bar.c b/src/icon_bar.c
index 341f4b8..f557d2b 100644
--- a/src/icon_bar.c
+++ b/src/icon_bar.c
@@ -29,6 +29,10 @@
#include <libxfce4util/libxfce4util.h>
+#include <libexif/exif-data.h>
+
+#include "util.h"
+#include "file.h"
#include "marshal.h"
#include "icon_bar.h"
@@ -70,7 +74,7 @@
* // create the icon bar
* bar = rstto_icon_bar_new_with_model (GTK_TREE_MODEL (store));
* rstto_icon_bar_set_pixbuf_column (RSTTO_ICON_BAR (bar), PIXBUF_COLUMN);
- * rstto_icon_bar_set_text_column (RSTTO_ICON_BAR (bar), TEXT_COLUMN);
+ * rstto_icon_bar_set_file_column (RSTTO_ICON_BAR (bar), FILE_COLUMN);
* gtk_widget_show (bar);
*
* // the icon bar keeps a reference on the store now
@@ -91,7 +95,7 @@
#define RSTTO_ICON_BAR_VALID_MODEL_AND_COLUMNS(obj) ((obj)->priv->model != NULL && \
(obj)->priv->pixbuf_column != -1 && \
- (obj)->priv->text_column != -1)
+ (obj)->priv->file_column != -1)
@@ -102,7 +106,7 @@ enum
PROP_0,
PROP_ORIENTATION,
PROP_PIXBUF_COLUMN,
- PROP_TEXT_COLUMN,
+ PROP_FILE_COLUMN,
PROP_MODEL,
PROP_ACTIVE,
PROP_SHOW_TEXT,
@@ -222,11 +226,6 @@ rstto_icon_bar_calculate_item_size (
RsttoIconBar *icon_bar,
RsttoIconBarItem *item);
-static void
-rstto_icon_bar_update_item_text (
- RsttoIconBar *icon_bar,
- RsttoIconBarItem *item);
-
static GdkPixbuf *
rstto_icon_bar_get_item_icon (
RsttoIconBar *icon_bar,
@@ -305,7 +304,7 @@ struct _RsttoIconBarPrivate
gint height;
gint pixbuf_column;
- gint text_column;
+ gint file_column;
RsttoIconBarItem *active_item;
RsttoIconBarItem *single_click_item;
@@ -401,18 +400,18 @@ rstto_icon_bar_class_init (RsttoIconBarClass *klass)
G_PARAM_READWRITE));
/**
- * RsttoIconBar:text-column:
+ * RsttoIconBar:file-column:
*
- * The ::text-column property contains the number of the model column
- * containing the texts which are displayed. The text column must be
- * of type #G_TYPE_STRING. If this property is set to -1, no texts
- * are displayed.
+ * The ::file-column property contains the number of the model column
+ * containing the files which are displayed. The text column must be
+ * of type #RSTTO_TYPE_FILE. If this property is set to -1, no
+ * details are displayed.
**/
g_object_class_install_property (gobject_class,
- PROP_TEXT_COLUMN,
- g_param_spec_int ("text-column",
- _("Text column"),
- _("Model column used to retrieve the text from"),
+ PROP_FILE_COLUMN,
+ g_param_spec_int ("file-column",
+ _("File column"),
+ _("Model column used to retrieve the file from"),
-1, G_MAXINT, -1,
G_PARAM_READWRITE));
@@ -550,7 +549,7 @@ rstto_icon_bar_init (RsttoIconBar *icon_bar)
icon_bar->priv->orientation = GTK_ORIENTATION_VERTICAL;
icon_bar->priv->pixbuf_column = -1;
- icon_bar->priv->text_column = -1;
+ icon_bar->priv->file_column = -1;
icon_bar->priv->show_text = TRUE;
icon_bar->priv->auto_center = TRUE;
@@ -611,8 +610,8 @@ rstto_icon_bar_get_property (
g_value_set_int (value, icon_bar->priv->pixbuf_column);
break;
- case PROP_TEXT_COLUMN:
- g_value_set_int (value, icon_bar->priv->text_column);
+ case PROP_FILE_COLUMN:
+ g_value_set_int (value, icon_bar->priv->file_column);
break;
case PROP_MODEL:
@@ -654,8 +653,8 @@ rstto_icon_bar_set_property (
rstto_icon_bar_set_pixbuf_column (icon_bar, g_value_get_int (value));
break;
- case PROP_TEXT_COLUMN:
- rstto_icon_bar_set_text_column (icon_bar, g_value_get_int (value));
+ case PROP_FILE_COLUMN:
+ rstto_icon_bar_set_file_column (icon_bar, g_value_get_int (value));
break;
case PROP_MODEL:
@@ -964,7 +963,7 @@ rstto_icon_bar_motion (
RsttoIconBar *icon_bar = RSTTO_ICON_BAR (widget);
GtkTreePath *path;
GtkTreeIter iter;
- gchar *text;
+ RsttoFile *file;
item = rstto_icon_bar_get_item_at_pos (icon_bar, event->x, event->y);
if (item != NULL && icon_bar->priv->cursor_item != item)
@@ -976,15 +975,9 @@ rstto_icon_bar_motion (
iter = item->iter;
gtk_tree_model_get (icon_bar->priv->model, &iter,
- icon_bar->priv->text_column, &text,
+ icon_bar->priv->file_column, &file,
-1);
- gtk_widget_set_tooltip_text (widget, text);
-
- if (text)
- {
- g_free (text);
- }
gtk_widget_trigger_tooltip_query (widget);
}
else if (icon_bar->priv->cursor_item != NULL
@@ -1236,7 +1229,6 @@ rstto_icon_bar_paint_item (
gint focus_pad;
gint x, y;
gint px, py;
- gint lx, ly;
if (!RSTTO_ICON_BAR_VALID_MODEL_AND_COLUMNS (icon_bar))
return;
@@ -1253,18 +1245,7 @@ rstto_icon_bar_paint_item (
y = icon_bar->priv->item_height * item->index;
px = (icon_bar->priv->item_width - item->pixbuf_width) / 2;
- if (icon_bar->priv->text_column != -1 && icon_bar->priv->show_text == TRUE)
- {
- py = (icon_bar->priv->item_height - (item->pixbuf_height + item->layout_height + ICON_TEXT_PADDING)) / 2
- + icon_bar->priv->item_height * item->index;
- }
- else
- {
- py = (icon_bar->priv->item_height - (item->pixbuf_height)) / 2
- + icon_bar->priv->item_height * item->index;
- }
- lx = (icon_bar->priv->item_width - (item->layout_width + ICON_TEXT_PADDING)) / 2 + focus_pad;
- ly = py + item->pixbuf_height + ICON_TEXT_PADDING;
+ py = (icon_bar->priv->item_height - (item->pixbuf_height)) / 2 + icon_bar->priv->item_height * item->index;
}
else
{
@@ -1272,16 +1253,7 @@ rstto_icon_bar_paint_item (
y = 0;
px = (icon_bar->priv->item_width - item->pixbuf_width) / 2 + icon_bar->priv->item_width * item->index;
- if (icon_bar->priv->text_column != -1 && icon_bar->priv->show_text == TRUE)
- {
- py = (icon_bar->priv->item_height - (item->pixbuf_height + item->layout_height)) / 2;
- }
- else
- {
- py = (icon_bar->priv->item_height - (item->pixbuf_height)) / 2;
- }
- lx = (icon_bar->priv->item_width - (item->layout_width)) / 2 + x;
- ly = py + item->pixbuf_height + ICON_TEXT_PADDING;
+ py = (icon_bar->priv->item_height - (item->pixbuf_height)) / 2;
}
if (icon_bar->priv->active_item == item)
@@ -1373,60 +1345,6 @@ rstto_icon_bar_paint_item (
g_object_unref (pixbuf);
}
}
-
- if (icon_bar->priv->text_column != -1 && icon_bar->priv->show_text == TRUE)
- {
- rstto_icon_bar_update_item_text (icon_bar, item);
-
- if (icon_bar->priv->active_item == item)
- {
- gtk_widget_style_get (GTK_WIDGET (icon_bar),
- "active-item-text-color", &text_color,
- NULL);
-
- if (text_color == NULL)
- {
- text_color = gdk_color_copy (>K_WIDGET (icon_bar)->style->base[GTK_STATE_SELECTED]);
- gdk_color_parse ("#000000", text_color);
- }
-
- gc = gdk_gc_new (GDK_DRAWABLE (icon_bar->priv->bin_window));
- gdk_gc_copy (gc, GTK_WIDGET (icon_bar)->style->text_gc[GTK_STATE_SELECTED]);
- gdk_gc_set_clip_rectangle (gc, area);
- gdk_gc_set_rgb_fg_color (gc, text_color);
- gdk_draw_layout (icon_bar->priv->bin_window, gc, lx, ly, icon_bar->priv->layout);
- g_object_unref (G_OBJECT (gc));
- gdk_color_free (text_color);
- }
- else if (icon_bar->priv->cursor_item == item)
- {
- gtk_widget_style_get (GTK_WIDGET (icon_bar),
- "cursor-item-text-color", &text_color,
- NULL);
-
- if (text_color == NULL)
- {
- text_color = gdk_color_copy (>K_WIDGET (icon_bar)->style->base[GTK_STATE_SELECTED]);
- gdk_color_parse ("#000000", text_color);
- }
-
- gc = gdk_gc_new (GDK_DRAWABLE (icon_bar->priv->bin_window));
- gdk_gc_copy (gc, GTK_WIDGET (icon_bar)->style->text_gc[GTK_STATE_SELECTED]);
- gdk_gc_set_clip_rectangle (gc, area);
- gdk_gc_set_rgb_fg_color (gc, text_color);
- gdk_draw_layout (icon_bar->priv->bin_window, gc, lx, ly, icon_bar->priv->layout);
- g_object_unref (G_OBJECT (gc));
- gdk_color_free (text_color);
- }
- else
- {
- gtk_paint_layout (GTK_WIDGET (icon_bar)->style,
- icon_bar->priv->bin_window,
- GTK_STATE_NORMAL, TRUE, area,
- GTK_WIDGET (icon_bar), "icon_bar",
- lx, ly, icon_bar->priv->layout);
- }
- }
}
@@ -1471,26 +1389,8 @@ rstto_icon_bar_calculate_item_size (
item->pixbuf_height = 0;
}
- if (icon_bar->priv->text_column != -1 && icon_bar->priv->show_text == TRUE)
- {
- rstto_icon_bar_update_item_text (icon_bar, item);
- pango_layout_get_pixel_size (icon_bar->priv->layout,
- &item->layout_width,
- &item->layout_height);
- item->width = MAX (item->layout_width, item->pixbuf_width) + 2 * ICON_TEXT_PADDING
- + 2 * (int_pad + focus_width + focus_pad);
- item->height = item->layout_height + 2 * (int_pad + focus_width + focus_pad + ICON_TEXT_PADDING)
- + item->pixbuf_height;
- }
- else
- {
- item->layout_width = 0;
- item->layout_height = 0;
-
- item->width = MAX (item->layout_width, item->pixbuf_width) + 2 *
- (int_pad + focus_width + focus_pad);
- item->height = item->layout_height + 2 * (int_pad + focus_width + focus_pad ) + item->pixbuf_height;
- }
+ item->width = item->pixbuf_width + 2 * (int_pad + focus_width + focus_pad);
+ item->height = item->pixbuf_height + 2 * (int_pad + focus_width + focus_pad );
if (item->width < item->height)
@@ -1500,37 +1400,6 @@ rstto_icon_bar_calculate_item_size (
}
-
-
-static void
-rstto_icon_bar_update_item_text (
- RsttoIconBar *icon_bar,
- RsttoIconBarItem *item)
-{
- GtkTreePath *path;
- GtkTreeIter iter;
- gchar *text;
-
- if ((gtk_tree_model_get_flags (icon_bar->priv->model) & GTK_TREE_MODEL_ITERS_PERSIST) == 0)
- {
- path = gtk_tree_path_new_from_indices (item->index, -1);
- gtk_tree_model_get_iter (icon_bar->priv->model, &iter, path);
- gtk_tree_path_free (path);
- }
- else
- {
- iter = item->iter;
- }
-
- gtk_tree_model_get (icon_bar->priv->model, &iter,
- icon_bar->priv->text_column, &text,
- -1);
- pango_layout_set_text (icon_bar->priv->layout, text, -1);
- g_free (text);
-}
-
-
-
static GdkPixbuf *
rstto_icon_bar_get_item_icon (
RsttoIconBar *icon_bar,
@@ -1827,7 +1696,7 @@ rstto_icon_bar_set_model (
GtkTreeModel *model)
{
GType pixbuf_column_type;
- GType text_column_type;
+ GType file_column_type;
gint active = -1;
g_return_if_fail (RSTTO_IS_ICON_BAR (icon_bar));
@@ -1846,10 +1715,10 @@ rstto_icon_bar_set_model (
g_return_if_fail (pixbuf_column_type == GDK_TYPE_PIXBUF);
}
- if (icon_bar->priv->text_column != -1)
+ if (icon_bar->priv->file_column != -1)
{
- text_column_type = gtk_tree_model_get_column_type (model, icon_bar->priv->text_column);
- g_return_if_fail (text_column_type == G_TYPE_STRING);
+ file_column_type = gtk_tree_model_get_column_type (model, icon_bar->priv->file_column);
+ g_return_if_fail (file_column_type == RSTTO_TYPE_FILE);
}
}
@@ -1967,24 +1836,24 @@ rstto_icon_bar_set_pixbuf_column (
/**
- * rstto_icon_bar_get_text_column:
+ * rstto_icon_bar_get_file_column:
* @icon_bar : An #RsttoIconBar.
*
- * Returns the column with text for @icon_bar.
+ * Returns the column with file for @icon_bar.
*
- * Returns: the text column, or -1 if it's unset.
+ * Returns: the file column, or -1 if it's unset.
**/
gint
-rstto_icon_bar_get_text_column (RsttoIconBar *icon_bar)
+rstto_icon_bar_get_file_column (RsttoIconBar *icon_bar)
{
g_return_val_if_fail (RSTTO_IS_ICON_BAR (icon_bar), -1);
- return icon_bar->priv->text_column;
+ return icon_bar->priv->file_column;
}
/**
- * rstto_icon_bar_set_text_column:
+ * rstto_icon_bar_set_file_column:
* @icon_bar : An #RsttoIconBar.
* @column : A column in the currently used model or -1 to
* use no text in @icon_bar.
@@ -1993,35 +1862,35 @@ rstto_icon_bar_get_text_column (RsttoIconBar *icon_bar)
* text column must be of type #G_TYPE_STRING.
**/
void
-rstto_icon_bar_set_text_column (
+rstto_icon_bar_set_file_column (
RsttoIconBar *icon_bar,
gint column)
{
- GType text_column_type;
+ GType file_column_type;
g_return_if_fail (RSTTO_IS_ICON_BAR (icon_bar));
- if (column == icon_bar->priv->text_column)
+ if (column == icon_bar->priv->file_column)
return;
if (column == -1)
{
- icon_bar->priv->text_column = -1;
+ icon_bar->priv->file_column = -1;
}
else
{
if (icon_bar->priv->model != NULL)
{
- text_column_type = gtk_tree_model_get_column_type (icon_bar->priv->model, column);
- g_return_if_fail (text_column_type == G_TYPE_STRING);
+ file_column_type = gtk_tree_model_get_column_type (icon_bar->priv->model, column);
+ g_return_if_fail (file_column_type == RSTTO_TYPE_FILE);
}
- icon_bar->priv->text_column = column;
+ icon_bar->priv->file_column = column;
}
rstto_icon_bar_invalidate (icon_bar);
- g_object_notify (G_OBJECT (icon_bar), "text-column");
+ g_object_notify (G_OBJECT (icon_bar), "file-column");
}
diff --git a/src/icon_bar.h b/src/icon_bar.h
index 6b9747c..aed7118 100644
--- a/src/icon_bar.h
+++ b/src/icon_bar.h
@@ -87,8 +87,8 @@ gint rstto_icon_bar_get_pixbuf_column (RsttoIconBar *icon_bar);
void rstto_icon_bar_set_pixbuf_column (RsttoIconBar *icon_bar,
gint column);
-gint rstto_icon_bar_get_text_column (RsttoIconBar *icon_bar);
-void rstto_icon_bar_set_text_column (RsttoIconBar *icon_bar,
+gint rstto_icon_bar_get_file_column (RsttoIconBar *icon_bar);
+void rstto_icon_bar_set_file_column (RsttoIconBar *icon_bar,
gint column);
GtkOrientation rstto_icon_bar_get_orientation (RsttoIconBar *icon_bar);
diff --git a/src/image_list.c b/src/image_list.c
index 2bacee0..f451aa2 100644
--- a/src/image_list.c
+++ b/src/image_list.c
@@ -582,8 +582,6 @@ rstto_image_list_remove_all (RsttoImageList *image_list)
image_iter = g_list_next (image_iter);
}
-
-
g_list_foreach (image_list->priv->images, (GFunc)g_object_unref, NULL);
g_list_free (image_list->priv->images);
image_list->priv->images = NULL;
@@ -1304,8 +1302,8 @@ image_list_model_get_column_type (
switch (index_)
{
- case 0: /* filename */
- return G_TYPE_STRING;
+ case 0: /* file */
+ return RSTTO_TYPE_FILE;
case 1:
return GDK_TYPE_PIXBUF;
break;
@@ -1491,8 +1489,8 @@ image_list_model_get_value (
switch (column)
{
case 0:
- g_value_init (value, G_TYPE_STRING);
- g_value_set_string (value, rstto_file_get_display_name (file));
+ g_value_init (value, RSTTO_TYPE_FILE);
+ g_value_set_object (value, file);
break;
case 1:
uri = rstto_file_get_uri (file);
diff --git a/src/main_window.c b/src/main_window.c
index 06466c1..03d1bbc 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -654,7 +654,7 @@ rstto_main_window_init (RsttoMainWindow *window)
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (window->priv->t_bar_s_window), GTK_POLICY_ALWAYS, GTK_POLICY_NEVER);
gtk_container_add (GTK_CONTAINER (window->priv->t_bar_s_window), window->priv->thumbnailbar);
- rstto_icon_bar_set_text_column (RSTTO_ICON_BAR (window->priv->thumbnailbar), 0);
+ rstto_icon_bar_set_file_column (RSTTO_ICON_BAR (window->priv->thumbnailbar), 0);
rstto_icon_bar_set_pixbuf_column (RSTTO_ICON_BAR (window->priv->thumbnailbar), 1);
rstto_icon_bar_set_item_width (RSTTO_ICON_BAR (window->priv->thumbnailbar), 96);
More information about the Xfce4-commits
mailing list