summaryrefslogtreecommitdiff
path: root/thunarx
diff options
context:
space:
mode:
authorBenedikt Meurer <benny@xfce.org>2005-11-29 17:28:56 +0000
committerBenedikt Meurer <benny@xfce.org>2005-11-29 17:28:56 +0000
commitf1883411d44c4435bc5527fff92201486d0d1d7a (patch)
tree22c78e33c2586f6fc991f1f4f0c51b9f9cc5a9bb /thunarx
parentfe6fede9b75018166e66a9a48d35c1196e704e44 (diff)
downloadthunar-f1883411d44c4435bc5527fff92201486d0d1d7a.tar.gz
2005-11-29 Benedikt Meurer <benny@xfce.org>
* thunar/thunar-standard-view.c (thunar_standard_view_merge_custom_actions): Fix typo. * thunarx/thunarx-private.{c,h}, thunarx/thunarx-menu-provider.c, thunarx/Makefile.am, thunarx/thunarx-property-page-provider.c: Add helper function thunarx_object_list_take_reference(), so we don't need to repeat the same code again and again. * thunar/thunar-window.c(action_entries): Add ... to the Preferences action, since it opens a dialog. Use "e" as mnemonic, as "P" is already used by "Paste". * thunar/thunar-standard-view.c(action_entries): Add ... to the Select by Pattern action, since it opens a dialog. * thunar/thunar-preferences-dialog.c: Close preferences dialog on Esc key press. * thunarx/thunarx-preferences-provider.{c,h}, thunarx/thunarx.h, thunarx/thunarx.symbols, thunarx/Makefile.am: Add new interface ThunarxPreferencesProvider, which can be implemented to add custom actions to the preferences section of the "Edit" menu. * thunar/thunar-window-ui.xml, thunar/thunar-window.c: Query custom preferences actions from the installed providers and add them to the preferences section of the "Edit" menu. Actions are loaded in an idle source to not delay folder loading when opening a new window, even if a lot of preferences providers are installed. * docs/reference/thunarx/: Update the thunarx reference documentation. * thunar-uca/, configure.in.in, Makefile.am: Import the thunar-uca module, which provides advanced users with an easy way to add custom actions to Thunar's context menus. With this extension in place there's no longer a need to add support G-Scripts (except maybe an importer for thunar-uca). * po/POTFILES.in: Add new translatable files. * po/: Merge new strings. * examples/tex-open-terminal/README: Add note to use thunar-uca, and consider the tex-open-terminal as example for extension writers. (Old svn revision: 18962)
Diffstat (limited to 'thunarx')
-rw-r--r--thunarx/Makefile.am3
-rw-r--r--thunarx/thunarx-menu-provider.c29
-rw-r--r--thunarx/thunarx-preferences-provider.c116
-rw-r--r--thunarx/thunarx-preferences-provider.h64
-rw-r--r--thunarx/thunarx-private.c53
-rw-r--r--thunarx/thunarx-private.h3
-rw-r--r--thunarx/thunarx-property-page-provider.c18
-rw-r--r--thunarx/thunarx.h1
-rw-r--r--thunarx/thunarx.symbols8
9 files changed, 260 insertions, 35 deletions
diff --git a/thunarx/Makefile.am b/thunarx/Makefile.am
index aa387843..e23dcae9 100644
--- a/thunarx/Makefile.am
+++ b/thunarx/Makefile.am
@@ -16,6 +16,7 @@ libthunarx_headers = \
thunarx-config.h \
thunarx-file-info.h \
thunarx-menu-provider.h \
+ thunarx-preferences-provider.h \
thunarx-property-page.h \
thunarx-property-page-provider.h \
thunarx-provider-factory.h \
@@ -36,6 +37,8 @@ libthunarx_1_la_SOURCES = \
thunarx-config.c \
thunarx-file-info.c \
thunarx-menu-provider.c \
+ thunarx-preferences-provider.c \
+ thunarx-private.c \
thunarx-private.h \
thunarx-property-page.c \
thunarx-property-page-provider.c \
diff --git a/thunarx/thunarx-menu-provider.c b/thunarx/thunarx-menu-provider.c
index 70f82a16..7c6f5f11 100644
--- a/thunarx/thunarx-menu-provider.c
+++ b/thunarx/thunarx-menu-provider.c
@@ -28,10 +28,6 @@
-static GQuark thunarx_menu_provider_action_quark;
-
-
-
GType
thunarx_menu_provider_get_type (void)
{
@@ -56,9 +52,6 @@ thunarx_menu_provider_get_type (void)
/* register the menu provider interface */
type = g_type_register_static (G_TYPE_INTERFACE, I_("ThunarxMenuProvider"), &info, 0);
g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
-
- /* allocate the thunarx-menu-provider-action quark */
- thunarx_menu_provider_action_quark = g_quark_from_static_string ("thunarx-menu-provider-action");
}
return type;
@@ -99,7 +92,6 @@ thunarx_menu_provider_get_file_actions (ThunarxMenuProvider *provider,
GList *files)
{
GList *actions;
- GList *lp;
g_return_val_if_fail (THUNARX_IS_MENU_PROVIDER (provider), NULL);
g_return_val_if_fail (GTK_IS_WINDOW (window), NULL);
@@ -107,13 +99,11 @@ thunarx_menu_provider_get_file_actions (ThunarxMenuProvider *provider,
if (THUNARX_MENU_PROVIDER_GET_IFACE (provider)->get_file_actions != NULL)
{
- /* query the actions and take a reference on the provider for each action */
+ /* query the actions from the implementation */
actions = (*THUNARX_MENU_PROVIDER_GET_IFACE (provider)->get_file_actions) (provider, window, files);
- for (lp = actions; lp != NULL; lp = lp->next)
- {
- g_object_set_qdata_full (G_OBJECT (lp->data), thunarx_menu_provider_action_quark, provider, g_object_unref);
- g_object_ref (G_OBJECT (provider));
- }
+
+ /* take a reference on the provider for each action */
+ thunarx_object_list_take_reference (actions, provider);
}
else
{
@@ -158,7 +148,6 @@ thunarx_menu_provider_get_folder_actions (ThunarxMenuProvider *provider,
ThunarxFileInfo *folder)
{
GList *actions;
- GList *lp;
g_return_val_if_fail (THUNARX_IS_MENU_PROVIDER (provider), NULL);
g_return_val_if_fail (GTK_IS_WINDOW (window), NULL);
@@ -167,13 +156,11 @@ thunarx_menu_provider_get_folder_actions (ThunarxMenuProvider *provider,
if (THUNARX_MENU_PROVIDER_GET_IFACE (provider)->get_folder_actions != NULL)
{
- /* query the actions and take a reference on the provider for each action */
+ /* query the actions from the implementation */
actions = (*THUNARX_MENU_PROVIDER_GET_IFACE (provider)->get_folder_actions) (provider, window, folder);
- for (lp = actions; lp != NULL; lp = lp->next)
- {
- g_object_set_qdata_full (G_OBJECT (lp->data), thunarx_menu_provider_action_quark, provider, g_object_unref);
- g_object_ref (G_OBJECT (provider));
- }
+
+ /* take a reference on the provider for each action */
+ thunarx_object_list_take_reference (actions, provider);
}
else
{
diff --git a/thunarx/thunarx-preferences-provider.c b/thunarx/thunarx-preferences-provider.c
new file mode 100644
index 00000000..3247b76c
--- /dev/null
+++ b/thunarx/thunarx-preferences-provider.c
@@ -0,0 +1,116 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <thunarx/thunarx-preferences-provider.h>
+#include <thunarx/thunarx-private.h>
+#include <thunarx/thunarx-alias.h>
+
+
+
+GType
+thunarx_preferences_provider_get_type (void)
+{
+ static GType type = G_TYPE_INVALID;
+
+ if (G_UNLIKELY (type == G_TYPE_INVALID))
+ {
+ static const GTypeInfo info =
+ {
+ sizeof (ThunarxPreferencesProviderIface),
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ 0,
+ NULL,
+ NULL,
+ };
+
+ /* register the preferences provider interface */
+ type = g_type_register_static (G_TYPE_INTERFACE, I_("ThunarxPreferencesProvider"), &info, 0);
+ g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
+ }
+
+ return type;
+}
+
+
+
+/**
+ * thunarx_preferences_provider_get_actions:
+ * @provider : a #ThunarxPreferencesProvider.
+ * @window : the #GtkWindow within which the actions will be used.
+ *
+ * Returns the list of #GtkAction<!---->s that @provider has to offer
+ * as preferences within @window. These actions will usually be added
+ * to the builtin list of preferences in the "Edit" menu of the file
+ * manager's @window.
+ *
+ * Plugin writers that implement this interface should make sure to
+ * choose descriptive action names and tooltips, and not to crowd the
+ * "Edit" menu too much. That said, think twice before implementing
+ * this interface, as too many preference actions will render the
+ * file manager useless over time!
+ *
+ * The caller is responsible to free the returned list of actions using
+ * something like this when no longer needed:
+ * <informalexample><programlisting>
+ * g_list_foreach (list, (GFunc) g_object_unref, NULL);
+ * g_list_free (list);
+ * </programlisting></informalexample>
+ *
+ * Return value: the list of #GtkAction<!---->s that @provider has
+ * to offer as preferences within @window.
+ **/
+GList*
+thunarx_preferences_provider_get_actions (ThunarxPreferencesProvider *provider,
+ GtkWidget *window)
+{
+ GList *actions;
+
+ g_return_val_if_fail (THUNARX_IS_PREFERENCES_PROVIDER (provider), NULL);
+ g_return_val_if_fail (GTK_IS_WINDOW (window), NULL);
+
+ if (THUNARX_PREFERENCES_PROVIDER_GET_IFACE (provider)->get_actions != NULL)
+ {
+ /* query the actions from the implementation */
+ actions = (*THUNARX_PREFERENCES_PROVIDER_GET_IFACE (provider)->get_actions) (provider, window);
+
+ /* take a reference on the provider for each action */
+ thunarx_object_list_take_reference (actions, provider);
+ }
+ else
+ {
+ actions = NULL;
+ }
+
+ return actions;
+}
+
+
+
+#define __THUNARX_PREFERENCES_PROVIDER_C__
+#include <thunarx/thunarx-aliasdef.c>
diff --git a/thunarx/thunarx-preferences-provider.h b/thunarx/thunarx-preferences-provider.h
new file mode 100644
index 00000000..669afdf6
--- /dev/null
+++ b/thunarx/thunarx-preferences-provider.h
@@ -0,0 +1,64 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if !defined(THUNARX_INSIDE_THUNARX_H) && !defined(THUNARX_COMPILATION)
+#error "Only <thunarx/thunarx.h> can be included directly, this file may disappear or change contents"
+#endif
+
+#ifndef __THUNARX_PREFERENCES_PROVIDER_H__
+#define __THUNARX_PREFERENCES_PROVIDER_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS;
+
+typedef struct _ThunarxPreferencesProviderIface ThunarxPreferencesProviderIface;
+typedef struct _ThunarxPreferencesProvider ThunarxPreferencesProvider;
+
+#define THUNARX_TYPE_PREFERENCES_PROVIDER (thunarx_preferences_provider_get_type ())
+#define THUNARX_PREFERENCES_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNARX_TYPE_PREFERENCES_PROVIDER, ThunarxPreferencesProvider))
+#define THUNARX_IS_PREFERENCES_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THUNARX_TYPE_PREFERENCES_PROVIDER))
+#define THUNARX_PREFERENCES_PROVIDER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), THUNARX_TYPE_PREFERENCES_PROVIDER, ThunarxPreferencesProviderIface))
+
+struct _ThunarxPreferencesProviderIface
+{
+ /*< private >*/
+ GTypeInterface __parent__;
+
+ /*< public >*/
+ GList *(*get_actions) (ThunarxPreferencesProvider *provider,
+ GtkWidget *window);
+
+ /*< private >*/
+ void (*reserved1) (void);
+ void (*reserved2) (void);
+ void (*reserved3) (void);
+ void (*reserved4) (void);
+ void (*reserved5) (void);
+};
+
+GType thunarx_preferences_provider_get_type (void) G_GNUC_CONST;
+
+GList *thunarx_preferences_provider_get_actions (ThunarxPreferencesProvider *provider,
+ GtkWidget *window);
+
+G_END_DECLS;
+
+#endif /* !__THUNARX_PREFERENCES_PROVIDER_H__ */
diff --git a/thunarx/thunarx-private.c b/thunarx/thunarx-private.c
new file mode 100644
index 00000000..854a4cb3
--- /dev/null
+++ b/thunarx/thunarx-private.c
@@ -0,0 +1,53 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib-object.h>
+
+#include <thunarx/thunarx-private.h>
+
+
+
+static GQuark thunarx_object_list_quark = 0;
+
+
+
+/* takes a reference on target for each object in object_list */
+void
+thunarx_object_list_take_reference (GList *object_list,
+ gpointer target)
+{
+ GList *lp;
+
+ /* allocate the "thunarx-object-list" quark on-demand */
+ if (G_UNLIKELY (thunarx_object_list_quark == 0))
+ thunarx_object_list_quark = g_quark_from_static_string ("thunarx-object-list");
+
+ for (lp = object_list; lp != NULL; lp = lp->next)
+ {
+ g_object_set_qdata_full (lp->data, thunarx_object_list_quark, target, g_object_unref);
+ g_object_ref (target);
+ }
+}
+
+
diff --git a/thunarx/thunarx-private.h b/thunarx/thunarx-private.h
index 2f2d4ac4..809a7471 100644
--- a/thunarx/thunarx-private.h
+++ b/thunarx/thunarx-private.h
@@ -35,6 +35,9 @@ G_BEGIN_DECLS;
#define I_(string) (g_quark_to_string (g_quark_from_static_string ((string))))
#endif
+void thunarx_object_list_take_reference (GList *object_list,
+ gpointer target) G_GNUC_INTERNAL;
+
G_END_DECLS;
#endif /* !__THUNARX_PRIVATE_H__ */
diff --git a/thunarx/thunarx-property-page-provider.c b/thunarx/thunarx-property-page-provider.c
index 06aa0d53..d45f3caf 100644
--- a/thunarx/thunarx-property-page-provider.c
+++ b/thunarx/thunarx-property-page-provider.c
@@ -28,10 +28,6 @@
-static GQuark thunarx_property_page_quark;
-
-
-
GType
thunarx_property_page_provider_get_type (void)
{
@@ -56,9 +52,6 @@ thunarx_property_page_provider_get_type (void)
/* register the property page provider interface */
type = g_type_register_static (G_TYPE_INTERFACE, I_("ThunarxPropertyPageProvider"), &info, 0);
g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
-
- /* allocate the thunarx-property-page quark */
- thunarx_property_page_quark = g_quark_from_static_string ("thunarx-property-page");
}
return type;
@@ -98,20 +91,17 @@ thunarx_property_page_provider_get_pages (ThunarxPropertyPageProvider *provider,
GList *files)
{
GList *pages;
- GList *lp;
g_return_val_if_fail (THUNARX_IS_PROPERTY_PAGE_PROVIDER (provider), NULL);
g_return_val_if_fail (files != NULL, NULL);
if (THUNARX_PROPERTY_PAGE_PROVIDER_GET_IFACE (provider)->get_pages != NULL)
{
- /* query the property pages and take a reference on the provider for each page */
+ /* query the property pages from the implementation */
pages = (*THUNARX_PROPERTY_PAGE_PROVIDER_GET_IFACE (provider)->get_pages) (provider, files);
- for (lp = pages; lp != NULL; lp = lp->next)
- {
- g_object_set_qdata_full (G_OBJECT (lp->data), thunarx_property_page_quark, provider, g_object_unref);
- g_object_ref (G_OBJECT (provider));
- }
+
+ /* take a reference on the provider for each page */
+ thunarx_object_list_take_reference (pages, provider);
}
else
{
diff --git a/thunarx/thunarx.h b/thunarx/thunarx.h
index 9557585e..eca7bba3 100644
--- a/thunarx/thunarx.h
+++ b/thunarx/thunarx.h
@@ -26,6 +26,7 @@
#include <thunarx/thunarx-config.h>
#include <thunarx/thunarx-file-info.h>
#include <thunarx/thunarx-menu-provider.h>
+#include <thunarx/thunarx-preferences-provider.h>
#include <thunarx/thunarx-property-page.h>
#include <thunarx/thunarx-property-page-provider.h>
#include <thunarx/thunarx-provider-factory.h>
diff --git a/thunarx/thunarx.symbols b/thunarx/thunarx.symbols
index 86d040e0..870cf7c3 100644
--- a/thunarx/thunarx.symbols
+++ b/thunarx/thunarx.symbols
@@ -70,6 +70,14 @@ thunarx_menu_provider_get_folder_actions
#endif
#endif
+/* ThunarxPreferencesProvider methods */
+#if IN_HEADER(__THUNARX_PREFERENCES_PROVIDER_H__)
+#if IN_SOURCE(__THUNARX_PREFERENCES_PROVIDER_C__)
+thunarx_preferences_provider_get_type G_GNUC_CONST
+thunarx_preferences_provider_get_actions
+#endif
+#endif
+
/* ThunarxPropertyPage methods */
#if IN_HEADER(__THUNARX_PROPERTY_PAGE_H__)
#if IN_SOURCE(__THUNARX_PROPERTY_PAGE_C__)