[giggle] Use gtk_show_uri() to open files
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [giggle] Use gtk_show_uri() to open files
- Date: Thu, 22 Apr 2010 01:46:18 +0000 (UTC)
commit f672b069b67019765b63716c77e08adeef6ad6be
Author: Javier Jardón <jjardon gnome org>
Date: Thu Apr 22 02:06:04 2010 +0200
Use gtk_show_uri() to open files
Instead the low level function g_app_info_launch_default_for_uri()
directly.
src/giggle-file-list.c | 6 +-----
src/giggle-helpers.c | 40 +++++++---------------------------------
src/giggle-helpers.h | 6 ------
3 files changed, 8 insertions(+), 44 deletions(-)
---
diff --git a/src/giggle-file-list.c b/src/giggle-file-list.c
index 3a9e9b8..172ea9a 100644
--- a/src/giggle-file-list.c
+++ b/src/giggle-file-list.c
@@ -711,19 +711,15 @@ file_list_edit_file (GtkAction *action,
{
GiggleFileListPriv *priv = GET_PRIV (list);
GList *selection, *l;
- GAppLaunchContext *context;
const char *dir;
- context = giggle_create_app_launch_context (GTK_WIDGET (list));
selection = giggle_file_list_get_selection (list);
dir = giggle_git_get_directory (priv->git);
for (l = selection; l; l = g_list_delete_link (l, l)) {
- giggle_open_file_with_context (context, dir, l->data);
+ giggle_open_file (GTK_WIDGET (list), dir, l->data);
g_free (l->data);
}
-
- g_object_unref (context);
}
static void
diff --git a/src/giggle-helpers.c b/src/giggle-helpers.c
index de8e61d..1d34798 100644
--- a/src/giggle-helpers.c
+++ b/src/giggle-helpers.c
@@ -163,31 +163,14 @@ giggle_ui_manager_get_action_group (GtkUIManager *manager,
return NULL;
}
-GAppLaunchContext *
-giggle_create_app_launch_context (GtkWidget *widget)
-{
- GdkAppLaunchContext *context;
- GdkScreen *screen = NULL;
-
- context = gdk_app_launch_context_new ();
-
- if (widget) {
- screen = gtk_widget_get_screen (widget);
- gdk_app_launch_context_set_screen (context, screen);
- }
-
- return G_APP_LAUNCH_CONTEXT (context);
-}
-
void
-giggle_open_file_with_context (GAppLaunchContext *context,
- const char *directory,
- const char *filename)
+giggle_open_file (GtkWidget *widget,
+ const char *directory,
+ const char *filename)
{
GError *error = NULL;
char *path, *uri;
- g_return_if_fail (G_IS_APP_LAUNCH_CONTEXT (context));
g_return_if_fail (NULL != filename);
if (!directory)
@@ -198,7 +181,10 @@ giggle_open_file_with_context (GAppLaunchContext *context,
path = g_build_filename (directory, filename, NULL);
uri = g_filename_to_uri (path, NULL, &error);
- if (!uri || !g_app_info_launch_default_for_uri (uri, context, &error)) {
+ gtk_show_uri (gtk_widget_get_screen (widget),
+ uri, gtk_get_current_event_time (),
+ &error);
+ if (error != NULL) {
g_warning ("%s: %s", G_STRFUNC, error->message);
g_clear_error (&error);
}
@@ -206,15 +192,3 @@ giggle_open_file_with_context (GAppLaunchContext *context,
g_free (path);
g_free (uri);
}
-
-void
-giggle_open_file (GtkWidget *widget,
- const char *directory,
- const char *filename)
-{
- GAppLaunchContext *context;
-
- context = giggle_create_app_launch_context (widget);
- giggle_open_file_with_context (context, directory, filename);
- g_object_unref (context);
-}
diff --git a/src/giggle-helpers.h b/src/giggle-helpers.h
index 2990ef8..8e2367e 100644
--- a/src/giggle-helpers.h
+++ b/src/giggle-helpers.h
@@ -36,12 +36,6 @@ gboolean giggle_tree_view_select_row_by_string (GtkWidget *tr
GtkActionGroup * giggle_ui_manager_get_action_group (GtkUIManager *manager,
const char *group_name);
-GAppLaunchContext * giggle_create_app_launch_context (GtkWidget *widget);
-
-void giggle_open_file_with_context (GAppLaunchContext *context,
- const char *directory,
- const char *filename);
-
void giggle_open_file (GtkWidget *widget,
const char *directory,
const char *filename);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]