3 * A file-manager extension which offers configurable context menu actions.
5 * Copyright (C) 2005 The GNOME Foundation
6 * Copyright (C) 2006-2008 Frederic Ruaudel and others (see AUTHORS)
7 * Copyright (C) 2009-2015 Pierre Wieser and others (see AUTHORS)
9 * FileManager-Actions is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * FileManager-Actions is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with FileManager-Actions; see the file COPYING. If not, see
21 * <http://www.gnu.org/licenses/>.
24 * Frederic Ruaudel <grumz@grumz.net>
25 * Rodrigo Moya <rodrigo@gnome-db.org>
26 * Pierre Wieser <pwieser@trychlos.org>
27 * ... and many others (see AUTHORS)
37 #include <api/fma-fm-defines.h>
39 #include "fma-tracker-plugin.h"
41 static void set_log_handler( void );
42 static void log_handler( const gchar
*log_domain
, GLogLevelFlags log_level
, const gchar
*message
, gpointer user_data
);
44 static GLogFunc st_default_log_func
= NULL
;
47 * A nautilus extension must implement three functions :
49 * - nautilus_module_initialize
50 * - nautilus_module_list_types
51 * - nautilus_module_shutdown
53 * The first two functions are called at nautilus startup.
55 * The prototypes for these functions are defined in nautilus-extension-types.h
59 #if FMA_TARGET_ID == NAUTILUS_ID
60 nautilus_module_initialize( GTypeModule
*module
)
61 #elif FMA_TARGET_ID == NEMO_ID
62 nemo_module_initialize( GTypeModule
*module
)
63 #elif FMA_TARGET_ID == CAJA_ID
64 caja_module_initialize( GTypeModule
*module
)
67 static const gchar
*thisfn
= "fma_tracker_module_" FMA_TARGET_LABEL
"_module_initialize";
69 syslog( LOG_USER
| LOG_INFO
, "[FMA] %s Tracker %s initializing...", PACKAGE_NAME
, PACKAGE_VERSION
);
73 g_debug( "%s: module=%p", thisfn
, ( void * ) module
);
75 g_type_module_set_name( module
, PACKAGE_STRING
);
77 fma_tracker_plugin_register_type( module
);
81 #if FMA_TARGET_ID == NAUTILUS_ID
82 nautilus_module_list_types( const GType
**types
, int *num_types
)
83 #elif FMA_TARGET_ID == NEMO_ID
84 nemo_module_list_types( const GType
**types
, int *num_types
)
85 #elif FMA_TARGET_ID == CAJA_ID
86 caja_module_list_types( const GType
**types
, int *num_types
)
89 static const gchar
*thisfn
= "fma_tracker_module_" FMA_TARGET_LABEL
"_module_list_types";
90 static GType type_list
[1];
92 g_debug( "%s: types=%p, num_types=%p", thisfn
, ( void * ) types
, ( void * ) num_types
);
94 type_list
[0] = FMA_TYPE_TRACKER_PLUGIN
;
100 #if FMA_TARGET_ID == NAUTILUS_ID
101 nautilus_module_shutdown( void )
102 #elif FMA_TARGET_ID == NEMO_ID
103 nemo_module_shutdown( void )
104 #elif FMA_TARGET_ID == CAJA_ID
105 caja_module_shutdown( void )
108 static const gchar
*thisfn
= "fma_tracker_module_" FMA_TARGET_LABEL
"_module_shutdown";
110 g_debug( "%s", thisfn
);
112 /* remove the log handler
113 * almost useless as the process is nonetheless terminating at this time
114 * but this is the art of coding...
116 if( st_default_log_func
){
117 g_log_set_default_handler( st_default_log_func
, NULL
);
118 st_default_log_func
= NULL
;
123 * a log handler that we install when in development mode in order to be
124 * able to log plugin runtime
125 * TODO: the debug flag should be dynamic, so that an advanced user could
126 * setup a given key and obtain a full log to send to Bugzilla..
127 * For now, is always install when compiled in maintainer mode, never else
130 set_log_handler( void )
132 st_default_log_func
= g_log_set_default_handler(( GLogFunc
) log_handler
, NULL
);
136 * we used to install a log handler for each and every log domain used
137 * in FileManager-Actions ; this led to a fastidious enumeration
138 * instead we install a default log handler which will receive all
139 * debug messages, i.e. not only from FMA, but also from other code
140 * in the Nautilus process
143 log_handler( const gchar
*log_domain
, GLogLevelFlags log_level
, const gchar
*message
, gpointer user_data
)
147 tmp
= g_strdup( "" );
148 if( log_domain
&& strlen( log_domain
)){
150 tmp
= g_strdup_printf( "[%s] ", log_domain
);
153 #ifdef FMA_MAINTAINER_MODE
154 /*( *st_default_log_func )( log_domain, log_level, message, user_data );*/
155 syslog( LOG_USER
| LOG_DEBUG
, "%s%s", tmp
, message
);
157 if( g_getenv( NAUTILUS_ACTIONS_DEBUG
)){
158 syslog( LOG_USER
| LOG_DEBUG
, "%s%s", tmp
, message
);