gthumb r2330 - in trunk: . src
- From: mjc svn gnome org
- To: svn-commits-list gnome org
- Subject: gthumb r2330 - in trunk: . src
- Date: Fri, 16 May 2008 16:06:55 +0100 (BST)
Author: mjc
Date: Fri May 16 15:06:55 2008
New Revision: 2330
URL: http://svn.gnome.org/viewvc/gthumb?rev=2330&view=rev
Log:
2008-05-16 Michael J. Chudobiak <mjc svn gnome org>
* src/gth-browser.c: (launch_selected_videos_or_audio):
* src/gth-viewer.c: (open_with_menu_item_activate_cb),
(viewer_update_open_with_menu):
Migrate from gnome_vfs_mime to g_app_info. Modified version
of an emailed patch from Gabriel FalcÃo (gabriel nacaolivre org).
* src/main.c: (initialize_data):
Removed left-over debug printf.
Modified:
trunk/ChangeLog
trunk/src/gth-browser.c
trunk/src/gth-viewer.c
trunk/src/main.c
Modified: trunk/src/gth-browser.c
==============================================================================
--- trunk/src/gth-browser.c (original)
+++ trunk/src/gth-browser.c Fri May 16 15:06:55 2008
@@ -32,7 +32,6 @@
#include <libgnomevfs/gnome-vfs-async-ops.h>
#include <libgnomevfs/gnome-vfs-result.h>
#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-mime.h>
#include <glade/glade.h>
#include "bookmarks.h"
@@ -2850,11 +2849,12 @@
static gboolean
launch_selected_videos_or_audio (GthBrowser *browser)
{
- gboolean result = FALSE;
- GnomeVFSMimeApplication *image_app;
- const char *image_mime_type;
- GList *video_list = NULL;
- GList *scan;
+ gboolean result = FALSE;
+ GAppInfo *app_info;
+ const char *image_mime_type;
+ GList *video_list = NULL;
+ GList *scan;
+ GList *selection;
if (browser->priv->image == NULL)
return FALSE;
@@ -2866,43 +2866,39 @@
return FALSE;
image_mime_type = browser->priv->image->mime_type;
- image_app = gnome_vfs_mime_get_default_application_for_uri (browser->priv->image->path, image_mime_type);
+ app_info = g_app_info_get_default_for_type (image_mime_type, TRUE);
- if (image_app == NULL)
+ if (app_info == NULL)
return FALSE;
- if (! image_app->can_open_multiple_files) {
- /* just pass the current (single) item */
- video_list = g_list_append (video_list, g_strdup (browser->priv->image->path));
+ if (! g_app_info_supports_uris (app_info)) {
+ g_warning ("%s does not support URIs as arguments.", g_app_info_get_name (app_info));
+ return FALSE;
}
- else {
- GList *selection;
-
- /* Scan through the list of selected items, and identify those that have the
- same mime_type, or can be launched by the same application. */
+
+ /* Scan through the list of selected items, and identify those that have the
+ same mime_type, or can be launched by the same application. */
- selection = gth_window_get_file_list_selection_as_fd (GTH_WINDOW (browser));
- for (scan = selection; scan; scan = scan->next) {
- FileData *file = scan->data;
+ selection = gth_window_get_file_list_selection_as_fd (GTH_WINDOW (browser));
+ for (scan = selection; scan; scan = scan->next) {
+ FileData *file = scan->data;
- if (mime_type_is (file->mime_type, image_mime_type)) {
+ if (mime_type_is (file->mime_type, image_mime_type)) {
+ video_list = g_list_append (video_list, g_strdup (file->path));
+ }
+ else {
+ GAppInfo *selected_app;
+ selected_app = g_app_info_get_default_for_type (file->mime_type, TRUE);
+ if (g_app_info_equal (app_info, selected_app))
video_list = g_list_append (video_list, g_strdup (file->path));
- }
- else {
- GnomeVFSMimeApplication *selected_app;
-
- selected_app = gnome_vfs_mime_get_default_application_for_uri (file->path, file->mime_type);
- if (gnome_vfs_mime_application_equal (image_app, selected_app))
- video_list = g_list_append (video_list, g_strdup (file->path));
- gnome_vfs_mime_application_free (selected_app);
- }
+ g_object_unref (selected_app);
}
- file_data_list_free (selection);
}
+ file_data_list_free (selection);
- result = gnome_vfs_mime_application_launch (image_app, video_list) == GNOME_VFS_OK;
-
- gnome_vfs_mime_application_free (image_app);
+ result = g_app_info_launch_uris (app_info, video_list, NULL, NULL);
+
+ g_object_unref (app_info);
path_list_free (video_list);
return result;
Modified: trunk/src/gth-viewer.c
==============================================================================
--- trunk/src/gth-viewer.c (original)
+++ trunk/src/gth-viewer.c Fri May 16 15:06:55 2008
@@ -28,8 +28,6 @@
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <gio/gio.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-mime.h>
#include "jpegutils/jpeg-data.h"
#include "comments.h"
@@ -711,7 +709,7 @@
gpointer user_data)
{
GthViewer *viewer = user_data;
- GnomeVFSMimeApplication *app;
+ GAppInfo *app;
GList *uris;
if (viewer->priv->image == NULL)
@@ -719,7 +717,7 @@
app = g_object_get_data (G_OBJECT (menuitem), "app");
uris = g_list_prepend (NULL, viewer->priv->image->path);
- gnome_vfs_mime_application_launch (app, uris);
+ g_app_info_launch_uris (app, uris, NULL, NULL);
g_list_free (uris);
}
@@ -742,26 +740,33 @@
mime_type = priv->image->mime_type;
if (mime_type != NULL) {
- GList *apps = gnome_vfs_mime_get_all_applications (mime_type);
+ GList *apps = g_app_info_get_all_for_type (mime_type);
GtkIconTheme *theme = gtk_icon_theme_get_default ();
int icon_size = get_folder_pixbuf_size_for_list (GTK_WIDGET (viewer));
for (scan = apps; scan; scan = scan->next) {
- GnomeVFSMimeApplication *app = scan->data;
- GtkWidget *mitem;
+ GAppInfo *app = scan->data;
+ GtkWidget *mitem;
+ GIcon *icon;
+ gchar *icon_name;
/* do not include gthumb itself */
- if (strncmp (gnome_vfs_mime_application_get_exec (app), "gthumb", 6) == 0)
+ if (strncmp (g_app_info_get_executable (app), "gthumb", 6) == 0)
continue;
- mitem = gtk_image_menu_item_new_with_label (gnome_vfs_mime_application_get_name (app));
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mitem), create_image (theme, gnome_vfs_mime_application_get_icon (app), icon_size));
- g_object_set_data_full (G_OBJECT (mitem), "app", app, (GDestroyNotify)gnome_vfs_mime_application_free);
+ mitem = gtk_image_menu_item_new_with_label (g_app_info_get_name (app));
+ icon = g_app_info_get_icon (app);
+ g_object_get (icon, "name", &icon_name, NULL);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mitem), create_image (theme, icon_name, icon_size));
+ g_object_set_data_full (G_OBJECT (mitem), "app", app, (GDestroyNotify)g_object_unref);
g_signal_connect (mitem, "activate",
G_CALLBACK (open_with_menu_item_activate_cb),
viewer);
gtk_widget_show_all (mitem);
gtk_menu_insert (priv->open_with_popup_menu, mitem, pos++);
+
+ g_object_unref (icon);
+ g_free (icon_name);
}
g_list_free (apps);
}
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Fri May 16 15:06:55 2008
@@ -473,7 +473,6 @@
dir_urls = g_list_prepend (dir_urls, path);
else
file_urls = g_list_prepend (file_urls, path);
-printf ("path %s\n\r",path);
g_object_unref (gfile);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]