Change help menu item from Gtk default to Gnome (apparent) standard
[nautilus-actions.git] / src / nact / nact-ischemes-tab.c
blob6bc97558aa43d3a1e5583c4e5d0df971ef6ac404
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-gtk-utils.h"
41 #include "nact-main-tab.h"
42 #include "nact-match-list.h"
43 #include "nact-add-scheme-dialog.h"
44 #include "nact-ischemes-tab.h"
46 /* private interface data
48 struct NactISchemesTabInterfacePrivate {
49 void *empty; /* so that gcc -pedantic is happy */
52 #define ITAB_NAME "schemes"
54 static gboolean st_initialized = FALSE;
55 static gboolean st_finalized = FALSE;
57 static GType register_type( void );
58 static void interface_base_init( NactISchemesTabInterface *klass );
59 static void interface_base_finalize( NactISchemesTabInterface *klass );
61 static void on_tab_updatable_selection_changed( BaseWindow *window, gint count_selected );
63 static void on_add_from_defaults( GtkButton *button, BaseWindow *window );
64 static GSList *get_schemes( void *context );
65 static void set_schemes( void *context, GSList *filters );
67 GType
68 nact_ischemes_tab_get_type( void )
70 static GType iface_type = 0;
72 if( !iface_type ){
73 iface_type = register_type();
76 return( iface_type );
79 static GType
80 register_type( void )
82 static const gchar *thisfn = "nact_ischemes_tab_register_type";
83 GType type;
85 static const GTypeInfo info = {
86 sizeof( NactISchemesTabInterface ),
87 ( GBaseInitFunc ) interface_base_init,
88 ( GBaseFinalizeFunc ) interface_base_finalize,
89 NULL,
90 NULL,
91 NULL,
94 NULL
97 g_debug( "%s", thisfn );
99 type = g_type_register_static( G_TYPE_INTERFACE, "NactISchemesTab", &info, 0 );
101 g_type_interface_add_prerequisite( type, BASE_WINDOW_TYPE );
103 return( type );
106 static void
107 interface_base_init( NactISchemesTabInterface *klass )
109 static const gchar *thisfn = "nact_ischemes_tab_interface_base_init";
111 if( !st_initialized ){
113 g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
115 klass->private = g_new0( NactISchemesTabInterfacePrivate, 1 );
117 st_initialized = TRUE;
121 static void
122 interface_base_finalize( NactISchemesTabInterface *klass )
124 static const gchar *thisfn = "nact_ischemes_tab_interface_base_finalize";
126 if( st_initialized && !st_finalized ){
128 g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
130 st_finalized = TRUE;
132 g_free( klass->private );
136 void
137 nact_ischemes_tab_initial_load_toplevel( NactISchemesTab *instance )
139 static const gchar *thisfn = "nact_ischemes_tab_initial_load_toplevel";
140 GtkWidget *list, *add, *remove;
142 g_return_if_fail( NACT_IS_ISCHEMES_TAB( instance ));
144 if( st_initialized && !st_finalized ){
146 g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
148 list = base_window_get_widget( BASE_WINDOW( instance ), "SchemesTreeView" );
149 add = base_window_get_widget( BASE_WINDOW( instance ), "AddSchemeButton" );
150 remove = base_window_get_widget( BASE_WINDOW( instance ), "RemoveSchemeButton" );
152 nact_match_list_create_model(
153 BASE_WINDOW( instance ),
154 ITAB_NAME,
155 TAB_SCHEMES,
156 list, add, remove,
157 ( pget_filters ) get_schemes,
158 ( pset_filters ) set_schemes,
159 NULL,
160 MATCH_LIST_MUST_MATCH_ONE_OF,
161 _( "Scheme filter" ), TRUE );
165 void
166 nact_ischemes_tab_runtime_init_toplevel( NactISchemesTab *instance )
168 static const gchar *thisfn = "nact_ischemes_tab_runtime_init_toplevel";
169 GtkWidget *button;
171 g_return_if_fail( NACT_IS_ISCHEMES_TAB( instance ));
173 if( st_initialized && !st_finalized ){
175 g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
177 base_window_signal_connect(
178 BASE_WINDOW( instance ),
179 G_OBJECT( instance ),
180 MAIN_WINDOW_SIGNAL_SELECTION_CHANGED,
181 G_CALLBACK( on_tab_updatable_selection_changed ));
183 nact_match_list_init_view( BASE_WINDOW( instance ), ITAB_NAME );
185 button = base_window_get_widget( BASE_WINDOW( instance ), "AddFromDefaultButton" );
186 base_window_signal_connect(
187 BASE_WINDOW( instance ),
188 G_OBJECT( button ),
189 "clicked",
190 G_CALLBACK( on_add_from_defaults ));
194 void
195 nact_ischemes_tab_all_widgets_showed( NactISchemesTab *instance )
197 static const gchar *thisfn = "nact_ischemes_tab_all_widgets_showed";
199 g_return_if_fail( NACT_IS_ISCHEMES_TAB( instance ));
201 if( st_initialized && !st_finalized ){
202 g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
206 void
207 nact_ischemes_tab_dispose( NactISchemesTab *instance )
209 static const gchar *thisfn = "nact_ischemes_tab_dispose";
211 g_return_if_fail( NACT_IS_ISCHEMES_TAB( instance ));
213 if( st_initialized && !st_finalized ){
214 g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
216 nact_match_list_dispose( BASE_WINDOW( instance ), ITAB_NAME );
220 static void
221 on_tab_updatable_selection_changed( BaseWindow *window, gint count_selected )
223 NAIContext *context;
224 gboolean editable;
225 GtkWidget *button;
227 nact_match_list_on_selection_changed( window, ITAB_NAME, count_selected );
229 context = nact_main_tab_get_context( NACT_MAIN_WINDOW( window ), &editable );
230 button = base_window_get_widget( window, "AddFromDefaultButton" );
231 nact_gtk_utils_set_editable( GTK_OBJECT( button ), editable );
234 static void
235 on_add_from_defaults( GtkButton *button, BaseWindow *window )
237 GSList *schemes;
238 gchar *new_scheme;
239 NAIContext *context;
241 context = nact_main_tab_get_context( NACT_MAIN_WINDOW( window ), NULL );
242 g_return_if_fail( context );
244 schemes = nact_match_list_get_rows( window, ITAB_NAME );
245 new_scheme = nact_add_scheme_dialog_run( window, schemes );
246 na_core_utils_slist_free( schemes );
248 if( new_scheme ){
249 nact_match_list_insert_row( window, ITAB_NAME, new_scheme, FALSE, FALSE );
250 g_free( new_scheme );
254 static GSList *
255 get_schemes( void *context )
257 return( na_object_get_schemes( context ));
260 static void
261 set_schemes( void *context, GSList *filters )
263 na_object_set_schemes( context, filters );