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, 2011 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-imimetypes-tab.h"
43 /* private interface data
45 struct NactIMimetypesTabInterfacePrivate
{
46 void *empty
; /* so that gcc -pedantic is happy */
49 #define ITAB_NAME "mimetypes"
51 static gboolean st_initialized
= FALSE
;
52 static gboolean st_finalized
= FALSE
;
54 static GType
register_type( void );
55 static void interface_base_init( NactIMimetypesTabInterface
*klass
);
56 static void interface_base_finalize( NactIMimetypesTabInterface
*klass
);
58 static void on_tab_updatable_selection_changed( BaseWindow
*window
, gint count_selected
);
60 static GSList
*get_mimetypes( void *context
);
61 static void set_mimetypes( void *context
, GSList
*filters
);
64 nact_imimetypes_tab_get_type( void )
66 static GType iface_type
= 0;
69 iface_type
= register_type();
78 static const gchar
*thisfn
= "nact_imimetypes_tab_register_type";
81 static const GTypeInfo info
= {
82 sizeof( NactIMimetypesTabInterface
),
83 ( GBaseInitFunc
) interface_base_init
,
84 ( GBaseFinalizeFunc
) interface_base_finalize
,
93 g_debug( "%s", thisfn
);
95 type
= g_type_register_static( G_TYPE_INTERFACE
, "NactIMimetypesTab", &info
, 0 );
97 g_type_interface_add_prerequisite( type
, BASE_WINDOW_TYPE
);
103 interface_base_init( NactIMimetypesTabInterface
*klass
)
105 static const gchar
*thisfn
= "nact_imimetypes_tab_interface_base_init";
107 if( !st_initialized
){
109 g_debug( "%s: klass=%p", thisfn
, ( void * ) klass
);
111 klass
->private = g_new0( NactIMimetypesTabInterfacePrivate
, 1 );
113 st_initialized
= TRUE
;
118 interface_base_finalize( NactIMimetypesTabInterface
*klass
)
120 static const gchar
*thisfn
= "nact_imimetypes_tab_interface_base_finalize";
122 if( st_initialized
&& !st_finalized
){
124 g_debug( "%s: klass=%p", thisfn
, ( void * ) klass
);
128 g_free( klass
->private );
133 * nact_imimetypes_tab_initial_load:
134 * @window: this #NactIMimetypesTab instance.
136 * Initializes the tab widget at initial load.
139 nact_imimetypes_tab_initial_load_toplevel( NactIMimetypesTab
*instance
)
141 static const gchar
*thisfn
= "nact_imimetypes_tab_initial_load_toplevel";
142 GtkWidget
*list
, *add
, *remove
;
144 g_return_if_fail( NACT_IS_IMIMETYPES_TAB( instance
));
146 if( st_initialized
&& !st_finalized
){
148 g_debug( "%s: instance=%p", thisfn
, ( void * ) instance
);
150 list
= base_window_get_widget( BASE_WINDOW( instance
), "MimetypesTreeView" );
151 add
= base_window_get_widget( BASE_WINDOW( instance
), "AddMimetypeButton" );
152 remove
= base_window_get_widget( BASE_WINDOW( instance
), "RemoveMimetypeButton" );
154 nact_match_list_create_model(
155 BASE_WINDOW( instance
),
159 ( pget_filters
) get_mimetypes
,
160 ( pset_filters
) set_mimetypes
,
162 MATCH_LIST_MUST_MATCH_ONE_OF
,
163 _( "Mimetype filter" ), TRUE
);
168 * nact_imimetypes_tab_runtime_init:
169 * @window: this #NactIMimetypesTab instance.
171 * Initializes the tab widget at each time the widget will be displayed.
172 * Connect signals and setup runtime values.
175 nact_imimetypes_tab_runtime_init_toplevel( NactIMimetypesTab
*instance
)
177 static const gchar
*thisfn
= "nact_imimetypes_tab_runtime_init_toplevel";
179 g_return_if_fail( NACT_IS_IMIMETYPES_TAB( instance
));
181 if( st_initialized
&& !st_finalized
){
183 g_debug( "%s: instance=%p", thisfn
, ( void * ) instance
);
185 base_window_signal_connect(
186 BASE_WINDOW( instance
),
187 G_OBJECT( instance
),
188 MAIN_WINDOW_SIGNAL_SELECTION_CHANGED
,
189 G_CALLBACK( on_tab_updatable_selection_changed
));
191 nact_match_list_init_view( BASE_WINDOW( instance
), ITAB_NAME
);
196 nact_imimetypes_tab_all_widgets_showed( NactIMimetypesTab
*instance
)
198 static const gchar
*thisfn
= "nact_imimetypes_tab_all_widgets_showed";
200 g_return_if_fail( NACT_IS_IMIMETYPES_TAB( instance
));
202 if( st_initialized
&& !st_finalized
){
204 g_debug( "%s: instance=%p", thisfn
, ( void * ) instance
);
209 * nact_imimetypes_tab_dispose:
210 * @window: this #NactIMimetypesTab instance.
212 * Called at instance_dispose time.
215 nact_imimetypes_tab_dispose( NactIMimetypesTab
*instance
)
217 static const gchar
*thisfn
= "nact_imimetypes_tab_dispose";
219 g_return_if_fail( NACT_IS_IMIMETYPES_TAB( instance
));
221 if( st_initialized
&& !st_finalized
){
223 g_debug( "%s: instance=%p", thisfn
, ( void * ) instance
);
225 nact_match_list_dispose( BASE_WINDOW( instance
), ITAB_NAME
);
230 on_tab_updatable_selection_changed( BaseWindow
*window
, gint count_selected
)
232 nact_match_list_on_selection_changed( window
, ITAB_NAME
, count_selected
);
236 get_mimetypes( void *context
)
238 return( na_object_get_mimetypes( context
));
242 set_mimetypes( void *context
, GSList
*filters
)
244 na_object_set_mimetypes( context
, filters
);