changeset 1621:7d631a8de48e

Minor code cleanup and redundancy reduction.
author zas_
date Mon, 01 Jun 2009 16:37:30 +0000
parents 19c7c73d9fc4
children 9e6cdef3bc3d
files src/view_file_icon.c
diffstat 1 files changed, 59 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/src/view_file_icon.c	Sun May 31 14:32:39 2009 +0000
+++ b/src/view_file_icon.c	Mon Jun 01 16:37:30 2009 +0000
@@ -2198,82 +2198,74 @@
 static void vficon_cell_data_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
 				GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
 {
+	GList *list;
+	IconData *id;
 	ColumnData *cd = data;
-	ViewFile *vf;
-	GtkStyle *style;
-	GList *list;
-	GdkColor color_fg;
-	GdkColor color_bg;
-	IconData *id;
-
-	vf = cd->vf;
+	ViewFile *vf = cd->vf;
+
+	if (!GQV_IS_CELL_RENDERER_ICON(cell)) return;
 
 	gtk_tree_model_get(tree_model, iter, FILE_COLUMN_POINTER, &list, -1);
 
 	id = g_list_nth_data(list, cd->number);
-
-	if (id) g_assert(id->fd->magick == 0x12345678);
-
-	style = gtk_widget_get_style(vf->listview);
-	if (id && id->selected & SELECTION_SELECTED)
+	
+	if (id)
 		{
-		memcpy(&color_fg, &style->text[GTK_STATE_SELECTED], sizeof(color_fg));
-		memcpy(&color_bg, &style->base[GTK_STATE_SELECTED], sizeof(color_bg));
+		GdkColor color_fg;
+		GdkColor color_bg;
+		GtkStyle *style;
+		gchar *name_sidecars;
+		gchar *link;
+		GtkStateType state = GTK_STATE_NORMAL;
+
+		g_assert(id->fd->magick == 0x12345678);
+
+		link = islink(id->fd->path) ? GQ_LINK_STR : "";
+		if (id->fd->sidecar_files)
+			{
+			gchar *sidecars = file_data_sc_list_to_string(id->fd);
+			name_sidecars = g_strdup_printf("%s%s %s", link, id->fd->name, sidecars);
+			g_free(sidecars);
+			}
+		else
+			{
+			gchar *disabled_grouping = id->fd->disable_grouping ? _(" [NO GROUPING]") : "";
+			name_sidecars = g_strdup_printf("%s%s%s", link, id->fd->name, disabled_grouping);
+			}
+		
+		style = gtk_widget_get_style(vf->listview);
+		if (id->selected & SELECTION_SELECTED)
+			{
+			state = GTK_STATE_SELECTED;
+			}
+		
+		memcpy(&color_fg, &style->text[state], sizeof(color_fg));
+		memcpy(&color_bg, &style->base[state], sizeof(color_bg));
+
+		if (id->selected & SELECTION_PRELIGHT)
+			{
+			shift_color(&color_bg, -1, 0);
+			}
+		
+		g_object_set(cell,	"pixbuf", id->fd->thumb_pixbuf,
+					"text", name_sidecars,
+					"marks", file_data_get_marks(id->fd),
+					"show_marks", vf->marks_enabled,
+					"cell-background-gdk", &color_bg,
+					"cell-background-set", TRUE,
+					"foreground-gdk", &color_fg,
+					"foreground-set", TRUE,
+					"has-focus", (VFICON(vf)->focus_id == id), NULL);
+		g_free(name_sidecars);
 		}
 	else
 		{
-		memcpy(&color_fg, &style->text[GTK_STATE_NORMAL], sizeof(color_fg));
-		memcpy(&color_bg, &style->base[GTK_STATE_NORMAL], sizeof(color_bg));
-		}
-
-	if (id && id->selected & SELECTION_PRELIGHT)
-		{
-#if 0
-		shift_color(&color_fg, -1, 0);
-#endif
-		shift_color(&color_bg, -1, 0);
-		}
-
-	if (GQV_IS_CELL_RENDERER_ICON(cell))
-		{
-		if (id)
-			{
-			gchar *name_sidecars;
-			gchar *sidecars = NULL;
-			gchar *link = islink(id->fd->path) ? GQ_LINK_STR : "";
-
-			if (id->fd->sidecar_files)
-				{
-				sidecars = file_data_sc_list_to_string(id->fd);
-				name_sidecars = g_strdup_printf("%s%s %s", link, id->fd->name, sidecars);
-				}
-			else
-				{
-				gchar *disabled_grouping = id->fd->disable_grouping ? _(" [NO GROUPING]") : "";
-				name_sidecars = g_strdup_printf("%s%s%s", link, id->fd->name, disabled_grouping);
-				}
-
-			g_object_set(cell,	"pixbuf", id->fd->thumb_pixbuf,
-						"text", name_sidecars,
-						"marks", file_data_get_marks(id->fd),
-						"show_marks", vf->marks_enabled,
-						"cell-background-gdk", &color_bg,
-						"cell-background-set", TRUE,
-						"foreground-gdk", &color_fg,
-						"foreground-set", TRUE,
-						"has-focus", (VFICON(vf)->focus_id == id), NULL);
-			g_free(sidecars);
-			g_free(name_sidecars);
-			}
-		else
-			{
-			g_object_set(cell,	"pixbuf", NULL,
-						"text", NULL,
-						"show_marks", FALSE,
-						"cell-background-set", FALSE,
-						"foreground-set", FALSE,
-						"has-focus", FALSE, NULL);
-			}
+		g_object_set(cell,	"pixbuf", NULL,
+					"text", NULL,
+					"show_marks", FALSE,
+					"cell-background-set", FALSE,
+					"foreground-set", FALSE,
+					"has-focus", FALSE, NULL);
 		}
 }