[nautilus-actions] Implement NactISchemesTab interface
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Implement NactISchemesTab interface
- Date: Thu, 10 Jun 2010 22:36:36 +0000 (UTC)
commit c255a3c48e945e1b1c8b824fd1e59ca8d2030573
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Jun 4 23:40:01 2010 +0200
Implement NactISchemesTab interface
ChangeLog | 10 +++
TODO | 5 +
src/api/na-object-api.h | 22 +++---
src/core/na-icontext-factory.c | 2 +-
src/nact/nact-icommand-tab.c | 13 +++-
src/nact/nact-ischemes-tab.c | 165 +++++++++++-----------------------------
src/nact/nact-ischemes-tab.h | 2 -
7 files changed, 85 insertions(+), 134 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e34175b..82696e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,16 @@
2010-06-04 Pierre Wieser <pwieser trychlos org>
+ * src/api/na-object-api.h: Reorganization.
+
+ * src/core/na-icontext-factory.c: Set schemes default to '*'.
+
+ * src/nact/nact-icommand-tab.c: Get schemes from current object.
+
+ * src/nact/nact-ischemes-tab.c:
+ * src/nact/nact-ischemes-tab.h:
+ Take advantage of new nact_match_list_xxx functions.
+
* src/api/na-object-api.h:
* src/api/na-ifactory-object-data.h:
* src/core/na-object-profile-factory.c: Add NAFO_DATA_WORKING_DIR data.
diff --git a/TODO b/TODO
index 76094c3..6b33fba 100644
--- a/TODO
+++ b/TODO
@@ -472,3 +472,8 @@ Parameter Description
- 2010-06-03: ui enhancement
sortable column headers in tab as basenames, mimetypes, and so on, should have
a small indicator of the current sort order
+
+- default has changed for schemes (was coded as 'file' instead of '*')
+ when version is recorded (as 1.4.1 or 2.0) then schemes is reliable
+ when version is not recorded, it is a 2.30 serie, and scheme is not recorded when default (i.e. file)
+ do not try to force anything than that, but this will have to be documented
diff --git a/src/api/na-object-api.h b/src/api/na-object-api.h
index 3747dfb..406091d 100644
--- a/src/api/na-object-api.h
+++ b/src/api/na-object-api.h
@@ -167,32 +167,32 @@ G_BEGIN_DECLS
#define na_object_set_isfile( obj, isfile ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_ISFILE, ( const void * ) GUINT_TO_POINTER( isfile ))
#define na_object_set_isdir( obj, isdir ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_ISDIR, ( const void * ) GUINT_TO_POINTER( isdir ))
#define na_object_set_multiple( obj, multiple ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_MULTIPLE, ( const void * ) GUINT_TO_POINTER( multiple ))
-#define na_object_set_schemes( obj, schemes ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_SCHEMES, ( const void * )( schemes ))
-#define na_object_set_folders( obj, folders ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_FOLDERS, ( const void * )( folders ))
/* NAIContext
*/
+#define na_object_get_basenames( obj ) (( GSList * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_BASENAMES ))
+#define na_object_get_matchcase( obj ) (( gboolean ) GPOINTER_TO_UINT( na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_MATCHCASE )))
+#define na_object_get_mimetypes( obj ) (( GSList * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_MIMETYPES ))
+#define na_object_get_all_mimetypes( obj ) (( gboolean ) GPOINTER_TO_UINT( na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_ALL_MIMETYPES )))
+#define na_object_get_folders( obj ) (( GSList * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_FOLDERS ))
+#define na_object_get_schemes( obj ) (( GSList * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_SCHEMES ))
#define na_object_get_only_show_in( obj ) (( GSList * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_ONLY_SHOW ))
#define na_object_get_not_show_in( obj ) (( GSList * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_NOT_SHOW ))
#define na_object_get_try_exec( obj ) (( gchar * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_TRY_EXEC ))
#define na_object_get_show_if_registered( obj ) (( gchar * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_SHOW_IF_REGISTERED ))
#define na_object_get_show_if_true( obj ) (( gchar * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_SHOW_IF_TRUE ))
#define na_object_get_show_if_running( obj ) (( gchar * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_SHOW_IF_RUNNING ))
-#define na_object_get_mimetypes( obj ) (( GSList * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_MIMETYPES ))
-#define na_object_get_all_mimetypes( obj ) (( gboolean ) GPOINTER_TO_UINT( na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_ALL_MIMETYPES )))
-#define na_object_get_basenames( obj ) (( GSList * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_BASENAMES ))
-#define na_object_get_matchcase( obj ) (( gboolean ) GPOINTER_TO_UINT( na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_MATCHCASE )))
#define na_object_get_selection_count( obj ) (( gchar * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_SELECTION_COUNT ))
-#define na_object_get_schemes( obj ) (( GSList * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_SCHEMES ))
-#define na_object_get_folders( obj ) (( GSList * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_FOLDERS ))
#define na_object_get_capabilities( obj ) (( GSList * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_CAPABILITITES ))
-#define na_object_set_mimetypes( obj, types ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_MIMETYPES, ( const void * )( types ))
-#define na_object_set_all_mimetypes( obj, all ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_ALL_MIMETYPES, ( const void * ) GUINT_TO_POINTER( all ))
#define na_object_set_basenames( obj, bnames ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_BASENAMES, ( const void * )( bnames ))
#define na_object_set_matchcase( obj, match ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_MATCHCASE, ( const void * ) GUINT_TO_POINTER( match ))
-#define na_object_set_scheme( obj, scheme, add ) na_icontext_set_scheme( NA_ICONTEXT( obj ), ( const gchar * )( scheme ), ( add ))
+#define na_object_set_mimetypes( obj, types ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_MIMETYPES, ( const void * )( types ))
+#define na_object_set_all_mimetypes( obj, all ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_ALL_MIMETYPES, ( const void * ) GUINT_TO_POINTER( all ))
+#define na_object_set_folders( obj, folders ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_FOLDERS, ( const void * )( folders ))
#define na_object_replace_folder( obj, old, new ) na_icontext_replace_folder( NA_ICONTEXT( obj ), ( const gchar * )( old ), ( const gchar * )( new ))
+#define na_object_set_scheme( obj, scheme, add ) na_icontext_set_scheme( NA_ICONTEXT( obj ), ( const gchar * )( scheme ), ( add ))
+#define na_object_set_schemes( obj, schemes ) na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_SCHEMES, ( const void * )( schemes ))
G_END_DECLS
diff --git a/src/core/na-icontext-factory.c b/src/core/na-icontext-factory.c
index a4d94bc..b324d39 100644
--- a/src/core/na-icontext-factory.c
+++ b/src/core/na-icontext-factory.c
@@ -264,7 +264,7 @@ NADataDef data_def_conditions [] = {
"or when targeting the special 'x-nautilus-desktop' scheme.\n" \
"Defaults to 'file'." ),
NAFD_TYPE_STRING_LIST,
- "[file]",
+ "[*]",
FALSE,
TRUE,
TRUE,
diff --git a/src/nact/nact-icommand-tab.c b/src/nact/nact-icommand-tab.c
index fb5a60d..2de8845 100644
--- a/src/nact/nact-icommand-tab.c
+++ b/src/nact/nact-icommand-tab.c
@@ -756,6 +756,9 @@ static gchar *
parse_parameters( NactICommandTab *instance )
{
GString *tmp_string = g_string_new( "" );
+ NAObjectItem *item;
+ NAObjectProfile *profile;
+ NAIContext *context;
/* i18n notes: example strings for the command preview */
gchar *ex_path = _( "/path/to" );
@@ -799,7 +802,15 @@ parse_parameters( NactICommandTab *instance )
is_dir = TRUE;
accept_multiple = TRUE;
- scheme_list = nact_ischemes_tab_get_schemes( NACT_ISCHEMES_TAB( instance ));
+ g_object_get(
+ G_OBJECT( instance ),
+ TAB_UPDATABLE_PROP_EDITED_ACTION, &item,
+ TAB_UPDATABLE_PROP_EDITED_PROFILE, &profile,
+ NULL );
+
+ context = ( profile ? NA_ICONTEXT( profile ) : ( NAIContext * ) item );
+
+ scheme_list = na_object_get_schemes( context );
separator = g_strdup_printf( " %s/", ex_path );
start = g_strdup_printf( "%s/", ex_path );
diff --git a/src/nact/nact-ischemes-tab.c b/src/nact/nact-ischemes-tab.c
index e22bb4a..67b1034 100644
--- a/src/nact/nact-ischemes-tab.c
+++ b/src/nact/nact-ischemes-tab.c
@@ -32,11 +32,12 @@
#include <config.h>
#endif
+#include <glib/gi18n.h>
+
#include <api/na-object-api.h>
-#include "base-window.h"
#include "nact-main-tab.h"
-#include "nact-schemes-list.h"
+#include "nact-match-list.h"
#include "nact-ischemes-tab.h"
/* private interface data
@@ -45,18 +46,20 @@ struct NactISchemesTabInterfacePrivate {
void *empty; /* so that gcc -pedantic is happy */
};
+#define ITAB_NAME "schemes"
+
static gboolean st_initialized = FALSE;
static gboolean st_finalized = FALSE;
-static GType register_type( void );
-static void interface_base_init( NactISchemesTabInterface *klass );
-static void interface_base_finalize( NactISchemesTabInterface *klass );
+static GType register_type( void );
+static void interface_base_init( NactISchemesTabInterface *klass );
+static void interface_base_finalize( NactISchemesTabInterface *klass );
-static void runtime_init_connect_signals( NactISchemesTab *instance, GtkTreeView *listview );
-static void on_tab_updatable_selection_changed( NactISchemesTab *instance, gint count_selected );
-static void on_tab_updatable_enable_tab( NactISchemesTab *instance, NAObjectItem *item );
-static gboolean tab_set_sensitive( NactISchemesTab *instance );
-static GtkTreeView *get_schemes_tree_view( NactISchemesTab *instance );
+static void on_tab_updatable_selection_changed( BaseWindow *window, gint count_selected );
+static void on_tab_updatable_enable_tab( BaseWindow *window, NAObjectItem *item );
+
+static GSList *get_schemes( void *context );
+static void set_schemes( void *context, GSList *filters );
GType
nact_ischemes_tab_get_type( void )
@@ -131,6 +134,7 @@ void
nact_ischemes_tab_initial_load_toplevel( NactISchemesTab *instance )
{
static const gchar *thisfn = "nact_ischemes_tab_initial_load_toplevel";
+ GtkWidget *list, *add, *remove;
g_return_if_fail( NACT_IS_ISCHEMES_TAB( instance ));
@@ -138,7 +142,19 @@ nact_ischemes_tab_initial_load_toplevel( NactISchemesTab *instance )
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
- nact_schemes_list_create_model( get_schemes_tree_view( instance ), TRUE );
+ list = base_window_get_widget( BASE_WINDOW( instance ), "SchemesTreeView" );
+ add = base_window_get_widget( BASE_WINDOW( instance ), "AddSchemeButton" );
+ remove = base_window_get_widget( BASE_WINDOW( instance ), "RemoveSchemeButton" );
+
+ nact_match_list_create_model(
+ BASE_WINDOW( instance ),
+ ITAB_NAME,
+ TAB_SCHEMES,
+ list, add, remove,
+ ( pget_filters ) get_schemes,
+ ( pset_filters ) set_schemes,
+ NULL,
+ _( "Scheme filter" ));
}
}
@@ -146,28 +162,12 @@ void
nact_ischemes_tab_runtime_init_toplevel( NactISchemesTab *instance )
{
static const gchar *thisfn = "nact_ischemes_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_ISCHEMES_TAB( instance ));
-
- listview = get_schemes_tree_view( instance );
- runtime_init_connect_signals( instance, listview );
- nact_schemes_list_init_view( listview, BASE_WINDOW( instance ));
- }
-}
-
-static void
-runtime_init_connect_signals( NactISchemesTab *instance, GtkTreeView *listview )
-{
- static const gchar *thisfn = "nact_ischemes_tab_runtime_init_connect_signals";
+ g_return_if_fail( NACT_IS_ISCHEMES_TAB( instance ));
if( st_initialized && !st_finalized ){
- g_debug( "%s: instance=%p, listview=%p", thisfn, ( void * ) instance, ( void * ) listview );
- g_return_if_fail( NACT_IS_ISCHEMES_TAB( instance ));
+ g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
base_window_signal_connect(
BASE_WINDOW( instance ),
@@ -180,6 +180,8 @@ runtime_init_connect_signals( NactISchemesTab *instance, GtkTreeView *listview )
G_OBJECT( instance ),
TAB_UPDATABLE_SIGNAL_ENABLE_TAB,
G_CALLBACK( on_tab_updatable_enable_tab ));
+
+ nact_match_list_init_view( BASE_WINDOW( instance ), ITAB_NAME );
}
}
@@ -188,10 +190,11 @@ nact_ischemes_tab_all_widgets_showed( NactISchemesTab *instance )
{
static const gchar *thisfn = "nact_ischemes_tab_all_widgets_showed";
+ g_return_if_fail( NACT_IS_ISCHEMES_TAB( instance ));
+
if( st_initialized && !st_finalized ){
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
- g_return_if_fail( NACT_IS_ISCHEMES_TAB( instance ));
}
}
@@ -200,112 +203,36 @@ nact_ischemes_tab_dispose( NactISchemesTab *instance )
{
static const gchar *thisfn = "nact_ischemes_tab_dispose";
+ g_return_if_fail( NACT_IS_ISCHEMES_TAB( instance ));
+
if( st_initialized && !st_finalized ){
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
- g_return_if_fail( NACT_IS_ISCHEMES_TAB( instance ));
-
- nact_schemes_list_dispose( BASE_WINDOW( instance ));
- }
-}
-
-/**
- * Returns selected schemes as a list of strings.
- * The caller should call na_core_utils_slist_free() after use.
- */
-GSList *
-nact_ischemes_tab_get_schemes( NactISchemesTab *instance )
-{
- GSList *list;
-
- list = NULL;
- g_return_val_if_fail( NACT_IS_ISCHEMES_TAB( instance ), list );
-
- if( st_initialized && !st_finalized ){
- list = nact_schemes_list_get_schemes( get_schemes_tree_view( instance ));
+ nact_match_list_dispose( BASE_WINDOW( instance ), ITAB_NAME );
}
-
- return( list );
}
static void
-on_tab_updatable_selection_changed( NactISchemesTab *instance, gint count_selected )
+on_tab_updatable_selection_changed( BaseWindow *window, gint count_selected )
{
- static const gchar *thisfn = "nact_ischemes_tab_on_tab_updatable_selection_changed";
- NAObjectItem *item;
- NAObjectProfile *profile;
- GSList *schemes;
- gboolean editable;
-
- schemes = 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_ISCHEMES_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 );
-
- if( profile ){
- schemes = na_object_get_schemes( profile );
- }
-
- nact_schemes_list_setup_values(
- get_schemes_tree_view( instance ),
- BASE_WINDOW( instance ),
- schemes,
- item && NA_IS_OBJECT_ACTION( item ),
- editable );
- }
+ nact_match_list_on_selection_changed( window, ITAB_NAME, count_selected );
}
static void
-on_tab_updatable_enable_tab( NactISchemesTab *instance, NAObjectItem *item )
+on_tab_updatable_enable_tab( BaseWindow *window, NAObjectItem *item )
{
- static const gchar *thisfn = "nact_ischemes_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_ISCHEMES_TAB( instance ));
-
- tab_set_sensitive( instance );
- }
+ nact_match_list_on_enable_tab( window, ITAB_NAME, item );
}
-static gboolean
-tab_set_sensitive( NactISchemesTab *instance )
+static GSList *
+get_schemes( void *context )
{
- 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_SCHEMES, enable_tab );
-
- return( enable_tab );
+ return( na_object_get_schemes( context ));
}
-static GtkTreeView *
-get_schemes_tree_view( NactISchemesTab *instance )
+static void
+set_schemes( void *context, GSList *filters )
{
- GtkWidget *treeview;
-
- treeview = base_window_get_widget( BASE_WINDOW( instance ), "SchemesTreeView" );
- g_assert( GTK_IS_TREE_VIEW( treeview ));
-
- return( GTK_TREE_VIEW( treeview ));
+ na_object_set_schemes( context, filters );
}
diff --git a/src/nact/nact-ischemes-tab.h b/src/nact/nact-ischemes-tab.h
index a12f447..9292c5a 100644
--- a/src/nact/nact-ischemes-tab.h
+++ b/src/nact/nact-ischemes-tab.h
@@ -66,8 +66,6 @@ void nact_ischemes_tab_runtime_init_toplevel( NactISchemesTab *instance );
void nact_ischemes_tab_all_widgets_showed ( NactISchemesTab *instance );
void nact_ischemes_tab_dispose ( NactISchemesTab *instance );
-GSList *nact_ischemes_tab_get_schemes ( NactISchemesTab *instance );
-
G_END_DECLS
#endif /* __NACT_ISCHEMES_TAB_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]