GdkPixbuf * gedit_file_browser_utils_pixbuf_from_file (GFile *file, GtkIconSize size, gboolean use_symbolic) { GIcon *icon; GFileInfo *info; GdkPixbuf *ret = NULL; const char *attribute; attribute = use_symbolic ? G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON : G_FILE_ATTRIBUTE_STANDARD_ICON; info = g_file_query_info (file, attribute, G_FILE_QUERY_INFO_NONE, NULL, NULL); if (!info) return NULL; icon = use_symbolic ? g_file_info_get_symbolic_icon (info) : g_file_info_get_icon (info); if (icon != NULL) ret = gedit_file_browser_utils_pixbuf_from_icon (icon, size); g_object_unref (info); return ret; }
static void place_query_info_ready (GObject *source, GAsyncResult *res, gpointer user_data) { GtkWidget *row, *box, *w; Place *place; GFileInfo *info; const gchar *desktop_path; gchar *path; info = g_file_query_info_finish (G_FILE (source), res, NULL); if (!info) return; row = user_data; place = g_object_get_data (G_OBJECT (row), "place"); g_clear_object (&place->cancellable); box = gtk_bin_get_child (GTK_BIN (row)); /* FIXME: GLib is currently buggy and returns a non-existent icon name * when asked for the desktop symbolic icon. */ desktop_path = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP); path = g_file_get_path (G_FILE (source)); if (g_strcmp0 (path, desktop_path) == 0) place->icon = g_themed_icon_new ("folder-symbolic"); else place->icon = g_object_ref (g_file_info_get_symbolic_icon (info)); if (g_strcmp0 (path, g_get_home_dir ()) == 0) place->settings_key = TRACKER_KEY_SINGLE_DIRECTORIES; else place->settings_key = TRACKER_KEY_RECURSIVE_DIRECTORIES; g_free (path); w = gtk_image_new_from_gicon (place->icon, GTK_ICON_SIZE_MENU); gtk_container_add (GTK_CONTAINER (box), w); w = gtk_label_new (place->display_name); gtk_container_add (GTK_CONTAINER (box), w); w = gtk_switch_new (); gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0); g_settings_bind_with_mapping (tracker_preferences, place->settings_key, w, "active", G_SETTINGS_BIND_DEFAULT, switch_tracker_get_mapping, switch_tracker_set_mapping, place, NULL); gtk_widget_show_all (row); g_object_unref (info); }
static void update_location_list (gpointer user_data) { GthLocationChooser *self = user_data; GtkTreeIter iter; self->priv->update_location_list_id = 0; if (self->priv->location == NULL) return; if (get_iter_from_current_file_entries (self, self->priv->location, &iter)) { g_signal_handlers_block_by_func (self->priv->combo, combo_changed_cb, self); gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self->priv->combo), &iter); g_signal_handlers_unblock_by_func (self->priv->combo, combo_changed_cb, self); } else { GList *list; GList *scan; int position = 0; delete_current_file_entries (self); list = gth_file_source_get_current_list (self->priv->file_source, self->priv->location); for (scan = list; scan; scan = scan->next) { GFile *file = scan->data; GFileInfo *info; info = gth_file_source_get_file_info (self->priv->file_source, file, GFILE_DISPLAY_ATTRIBUTES); if (info == NULL) continue; add_file_source_entries (self, file, g_file_info_get_display_name (info), g_file_info_get_symbolic_icon (info), position++, TRUE, ITEM_TYPE_LOCATION); g_object_unref (info); } _g_object_list_unref (list); } }
static void update_entry_point_list (GthLocationChooser *self) { int first_position; int position; GList *entry_points; GList *scan; self->priv->update_entry_list_id = 0; clear_entry_point_list (self); if (! get_nth_separator_pos (self, 1, &first_position)) { GtkTreeIter iter; GtkTreePath *path; gtk_tree_store_append (self->priv->model, &iter, NULL); gtk_tree_store_set (self->priv->model, &iter, TYPE_COLUMN, ITEM_TYPE_SEPARATOR, -1); path = gtk_tree_model_get_path (GTK_TREE_MODEL (self->priv->model), &iter); if (path == NULL) return; first_position = gtk_tree_path_get_indices(path)[0]; gtk_tree_path_free (path); } position = first_position + 1; entry_points = gth_main_get_all_entry_points (); for (scan = entry_points; scan; scan = scan->next) { GthFileData *file_data = scan->data; add_file_source_entries (self, file_data->file, g_file_info_get_display_name (file_data->info), g_file_info_get_symbolic_icon (file_data->info), position++, FALSE, ITEM_TYPE_ENTRY_POINT); } _g_object_list_unref (entry_points); }