예제 #1
0
static void
file_chooser_dialog_response_cb (GtkDialog *dialog,
				 int        response,
				 gpointer   user_data)
{
	GthSlideshowPreferences *self = user_data;

	switch (response) {
	case GTK_RESPONSE_DELETE_EVENT:
	case GTK_RESPONSE_CANCEL:
		gtk_widget_destroy (GTK_WIDGET (dialog));
		break;

	case GTK_RESPONSE_OK:
		{
			GSList       *files;
			GthIconCache *icon_cache;
			GtkListStore *list_store;
			GSList       *scan;

			files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (dialog));
			icon_cache = gth_icon_cache_new_for_widget(GTK_WIDGET (self), GTK_ICON_SIZE_MENU);
			list_store = (GtkListStore *) gtk_builder_get_object (self->priv->builder, "files_liststore");
			for (scan = files; scan; scan = scan->next) {
				GFile       *file = scan->data;
				GIcon       *icon;
				GdkPixbuf   *pixbuf;
				char        *uri;
				char        *name;
				GtkTreeIter  iter;

				icon = g_content_type_get_icon ("audio");
				pixbuf = gth_icon_cache_get_pixbuf (icon_cache, icon);
				uri = g_file_get_uri (file);
				name = _g_file_get_display_name (file);

				gtk_list_store_append (list_store, &iter);
				gtk_list_store_set (list_store, &iter,
						    FILE_COLUMN_ICON, pixbuf,
						    FILE_COLUMN_NAME, name,
						    FILE_COLUMN_URI, uri,
						    -1);

				g_free (name);
				g_free (uri);
				g_object_unref (pixbuf);
			}

			gth_icon_cache_free (icon_cache);
			g_slist_foreach (files, (GFunc) g_object_unref, NULL);
			g_slist_free (files);
		}
		gtk_widget_destroy (GTK_WIDGET (dialog));
		break;
	}
}
예제 #2
0
파일: callbacks.c 프로젝트: GNOME/gthumb
static void
update_system_bookmark_list_from_content (GthBrowser *browser,
        const char *content)
{
    BrowserData   *data;
    char        **lines;
    int           i;

    data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
    g_return_if_fail (data != NULL);

    lines = g_strsplit (content, "\n", -1);
    for (i = 0; lines[i] != NULL; i++) {
        char      **line;
        char       *uri;
        GFile      *file;
        char       *name;
        GMenuItem  *item;

        line = g_strsplit (lines[i], " ", 2);
        uri = line[0];
        if (uri == NULL) {
            g_strfreev (line);
            continue;
        }

        file = g_file_new_for_uri (uri);
        name = g_strdup (strchr (lines[i], ' '));
        if (name == NULL)
            name = _g_file_get_display_name (file);
        if (name == NULL)
            name = g_file_get_parse_name (file);
        item = _g_menu_item_new_for_file (file, name);
        g_menu_item_set_action_and_target (item, "win.go-to-location", "s", uri);
        g_menu_append_item (data->system_bookmarks_menu, item);

        g_object_unref (item);
        g_free (name);
        g_object_unref (file);
        g_strfreev (line);
    }

    g_strfreev (lines);
}
예제 #3
0
파일: actions.c 프로젝트: JosephMcc/pix
static void
wallpaper_data_set (WallpaperData *wdata)
{
	GtkWidget *infobar;

	wallpaper_style_set_as_current (&wdata->new_style);

	infobar = gth_browser_get_infobar (wdata->browser);
	gth_info_bar_set_icon (GTH_INFO_BAR (infobar), GTK_STOCK_DIALOG_INFO);

	{
		char *name;
		char *msg;

		name = _g_file_get_display_name (wdata->new_style.file);
		msg = g_strdup_printf ("The image \"%s\" has been set as desktop background", name);
		gth_info_bar_set_primary_text (GTH_INFO_BAR (infobar), msg);

		g_free (msg);
		g_free (name);
	}

	_gtk_info_bar_clear_action_area (GTK_INFO_BAR (infobar));
	gtk_orientable_set_orientation (GTK_ORIENTABLE (gtk_info_bar_get_action_area (GTK_INFO_BAR (infobar))), GTK_ORIENTATION_HORIZONTAL);
	gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), GTK_MESSAGE_INFO);
	gtk_info_bar_add_buttons (GTK_INFO_BAR (infobar),
				  GTK_STOCK_PREFERENCES, _RESPONSE_PREFERENCES,
				  GTK_STOCK_UNDO, _RESPONSE_UNDO,
				  GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
				  NULL);
	gtk_info_bar_set_response_sensitive (GTK_INFO_BAR (infobar),
					     _RESPONSE_UNDO,
					     wdata->old_style.file != NULL);
	wdata->response_id = g_signal_connect (infobar,
			  	  	       "response",
			  	  	       G_CALLBACK (infobar_response_cb),
			  	  	       wdata);

	gtk_widget_show (infobar);
}
예제 #4
0
void
gth_slideshow_preferences_set_audio (GthSlideshowPreferences  *self,
				     char                    **files)
{
	GthIconCache *icon_cache;
	GtkListStore *list_store;
	int           i;

	icon_cache = gth_icon_cache_new_for_widget(GTK_WIDGET (self), GTK_ICON_SIZE_MENU);
	list_store = (GtkListStore *) gtk_builder_get_object (self->priv->builder, "files_liststore");
	gtk_list_store_clear (list_store);
	for (i = 0; files[i] != NULL; i++) {
		GIcon       *icon;
		GdkPixbuf   *pixbuf;
		GFile       *file;
		char        *name;
		GtkTreeIter  iter;

		icon = g_content_type_get_icon ("audio");
		pixbuf = gth_icon_cache_get_pixbuf (icon_cache, icon);
		file = g_file_new_for_uri (files[i]);
		name = _g_file_get_display_name (file);

		gtk_list_store_append (list_store, &iter);
		gtk_list_store_set (list_store, &iter,
				    FILE_COLUMN_ICON, pixbuf,
				    FILE_COLUMN_NAME, name,
				    FILE_COLUMN_URI, files[i],
				    -1);

		g_free (name);
		g_object_unref (file);
		g_object_unref (pixbuf);
	}

	gth_icon_cache_free (icon_cache);
}