summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2010-01-14 00:27:48 +0100
committerGravatar Martin Szulecki2010-01-14 01:00:07 +0100
commita340c7548c33018798021b6f71d25e6761eaf6a0 (patch)
treed02314f230651f87a765c0a4794ece2df5913c87
parentc9b0721d65834ab6cf22453c39d6b9e97bd9db25 (diff)
downloadsbmanager-a340c7548c33018798021b6f71d25e6761eaf6a0.tar.gz
sbmanager-a340c7548c33018798021b6f71d25e6761eaf6a0.tar.bz2
nautilus-sbmanager: adds a 'launch sbmanager' entry to nautilus' context menu
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac7
-rw-r--r--nautilus/Makefile.am22
-rw-r--r--nautilus/nautilus-sbmanager.c180
-rw-r--r--nautilus/nautilus-sbmanager.h54
-rw-r--r--nautilus/nautilus-sbmgr.c57
-rw-r--r--po/POTFILES.in1
-rw-r--r--po/de.po8
8 files changed, 330 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 0e07060..2a7ff6f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
AUTOMAKE_OPTIONS = foreign
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = data src po
+SUBDIRS = data src po nautilus
diff --git a/configure.ac b/configure.ac
index d7136b0..e51c454 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,7 @@ PKG_CHECK_MODULES(libclutter, clutter-1.0 >= 1.0.6)
PKG_CHECK_MODULES(libcluttergtk, clutter-gtk-0.10 >= 0.10)
PKG_CHECK_MODULES(libgtk, gtk+-2.0 >= 2.16)
PKG_CHECK_MODULES(libgdkpixbuf, gdk-pixbuf-2.0 >= 2.16)
+PKG_CHECK_MODULES(libnautilusextension, libnautilus-extension >= 2.21.2)
# Checks for header files.
AC_HEADER_STDC
@@ -44,6 +45,11 @@ AC_CHECK_FUNCS([strcasecmp strdup strerror strndup])
AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -Werror")
AC_SUBST(GLOBAL_CFLAGS)
+# Get nautilus extensions directory
+
+NAUTILUS_EXTENSION_DIR=`$PKG_CONFIG --variable=extensiondir libnautilus-extension`
+AC_SUBST(NAUTILUS_EXTENSION_DIR)
+
# i18n
GETTEXT_PACKAGE=sbmanager
@@ -59,5 +65,6 @@ Makefile
data/Makefile
src/Makefile
po/Makefile.in
+nautilus/Makefile
])
diff --git a/nautilus/Makefile.am b/nautilus/Makefile.am
new file mode 100644
index 0000000..8a43af8
--- /dev/null
+++ b/nautilus/Makefile.am
@@ -0,0 +1,22 @@
+INCLUDES = \
+ -DG_LOG_DOMAIN=\"Nautilus-SBManager\" \
+ -DDATADIR=\"$(datadir)\" \
+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
+ -I$(top_srcdir) \
+ -I$(top_builddir) \
+ -Werror \
+ $(libglib2_CFLAGS) \
+ $(libgtk_CFLAGS) \
+ $(libnautilusextension_CFLAGS)
+
+nautilus_extensiondir=$(NAUTILUS_EXTENSION_DIR)
+
+nautilus_extension_LTLIBRARIES=libnautilus-sbmanager.la
+
+libnautilus_sbmanager_la_SOURCES = \
+ nautilus-sbmanager.h \
+ nautilus-sbmanager.c \
+ nautilus-sbmgr.c
+
+libnautilus_sbmanager_la_LDFLAGS = -module -avoid-version
+libnautilus_sbmanager_la_LIBADD = $(libglib2_LIBS) $(libgtk_LIBS) $(libnautilusextension_LIBS)
diff --git a/nautilus/nautilus-sbmanager.c b/nautilus/nautilus-sbmanager.c
new file mode 100644
index 0000000..302d98e
--- /dev/null
+++ b/nautilus/nautilus-sbmanager.c
@@ -0,0 +1,180 @@
+/*
+ * nautilus-sbmanager.c
+ *
+ * Copyright (C) 2010 Nikias Bassen <nikias@gmx.li>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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 2 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 profile.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+#ifdef HAVE_CONFIG_H
+ #include <config.h> /* for GETTEXT_PACKAGE */
+#endif
+
+#include "nautilus-sbmanager.h"
+
+#include <libnautilus-extension/nautilus-menu-provider.h>
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h> /* for atoi */
+#include <string.h> /* for strcmp */
+#include <unistd.h> /* for chdir */
+#include <sys/stat.h>
+
+static void nautilus_sbmanager_instance_init (NautilusSBManager *cvs);
+static void nautilus_sbmanager_class_init (NautilusSBManagerClass *class);
+
+static GType sbmanager_type = 0;
+
+static void launch_sbmanager (NautilusMenuItem *item)
+{
+ GdkScreen *screen;
+ GError *error = NULL;
+ gchar *argvp[4] = {(char*)"sbmanager", (char*)"-u", NULL, NULL};
+ argvp[2] = g_object_get_data (G_OBJECT (item), "NautilusSBManager::uuid");
+
+ screen = g_object_get_data (G_OBJECT (item), "NautilusSBManager::screen");
+ gdk_spawn_on_screen(screen, NULL, argvp, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error);
+ if (error) {
+ g_error_free(error);
+ }
+}
+
+static void launch_sbmanager_callback (NautilusMenuItem *item, const char *uuid)
+{
+ launch_sbmanager (item);
+}
+
+static NautilusMenuItem *launch_sbmanager_menu_item_new (const char *uuid, GdkScreen *screen)
+{
+ NautilusMenuItem *ret = NULL;
+ char *action_name = g_strdup_printf("NautilusSBManager::launch_sbmanager");
+ const char *name = _("Manage _SpringBoard");
+ const char *tooltip = _("Launch SBManager to manage the SpringBoard of this device");
+
+ ret = nautilus_menu_item_new (action_name, name, tooltip, "phone-apple-iphone");
+ g_free (action_name);
+
+ g_object_set_data (G_OBJECT (ret),
+ "NautilusSBManager::screen",
+ screen);
+ g_object_set_data (G_OBJECT (ret),
+ "NautilusSBManager::uuid",
+ (gpointer)g_strdup(uuid));
+ g_signal_connect (ret, "activate",
+ G_CALLBACK (launch_sbmanager_callback),
+ NULL);
+
+ return ret;
+}
+
+GList *
+nautilus_launch_sbmanager_get_file_items (NautilusMenuProvider *provider,
+ GtkWidget *window,
+ GList *files)
+{
+ gchar *uri;
+ gchar *uri_scheme;
+ GList *items;
+ NautilusMenuItem *item;
+
+ if (g_list_length (files) != 1
+ || ((nautilus_file_info_get_file_type (files->data) != G_FILE_TYPE_SHORTCUT)
+ && (nautilus_file_info_get_file_type (files->data) != G_FILE_TYPE_MOUNTABLE))) {
+ return NULL;
+ }
+
+ items = NULL;
+ uri = nautilus_file_info_get_activation_uri (files->data);
+ uri_scheme = g_uri_parse_scheme (uri);
+ if ((strcmp(uri_scheme, "afc") == 0) && g_find_program_in_path("sbmanager")) {
+ gchar *uuid = g_strndup(uri + 6, 40);
+ item = launch_sbmanager_menu_item_new (uuid, gtk_widget_get_screen (window));
+ g_free(uuid);
+ items = g_list_append (items, item);
+ }
+ g_free(uri_scheme);
+ g_free (uri);
+
+ return items;
+}
+
+static void
+nautilus_launch_sbmanager_menu_provider_iface_init (NautilusMenuProviderIface *iface)
+{
+ iface->get_background_items = NULL;
+ iface->get_file_items = nautilus_launch_sbmanager_get_file_items;
+}
+
+static void
+nautilus_sbmanager_instance_init (NautilusSBManager *cvs)
+{
+}
+
+static void
+nautilus_sbmanager_class_init (NautilusSBManagerClass *class)
+{
+}
+
+static void
+nautilus_sbmanager_class_finalize (NautilusSBManagerClass *class)
+{
+}
+
+GType
+nautilus_sbmanager_get_type (void)
+{
+ return sbmanager_type;
+}
+
+void
+nautilus_sbmanager_register_type (GTypeModule *module)
+{
+ static const GTypeInfo info = {
+ sizeof (NautilusSBManagerClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) nautilus_sbmanager_class_init,
+ (GClassFinalizeFunc) nautilus_sbmanager_class_finalize,
+ NULL,
+ sizeof (NautilusSBManager),
+ 0,
+ (GInstanceInitFunc) nautilus_sbmanager_instance_init,
+ NULL
+ };
+
+ static const GInterfaceInfo menu_provider_iface_info = {
+ (GInterfaceInitFunc) nautilus_launch_sbmanager_menu_provider_iface_init,
+ NULL,
+ NULL
+ };
+
+ sbmanager_type = g_type_module_register_type (module,
+ G_TYPE_OBJECT,
+ "NautilusSBManager",
+ &info, 0);
+
+ g_type_module_add_interface (module,
+ sbmanager_type,
+ NAUTILUS_TYPE_MENU_PROVIDER,
+ &menu_provider_iface_info);
+}
diff --git a/nautilus/nautilus-sbmanager.h b/nautilus/nautilus-sbmanager.h
new file mode 100644
index 0000000..d3179f8
--- /dev/null
+++ b/nautilus/nautilus-sbmanager.h
@@ -0,0 +1,54 @@
+/*
+ * nautilus-sbmanager.h
+ *
+ * Copyright (C) 2010 Nikias Bassen <nikias@gmx.li>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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 2 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 profile.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+#ifndef NAUTILUS_SBMANAGER_H
+#define NAUTILUS_SBMANAGER_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* Declarations for the open terminal extension object. This object will be
+ * instantiated by nautilus. It implements the GInterfaces
+ * exported by libnautilus. */
+
+
+#define NAUTILUS_TYPE_SBMANAGER (nautilus_sbmanager_get_type ())
+#define NAUTILUS_SBMANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NAUTILUS_TYPE_SBMANAGER, NautilusSBManager))
+#define NAUTILUS_IS_SBMANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NAUTILUS_TYPE_SBMANAGER))
+typedef struct _NautilusSBManager NautilusSBManager;
+typedef struct _NautilusSBManagerClass NautilusSBManagerClass;
+
+struct _NautilusSBManager {
+ GObject parent_slot;
+};
+
+struct _NautilusSBManagerClass {
+ GObjectClass parent_slot;
+};
+
+GType nautilus_sbmanager_get_type (void);
+void nautilus_sbmanager_register_type (GTypeModule *module);
+
+G_END_DECLS
+
+#endif
diff --git a/nautilus/nautilus-sbmgr.c b/nautilus/nautilus-sbmgr.c
new file mode 100644
index 0000000..7bff0d0
--- /dev/null
+++ b/nautilus/nautilus-sbmgr.c
@@ -0,0 +1,57 @@
+/*
+ * nautilus-sbmgr.c
+ *
+ * Copyright (C) 2010 Nikias Bassen <nikias@gmx.li>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * 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 2 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 profile.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+
+#include "nautilus-sbmanager.h"
+
+#include <libintl.h>
+
+static GType type_list[1];
+
+void nautilus_module_initialize (GTypeModule *module);
+void nautilus_module_shutdown (void);
+void nautilus_module_list_types (const GType **types, int *num_types);
+
+void nautilus_module_initialize (GTypeModule *module)
+{
+ g_print ("Initializing nautilus-sbmanager extension\n");
+
+ nautilus_sbmanager_register_type (module);
+ type_list[0] = NAUTILUS_TYPE_SBMANAGER;
+
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+}
+
+void nautilus_module_shutdown (void)
+{
+ g_print ("Shutting down nautilus-sbmanager extension\n");
+}
+
+void nautilus_module_list_types (const GType **types, int *num_types)
+{
+ *types = type_list;
+ *num_types = G_N_ELEMENTS (type_list);
+}
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c631583..7123164 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,3 +1,4 @@
# List of source files containing translatable strings.
# Please keep this list in alphabetic order.
+nautilus/nautilus-sbmanager.c
src/sbmanager.c
diff --git a/po/de.po b/po/de.po
index 92f9e74..c5471be 100644
--- a/po/de.po
+++ b/po/de.po
@@ -15,6 +15,14 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
+#: ../nautilus/nautilus-sbmanager.c:71
+msgid "Manage _SpringBoard"
+msgstr "_SpringBoard bearbeiten"
+
+#: ../nautilus/nautilus-sbmanager.c:72
+msgid "Launch SBManager to manage the SpringBoard of this device"
+msgstr "Startet SBManager mit dem Sie das SpringBoard dieses Gerätes bearbeiten können"
+
#: ../src/sbmanager.c:1336
msgid "Upload changes to device"
msgstr "Änderungen auf das Gerät übertragen"