[nautilus-actions] Define new NactICapabilitiesInterface interface



commit 3ad7d5ee590a85e20c2cb1988c3bd228a621df5e
Author: Pierre Wieser <pwieser trychlos org>
Date:   Thu Jun 3 00:23:49 2010 +0200

    Define new NactICapabilitiesInterface interface

 ChangeLog                         |    9 ++
 src/nact/Makefile.am              |    2 +
 src/nact/nact-icapabilities-tab.c |  272 +++++++++++++++++++++++++++++++++++++
 src/nact/nact-icapabilities-tab.h |   71 ++++++++++
 src/nact/nact-main-tab.h          |    1 +
 src/nact/nact-main-window.c       |   22 +++
 6 files changed, 377 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 507d93e..ed879bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,15 @@
 
 	* src/core/na-iabout.c: Update copyright notice.
 
+2010-06-02 Pierre Wieser <pwieser trychlos org>
+
+	* src/nact/nact-icapabilities-tab.c:
+	* src/nact/nact-icapabilities-tab.h: Define NactICapabilitiesInterface interface.
+
+	* src/nact/Makefile.am:
+	* src/nact/nact-main-tab.h:
+	* src/nact/nact-main-window.c: Updated accordingly.
+
 2010-05-30 Pierre Wieser <pwieser trychlos org>
 
 	* src/nact/nact-ibasenames-tab.c:
diff --git a/src/nact/Makefile.am b/src/nact/Makefile.am
index cb4af66..d83db20 100644
--- a/src/nact/Makefile.am
+++ b/src/nact/Makefile.am
@@ -95,6 +95,8 @@ nautilus_actions_config_tool_SOURCES = \
 	nact-iaction-tab.h									\
 	nact-ibasenames-tab.c								\
 	nact-ibasenames-tab.h								\
+	nact-icapabilities-tab.c							\
+	nact-icapabilities-tab.h							\
 	nact-ienvironment-tab.c								\
 	nact-ienvironment-tab.h								\
 	nact-iexecution-tab.c								\
diff --git a/src/nact/nact-icapabilities-tab.c b/src/nact/nact-icapabilities-tab.c
new file mode 100644
index 0000000..7b42e88
--- /dev/null
+++ b/src/nact/nact-icapabilities-tab.c
@@ -0,0 +1,272 @@
+/*
+ * 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, 2010 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 <api/na-object-api.h>
+
+#include "nact-main-tab.h"
+#include "nact-icapabilities-tab.h"
+
+/* private interface data
+ */
+struct NactICapabilitiesTabInterfacePrivate {
+	void *empty;						/* so that gcc -pedantic is happy */
+};
+
+static gboolean st_initialized = FALSE;
+static gboolean st_finalized = FALSE;
+
+static GType        register_type( void );
+static void         interface_base_init( NactICapabilitiesTabInterface *klass );
+static void         interface_base_finalize( NactICapabilitiesTabInterface *klass );
+
+static void         runtime_init_connect_signals( NactICapabilitiesTab *instance, GtkTreeView *listview );
+static void         on_tab_updatable_selection_changed( NactICapabilitiesTab *instance, gint count_selected );
+static void         on_tab_updatable_enable_tab( NactICapabilitiesTab *instance, NAObjectItem *item );
+static gboolean     tab_set_sensitive( NactICapabilitiesTab *instance );
+static GtkTreeView *get_capabilities_tree_view( NactICapabilitiesTab *instance );
+
+GType
+nact_icapabilities_tab_get_type( void )
+{
+	static GType iface_type = 0;
+
+	if( !iface_type ){
+		iface_type = register_type();
+	}
+
+	return( iface_type );
+}
+
+static GType
+register_type( void )
+{
+	static const gchar *thisfn = "nact_icapabilities_tab_register_type";
+	GType type;
+
+	static const GTypeInfo info = {
+		sizeof( NactICapabilitiesTabInterface ),
+		( GBaseInitFunc ) interface_base_init,
+		( GBaseFinalizeFunc ) interface_base_finalize,
+		NULL,
+		NULL,
+		NULL,
+		0,
+		0,
+		NULL
+	};
+
+	g_debug( "%s", thisfn );
+
+	type = g_type_register_static( G_TYPE_INTERFACE, "NactICapabilitiesTab", &info, 0 );
+
+	g_type_interface_add_prerequisite( type, BASE_WINDOW_TYPE );
+
+	return( type );
+}
+
+static void
+interface_base_init( NactICapabilitiesTabInterface *klass )
+{
+	static const gchar *thisfn = "nact_icapabilities_tab_interface_base_init";
+
+	if( !st_initialized ){
+
+		g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
+
+		klass->private = g_new0( NactICapabilitiesTabInterfacePrivate, 1 );
+
+		st_initialized = TRUE;
+	}
+}
+
+static void
+interface_base_finalize( NactICapabilitiesTabInterface *klass )
+{
+	static const gchar *thisfn = "nact_icapabilities_tab_interface_base_finalize";
+
+	if( st_initialized && !st_finalized ){
+
+		g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
+
+		st_finalized = TRUE;
+
+		g_free( klass->private );
+	}
+}
+
+void
+nact_icapabilities_tab_initial_load_toplevel( NactICapabilitiesTab *instance )
+{
+	static const gchar *thisfn = "nact_icapabilities_tab_initial_load_toplevel";
+
+	if( st_initialized && !st_finalized ){
+
+		g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+		g_return_if_fail( NACT_IS_ICAPABILITIES_TAB( instance ));
+	}
+}
+
+void
+nact_icapabilities_tab_runtime_init_toplevel( NactICapabilitiesTab *instance )
+{
+	static const gchar *thisfn = "nact_icapabilities_tab_runtime_init_toplevel";
+	GtkTreeView *listview;
+
+	if( st_initialized && !st_finalized ){
+
+		g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+		g_return_if_fail( NACT_IS_ICAPABILITIES_TAB( instance ));
+
+		listview = get_capabilities_tree_view( instance );
+		runtime_init_connect_signals( instance, listview );
+	}
+}
+
+static void
+runtime_init_connect_signals( NactICapabilitiesTab *instance, GtkTreeView *listview )
+{
+	static const gchar *thisfn = "nact_icapabilities_tab_runtime_init_connect_signals";
+
+	if( st_initialized && !st_finalized ){
+
+		g_debug( "%s: instance=%p, listview=%p", thisfn, ( void * ) instance, ( void * ) listview );
+		g_return_if_fail( NACT_IS_ICAPABILITIES_TAB( instance ));
+
+		base_window_signal_connect(
+				BASE_WINDOW( instance ),
+				G_OBJECT( instance ),
+				MAIN_WINDOW_SIGNAL_SELECTION_CHANGED,
+				G_CALLBACK( on_tab_updatable_selection_changed ));
+
+		base_window_signal_connect(
+				BASE_WINDOW( instance ),
+				G_OBJECT( instance ),
+				TAB_UPDATABLE_SIGNAL_ENABLE_TAB,
+				G_CALLBACK( on_tab_updatable_enable_tab ));
+	}
+}
+
+void
+nact_icapabilities_tab_all_widgets_showed( NactICapabilitiesTab *instance )
+{
+	static const gchar *thisfn = "nact_icapabilities_tab_all_widgets_showed";
+
+	if( st_initialized && !st_finalized ){
+
+		g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+		g_return_if_fail( NACT_IS_ICAPABILITIES_TAB( instance ));
+	}
+}
+
+void
+nact_icapabilities_tab_dispose( NactICapabilitiesTab *instance )
+{
+	static const gchar *thisfn = "nact_icapabilities_tab_dispose";
+
+	if( st_initialized && !st_finalized ){
+
+		g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+		g_return_if_fail( NACT_IS_ICAPABILITIES_TAB( instance ));
+	}
+}
+
+static void
+on_tab_updatable_selection_changed( NactICapabilitiesTab *instance, gint count_selected )
+{
+	static const gchar *thisfn = "nact_icapabilities_tab_on_tab_updatable_selection_changed";
+	NAObjectItem *item;
+	NAObjectProfile *profile;
+	GSList *capabilities;
+	gboolean editable;
+
+	capabilities = NULL;
+	if( st_initialized && !st_finalized ){
+
+		g_debug( "%s: instance=%p, count_selected=%d", thisfn, ( void * ) instance, count_selected );
+		g_return_if_fail( NACT_IS_ICAPABILITIES_TAB( instance ));
+
+		g_object_get(
+				G_OBJECT( instance ),
+				TAB_UPDATABLE_PROP_EDITED_ACTION, &item,
+				TAB_UPDATABLE_PROP_EDITED_PROFILE, &profile,
+				TAB_UPDATABLE_PROP_EDITABLE, &editable,
+				NULL );
+
+		tab_set_sensitive( instance );
+	}
+}
+
+static void
+on_tab_updatable_enable_tab( NactICapabilitiesTab *instance, NAObjectItem *item )
+{
+	static const gchar *thisfn = "nact_icapabilities_tab_on_tab_updatable_enable_tab";
+
+	if( st_initialized && !st_finalized ){
+
+		g_debug( "%s: instance=%p, item=%p", thisfn, ( void * ) instance, ( void * ) item );
+		g_return_if_fail( NACT_IS_ICAPABILITIES_TAB( instance ));
+
+		tab_set_sensitive( instance );
+	}
+}
+
+static gboolean
+tab_set_sensitive( NactICapabilitiesTab *instance )
+{
+	NAObjectItem *item;
+	NAObjectProfile *profile;
+	gboolean enable_tab;
+
+	g_object_get(
+			G_OBJECT( instance ),
+			TAB_UPDATABLE_PROP_EDITED_ACTION, &item,
+			TAB_UPDATABLE_PROP_EDITED_PROFILE, &profile,
+			NULL );
+
+	enable_tab = ( profile != NULL && na_object_is_target_selection( NA_OBJECT_ACTION( item )));
+	nact_main_tab_enable_page( NACT_MAIN_WINDOW( instance ), TAB_CAPABILITIES, enable_tab );
+
+	return( enable_tab );
+}
+
+static GtkTreeView *
+get_capabilities_tree_view( NactICapabilitiesTab *instance )
+{
+	GtkWidget *treeview;
+
+	treeview = base_window_get_widget( BASE_WINDOW( instance ), "CapabilitiesTreeView" );
+	g_assert( GTK_IS_TREE_VIEW( treeview ));
+
+	return( GTK_TREE_VIEW( treeview ));
+}
diff --git a/src/nact/nact-icapabilities-tab.h b/src/nact/nact-icapabilities-tab.h
new file mode 100644
index 0000000..ec437ed
--- /dev/null
+++ b/src/nact/nact-icapabilities-tab.h
@@ -0,0 +1,71 @@
+/*
+ * 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, 2010 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 __NACT_ICAPABILITIES_TAB_H__
+#define __NACT_ICAPABILITIES_TAB_H__
+
+/**
+ * SECTION: nact_icapabilities_tab
+ * @short_description: #NactICapabilitiesTab interface declaration.
+ * @include: nact/nact-icapabilities-tab.h
+ *
+ * This interface implements all the widgets which define the
+ * conditions for the action.
+ */
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define NACT_ICAPABILITIES_TAB_TYPE							( nact_icapabilities_tab_get_type())
+#define NACT_ICAPABILITIES_TAB( object )					( G_TYPE_CHECK_INSTANCE_CAST( object, NACT_ICAPABILITIES_TAB_TYPE, NactICapabilitiesTab ))
+#define NACT_IS_ICAPABILITIES_TAB( object )					( G_TYPE_CHECK_INSTANCE_TYPE( object, NACT_ICAPABILITIES_TAB_TYPE ))
+#define NACT_ICAPABILITIES_TAB_GET_INTERFACE( instance )	( G_TYPE_INSTANCE_GET_INTERFACE(( instance ), NACT_ICAPABILITIES_TAB_TYPE, NactICapabilitiesTabInterface ))
+
+typedef struct NactICapabilitiesTab                 NactICapabilitiesTab;
+
+typedef struct NactICapabilitiesTabInterfacePrivate NactICapabilitiesTabInterfacePrivate;
+
+typedef struct {
+	GTypeInterface                        parent;
+	NactICapabilitiesTabInterfacePrivate *private;
+}
+	NactICapabilitiesTabInterface;
+
+GType   nact_icapabilities_tab_get_type( void );
+
+void    nact_icapabilities_tab_initial_load_toplevel( NactICapabilitiesTab *instance );
+void    nact_icapabilities_tab_runtime_init_toplevel( NactICapabilitiesTab *instance );
+void    nact_icapabilities_tab_all_widgets_showed   ( NactICapabilitiesTab *instance );
+void    nact_icapabilities_tab_dispose              ( NactICapabilitiesTab *instance );
+
+G_END_DECLS
+
+#endif /* __NACT_ICAPABILITIES_TAB_H__ */
diff --git a/src/nact/nact-main-tab.h b/src/nact/nact-main-tab.h
index 6edf574..4c1c9cd 100644
--- a/src/nact/nact-main-tab.h
+++ b/src/nact/nact-main-tab.h
@@ -65,6 +65,7 @@ enum {
 	TAB_MIMETYPES,
 	TAB_FOLDERS,
 	TAB_SCHEMES,
+	TAB_CAPABILITIES,
 	TAB_ENVIRONMENT,
 	TAB_EXECUTION,
 	TAB_PROPERTIES
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 1817d0b..a621d95 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -53,6 +53,7 @@
 #include "nact-imimetypes-tab.h"
 #include "nact-ifolders-tab.h"
 #include "nact-ischemes-tab.h"
+#include "nact-icapabilities-tab.h"
 #include "nact-ienvironment-tab.h"
 #include "nact-iexecution-tab.h"
 #include "nact-iproperties-tab.h"
@@ -153,6 +154,7 @@ static void     ibasenames_tab_iface_init( NactIBasenamesTabInterface *iface );
 static void     imimetypes_tab_iface_init( NactIMimetypesTabInterface *iface );
 static void     ifolders_tab_iface_init( NactIFoldersTabInterface *iface );
 static void     ischemes_tab_iface_init( NactISchemesTabInterface *iface );
+static void     icapabilities_tab_iface_init( NactICapabilitiesTabInterface *iface );
 static void     ienvironment_tab_iface_init( NactIEnvironmentTabInterface *iface );
 static void     iexecution_tab_iface_init( NactIExecutionTabInterface *iface );
 static void     iproperties_tab_iface_init( NactIPropertiesTabInterface *iface );
@@ -265,6 +267,12 @@ register_type( void )
 		NULL
 	};
 
+	static const GInterfaceInfo icapabilities_tab_iface_info = {
+		( GInterfaceInitFunc ) icapabilities_tab_iface_init,
+		NULL,
+		NULL
+	};
+
 	static const GInterfaceInfo ienvironment_tab_iface_info = {
 		( GInterfaceInitFunc ) ienvironment_tab_iface_init,
 		NULL,
@@ -319,6 +327,8 @@ register_type( void )
 
 	g_type_add_interface_static( type, NACT_ISCHEMES_TAB_TYPE, &ischemes_tab_iface_info );
 
+	g_type_add_interface_static( type, NACT_ICAPABILITIES_TAB_TYPE, &icapabilities_tab_iface_info );
+
 	g_type_add_interface_static( type, NACT_IENVIRONMENT_TAB_TYPE, &ienvironment_tab_iface_info );
 
 	g_type_add_interface_static( type, NACT_IEXECUTION_TAB_TYPE, &iexecution_tab_iface_info );
@@ -579,6 +589,14 @@ ischemes_tab_iface_init( NactISchemesTabInterface *iface )
 }
 
 static void
+icapabilities_tab_iface_init( NactICapabilitiesTabInterface *iface )
+{
+	static const gchar *thisfn = "nact_main_window_icapabilities_tab_iface_init";
+
+	g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
+}
+
+static void
 ienvironment_tab_iface_init( NactIEnvironmentTabInterface *iface )
 {
 	static const gchar *thisfn = "nact_main_window_ienvironment_tab_iface_init";
@@ -786,6 +804,7 @@ instance_dispose( GObject *window )
 		nact_imimetypes_tab_dispose( NACT_IMIMETYPES_TAB( window ));
 		nact_ifolders_tab_dispose( NACT_IFOLDERS_TAB( window ));
 		nact_ischemes_tab_dispose( NACT_ISCHEMES_TAB( window ));
+		nact_icapabilities_tab_dispose( NACT_ICAPABILITIES_TAB( window ));
 		nact_ienvironment_tab_dispose( NACT_IENVIRONMENT_TAB( window ));
 		nact_iexecution_tab_dispose( NACT_IEXECUTION_TAB( window ));
 		nact_iproperties_tab_dispose( NACT_IPROPERTIES_TAB( window ));
@@ -1113,6 +1132,7 @@ on_base_initial_load_toplevel( NactMainWindow *window, gpointer user_data )
 		nact_imimetypes_tab_initial_load_toplevel( NACT_IMIMETYPES_TAB( window ));
 		nact_ifolders_tab_initial_load_toplevel( NACT_IFOLDERS_TAB( window ));
 		nact_ischemes_tab_initial_load_toplevel( NACT_ISCHEMES_TAB( window ));
+		nact_icapabilities_tab_initial_load_toplevel( NACT_ICAPABILITIES_TAB( window ));
 		nact_ienvironment_tab_initial_load_toplevel( NACT_IENVIRONMENT_TAB( window ));
 		nact_iexecution_tab_initial_load_toplevel( NACT_IEXECUTION_TAB( window ));
 		nact_iproperties_tab_initial_load_toplevel( NACT_IPROPERTIES_TAB( window ));
@@ -1154,6 +1174,7 @@ on_base_runtime_init_toplevel( NactMainWindow *window, gpointer user_data )
 		nact_imimetypes_tab_runtime_init_toplevel( NACT_IMIMETYPES_TAB( window ));
 		nact_ifolders_tab_runtime_init_toplevel( NACT_IFOLDERS_TAB( window ));
 		nact_ischemes_tab_runtime_init_toplevel( NACT_ISCHEMES_TAB( window ));
+		nact_icapabilities_tab_runtime_init_toplevel( NACT_ICAPABILITIES_TAB( window ));
 		nact_ienvironment_tab_runtime_init_toplevel( NACT_IENVIRONMENT_TAB( window ));
 		nact_iexecution_tab_runtime_init_toplevel( NACT_IEXECUTION_TAB( window ));
 		nact_iproperties_tab_runtime_init_toplevel( NACT_IPROPERTIES_TAB( window ));
@@ -1210,6 +1231,7 @@ on_base_all_widgets_showed( NactMainWindow *window, gpointer user_data )
 		nact_imimetypes_tab_all_widgets_showed( NACT_IMIMETYPES_TAB( window ));
 		nact_ifolders_tab_all_widgets_showed( NACT_IFOLDERS_TAB( window ));
 		nact_ischemes_tab_all_widgets_showed( NACT_ISCHEMES_TAB( window ));
+		nact_icapabilities_tab_all_widgets_showed( NACT_ICAPABILITIES_TAB( window ));
 		nact_ienvironment_tab_all_widgets_showed( NACT_IENVIRONMENT_TAB( window ));
 		nact_iexecution_tab_all_widgets_showed( NACT_IEXECUTION_TAB( window ));
 		nact_iproperties_tab_all_widgets_showed( NACT_IPROPERTIES_TAB( window ));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]