Mercurial > geeqie.yaz
changeset 852:8308d3606991
show marks in iconview
author | nadvornik |
---|---|
date | Sun, 22 Jun 2008 20:01:20 +0000 |
parents | 6e521e987105 |
children | b54e3fc9cafb |
files | src/cellrenderericon.c src/cellrenderericon.h src/view_file.c src/view_file_icon.c src/view_file_icon.h src/view_file_list.c |
diffstat | 6 files changed, 110 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/cellrenderericon.c Sun Jun 22 10:01:26 2008 +0000 +++ b/src/cellrenderericon.c Sun Jun 22 20:01:20 2008 +0000 @@ -26,6 +26,10 @@ #define FIXED_ICON_SIZE_MAX 512 +#define TOGGLE_WIDTH 13 +#define TOGGLE_SPACING 18 + + static void gqv_cell_renderer_icon_get_property(GObject *object, guint param_id, GValue *value, @@ -65,7 +69,10 @@ PROP_BACKGROUND_SET, PROP_FOREGROUND_SET, - PROP_SHOW_TEXT + PROP_SHOW_TEXT, + PROP_SHOW_MARKS, + PROP_NUM_MARKS, + PROP_MARKS }; static gpointer parent_class; @@ -203,6 +210,32 @@ _("Whether the text is displayed"), TRUE, G_PARAM_READWRITE)); + + g_object_class_install_property(object_class, + PROP_SHOW_MARKS, + g_param_spec_boolean("show_marks", + _("Show marks"), + _("Whether the marks are displayed"), + TRUE, + G_PARAM_READWRITE)); + + g_object_class_install_property(object_class, + PROP_NUM_MARKS, + g_param_spec_int("num_marks", + _("Number of marks"), + _("Number of marks"), + 0, 32, + 6, + G_PARAM_READWRITE)); + + g_object_class_install_property(object_class, + PROP_MARKS, + g_param_spec_uint("marks", + _("Marks"), + _("Marks bit array"), + 0, 0xffffffff, + 0, + G_PARAM_READWRITE)); } static void @@ -273,6 +306,15 @@ case PROP_SHOW_TEXT: g_value_set_boolean(value, cellicon->show_text); break; + case PROP_SHOW_MARKS: + g_value_set_boolean(value, cellicon->show_marks); + break; + case PROP_NUM_MARKS: + g_value_set_int(value, cellicon->num_marks); + break; + case PROP_MARKS: + g_value_set_uint(value, cellicon->marks); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); break; @@ -385,6 +427,15 @@ case PROP_SHOW_TEXT: cellicon->show_text = g_value_get_boolean(value); break; + case PROP_SHOW_MARKS: + cellicon->show_marks = g_value_get_boolean(value); + break; + case PROP_NUM_MARKS: + cellicon->num_marks = g_value_get_int(value); + break; + case PROP_MARKS: + cellicon->marks = g_value_get_uint(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); break; @@ -494,6 +545,12 @@ calc_height += rect.height; } + if (cellicon->show_marks) + { + calc_height += TOGGLE_SPACING; + calc_width = MAX(calc_width, TOGGLE_SPACING * cellicon->num_marks); + } + calc_width += (gint)cell->xpad * 2; calc_height += (gint)cell->ypad * 2; @@ -614,6 +671,11 @@ pix_rect.height = text_rect.height; pix_rect.x = cell_area->x + cell->xpad + (cell_rect.width - text_rect.width + 1) / 2; pix_rect.y = cell_area->y + cell->ypad + (cell_rect.height - text_rect.height); + + if (cellicon->show_marks) + { + pix_rect.y -= TOGGLE_SPACING; + } if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) && gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect)) @@ -629,6 +691,28 @@ g_object_unref(layout); } + if (cellicon->show_marks) + { + GdkRectangle pix_rect; + GdkRectangle draw_rect; + gint i; + + pix_rect.width = TOGGLE_SPACING * cellicon->num_marks; + pix_rect.height = TOGGLE_SPACING; + pix_rect.x = cell_area->x + cell->xpad + (cell_rect.width - pix_rect.width + 1) / 2 + (TOGGLE_SPACING - TOGGLE_WIDTH) / 2; + pix_rect.y = cell_area->y + cell->ypad + (cell_rect.height - pix_rect.height) + (TOGGLE_SPACING - TOGGLE_WIDTH) / 2; + + for (i = 0; i < cellicon->num_marks; i++) + { + gtk_paint_check (widget->style, window, + state, (cellicon->marks & (1 << i)) ? GTK_SHADOW_IN : GTK_SHADOW_OUT, + cell_area, widget, "cellcheck", + pix_rect.x + i * TOGGLE_SPACING + (TOGGLE_WIDTH - TOGGLE_SPACING) / 2, + pix_rect.y, + TOGGLE_WIDTH, TOGGLE_WIDTH); + } + } + if (cellicon->focused && GTK_WIDGET_HAS_FOCUS(widget)) { gtk_paint_focus(widget->style, window,
--- a/src/cellrenderericon.h Sun Jun 22 10:01:26 2008 +0000 +++ b/src/cellrenderericon.h Sun Jun 22 20:01:20 2008 +0000 @@ -56,7 +56,13 @@ gboolean foreground_set; gboolean background_set; + gint num_marks; + gboolean show_text; + gboolean show_marks; + + guint marks; + }; struct _GQvCellRendererIconClass
--- a/src/view_file.c Sun Jun 22 10:01:26 2008 +0000 +++ b/src/view_file.c Sun Jun 22 20:01:20 2008 +0000 @@ -732,10 +732,14 @@ void vf_marks_set(ViewFile *vf, gint enable) { + if (vf->marks_enabled == enable) return; + + vf->marks_enabled = enable; + switch(vf->type) { case FILEVIEW_LIST: vflist_marks_set(vf, enable); break; - case FILEVIEW_ICON: /*vficon_marks_set(vf, enable);*/ break; + case FILEVIEW_ICON: vficon_marks_set(vf, enable); break; } }
--- a/src/view_file_icon.c Sun Jun 22 10:01:26 2008 +0000 +++ b/src/view_file_icon.c Sun Jun 22 20:01:20 2008 +0000 @@ -617,6 +617,11 @@ vficon_selection_set(vf, id, id->selected & ~mask, iter); } +void vficon_marks_set(ViewFile *vf, gint enable) +{ + vficon_populate_at_new_size(vf, vf->listview->allocation.width, vf->listview->allocation.height, TRUE); +} + /* *------------------------------------------------------------------- * selections @@ -1572,7 +1577,10 @@ { g_object_set(G_OBJECT(cell), "fixed_width", thumb_width, "fixed_height", options->thumbnails.max_height, - "show_text", VFICON_INFO(vf, show_text), NULL); + "show_text", VFICON_INFO(vf, show_text), + "show_marks", vf->marks_enabled, + "num_marks", FILEDATA_MARKS_SIZE, + NULL); } } if (GTK_WIDGET_REALIZED(vf->listview)) gtk_tree_view_columns_autosize(GTK_TREE_VIEW(vf->listview)); @@ -2274,6 +2282,8 @@ g_object_set(cell, "pixbuf", id->fd->thumb_pixbuf, "text", name_sidecars, + "marks", id->fd->marks, + "show_marks", vf->marks_enabled, "cell-background-gdk", &color_bg, "cell-background-set", TRUE, "foreground-gdk", &color_fg, @@ -2289,6 +2299,7 @@ { g_object_set(cell, "pixbuf", NULL, "text", NULL, + "show_marks", FALSE, "cell-background-set", FALSE, "foreground-set", FALSE, "has-focus", FALSE, NULL);
--- a/src/view_file_icon.h Sun Jun 22 10:01:26 2008 +0000 +++ b/src/view_file_icon.h Sun Jun 22 20:01:20 2008 +0000 @@ -27,6 +27,8 @@ void vficon_sort_set(ViewFile *vf, SortType type, gint ascend); +void vficon_marks_set(ViewFile *vf, gint enable); + GList *vficon_pop_menu_file_list(ViewFile *vf); void vficon_pop_menu_view_cb(GtkWidget *widget, gpointer data); void vficon_pop_menu_rename_cb(GtkWidget *widget, gpointer data);
--- a/src/view_file_list.c Sun Jun 22 10:01:26 2008 +0000 +++ b/src/view_file_list.c Sun Jun 22 20:01:20 2008 +0000 @@ -1977,10 +1977,6 @@ { GList *columns, *work; - if (vf->marks_enabled == enable) return; - - vf->marks_enabled = enable; - columns = gtk_tree_view_get_columns(GTK_TREE_VIEW(vf->listview)); work = columns;