Commit 2e66aed1 authored by Pierre Wieser's avatar Pierre Wieser

Rearchitecturing the code

parent c8c54a8c
2009-09-16 Pierre Wieser <pwieser@trychlos.org>
* configure.ac:
Remove NAUTILUS_ACTIONS_CONFIG_GCONF_BASEDIR (not a configuration
variable).
* src/common/na-action.c: Renamed as na-obj-action.c.
* src/common/na-action.h: Renamed as na-obj-action.h.
* src/common/na-action-class.h: Renamed as na-obj-action-class.h.
Takes part of renaming NAAction class to NAObjectAction.
* src/common/na-action-profile.c: Renamed as na-obj-profile.c.
* src/common/na-action-profile.h: Renamed as na-obj-profile.h.
* src/common/na-action-profile-class.h:
Renamed as na-obj-profile-class.h.
Takes part of renaming NAActionProfile class to NAObjectProfile.
* src/common/na-action-menu.c: Renamed as na-obj-menu.c.
* src/common/na-action-menu.h: Renamed as na-obj-menu.h.
Takes part of renaming NAActionMenu class to NAObjectMenu.
* src/common/na-gconf.c: Renamed as na-gconf-provider.c.
* src/common/na-gconf.h: Renamed as na-gconf-provider.h.
Takes part of NAGConf class to NAGConfProvider.
This let us clearly identify the rule of the class, distinguishing
it from GConf as a preferences repository.
* src/common/na-gconf-key.h: Splitted in na-gconf-keys-base.h,
na-gconf-keys-schemas.h and na-gconf-provider-keys.h files.
* src/common/na-gconf-monitor.c: New file.
* src/common/na-gconf-monitor.h: New file.
New class NAGConfMonitor.
* src/common/na-gconf-utils.c: New file.
* src/common/na-gconf-utils.h: New file.
Handle some GConf general utilities.
* src/common/na-object.h: Splitted in na-object-fn.h,
na-object-class.h and na-object-api.h.
All NAObject-derived public functions are now declared in
na-object-api.h.
* src/common/na-object-id.h: Splitted in na-object-id-fn.h and
na-object-id-class.h.
* src/common/na-object-item.h: Splitted in na-object-item-fn.h
and na-object-item-class.h.
2009-08-30 Pierre Wieser <pwieser@trychlos.org>
* data/nautilus-actions.schemas.in:
......
......@@ -156,6 +156,5 @@ AC_CHECK_LIB(nautilus-extension, nautilus_menu_item_new)
AC_CHECK_FUNCS(nautilus_menu_provider_emit_items_updated_signal)
AC_DEFINE_UNQUOTED(NAUTILUS_ACTIONS_CONFIG_VERSION, "2.0", [Version of the configuration format])
AC_DEFINE_UNQUOTED(NAUTILUS_ACTIONS_CONFIG_GCONF_BASEDIR, "/apps/nautilus-actions", [GConf base dir where all config will be stored])
AC_OUTPUT
......@@ -37,17 +37,15 @@ AM_CPPFLAGS += \
libnact_la_SOURCES = \
na-about.c \
na-about.h \
na-action.c \
na-action.h \
na-action-class.h \
na-action-menu.c \
na-action-menu.h \
na-action-profile.c \
na-action-profile.h \
na-action-profile-class.h \
na-gconf.c \
na-gconf.h \
na-gconf-keys.h \
na-gconf-keys-base.h \
na-gconf-keys-schemas.h \
na-gconf-monitor.c \
na-gconf-monitor.h \
na-gconf-provider.c \
na-gconf-provider.h \
na-gconf-provider-keys.h \
na-gconf-utils.c \
na-gconf-utils.h \
na-gnome-vfs-uri.c \
na-gnome-vfs-uri.h \
na-iduplicable.c \
......@@ -59,9 +57,23 @@ libnact_la_SOURCES = \
na-iprefs.c \
na-iprefs.h \
na-object.c \
na-object.h \
na-object-api.h \
na-object-class.h \
na-object-fn.h \
na-object-id.c \
na-object-id-class.h \
na-object-id-fn.h \
na-object-item.c \
na-object-item.h \
na-object-item-class.h \
na-object-item-fn.h \
na-obj-action.c \
na-obj-action.h \
na-obj-action-class.h \
na-obj-menu.c \
na-obj-menu.h \
na-obj-profile.c \
na-obj-profile.h \
na-obj-profile-class.h \
na-pivot.c \
na-pivot.h \
na-utils.c \
......
This diff is collapsed.
/*
* Nautilus Actions
* A Nautilus extension which offers configurable context menu actions.
*
* Copyright (C) 2005 The GNOME Foundation
* Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
* Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
*
* This Program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This Program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this Library; see the file COPYING. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307, USA.
*
* Authors:
* Frederic Ruaudel <grumz@grumz.net>
* Rodrigo Moya <rodrigo@gnome-db.org>
* Pierre Wieser <pwieser@trychlos.org>
* ... and many others (see AUTHORS)
*/
#ifndef __NA_ACTION_H__
#define __NA_ACTION_H__
/**
* SECTION: na_action
* @short_description: #NAAction class definition.
* @include: common/na-action.h
*
* This is the class which maintains data and properties of an Nautilus
* action.
*/
#include <glib/gi18n.h>
#include "na-action-class.h"
#include "na-action-profile-class.h"
#include "na-iio-provider.h"
G_BEGIN_DECLS
/* i18n: default label for a newly created action */
#define NA_ACTION_DEFAULT_LABEL _( "New Nautilus action" )
/* i18n: default label for a newly created profile */
#define NA_ACTION_PROFILE_DEFAULT_LABEL _( "Default profile" )
NAAction *na_action_new( void );
NAAction *na_action_new_with_profile( void );
gchar *na_action_get_uuid( const NAAction *action );
gchar *na_action_get_label( const NAAction *action );
gchar *na_action_get_version( const NAAction *action );
gchar *na_action_get_tooltip( const NAAction *action );
gchar *na_action_get_icon( const NAAction *action );
gchar *na_action_get_verified_icon_name( const NAAction *action );
gboolean na_action_is_enabled( const NAAction *action );
gboolean na_action_is_readonly( const NAAction *action );
NAIIOProvider *na_action_get_provider( const NAAction *action );
void na_action_set_new_uuid( NAAction *action );
void na_action_set_uuid( NAAction *action, const gchar *uuid );
void na_action_set_label( NAAction *action, const gchar *label );
void na_action_set_version( NAAction *action, const gchar *version );
void na_action_set_tooltip( NAAction *action, const gchar *tooltip );
void na_action_set_icon( NAAction *action, const gchar *icon );
void na_action_set_enabled( NAAction *action, gboolean enabled );
void na_action_set_readonly( NAAction *action, gboolean readonly );
void na_action_set_provider( NAAction *action, const NAIIOProvider *provider );
gchar *na_action_get_new_profile_name( const NAAction *action );
NAActionProfile *na_action_get_profile( const NAAction *action, const gchar *name );
GSList *na_action_get_profiles( const NAAction *action );
void na_action_attach_profile( NAAction *action, NAActionProfile *profile );
void na_action_remove_profile( NAAction *action, NAActionProfile *profile );
void na_action_set_profiles( NAAction *action, GSList *list );
void na_action_free_profiles( GSList *list );
guint na_action_get_profiles_count( const NAAction *action );
G_END_DECLS
#endif /* __NA_ACTION_H__ */
/*
* Nautilus Actions
* A Nautilus extension which offers configurable context menu actions.
*
* Copyright (C) 2005 The GNOME Foundation
* Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
* Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
*
* This Program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This Program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this Library; see the file COPYING. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307, USA.
*
* Authors:
* Frederic Ruaudel <grumz@grumz.net>
* Rodrigo Moya <rodrigo@gnome-db.org>
* Pierre Wieser <pwieser@trychlos.org>
* ... and many others (see AUTHORS)
*/
#ifndef __NA_GCONF_KEYS_BASE_H__
#define __NA_GCONF_KEYS_BASE_H__
/* GConf general information
*
* They are used both:
* - by GConf as a NAIIOProvider
* - by GConf as the preferences storage system
* - for providing schemas in import/export actions
*/
#define NAUTILUS_ACTIONS_GCONF_BASEDIR "/apps/nautilus-actions"
#endif /* __NA_GCONF_KEYS_BASE_H__ */
/*
* Nautilus Actions
* A Nautilus extension which offers configurable context menu actions.
*
* Copyright (C) 2005 The GNOME Foundation
* Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
* Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
*
* This Program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This Program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this Library; see the file COPYING. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307, USA.
*
* Authors:
* Frederic Ruaudel <grumz@grumz.net>
* Rodrigo Moya <rodrigo@gnome-db.org>
* Pierre Wieser <pwieser@trychlos.org>
* ... and many others (see AUTHORS)
*/
#ifndef __NA_GCONF_KEYS_SCHEMAS_H__
#define __NA_GCONF_KEYS_SCHEMAS_H__
#include "na-gconf-keys-base.h"
/* GConf general information
*/
#define NAUTILUS_ACTIONS_GCONF_SCHEMASDIR "/schemas"
#endif /* __NA_GCONF_KEYS_SCHEMAS_H__ */
/*
* Nautilus Actions
* A Nautilus extension which offers configurable context menu actions.
*
* Copyright (C) 2005 The GNOME Foundation
* Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
* Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
*
* This Program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This Program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this Library; see the file COPYING. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307, USA.
*
* Authors:
* Frederic Ruaudel <grumz@grumz.net>
* Rodrigo Moya <rodrigo@gnome-db.org>
* Pierre Wieser <pwieser@trychlos.org>
* ... and many others (see AUTHORS)
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "na-gconf-monitor.h"
/* private class data
*/
struct NAGConfMonitorClassPrivate {
void *empty; /* so that gcc -pedantic is happy */
};
/* private instance data
*/
struct NAGConfMonitorPrivate {
gboolean dispose_has_run;
GConfClient *gconf;
gchar *path;
gint preload;
GConfClientNotifyFunc handler;
gpointer user_data;
guint monitor_id;
};
static GObjectClass *st_parent_class = NULL;
static GType register_type( void );
static void class_init( NAGConfMonitorClass *klass );
static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *object );
static void instance_finalize( GObject *object );
static guint install_monitor( NAGConfMonitor *monitor );
static void release_monitor( NAGConfMonitor *monitor );
GType
na_gconf_monitor_get_type( void )
{
static GType object_type = 0;
if( !object_type ){
object_type = register_type();
}
return( object_type );
}
static GType
register_type( void )
{
static const gchar *thisfn = "na_gconf_monitor_register_type";
GType type;
static GTypeInfo info = {
sizeof( NAGConfMonitorClass ),
NULL,
NULL,
( GClassInitFunc ) class_init,
NULL,
NULL,
sizeof( NAGConfMonitor ),
0,
( GInstanceInitFunc ) instance_init
};
g_debug( "%s", thisfn );
type = g_type_register_static( G_TYPE_OBJECT, "NAGConfMonitor", &info, 0 );
return( type );
}
static void
class_init( NAGConfMonitorClass *klass )
{
static const gchar *thisfn = "na_gconf_monitor_class_init";
GObjectClass *object_class;
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
st_parent_class = g_type_class_peek_parent( klass );
object_class = G_OBJECT_CLASS( klass );
object_class->dispose = instance_dispose;
object_class->finalize = instance_finalize;
klass->private = g_new0( NAGConfMonitorClassPrivate, 1 );
}
static void
instance_init( GTypeInstance *instance, gpointer klass )
{
static const gchar *thisfn = "na_gconf_monitor_instance_init";
NAGConfMonitor *self;
g_debug( "%s: instance=%p, klass=%p", thisfn, ( void * ) instance, ( void * ) klass );
g_return_if_fail( NA_IS_GCONF_MONITOR( instance ));
self = NA_GCONF_MONITOR( instance );
self->private = g_new0( NAGConfMonitorPrivate, 1 );
}
static void
instance_dispose( GObject *object )
{
static const gchar *thisfn = "na_gconf_monitor_instance_dispose";
NAGConfMonitor *self;
g_debug( "%s: object=%p", thisfn, ( void * ) object );
g_return_if_fail( NA_IS_GCONF_MONITOR( object ));
self = NA_GCONF_MONITOR( object );
if( !self->private->dispose_has_run ){
self->private->dispose_has_run = TRUE;
/* release the installed monitor */
release_monitor( self );
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->dispose ){
G_OBJECT_CLASS( st_parent_class )->dispose( object );
}
}
}
static void
instance_finalize( GObject *object )
{
NAGConfMonitor *self;
g_return_if_fail( NA_IS_GCONF_MONITOR( object ));
self = NA_GCONF_MONITOR( object );
g_free( self->private->path );
g_free( self->private );
/* chain call to parent class */
if( G_OBJECT_CLASS( st_parent_class )->finalize ){
G_OBJECT_CLASS( st_parent_class )->finalize( object );
}
}
/**
* na_gconf_monitor_new:
* @client: a #GConfClient object already initialized by the caller.
* @path: the absolute path to monitor.
* @preload: a #GConfClientPreloadType for this monitoring.
* @handler: the function to be triggered by the monitor.
* @user_data: data to pass to the @handler.
*
* Initializes the monitoring of a GConf path.
*/
NAGConfMonitor *
na_gconf_monitor_new( GConfClient *client, const gchar *path, gint preload, GConfClientNotifyFunc handler, gpointer user_data )
{
static const gchar *thisfn = "na_gconf_monitor_new";
NAGConfMonitor *monitor;
g_debug( "%s: client=%p, path=%s, preload=%d, user_data=%p",
thisfn, ( void * ) client, path, preload, ( void * ) user_data );
monitor = g_object_new( NA_GCONF_MONITOR_TYPE, NULL );
monitor->private->gconf = client;
monitor->private->path = g_strdup( path );
monitor->private->preload = preload;
monitor->private->handler = handler;
monitor->private->user_data = user_data;
monitor->private->monitor_id = install_monitor( monitor );
return( monitor );
}
static guint
install_monitor( NAGConfMonitor *monitor )
{
static const gchar *thisfn = "na_gconf_monitor_install_monitor";
GError *error = NULL;
guint notify_id;
g_return_val_if_fail( NA_IS_GCONF_MONITOR( monitor ), 0 );
g_return_val_if_fail( !monitor->private->dispose_has_run, 0 );
gconf_client_add_dir(
monitor->private->gconf,
monitor->private->path,
monitor->private->preload,
&error );
if( error ){
g_warning( "%s[gconf_client_add_dir] path=%s, error=%s", thisfn, monitor->private->path, error->message );
g_error_free( error );
return( 0 );
}
notify_id = gconf_client_notify_add(
monitor->private->gconf,
monitor->private->path,
monitor->private->handler,
monitor->private->user_data,
NULL,
&error );
if( error ){
g_warning( "%s[gconf_client_notify_add] path=%s, error=%s", thisfn, monitor->private->path, error->message );
g_error_free( error );
return( 0 );
}
return( notify_id );
}
/**
* na_gconf_monitor_release_monitors:
* @monitors: a list of #NAGConfMonitors.
*
* Release allocated monitors.
*/
void
na_gconf_monitor_release_monitors( GSList *monitors )
{
g_slist_foreach( monitors, ( GFunc ) g_object_unref, NULL );
g_slist_free( monitors );
}
static void
release_monitor( NAGConfMonitor *monitor )
{
static const gchar *thisfn = "na_gconf_monitor_release_monitor";
GError *error = NULL;
g_debug( "%s: monitor=%p", thisfn, ( void * ) monitor );
g_return_if_fail( NA_IS_GCONF_MONITOR( monitor ));
if( monitor->private->monitor_id ){
gconf_client_notify_remove( monitor->private->gconf, monitor->private->monitor_id );
}
gconf_client_remove_dir( monitor->private->gconf, monitor->private->path, &error );
if( error ){
g_warning( "%s[gconf_client_remove_dir] path=%s, error=%s", thisfn, monitor->private->path, error->message );
g_error_free( error );
}
}
/*
* Nautilus Actions
* A Nautilus extension which offers configurable context menu actions.
*
* Copyright (C) 2005 The GNOME Foundation
* Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
* Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
*
* This Program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This Program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this Library; see the file COPYING. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307, USA.
*
* Authors:
* Frederic Ruaudel <grumz@grumz.net>
* Rodrigo Moya <rodrigo@gnome-db.org>
* Pierre Wieser <pwieser@trychlos.org>
* ... and many others (see AUTHORS)
*/
#ifndef __NA_GCONF_MONITOR_H__
#define __NA_GCONF_MONITOR_H__
/**
* SECTION: na_gconf_monitor
* @short_description: #NAGConfMonitor class definition.
* @include: common/na-gconf-monitor.h
*
* This class manages the GConf monitoring.
*/
#include <gconf/gconf-client.h>
G_BEGIN_DECLS
#define NA_GCONF_MONITOR_TYPE ( na_gconf_monitor_get_type())
#define NA_GCONF_MONITOR( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NA_GCONF_MONITOR_TYPE, NAGConfMonitor ))
#define NA_GCONF_MONITOR_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, NA_GCONF_MONITOR_TYPE, NAGConfMonitorClass ))
#define NA_IS_GCONF_MONITOR( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NA_GCONF_MONITOR_TYPE ))
#define NA_IS_GCONF_MONITOR_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NA_GCONF_MONITOR_TYPE ))
#define NA_GCONF_MONITOR_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NA_GCONF_MONITOR_TYPE, NAGConfMonitorClass ))
typedef struct NAGConfMonitorPrivate NAGConfMonitorPrivate;
typedef struct {
GObject parent;
NAGConfMonitorPrivate *private;
}
NAGConfMonitor;
typedef struct NAGConfMonitorClassPrivate NAGConfMonitorClassPrivate;
typedef struct {
GObjectClass parent;
NAGConfMonitorClassPrivate *private;
}
NAGConfMonitorClass;
GType na_gconf_monitor_get_type( void );
NAGConfMonitor *na_gconf_monitor_new( GConfClient *client, const gchar *path, gint preload, GConfClientNotifyFunc handler, gpointer user_data );
void na_gconf_monitor_release_monitors( GSList *monitors );
G_END_DECLS
#endif /* __NA_GCONF_MONITOR_MONITOR_H__ */
......@@ -28,23 +28,33 @@
* ... and many others (see AUTHORS)
*/
#ifndef __NA_GCONF_KEYS_H__
#define __NA_GCONF_KEYS_H__
#ifndef __NA_GCONF_PROVIDER_KEYS_H__
#define __NA_GCONF_PROVIDER_KEYS_H__
#include "na-gconf-keys-base.h"
#include "na-gconf-keys-schemas.h"
/* GConf general information
*/
#define NA_GCONF_CONFIG_CONFIGURATION "configurations"
#define NA_GCONF_CONFIG_PATH NAUTILUS_ACTIONS_CONFIG_GCONF_BASEDIR "/" NA_GCONF_CONFIG_CONFIGURATION
#define NA_GCONF_SCHEMA_PREFIX "/schemas"
#define NA_GCONF_SCHEMA_PREFERENCES "preferences"
#define NA_GCONF_CONFIG_PATH NAUTILUS_ACTIONS_GCONF_BASEDIR "/configurations"
/* GConf key names (common to menu and actions)
*/
#define OBJECT_ITEM_LABEL_ENTRY "label"
#define OBJECT_ITEM_TOOLTIP_ENTRY "tooltip"
#define OBJECT_ITEM_ICON_ENTRY "icon"
#define OBJECT_ITEM_ENABLED_ENTRY "enabled"
/* GConf key names
/* GConf key names (specific to menu)
*/
#define MENU_ITEMS_ENTRY "items"
/* GConf key names (specific to action)
*/
#define ACTION_VERSION_ENTRY "version"
#define ACTION_LABEL_ENTRY "label"
#define ACTION_TOOLTIP_ENTRY "tooltip"
#define ACTION_ICON_ENTRY "icon"
#define ACTION_ENABLED_ENTRY "enabled"
/* GConf key names (specific to profile)
*/
#define ACTION_PROFILE_LABEL_ENTRY "desc-name"
#define ACTION_PATH_ENTRY "path"
#define ACTION_PARAMETERS_ENTRY "parameters"
......@@ -56,4 +66,4 @@
#define ACTION_MULTIPLE_ENTRY "accept-multiple-files"
#define ACTION_SCHEMES_ENTRY "schemes"
#endif /* __NA_GCONF_KEYS_H__ */
#endif /* __NA_GCONF_PROVIDER_KEYS_H__ */
/*
* Nautilus Actions
* A Nautilus extension which offers configurable context menu actions.