Use constants for column indexes
This commit is contained in:
parent
a258ca7cdc
commit
50bae5b5cf
|
@ -38,6 +38,13 @@ typedef struct _BrowserPlugin
|
||||||
GtkWidget * status;
|
GtkWidget * status;
|
||||||
} Selection;
|
} Selection;
|
||||||
|
|
||||||
|
typedef enum _SelectionCount
|
||||||
|
{
|
||||||
|
SC_ICON = 0, SC_FILENAME, SC_FILENAME_DISPLAY
|
||||||
|
} SelectionCount;
|
||||||
|
#define SC_LAST SC_FILENAME_DISPLAY
|
||||||
|
#define SC_COUNT (SC_LAST + 1)
|
||||||
|
|
||||||
|
|
||||||
/* prototypes */
|
/* prototypes */
|
||||||
static Selection * _selection_init(BrowserPluginHelper * helper);
|
static Selection * _selection_init(BrowserPluginHelper * helper);
|
||||||
|
@ -81,19 +88,23 @@ static Selection * _selection_init(BrowserPluginHelper * helper)
|
||||||
widget = gtk_scrolled_window_new(NULL, NULL);
|
widget = gtk_scrolled_window_new(NULL, NULL);
|
||||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget),
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget),
|
||||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||||
selection->store = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING,
|
selection->store = gtk_list_store_new(SC_COUNT,
|
||||||
|
GDK_TYPE_PIXBUF,
|
||||||
|
G_TYPE_STRING,
|
||||||
G_TYPE_STRING);
|
G_TYPE_STRING);
|
||||||
selection->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
|
selection->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
|
||||||
selection->store));
|
selection->store));
|
||||||
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(selection->view),
|
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(selection->view),
|
||||||
FALSE);
|
FALSE);
|
||||||
|
/* column: icon */
|
||||||
renderer = gtk_cell_renderer_pixbuf_new();
|
renderer = gtk_cell_renderer_pixbuf_new();
|
||||||
column = gtk_tree_view_column_new_with_attributes(NULL, renderer,
|
column = gtk_tree_view_column_new_with_attributes(NULL, renderer,
|
||||||
"pixbuf", 0, NULL);
|
"pixbuf", SC_ICON, NULL);
|
||||||
gtk_tree_view_append_column(GTK_TREE_VIEW(selection->view), column);
|
gtk_tree_view_append_column(GTK_TREE_VIEW(selection->view), column);
|
||||||
|
/* column: filename */
|
||||||
renderer = gtk_cell_renderer_text_new();
|
renderer = gtk_cell_renderer_text_new();
|
||||||
column = gtk_tree_view_column_new_with_attributes(_("Filename"),
|
column = gtk_tree_view_column_new_with_attributes(_("Filename"),
|
||||||
renderer, "text", 2, NULL);
|
renderer, "text", SC_FILENAME_DISPLAY, NULL);
|
||||||
gtk_tree_view_append_column(GTK_TREE_VIEW(selection->view), column);
|
gtk_tree_view_append_column(GTK_TREE_VIEW(selection->view), column);
|
||||||
gtk_container_add(GTK_CONTAINER(widget), selection->view);
|
gtk_container_add(GTK_CONTAINER(widget), selection->view);
|
||||||
gtk_box_pack_start(GTK_BOX(selection->widget), widget, TRUE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(selection->widget), widget, TRUE, TRUE, 0);
|
||||||
|
@ -146,8 +157,9 @@ static void _selection_refresh(Selection * selection, GList * selected)
|
||||||
pst, 16);
|
pst, 16);
|
||||||
basename = g_path_get_basename(l->data);
|
basename = g_path_get_basename(l->data);
|
||||||
gtk_list_store_append(selection->store, &iter);
|
gtk_list_store_append(selection->store, &iter);
|
||||||
gtk_list_store_set(selection->store, &iter, 0, pixbuf,
|
gtk_list_store_set(selection->store, &iter, SC_ICON, pixbuf,
|
||||||
1, l->data, 2, basename, -1);
|
SC_FILENAME, l->data,
|
||||||
|
SC_FILENAME_DISPLAY, basename, -1);
|
||||||
g_free(basename);
|
g_free(basename);
|
||||||
if(plst != NULL)
|
if(plst != NULL)
|
||||||
size += lst.st_size;
|
size += lst.st_size;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user