[gnome-builder] nautilus: add helper to select file in nautilus window
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] nautilus: add helper to select file in nautilus window
- Date: Thu, 9 Apr 2015 00:09:41 +0000 (UTC)
commit 03ae02defb8b35b58a397bc0ad6249d178b6ef8d
Author: Christian Hergert <christian hergert me>
Date: Wed Apr 8 02:11:03 2015 -0700
nautilus: add helper to select file in nautilus window
src/gnome-builder.mk | 2 +
src/util/gb-nautilus.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++
src/util/gb-nautilus.h | 33 +++++++++++++++++++++++
3 files changed, 104 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-builder.mk b/src/gnome-builder.mk
index 395f131..ce786e6 100644
--- a/src/gnome-builder.mk
+++ b/src/gnome-builder.mk
@@ -120,6 +120,8 @@ libgnome_builder_la_SOURCES = \
src/util/gb-glib.h \
src/util/gb-gtk.c \
src/util/gb-gtk.h \
+ src/util/gb-nautilus.c \
+ src/util/gb-nautilus.h \
src/util/gb-pango.c \
src/util/gb-pango.h \
src/util/gb-rgba.c \
diff --git a/src/util/gb-nautilus.c b/src/util/gb-nautilus.c
new file mode 100644
index 0000000..d4e7fca
--- /dev/null
+++ b/src/util/gb-nautilus.c
@@ -0,0 +1,69 @@
+/* gb-nautilus.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gb-nautilus.h"
+
+gboolean
+gb_nautilus_select_file (GtkWidget *widget,
+ GFile *file,
+ guint32 user_time)
+{
+ GdkAppLaunchContext *launch_context;
+ GdkDisplay *display;
+ GdkScreen *screen;
+ GAppInfo *app_info;
+ GList *files = NULL;
+ gboolean ret;
+
+ /*
+ * FIXME:
+ *
+ * Currently, this will select the file in the parent folder. But it does not
+ * work for selecting a folder within a parent folder.
+ */
+
+ g_return_val_if_fail (!widget || GTK_IS_WIDGET (widget), FALSE);
+ g_return_val_if_fail (G_IS_FILE (file), FALSE);
+
+ app_info = g_app_info_get_default_for_type ("inode/directory", FALSE);
+
+ if (widget)
+ {
+ display = gtk_widget_get_display (widget);
+ screen = gtk_widget_get_screen (widget);
+ }
+ else
+ {
+ display = gdk_display_get_default ();
+ screen = gdk_screen_get_default ();
+ }
+
+ launch_context = gdk_display_get_app_launch_context (display);
+ gdk_app_launch_context_set_screen (launch_context, screen);
+ gdk_app_launch_context_set_timestamp (launch_context, user_time);
+
+ files = g_list_prepend (files, file);
+
+ ret = g_app_info_launch (app_info, files, G_APP_LAUNCH_CONTEXT (launch_context), NULL);
+
+ g_list_free (files);
+ g_object_unref (launch_context);
+ g_object_unref (app_info);
+
+ return ret;
+}
diff --git a/src/util/gb-nautilus.h b/src/util/gb-nautilus.h
new file mode 100644
index 0000000..fcd7ade
--- /dev/null
+++ b/src/util/gb-nautilus.h
@@ -0,0 +1,33 @@
+/* gb-nautilus.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GB_NAUTILUS_H
+#define GB_NAUTILUS_H
+
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+gboolean gb_nautilus_select_file (GtkWidget *widget,
+ GFile *file,
+ guint32 user_time);
+
+G_END_DECLS
+
+#endif /* GB_NAUTILUS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]