Define new 'pivot-prop-loadable' property
[nautilus-actions.git] / src / plugin-menu / nautilus-module.c
blobb83b52938dbe9e389fad84205ab9e32ea4d5e08e
1 /*
2 * Nautilus-Actions
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.
24 * Authors:
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)
31 #ifdef HAVE_CONFIG_H
32 #include <config.h>
33 #endif
35 #include <string.h>
36 #include <syslog.h>
37 #include <unistd.h>
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
62 void
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 );
69 set_log_handler();
71 g_debug( "%s: module=%p", thisfn, ( void * ) module );
73 g_type_module_set_name( module, PACKAGE_STRING );
75 /* pwi 2011-01-05
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 );
84 void
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;
93 *types = type_list;
94 *num_types = 1;
96 /* this may let us some time to attach nautilus to the debugger :) */
97 /*sleep( 60 ); */
100 void
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
121 static void
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
134 static void
135 log_handler( const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data )
137 gchar *tmp;
139 tmp = g_strdup( "" );
140 if( log_domain && strlen( log_domain )){
141 g_free( tmp );
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 );
148 #else
149 if( g_getenv( NAUTILUS_ACTIONS_DEBUG )){
150 syslog( LOG_USER | LOG_DEBUG, "%s%s", tmp, message );
152 #endif
154 g_free( tmp );