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.
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)
35 #include <glib/gi18n.h>
37 #include <api/na-object-api.h>
39 #include "nact-main-tab.h"
40 #include "nact-match-list.h"
41 #include "nact-ibasenames-tab.h"
43 /* private interface data
45 struct NactIBasenamesTabInterfacePrivate
{
46 void *empty
; /* so that gcc -pedantic is happy */
49 #define ITAB_NAME "basenames"
51 static gboolean st_initialized
= FALSE
;
52 static gboolean st_finalized
= FALSE
;
53 static gboolean st_on_selection_change
= FALSE
;
55 static GType
register_type( void );
56 static void interface_base_init( NactIBasenamesTabInterface
*klass
);
57 static void interface_base_finalize( NactIBasenamesTabInterface
*klass
);
59 static void on_tab_updatable_selection_changed( BaseWindow
*window
, gint count_selected
);
61 static void on_matchcase_toggled( GtkToggleButton
*button
, BaseWindow
*window
);
62 static GSList
*get_basenames( void *context
);
63 static void set_basenames( void *context
, GSList
*filters
);
66 nact_ibasenames_tab_get_type( void )
68 static GType iface_type
= 0;
71 iface_type
= register_type();
80 static const gchar
*thisfn
= "nact_ibasenames_tab_register_type";
83 static const GTypeInfo info
= {
84 sizeof( NactIBasenamesTabInterface
),
85 ( GBaseInitFunc
) interface_base_init
,
86 ( GBaseFinalizeFunc
) interface_base_finalize
,
95 g_debug( "%s", thisfn
);
97 type
= g_type_register_static( G_TYPE_INTERFACE
, "NactIBasenamesTab", &info
, 0 );
99 g_type_interface_add_prerequisite( type
, BASE_WINDOW_TYPE
);
105 interface_base_init( NactIBasenamesTabInterface
*klass
)
107 static const gchar
*thisfn
= "nact_ibasenames_tab_interface_base_init";
109 if( !st_initialized
){
111 g_debug( "%s: klass=%p", thisfn
, ( void * ) klass
);
113 klass
->private = g_new0( NactIBasenamesTabInterfacePrivate
, 1 );
115 st_initialized
= TRUE
;
120 interface_base_finalize( NactIBasenamesTabInterface
*klass
)
122 static const gchar
*thisfn
= "nact_ibasenames_tab_interface_base_finalize";
124 if( st_initialized
&& !st_finalized
){
126 g_debug( "%s: klass=%p", thisfn
, ( void * ) klass
);
130 g_free( klass
->private );
135 * nact_ibasenames_tab_initial_load:
136 * @window: this #NactIBasenamesTab instance.
138 * Initializes the tab widget at initial load.
141 nact_ibasenames_tab_initial_load_toplevel( NactIBasenamesTab
*instance
)
143 static const gchar
*thisfn
= "nact_ibasenames_tab_initial_load_toplevel";
144 GtkWidget
*list
, *add
, *remove
;
146 g_return_if_fail( NACT_IS_IBASENAMES_TAB( instance
));
148 if( st_initialized
&& !st_finalized
){
150 g_debug( "%s: instance=%p", thisfn
, ( void * ) instance
);
152 list
= base_window_get_widget( BASE_WINDOW( instance
), "BasenamesTreeView" );
153 add
= base_window_get_widget( BASE_WINDOW( instance
), "AddBasenameButton" );
154 remove
= base_window_get_widget( BASE_WINDOW( instance
), "RemoveBasenameButton" );
156 nact_match_list_create_model(
157 BASE_WINDOW( instance
),
161 ( pget_filters
) get_basenames
,
162 ( pset_filters
) set_basenames
,
164 MATCH_LIST_MUST_MATCH_ONE_OF
,
165 _( "Basename filter" ), TRUE
);
170 * nact_ibasenames_tab_runtime_init:
171 * @window: this #NactIBasenamesTab instance.
173 * Initializes the tab widget at each time the widget will be displayed.
174 * Connect signals and setup runtime values.
177 nact_ibasenames_tab_runtime_init_toplevel( NactIBasenamesTab
*instance
)
179 static const gchar
*thisfn
= "nact_ibasenames_tab_runtime_init_toplevel";
182 g_return_if_fail( NACT_IS_IBASENAMES_TAB( instance
));
184 if( st_initialized
&& !st_finalized
){
186 g_debug( "%s: instance=%p", thisfn
, ( void * ) instance
);
188 base_window_signal_connect(
189 BASE_WINDOW( instance
),
190 G_OBJECT( instance
),
191 MAIN_WINDOW_SIGNAL_SELECTION_CHANGED
,
192 G_CALLBACK( on_tab_updatable_selection_changed
));
194 button
= base_window_get_widget( BASE_WINDOW( instance
), "BasenamesMatchcaseButton" );
195 base_window_signal_connect(
196 BASE_WINDOW( instance
),
199 G_CALLBACK( on_matchcase_toggled
));
201 nact_match_list_init_view( BASE_WINDOW( instance
), ITAB_NAME
);
206 nact_ibasenames_tab_all_widgets_showed( NactIBasenamesTab
*instance
)
208 static const gchar
*thisfn
= "nact_ibasenames_tab_all_widgets_showed";
210 g_return_if_fail( NACT_IS_IBASENAMES_TAB( instance
));
212 if( st_initialized
&& !st_finalized
){
214 g_debug( "%s: instance=%p", thisfn
, ( void * ) instance
);
219 * nact_ibasenames_tab_dispose:
220 * @window: this #NactIBasenamesTab instance.
222 * Called at instance_dispose time.
225 nact_ibasenames_tab_dispose( NactIBasenamesTab
*instance
)
227 static const gchar
*thisfn
= "nact_ibasenames_tab_dispose";
229 g_return_if_fail( NACT_IS_IBASENAMES_TAB( instance
));
231 if( st_initialized
&& !st_finalized
){
233 g_debug( "%s: instance=%p", thisfn
, ( void * ) instance
);
235 nact_match_list_dispose( BASE_WINDOW( instance
), ITAB_NAME
);
240 on_tab_updatable_selection_changed( BaseWindow
*window
, gint count_selected
)
242 st_on_selection_change
= TRUE
;
244 nact_match_list_on_selection_changed( window
, ITAB_NAME
, count_selected
);
246 st_on_selection_change
= FALSE
;
250 on_matchcase_toggled( GtkToggleButton
*button
, BaseWindow
*window
)
256 if( !st_on_selection_change
){
257 context
= nact_main_tab_get_context( NACT_MAIN_WINDOW( window
), &editable
);
260 matchcase
= gtk_toggle_button_get_active( button
);
263 na_object_set_matchcase( context
, matchcase
);
264 g_signal_emit_by_name( G_OBJECT( window
), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED
, context
, FALSE
);
267 g_signal_handlers_block_by_func(( gpointer
) button
, on_matchcase_toggled
, window
);
268 gtk_toggle_button_set_active( button
, !matchcase
);
269 g_signal_handlers_unblock_by_func(( gpointer
) button
, on_matchcase_toggled
, window
);
276 get_basenames( void *context
)
278 return( na_object_get_basenames( context
));
282 set_basenames( void *context
, GSList
*filters
)
284 na_object_set_basenames( context
, filters
);