static gboolean get_column_iter (NautilusColumnChooser *chooser, NautilusColumn *column, GtkTreeIter *iter) { char *column_name; g_object_get (NAUTILUS_COLUMN (column), "name", &column_name, NULL); if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (chooser->details->store), iter)) { do { char *name; gtk_tree_model_get (GTK_TREE_MODEL (chooser->details->store), iter, COLUMN_NAME, &name, -1); if (!strcmp (name, column_name)) { g_free (column_name); g_free (name); return TRUE; } g_free (name); } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (chooser->details->store), iter)); } g_free (column_name); return FALSE; }
static void nautilus_column_finalize (GObject *object) { NautilusColumn *column; column = NAUTILUS_COLUMN (object); g_free (column->name); g_free (column->label); g_free (column->description); G_OBJECT_CLASS (nautilus_column_parent_class)->finalize (object); }
static void nautilus_column_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec) { NautilusColumn *column; column = NAUTILUS_COLUMN (object); switch (param_id) { case PROP_NAME : g_free (column->details->name); column->details->name = g_strdup (g_value_get_string (value)); g_object_notify (object, "name"); break; case PROP_ATTRIBUTE : column->details->attribute = g_quark_from_string (g_value_get_string (value)); g_object_notify (object, "attribute"); g_object_notify (object, "attribute_q"); break; case PROP_LABEL : g_free (column->details->label); column->details->label = g_strdup (g_value_get_string (value)); g_object_notify (object, "label"); break; case PROP_DESCRIPTION : g_free (column->details->description); column->details->description = g_strdup (g_value_get_string (value)); g_object_notify (object, "description"); break; case PROP_XALIGN : column->details->xalign = g_value_get_float (value); g_object_notify (object, "xalign"); break; case PROP_DEFAULT_SORT_ORDER : column->details->default_sort_order = g_value_get_enum (value); g_object_notify (object, "default-sort-order"); break; default : G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; } }
static void set_column_order (NautilusColumnChooser *chooser, char **column_order) { GList *columns; GList *l; GtkTreePath *path; columns = nautilus_get_columns_for_file (chooser->details->file); columns = nautilus_sort_columns (columns, column_order); g_signal_handlers_block_by_func (chooser->details->store, G_CALLBACK (row_deleted_callback), chooser); path = gtk_tree_path_new_first (); for (l = columns; l != NULL; l = l->next) { GtkTreeIter iter; if (get_column_iter (chooser, NAUTILUS_COLUMN (l->data), &iter)) { GtkTreeIter before; if (path) { gtk_tree_model_get_iter (GTK_TREE_MODEL (chooser->details->store), &before, path); gtk_list_store_move_after (chooser->details->store, &iter, &before); gtk_tree_path_next (path); } else { gtk_list_store_move_after (chooser->details->store, &iter, NULL); } } } gtk_tree_path_free (path); g_signal_handlers_unblock_by_func (chooser->details->store, G_CALLBACK (row_deleted_callback), chooser); nautilus_column_list_free (columns); }
static void populate_tree (NautilusColumnChooser *chooser) { GList *columns; GList *l; columns = nautilus_get_columns_for_file (chooser->details->file); for (l = columns; l != NULL; l = l->next) { GtkTreeIter iter; NautilusColumn *column; char *name; char *label; gboolean visible = FALSE; gboolean sensitive = TRUE; column = NAUTILUS_COLUMN (l->data); g_object_get (G_OBJECT (column), "name", &name, "label", &label, NULL); if (strcmp (name, "name") == 0) { visible = TRUE; sensitive = FALSE; } gtk_list_store_append (chooser->details->store, &iter); gtk_list_store_set (chooser->details->store, &iter, COLUMN_VISIBLE, visible, COLUMN_LABEL, label, COLUMN_NAME, name, COLUMN_SENSITIVE, sensitive, -1); g_free (name); g_free (label); } nautilus_column_list_free (columns); }
static void create_icon_caption_combo_box_items (GtkComboBoxText *combo_box, GList *columns) { GList *l; GPtrArray *column_names; column_names = g_ptr_array_new (); /* Translators: this is referred to captions under icons. */ gtk_combo_box_text_append_text (combo_box, _("None")); g_ptr_array_add (column_names, g_strdup ("none")); for (l = columns; l != NULL; l = l->next) { NautilusColumn *column; char *name; char *label; column = NAUTILUS_COLUMN (l->data); g_object_get (G_OBJECT (column), "name", &name, "label", &label, NULL); /* Don't show name here, it doesn't make sense */ if (!strcmp (name, "name")) { g_free (name); g_free (label); continue; } gtk_combo_box_text_append_text (combo_box, label); g_ptr_array_add (column_names, name); g_free (label); } g_object_set_data_full (G_OBJECT (combo_box), "column_names", column_names, (GDestroyNotify) free_column_names_array); }
static void nautilus_column_get_property (GObject *object, guint param_id, GValue *value, GParamSpec *pspec) { NautilusColumn *column; column = NAUTILUS_COLUMN (object); switch (param_id) { case PROP_NAME : g_value_set_string (value, column->details->name); break; case PROP_ATTRIBUTE : g_value_set_string (value, g_quark_to_string (column->details->attribute)); break; case PROP_ATTRIBUTE_Q : g_value_set_uint (value, column->details->attribute); break; case PROP_LABEL : g_value_set_string (value, column->details->label); break; case PROP_DESCRIPTION : g_value_set_string (value, column->details->description); break; case PROP_XALIGN : g_value_set_float (value, column->details->xalign); break; case PROP_DEFAULT_SORT_ORDER : g_value_set_enum (value, column->details->default_sort_order); break; default : G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; } }