Change help menu item from Gtk default to Gnome (apparent) standard
[nautilus-actions.git] / src / nact / nact-icapabilities-tab.c
bloba0ed424ceeece78e099e4e1ad9d655e06efd7f70
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 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 <glib/gi18n.h>
37 #include <api/na-core-utils.h>
38 #include <api/na-object-api.h>
40 #include "nact-main-tab.h"
41 #include "nact-match-list.h"
42 #include "nact-add-capability-dialog.h"
43 #include "nact-icapabilities-tab.h"
45 /* private interface data
47 struct NactICapabilitiesTabInterfacePrivate {
48 void *empty; /* so that gcc -pedantic is happy */
51 #define ITAB_NAME "capabilities"
53 static gboolean st_initialized = FALSE;
54 static gboolean st_finalized = FALSE;
56 static GType register_type( void );
57 static void interface_base_init( NactICapabilitiesTabInterface *klass );
58 static void interface_base_finalize( NactICapabilitiesTabInterface *klass );
60 static void on_tab_updatable_selection_changed( NactICapabilitiesTab *instance, gint count_selected );
62 static void on_add_clicked( GtkButton *button, BaseWindow *window );
63 static GSList *get_capabilities( NAIContext *context );
64 static void set_capabilities( NAIContext *context, GSList *list );
66 GType
67 nact_icapabilities_tab_get_type( void )
69 static GType iface_type = 0;
71 if( !iface_type ){
72 iface_type = register_type();
75 return( iface_type );
78 static GType
79 register_type( void )
81 static const gchar *thisfn = "nact_icapabilities_tab_register_type";
82 GType type;
84 static const GTypeInfo info = {
85 sizeof( NactICapabilitiesTabInterface ),
86 ( GBaseInitFunc ) interface_base_init,
87 ( GBaseFinalizeFunc ) interface_base_finalize,
88 NULL,
89 NULL,
90 NULL,
93 NULL
96 g_debug( "%s", thisfn );
98 type = g_type_register_static( G_TYPE_INTERFACE, "NactICapabilitiesTab", &info, 0 );
100 g_type_interface_add_prerequisite( type, BASE_WINDOW_TYPE );
102 return( type );
105 static void
106 interface_base_init( NactICapabilitiesTabInterface *klass )
108 static const gchar *thisfn = "nact_icapabilities_tab_interface_base_init";
110 if( !st_initialized ){
112 g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
114 klass->private = g_new0( NactICapabilitiesTabInterfacePrivate, 1 );
116 st_initialized = TRUE;
120 static void
121 interface_base_finalize( NactICapabilitiesTabInterface *klass )
123 static const gchar *thisfn = "nact_icapabilities_tab_interface_base_finalize";
125 if( st_initialized && !st_finalized ){
127 g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
129 st_finalized = TRUE;
131 g_free( klass->private );
135 void
136 nact_icapabilities_tab_initial_load_toplevel( NactICapabilitiesTab *instance )
138 static const gchar *thisfn = "nact_icapabilities_tab_initial_load_toplevel";
139 GtkWidget *list, *add, *remove;
141 g_return_if_fail( NACT_IS_ICAPABILITIES_TAB( instance ));
143 if( st_initialized && !st_finalized ){
145 g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
147 list = base_window_get_widget( BASE_WINDOW( instance ), "CapabilitiesTreeView" );
148 add = base_window_get_widget( BASE_WINDOW( instance ), "AddCapabilityButton" );
149 remove = base_window_get_widget( BASE_WINDOW( instance ), "RemoveCapabilityButton" );
151 nact_match_list_create_model( BASE_WINDOW( instance ),
152 ITAB_NAME, TAB_CAPABILITIES,
153 list, add, remove,
154 ( pget_filters ) get_capabilities,
155 ( pset_filters ) set_capabilities,
156 ( pon_add_cb ) on_add_clicked,
157 MATCH_LIST_MUST_MATCH_ALL_OF,
158 _( "Capability filter" ), FALSE );
162 void
163 nact_icapabilities_tab_runtime_init_toplevel( NactICapabilitiesTab *instance )
165 static const gchar *thisfn = "nact_icapabilities_tab_runtime_init_toplevel";
167 g_return_if_fail( NACT_IS_ICAPABILITIES_TAB( instance ));
169 if( st_initialized && !st_finalized ){
171 g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
173 nact_match_list_init_view( BASE_WINDOW( instance ), ITAB_NAME );
175 base_window_signal_connect(
176 BASE_WINDOW( instance ),
177 G_OBJECT( instance ),
178 MAIN_WINDOW_SIGNAL_SELECTION_CHANGED,
179 G_CALLBACK( on_tab_updatable_selection_changed ));
183 void
184 nact_icapabilities_tab_all_widgets_showed( NactICapabilitiesTab *instance )
186 static const gchar *thisfn = "nact_icapabilities_tab_all_widgets_showed";
188 g_return_if_fail( NACT_IS_ICAPABILITIES_TAB( instance ));
190 if( st_initialized && !st_finalized ){
192 g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
196 void
197 nact_icapabilities_tab_dispose( NactICapabilitiesTab *instance )
199 static const gchar *thisfn = "nact_icapabilities_tab_dispose";
201 g_return_if_fail( NACT_IS_ICAPABILITIES_TAB( instance ));
203 if( st_initialized && !st_finalized ){
205 g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
207 nact_match_list_dispose( BASE_WINDOW( instance ), ITAB_NAME );
211 static void
212 on_tab_updatable_selection_changed( NactICapabilitiesTab *instance, gint count_selected )
214 nact_match_list_on_selection_changed( BASE_WINDOW( instance ), ITAB_NAME, count_selected );
217 static void
218 on_add_clicked( GtkButton *button, BaseWindow *window )
220 NAIContext *context;
221 GSList *capabilities;
222 gchar *new_cap;
224 context = nact_main_tab_get_context( NACT_MAIN_WINDOW( window ), NULL );
226 if( context ){
227 capabilities = nact_match_list_get_rows( window, ITAB_NAME );
228 new_cap = nact_add_capability_dialog_run( window, capabilities );
230 if( new_cap ){
231 nact_match_list_insert_row( window, ITAB_NAME, new_cap, FALSE, FALSE );
232 g_free( new_cap );
235 na_core_utils_slist_free( capabilities );
239 static GSList *
240 get_capabilities( NAIContext *context )
242 return( na_object_get_capabilities( context ));
245 static void
246 set_capabilities( NAIContext *context, GSList *list )
248 na_object_set_capabilities( context, list );