[nautilus-actions] Allow plugin debug from user preference
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Allow plugin debug from user preference
- Date: Thu, 24 Feb 2011 00:50:25 +0000 (UTC)
commit 44e161d0add2f7d3b58ab98c0ccb957c606edce0
Author: Pierre Wieser <pwieser trychlos org>
Date: Thu Feb 24 01:49:41 2011 +0100
Allow plugin debug from user preference
ChangeLog | 10 ++++++++++
src/core/na-settings.c | 1 +
src/core/na-settings.h | 1 +
src/plugin-menu/nautilus-actions.c | 29 ++++++++++++++++++++++++++---
src/plugin-menu/nautilus-actions.h | 6 ++++--
src/plugin-menu/nautilus-module.c | 2 +-
6 files changed, 43 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e128113..55c13d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2011-02-23 Pierre Wieser <pwieser trychlos org>
+ * src/core/na-settings.c:
+ * src/core/na-settings.h: Define a new NA_IPREFS_PLUGIN_LOG user preference.
+
+ * src/plugin-menu/nautilus-actions.c:
+ * src/plugin-menu/nautilus-actions.h (nautilus_action_is_log_enabled):
+ New function.
+
+ * src/plugin-menu/nautilus-module.c (log_handler): Send debug trace to
+ syslog if the NA_IPREFS_PLUGIN_LOG preference is set.
+
* configure.ac: Bump Nautilus required version to 2.16
for having nautilus_menu_provider_emit_items_updated_signal() function.
diff --git a/src/core/na-settings.c b/src/core/na-settings.c
index 6a044e2..21e819e 100644
--- a/src/core/na-settings.c
+++ b/src/core/na-settings.c
@@ -151,6 +151,7 @@ static const KeyDef st_def_keys[] = {
{ NA_IPREFS_MAIN_TOOLBAR_TOOLS_DISPLAY, GROUP_NACT, NA_DATA_TYPE_BOOLEAN, "false" },
{ NA_IPREFS_MAIN_WINDOW_WSP, GROUP_NACT, NA_DATA_TYPE_UINT_LIST, "" },
{ NA_IPREFS_PREFERENCES_WSP, GROUP_NACT, NA_DATA_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_PLUGIN_LOG, GROUP_RUNTIME, NA_DATA_TYPE_BOOLEAN, "false" },
{ NA_IPREFS_RELABEL_DUPLICATE_ACTION, GROUP_NACT, NA_DATA_TYPE_BOOLEAN, "false" },
{ NA_IPREFS_RELABEL_DUPLICATE_MENU, GROUP_NACT, NA_DATA_TYPE_BOOLEAN, "false" },
{ NA_IPREFS_RELABEL_DUPLICATE_PROFILE, GROUP_NACT, NA_DATA_TYPE_BOOLEAN, "false" },
diff --git a/src/core/na-settings.h b/src/core/na-settings.h
index ac4b468..f00ea6c 100644
--- a/src/core/na-settings.h
+++ b/src/core/na-settings.h
@@ -141,6 +141,7 @@ GType na_settings_get_type( void );
#define NA_IPREFS_MAIN_TOOLBAR_TOOLS_DISPLAY "main-toolbar-tools-display"
#define NA_IPREFS_MAIN_WINDOW_WSP "main-window-wsp"
#define NA_IPREFS_PREFERENCES_WSP "preferences-wsp"
+#define NA_IPREFS_PLUGIN_LOG "log-enabled"
#define NA_IPREFS_RELABEL_DUPLICATE_ACTION "relabel-when-duplicate-action"
#define NA_IPREFS_RELABEL_DUPLICATE_MENU "relabel-when-duplicate-menu"
#define NA_IPREFS_RELABEL_DUPLICATE_PROFILE "relabel-when-duplicate-profile"
diff --git a/src/plugin-menu/nautilus-actions.c b/src/plugin-menu/nautilus-actions.c
index 7b68cab..1fe170a 100644
--- a/src/plugin-menu/nautilus-actions.c
+++ b/src/plugin-menu/nautilus-actions.c
@@ -67,9 +67,12 @@ struct _NautilusActionsPrivate {
NATimeout change_timeout;
};
-static GObjectClass *st_parent_class = NULL;
-static GType st_actions_type = 0;
-static gint st_burst_timeout = 100; /* burst timeout in msec */
+static GObjectClass *st_parent_class = NULL;
+static GType st_actions_type = 0;
+static gint st_burst_timeout = 100; /* burst timeout in msec */
+
+/* used in order to be able to get settings from the module */
+static NautilusActions *st_plugin = NULL;
static void class_init( NautilusActionsClass *klass );
static void instance_init( GTypeInstance *instance, gpointer klass );
@@ -187,6 +190,7 @@ instance_init( GTypeInstance *instance, gpointer klass )
thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ), ( void * ) klass );
self = NAUTILUS_ACTIONS( instance );
+ st_plugin = self;
self->private = g_new0( NautilusActionsPrivate, 1 );
@@ -273,6 +277,7 @@ instance_dispose( GObject *object )
if( !self->private->dispose_has_run ){
self->private->dispose_has_run = TRUE;
+ st_plugin = NULL;
if( self->private->items_changed_handler ){
g_signal_handler_disconnect( self->private->pivot, self->private->items_changed_handler );
@@ -321,6 +326,24 @@ iabout_get_application_name( NAIAbout *instance )
return( g_strdup( _( "Nautilus-Actions" )));
}
+gboolean
+nautilus_action_is_log_enabled( void )
+{
+ gboolean log_ok;
+ NASettings *settings;
+
+ log_ok = FALSE;
+
+ if( st_plugin ){
+ g_return_val_if_fail( NAUTILUS_IS_ACTIONS( st_plugin ), FALSE );
+
+ settings = na_pivot_get_settings( st_plugin->private->pivot );
+ log_ok = na_settings_get_boolean( settings, NA_IPREFS_PLUGIN_LOG, NULL, NULL );
+ }
+
+ return( log_ok );
+}
+
static void
menu_provider_iface_init( NautilusMenuProviderIface *iface )
{
diff --git a/src/plugin-menu/nautilus-actions.h b/src/plugin-menu/nautilus-actions.h
index 78e3e1a..adfaede 100644
--- a/src/plugin-menu/nautilus-actions.h
+++ b/src/plugin-menu/nautilus-actions.h
@@ -69,8 +69,10 @@ typedef struct {
}
NautilusActionsClass;
-GType nautilus_actions_get_type ( void );
-void nautilus_actions_register_type( GTypeModule *module );
+GType nautilus_actions_get_type ( void );
+void nautilus_actions_register_type( GTypeModule *module );
+
+gboolean nautilus_action_is_log_enabled( void );
G_END_DECLS
diff --git a/src/plugin-menu/nautilus-module.c b/src/plugin-menu/nautilus-module.c
index b83b529..cbda460 100644
--- a/src/plugin-menu/nautilus-module.c
+++ b/src/plugin-menu/nautilus-module.c
@@ -146,7 +146,7 @@ log_handler( const gchar *log_domain, GLogLevelFlags log_level, const gchar *mes
/*( *st_default_log_func )( log_domain, log_level, message, user_data );*/
syslog( LOG_USER | LOG_DEBUG, "%s%s", tmp, message );
#else
- if( g_getenv( NAUTILUS_ACTIONS_DEBUG )){
+ if( g_getenv( NAUTILUS_ACTIONS_DEBUG ) || nautilus_actions_is_log_enabled()){
syslog( LOG_USER | LOG_DEBUG, "%s%s", tmp, message );
}
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]