int main (int argc, char **argv) { GdkPixbuf *pixbuf; GnomeDesktopThumbnailFactory *factory; GtkWidget *window, *image; char *content_type; gtk_init (&argc, &argv); if (argc < 2) { g_print ("Usage: %s FILE...\n", argv[0]); return 1; } content_type = g_content_type_guess (argv[1], NULL, 0, NULL); factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE); pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (factory, argv[1], content_type); g_free (content_type); if (pixbuf == NULL) { g_warning ("gnome_desktop_thumbnail_factory_generate_thumbnail() failed to generate a thumbnail for %s", argv[1]); return 1; } window = gtk_window_new (GTK_WINDOW_TOPLEVEL); image = gtk_image_new_from_pixbuf (pixbuf); gtk_container_add (GTK_CONTAINER (window), image); gtk_widget_show_all (window); gtk_main (); return 0; }
UmPhotoDialog * um_photo_dialog_new (GtkWidget *button) { UmPhotoDialog *um; um = g_new0 (UmPhotoDialog, 1); um->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL); /* Set up the popup */ um->popup_button = button; setup_photo_popup (um); g_signal_connect (button, "toggled", G_CALLBACK (popup_icon_menu), um); g_signal_connect (button, "button-press-event", G_CALLBACK (on_popup_button_button_pressed), um); g_signal_connect (button, "notify::is-focus", G_CALLBACK (popup_button_focus_changed), um); g_signal_connect_after (button, "draw", G_CALLBACK (popup_button_draw), um); g_signal_connect (um->photo_popup, "unmap", G_CALLBACK (on_photo_popup_unmap), um); return um; }
static gboolean create_thumbnail (GIOSchedulerJob *job, GCancellable *cancellable, gpointer user_data) { GSimpleAsyncResult *result = user_data; GFile *file = G_FILE (g_async_result_get_source_object (G_ASYNC_RESULT (result))); GnomeDesktopThumbnailFactory *factory; GFileInfo *info; gchar *uri; GdkPixbuf *pixbuf; guint64 mtime; uri = g_file_get_uri (file); info = g_file_query_info (file, ATTRIBUTES_FOR_THUMBNAIL, G_FILE_QUERY_INFO_NONE, NULL, NULL); /* we don't care about reporting errors here, just fail the * thumbnail. */ if (info == NULL) { g_simple_async_result_set_op_res_gboolean (result, FALSE); goto out; } mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED); factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL); pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (factory, uri, g_file_info_get_content_type (info)); if (pixbuf != NULL) { gnome_desktop_thumbnail_factory_save_thumbnail (factory, pixbuf, uri, (time_t) mtime); g_simple_async_result_set_op_res_gboolean (result, TRUE); } else { g_simple_async_result_set_op_res_gboolean (result, FALSE); } g_object_unref (info); g_object_unref (file); g_object_unref (factory); g_clear_object (&pixbuf); out: g_simple_async_result_complete_in_idle (result); g_object_unref (result); return FALSE; }
static void st_texture_cache_init (StTextureCache *self) { self->priv = g_new0 (StTextureCachePrivate, 1); self->priv->keyed_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, cogl_handle_unref); self->priv->outstanding_requests = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); self->priv->thumbnails = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL); }
void eog_thumbnail_init (void) { if (factory == NULL) { factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL); } if (frame == NULL) { frame = gdk_pixbuf_new_from_file (EOG_DATA_DIR "/pixmaps/thumbnail-frame.png", NULL); } }
static GnomeDesktopThumbnailFactory * get_thumbnail_factory (void) { static GnomeDesktopThumbnailFactory *thumbnail_factory = NULL; if (thumbnail_factory == NULL) { thumbnail_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL); } return thumbnail_factory; }
/** * e_icon_factory_create_thumbnail * @filename: the file name to create the thumbnail for * * Creates system thumbnail for @filename. * * Returns: Path to system thumbnail of the file; %NULL if couldn't * create it. Free it with g_free(). **/ gchar * e_icon_factory_create_thumbnail (const gchar *filename) { #ifdef HAVE_GNOME_DESKTOP static GnomeDesktopThumbnailFactory *thumbnail_factory = NULL; struct stat file_stat; gchar *thumbnail = NULL; g_return_val_if_fail (filename != NULL, NULL); if (thumbnail_factory == NULL) { thumbnail_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL); } if (g_stat (filename, &file_stat) != -1 && S_ISREG (file_stat.st_mode)) { gchar *content_type, *mime = NULL; gboolean uncertain = FALSE; content_type = g_content_type_guess (filename, NULL, 0, &uncertain); if (content_type) mime = g_content_type_get_mime_type (content_type); if (mime) { gchar *uri = g_filename_to_uri (filename, NULL, NULL); g_return_val_if_fail (uri != NULL, NULL); thumbnail = gnome_desktop_thumbnail_factory_lookup (thumbnail_factory, uri, file_stat.st_mtime); if (!thumbnail && gnome_desktop_thumbnail_factory_can_thumbnail (thumbnail_factory, uri, mime, file_stat.st_mtime)) { GdkPixbuf *pixbuf; pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (thumbnail_factory, uri, mime); if (pixbuf) { gnome_desktop_thumbnail_factory_save_thumbnail (thumbnail_factory, pixbuf, uri, file_stat.st_mtime); g_object_unref (pixbuf); thumbnail = gnome_desktop_thumbnail_factory_lookup (thumbnail_factory, uri, file_stat.st_mtime); } } g_free (uri); } g_free (content_type); g_free (mime); } return thumbnail; #else return NULL; #endif /* HAVE_GNOME_DESKTOP */ }
gboolean bg_colors_source_add (BgColorsSource *self, GdkRGBA *rgba, GtkTreeRowReference **ret_row_ref) { GnomeDesktopThumbnailFactory *thumb_factory; GtkListStore *store; gchar *c; char **colors; gsize len; GKeyFile *keyfile; GError *error = NULL; char *path; c = g_strdup_printf ("#%02x%02x%02x", (int)(255*rgba->red), (int)(255*rgba->green), (int)(255*rgba->blue)); thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE); store = bg_source_get_liststore (BG_SOURCE (self)); bg_colors_source_add_color (self, thumb_factory, store, c, ret_row_ref); g_object_unref (thumb_factory); /* Save to the keyfile */ path = get_colors_dir (); g_mkdir_with_parents (path, 0700); g_free (path); path = get_colors_path (); colors = NULL; len = 0; keyfile = g_key_file_new (); if (g_key_file_load_from_file (keyfile, path, G_KEY_FILE_NONE, NULL)) colors = g_key_file_get_string_list (keyfile, "Colors", "custom-colors", &len, NULL); if (len == 0 && colors != NULL) { g_strfreev (colors); colors = NULL; } if (colors == NULL) { colors = g_new0 (char *, 2); colors[0] = c; len = 1; }
static void cc_background_panel_init (CcBackgroundPanel *self) { CcBackgroundPanelPrivate *priv; gchar *objects[] = {"background-panel", NULL }; GError *err = NULL; GtkWidget *widget; priv = self->priv = BACKGROUND_PANEL_PRIVATE (self); priv->builder = gtk_builder_new (); priv->connection = g_application_get_dbus_connection (g_application_get_default ()); gtk_builder_add_objects_from_file (priv->builder, UIDIR"/background.ui", objects, &err); if (err) { g_warning ("Could not load ui: %s", err->message); g_error_free (err); return; } priv->settings = g_settings_new (WP_PATH_ID); g_settings_delay (priv->settings); /* add the top level widget */ widget = WID ("background-panel"); gtk_container_add (GTK_CONTAINER (self), widget); gtk_widget_show_all (GTK_WIDGET (self)); /* setup preview area */ widget = WID ("background-desktop-drawingarea"); g_signal_connect (widget, "draw", G_CALLBACK (on_preview_draw), self); priv->copy_cancellable = g_cancellable_new (); priv->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE); reload_current_bg (self); update_preview (priv, NULL); g_signal_connect (priv->settings, "changed", G_CALLBACK (on_settings_changed), self); widget = WID ("background-set-button"); g_signal_connect (widget, "clicked", G_CALLBACK (on_background_button_clicked), self); }
static void bg_colors_source_init (BgColorsSource *self) { GnomeDesktopThumbnailFactory *thumb_factory; guint i; GtkListStore *store; store = bg_source_get_liststore (BG_SOURCE (self)); thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE); for (i = 0; i < G_N_ELEMENTS (items); i++) { CcBackgroundItemFlags flags; CcBackgroundItem *item; GIcon *pixbuf; item = cc_background_item_new (NULL); flags = CC_BACKGROUND_ITEM_HAS_PCOLOR | CC_BACKGROUND_ITEM_HAS_SCOLOR | CC_BACKGROUND_ITEM_HAS_SHADING | CC_BACKGROUND_ITEM_HAS_PLACEMENT | CC_BACKGROUND_ITEM_HAS_URI; /* It does have a URI, it's "none" */ g_object_set (G_OBJECT (item), "uri", "file:///" DATADIR "/cinnamon-control-center/pixmaps/noise-texture-light.png", "primary-color", items[i].pcolor, "secondary-color", items[i].pcolor, "shading", items[i].type, "placement", G_DESKTOP_BACKGROUND_STYLE_WALLPAPER, "flags", flags, NULL); cc_background_item_load (item, NULL); /* insert the item into the liststore */ pixbuf = cc_background_item_get_thumbnail (item, thumb_factory, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT); gtk_list_store_insert_with_values (store, NULL, 0, 0, pixbuf, 1, item, -1); g_object_unref (pixbuf); } g_object_unref (thumb_factory); }
static void create_thumbnail (GTask *task, gpointer source_object, gpointer task_data, GCancellable *cancellable) { GFile *file = G_FILE (source_object); GnomeDesktopThumbnailFactory *factory = NULL; GError *error = NULL; GFileInfo *info = NULL; gchar *uri = NULL; GdkPixbuf *pixbuf = NULL; guint64 mtime; uri = g_file_get_uri (file); info = g_file_query_info (file, ATTRIBUTES_FOR_THUMBNAIL, G_FILE_QUERY_INFO_NONE, NULL, &error); if (info == NULL) { g_task_return_error (task, error); goto out; } mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED); factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE); pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (factory, uri, g_file_info_get_content_type (info)); if (pixbuf == NULL) { g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "GnomeDesktopThumbnailFactory failed"); goto out; } gnome_desktop_thumbnail_factory_save_thumbnail (factory, pixbuf, uri, (time_t) mtime); g_task_return_boolean (task, TRUE); out: g_clear_object (&info); g_clear_object (&factory); g_clear_object (&pixbuf); g_free (uri); }
static void bg_wallpapers_source_init (BgWallpapersSource *self) { BgWallpapersSourcePrivate *priv; priv = self->priv = WALLPAPERS_SOURCE_PRIVATE (self); priv->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE); priv->xml = cc_background_xml_new (); g_signal_connect (G_OBJECT (priv->xml), "added", G_CALLBACK (item_added), self); /* Try adding the default background first */ load_default_bg (self); cc_background_xml_load_list_async (priv->xml, NULL, list_load_cb, self); }
/** * gs_screenshot_image_get_desktop_pixbuf: **/ static GdkPixbuf * gs_screenshot_image_get_desktop_pixbuf (GsScreenshotImage *ssimg) { GsScreenshotImagePrivate *priv; _cleanup_object_unref_ GnomeBG *bg = NULL; _cleanup_object_unref_ GnomeDesktopThumbnailFactory *factory = NULL; _cleanup_object_unref_ GSettings *settings = NULL; priv = gs_screenshot_image_get_instance_private (ssimg); factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE); bg = gnome_bg_new (); settings = g_settings_new ("org.gnome.desktop.background"); gnome_bg_load_from_preferences (bg, settings); return gnome_bg_create_thumbnail (bg, factory, gdk_screen_get_default (), priv->width, priv->height); }
static GdkPixbuf * create_thumbnail (LoadThumbnailData *data) { GFile *file = data->font_file; GnomeDesktopThumbnailFactory *factory; gchar *uri; guint64 mtime; GdkPixbuf *pixbuf = NULL; GFileInfo *info = NULL; uri = g_file_get_uri (file); info = g_file_query_info (file, ATTRIBUTES_FOR_CREATING_THUMBNAIL, G_FILE_QUERY_INFO_NONE, NULL, NULL); /* we don't care about reporting errors here, just fail the * thumbnail. */ if (info == NULL) goto out; mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED); factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL); pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (factory, uri, g_file_info_get_content_type (info)); if (pixbuf != NULL) gnome_desktop_thumbnail_factory_save_thumbnail (factory, pixbuf, uri, (time_t) mtime); else gnome_desktop_thumbnail_factory_create_failed_thumbnail (factory, uri, (time_t) mtime); g_object_unref (factory); out: g_clear_object (&info); return pixbuf; }
static void bg_colors_source_constructed (GObject *object) { BgColorsSource *self = BG_COLORS_SOURCE (object); GnomeDesktopThumbnailFactory *thumb_factory; guint i; GtkListStore *store; GKeyFile *keyfile; char *path; G_OBJECT_CLASS (bg_colors_source_parent_class)->constructed (object); store = bg_source_get_liststore (BG_SOURCE (self)); thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE); for (i = 0; i < G_N_ELEMENTS (items); i++) { bg_colors_source_add_color (self, thumb_factory, store, items[i].pcolor, NULL); } keyfile = g_key_file_new (); path = get_colors_path (); if (g_key_file_load_from_file (keyfile, path, G_KEY_FILE_NONE, NULL)) { char **colors; colors = g_key_file_get_string_list (keyfile, "Colors", "custom-colors", NULL, NULL); for (i = 0; colors != NULL && colors[i] != NULL; i++) { bg_colors_source_add_color (self, thumb_factory, store, colors[i], NULL); } if (colors) g_strfreev (colors); } g_key_file_unref (keyfile); g_free (path); g_object_unref (thumb_factory); }
gboolean photos_utils_create_thumbnail (GFile *file, GCancellable *cancellable, GError **error) { GnomeDesktopThumbnailFactory *factory = NULL; GFileInfo *info = NULL; const gchar *attributes = G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE","G_FILE_ATTRIBUTE_TIME_MODIFIED; gboolean ret_val = FALSE; gchar *uri = NULL; GdkPixbuf *pixbuf = NULL; guint64 mtime; uri = g_file_get_uri (file); info = g_file_query_info (file, attributes, G_FILE_QUERY_INFO_NONE, cancellable, error); if (info == NULL) goto out; mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED); factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE); pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (factory, uri, g_file_info_get_content_type (info)); if (pixbuf == NULL) { /* FIXME: use proper #defines and enumerated types */ g_set_error (error, g_quark_from_static_string ("gnome-desktop-error"), 0, "GnomeDesktopThumbnailFactory failed"); goto out; } gnome_desktop_thumbnail_factory_save_thumbnail (factory, pixbuf, uri, (time_t) mtime); ret_val = TRUE; out: g_clear_object (&pixbuf); g_clear_object (&factory); g_clear_object (&info); g_free (uri); return ret_val; }
static void bg_pictures_source_init (BgPicturesSource *self) { const gchar *pictures_path; BgPicturesSourcePrivate *priv; GFile *dir; char *cache_path; priv = self->priv = PICTURES_SOURCE_PRIVATE (self); priv->cancellable = g_cancellable_new (); priv->known_items = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL); pictures_path = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES); dir = g_file_new_for_path (pictures_path); g_file_enumerate_children_async (dir, ATTRIBUTES, G_FILE_QUERY_INFO_NONE, G_PRIORITY_LOW, priv->cancellable, dir_enum_async_ready, self); g_object_unref (dir); cache_path = bg_pictures_source_get_cache_path (); dir = g_file_new_for_path (cache_path); g_file_enumerate_children_async (dir, ATTRIBUTES, G_FILE_QUERY_INFO_NONE, G_PRIORITY_LOW, priv->cancellable, dir_enum_async_ready, self); g_object_unref (dir); priv->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE); }
static void cheese_thumb_view_init (CheeseThumbView *thumb_view) { CheeseThumbViewPrivate *priv = cheese_thumb_view_get_instance_private (thumb_view); priv->video_file_monitor = NULL; priv->photo_file_monitor = NULL; cheese_thumbnail_init (); priv->store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING); priv->n_items = 0; priv->idle_id = 0; priv->thumbnails = g_queue_new (); priv->fileutil = cheese_fileutil_new (); priv->factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL); g_signal_connect (G_OBJECT (priv->store), "row-inserted", G_CALLBACK (cheese_thumb_view_row_inserted_cb), thumb_view); g_signal_connect (G_OBJECT (priv->store), "row-deleted", G_CALLBACK (cheese_thumb_view_row_deleted_cb), thumb_view); g_signal_connect (G_OBJECT (thumb_view), "drag-data-get", G_CALLBACK (cheese_thumb_view_on_drag_data_get_cb), NULL); /* We do the rest of the initialization in our constructed() implementation, * because GtkIconView may not be ready for us to do more now. * See https://bugzilla.gnome.org/show_bug.cgi?id=643286#c6 */ }
static void cc_background_panel_init (CcBackgroundPanel *self) { CcBackgroundPanelPrivate *priv; gchar *objects[] = { "style-liststore", "sources-liststore", "background-panel", "sizegroup", NULL }; GError *err = NULL; GtkWidget *widget; GtkListStore *store; GtkStyleContext *context; priv = self->priv = BACKGROUND_PANEL_PRIVATE (self); priv->builder = gtk_builder_new (); gtk_builder_add_objects_from_file (priv->builder, DATADIR"/background.ui", objects, &err); if (err) { g_warning ("Could not load ui: %s", err->message); g_error_free (err); return; } /* See shell_notify_cb for details */ g_signal_connect (WID ("scrolledwindow1"), "realize", G_CALLBACK (scrolled_realize_cb), self); priv->settings = g_settings_new (WP_PATH_ID); g_settings_delay (priv->settings); store = (GtkListStore*) gtk_builder_get_object (priv->builder, "sources-liststore"); priv->wallpapers_source = bg_wallpapers_source_new (); gtk_list_store_insert_with_values (store, NULL, G_MAXINT, COL_SOURCE_NAME, _("Wallpapers"), COL_SOURCE_TYPE, SOURCE_WALLPAPERS, COL_SOURCE, priv->wallpapers_source, -1); priv->pictures_source = bg_pictures_source_new (); gtk_list_store_insert_with_values (store, NULL, G_MAXINT, COL_SOURCE_NAME, _("Pictures Folder"), COL_SOURCE_TYPE, SOURCE_PICTURES, COL_SOURCE, priv->pictures_source, -1); priv->colors_source = bg_colors_source_new (); gtk_list_store_insert_with_values (store, NULL, G_MAXINT, COL_SOURCE_NAME, _("Colors & Gradients"), COL_SOURCE_TYPE, SOURCE_COLORS, COL_SOURCE, priv->colors_source, -1); #ifdef HAVE_LIBSOCIALWEB priv->flickr_source = bg_flickr_source_new (); gtk_list_store_insert_with_values (store, NULL, G_MAXINT, COL_SOURCE_NAME, _("Flickr"), COL_SOURCE_TYPE, SOURCE_FLICKR, COL_SOURCE, priv->flickr_source, -1); #endif /* add the top level widget */ widget = WID ("background-panel"); gtk_container_add (GTK_CONTAINER (self), widget); gtk_widget_show_all (GTK_WIDGET (self)); /* connect to source change signal */ widget = WID ("sources-combobox"); g_signal_connect (widget, "changed", G_CALLBACK (source_changed_cb), priv); /* select first item */ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); /* connect to the background iconview change signal */ widget = WID ("backgrounds-iconview"); g_signal_connect (widget, "selection-changed", G_CALLBACK (backgrounds_changed_cb), self); /* Join treeview and buttons */ widget = WID ("scrolledwindow1"); context = gtk_widget_get_style_context (widget); gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM); widget = WID ("toolbar1"); context = gtk_widget_get_style_context (widget); gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP); g_signal_connect (WID ("add_button"), "clicked", G_CALLBACK (add_button_clicked), self); g_signal_connect (WID ("remove_button"), "clicked", G_CALLBACK (remove_button_clicked), self); /* Add drag and drop support for bg images */ widget = WID ("scrolledwindow1"); gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY); gtk_drag_dest_add_uri_targets (widget); g_signal_connect (widget, "drag-data-received", G_CALLBACK (cc_background_panel_drag_uris), self); /* setup preview area */ gtk_label_set_ellipsize (GTK_LABEL (WID ("background-label")), PANGO_ELLIPSIZE_END); widget = WID ("preview-area"); g_signal_connect (widget, "draw", G_CALLBACK (preview_draw_cb), self); priv->display_base = gdk_pixbuf_new_from_file (DATADIR "/display-base.png", NULL); priv->display_overlay = gdk_pixbuf_new_from_file (DATADIR "/display-overlay.png", NULL); g_signal_connect (WID ("style-combobox"), "changed", G_CALLBACK (style_changed_cb), self); g_signal_connect (WID ("style-pcolor"), "color-set", G_CALLBACK (color_changed_cb), self); g_signal_connect (WID ("style-scolor"), "color-set", G_CALLBACK (color_changed_cb), self); g_signal_connect (WID ("swap-color-button"), "clicked", G_CALLBACK (swap_colors_clicked), self); priv->copy_cancellable = g_cancellable_new (); priv->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL); load_current_bg (self); update_preview (priv, NULL); /* Setup the edit box with our current settings */ source_update_edit_box (priv, TRUE); }
static void bg_pictures_source_init (BgPicturesSource *self) { const gchar *pictures_path; BgPicturesSourcePrivate *priv; GFile *dir; char *cache_path; GtkListStore *store; priv = self->priv = PICTURES_SOURCE_PRIVATE (self); priv->cancellable = g_cancellable_new (); priv->known_items = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL); pictures_path = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES); if (pictures_path == NULL) pictures_path = g_get_home_dir (); g_mkdir_with_parents (pictures_path, USER_DIR_MODE); dir = g_file_new_for_path (pictures_path); g_file_enumerate_children_async (dir, ATTRIBUTES, G_FILE_QUERY_INFO_NONE, G_PRIORITY_LOW, priv->cancellable, dir_enum_async_ready, self); priv->picture_dir_monitor = g_file_monitor_directory (dir, G_FILE_MONITOR_NONE, priv->cancellable, NULL); if (priv->picture_dir_monitor) g_signal_connect (priv->picture_dir_monitor, "changed", G_CALLBACK (files_changed_cb), self); g_object_unref (dir); cache_path = bg_pictures_source_get_cache_path (); g_mkdir_with_parents (cache_path, USER_DIR_MODE); dir = g_file_new_for_path (cache_path); g_file_enumerate_children_async (dir, ATTRIBUTES, G_FILE_QUERY_INFO_NONE, G_PRIORITY_LOW, priv->cancellable, dir_enum_async_ready, self); g_free (cache_path); priv->cache_dir_monitor = g_file_monitor_directory (dir, G_FILE_MONITOR_NONE, priv->cancellable, NULL); if (priv->cache_dir_monitor) g_signal_connect (priv->cache_dir_monitor, "changed", G_CALLBACK (files_changed_cb), self); g_object_unref (dir); priv->grl_miner = cc_background_grilo_miner_new (); g_signal_connect_swapped (priv->grl_miner, "media-found", G_CALLBACK (media_found_cb), self); cc_background_grilo_miner_start (priv->grl_miner); priv->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE); store = bg_source_get_liststore (BG_SOURCE (self)); gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store), 1, (GtkTreeIterCompareFunc)sort_func, self, NULL); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), 1, GTK_SORT_ASCENDING); }