3 * A Nautilus extension which offers configurable context menu actions.
5 * Copyright (C) 2005 The GNOME Foundation
6 * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
7 * Copyright (C) 2009, 2010, 2011 Pierre Wieser and others (see AUTHORS)
9 * This Program 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 * This Program 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
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public
20 * License along with this Library; see the file COPYING. If not,
21 * write to the Free Software Foundation, Inc., 59 Temple Place,
22 * Suite 330, Boston, MA 02111-1307, USA.
25 * Frederic Ruaudel <grumz@grumz.net>
26 * Rodrigo Moya <rodrigo@gnome-db.org>
27 * Pierre Wieser <pwieser@trychlos.org>
28 * ... and many others (see AUTHORS)
39 #include <libnautilus-extension/nautilus-extension-types.h>
41 #include <core/na-gconf-migration.h>
43 #include "nautilus-actions.h"
45 static void set_log_handler( void );
46 static void log_handler( const gchar
*log_domain
, GLogLevelFlags log_level
, const gchar
*message
, gpointer user_data
);
48 static GLogFunc st_default_log_func
= NULL
;
51 * A nautilus extension must implement three functions :
53 * - nautilus_module_initialize
54 * - nautilus_module_list_types
55 * - nautilus_module_shutdown
57 * The first two functions are called at nautilus startup.
59 * The prototypes for these functions are defined in nautilus-extension-types.h
63 nautilus_module_initialize( GTypeModule
*module
)
65 static const gchar
*thisfn
= "nautilus_module_initialize";
67 syslog( LOG_USER
| LOG_INFO
, "[N-A] %s Menu Extender %s initializing...", PACKAGE_NAME
, PACKAGE_VERSION
);
71 g_debug( "%s: module=%p", thisfn
, ( void * ) module
);
73 g_type_module_set_name( module
, PACKAGE_STRING
);
76 * run GConf migration tools before doing anything else
77 * above all before allocating a new NAPivot
79 na_gconf_migration_run();
81 nautilus_actions_register_type( module
);
85 nautilus_module_list_types( const GType
**types
, int *num_types
)
87 static const gchar
*thisfn
= "nautilus_module_list_types";
88 static GType type_list
[1];
90 g_debug( "%s: types=%p, num_types=%p", thisfn
, ( void * ) types
, ( void * ) num_types
);
92 type_list
[0] = NAUTILUS_ACTIONS_TYPE
;
96 /* this may let us some time to attach nautilus to the debugger :) */
101 nautilus_module_shutdown( void )
103 static const gchar
*thisfn
= "nautilus_module_shutdown";
105 g_debug( "%s", thisfn
);
107 /* remove the log handler
108 * almost useless as the process is nonetheless terminating at this time
109 * but this is the art of coding...
111 if( st_default_log_func
){
112 g_log_set_default_handler( st_default_log_func
, NULL
);
113 st_default_log_func
= NULL
;
118 * a log handler that we install when in development mode in order to be
119 * able to log plugin runtime
122 set_log_handler( void )
124 st_default_log_func
= g_log_set_default_handler(( GLogFunc
) log_handler
, NULL
);
128 * we used to install a log handler for each and every log domain used
129 * in Nautilus-Actions ; this led to a fastidious enumeration
130 * instead we install a default log handler which will receive all
131 * debug messages, i.e. not only from N-A, but also from other code
132 * in the Nautilus process
135 log_handler( const gchar
*log_domain
, GLogLevelFlags log_level
, const gchar
*message
, gpointer user_data
)
139 tmp
= g_strdup( "" );
140 if( log_domain
&& strlen( log_domain
)){
142 tmp
= g_strdup_printf( "[%s] ", log_domain
);
145 #ifdef NA_MAINTAINER_MODE
146 /*( *st_default_log_func )( log_domain, log_level, message, user_data );*/
147 syslog( LOG_USER
| LOG_DEBUG
, "%s%s", tmp
, message
);
149 if( g_getenv( NAUTILUS_ACTIONS_DEBUG
)){
150 syslog( LOG_USER
| LOG_DEBUG
, "%s%s", tmp
, message
);