[nautilus-actions] Another update on data model
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Another update on data model
- Date: Sun, 25 Oct 2009 15:19:01 +0000 (UTC)
commit cdd0fb4643f045bda99c26cfb7046c47946a79a2
Author: Pierre Wieser <pwieser trychlos org>
Date: Sat Oct 24 17:43:37 2009 +0200
Another update on data model
Targeting selection, background or toolbar is only relevant for actions.
Folders, to be compared to Nautilus current_folder, is only relevant in profiles.
data/nautilus-actions.schemas.in | 23 ++
src/common/na-xml-writer.c | 12 +-
src/nact/nact-iaction-tab.c | 81 ++++---
src/nact/nact-iactions-list.c | 26 ++-
src/nact/nact-iadvanced-tab.c | 4 +-
src/nact/nact-ibackground-tab.c | 352 ++++++++++++++++++++++++++++--
src/nact/nact-icommand-tab.c | 6 +-
src/nact/nact-iconditions-tab.c | 2 +-
src/nact/nact-main-menubar.c | 2 +
src/nact/nact-xml-reader.c | 6 +-
src/nact/nautilus-actions-config-tool.ui | 226 ++++++++++++++------
src/runtime/na-gconf-provider.c | 32 ++--
src/runtime/na-object-action-fn.h | 16 ++
src/runtime/na-object-action-priv.h | 8 +-
src/runtime/na-object-action.c | 213 +++++++++++++++++-
src/runtime/na-object-api.h | 6 -
src/runtime/na-object-item-fn.h | 6 -
src/runtime/na-object-item-priv.h | 13 +-
src/runtime/na-object-item.c | 218 +------------------
src/runtime/na-object-profile-fn.h | 9 +-
src/runtime/na-object-profile-priv.h | 4 +-
src/runtime/na-object-profile.c | 62 ++++--
22 files changed, 894 insertions(+), 433 deletions(-)
---
diff --git a/data/nautilus-actions.schemas.in b/data/nautilus-actions.schemas.in
index d45009b..b3696a8 100644
--- a/data/nautilus-actions.schemas.in
+++ b/data/nautilus-actions.schemas.in
@@ -334,6 +334,29 @@ All schemes used by Nautilus can be used here. This only applies when targeting
</schema>
<schema>
+ <key>/schemas/apps/nautilus-actions/preferences/ibackground-chooser</key>
+ <owner>nautilus-actions</owner>
+ <type>list</type>
+ <list_type>int</list_type>
+ <locale name="C">
+ <short>Position and size of the URI chooser window</short>
+ <long>Position and size of the URI chooser window in the Background tab ; default is set by the window manager.</long>
+ </locale>
+ <default>[]</default>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/nautilus-actions/preferences/ibackground-uri</key>
+ <owner>nautilus-actions</owner>
+ <type>string</type>
+ <locale name="C">
+ <short>Last selected folder</short>
+ <long>Last folder selected when browsing for an URI in the Background tab.</long>
+ </locale>
+ <default>/bin</default>
+ </schema>
+
+ <schema>
<key>/schemas/apps/nautilus-actions/preferences/icommand-command-chooser</key>
<owner>nautilus-actions</owner>
<type>list</type>
diff --git a/src/common/na-xml-writer.c b/src/common/na-xml-writer.c
index f2ff25e..88efd49 100644
--- a/src/common/na-xml-writer.c
+++ b/src/common/na-xml-writer.c
@@ -589,19 +589,19 @@ create_xml_schema( NAXMLWriter *writer, gint format, const NAObjectAction *actio
g_free( type );
/* target selection */
- target_selection = na_object_is_target_selection( action );
+ target_selection = na_object_action_is_target_selection( action );
text = na_utils_boolean_to_schema( target_selection );
create_schema_entry( writer, format, NULL, OBJECT_ITEM_TARGET_SELECTION_ENTRY, text, doc, list_node, "bool", FALSE, ACTION_TARGET_SELECTION_DESC_SHORT, ACTION_TARGET_SELECTION_DESC_LONG );
g_free( text );
/* target background */
- target_background = na_object_is_target_background( action );
+ target_background = na_object_action_is_target_background( action );
text = na_utils_boolean_to_schema( target_background );
create_schema_entry( writer, format, NULL, OBJECT_ITEM_TARGET_BACKGROUND_ENTRY, text, doc, list_node, "bool", FALSE, ACTION_TARGET_BACKGROUND_DESC_SHORT, ACTION_TARGET_BACKGROUND_DESC_LONG );
g_free( text );
/* target toolbar */
- target_toolbar = na_object_is_target_toolbar( action );
+ target_toolbar = na_object_action_is_target_toolbar( action );
text = na_utils_boolean_to_schema( target_toolbar );
create_schema_entry( writer, format, NULL, OBJECT_ITEM_TARGET_TOOLBAR_ENTRY, text, doc, list_node, "bool", FALSE, ACTION_TARGET_TOOLBAR_DESC_SHORT, ACTION_TARGET_TOOLBAR_DESC_LONG );
g_free( text );
@@ -827,19 +827,19 @@ create_xml_dump( NAXMLWriter *writer, gint format, const NAObjectAction *action
g_free( type );
/* target selection */
- target_selection = na_object_is_target_selection( action );
+ target_selection = na_object_action_is_target_selection( action );
text = na_utils_boolean_to_schema( target_selection );
create_dump_entry( writer, format, NULL, OBJECT_ITEM_TARGET_SELECTION_ENTRY, text, doc, list_node, "bool" );
g_free( text );
/* target background */
- target_background = na_object_is_target_background( action );
+ target_background = na_object_action_is_target_background( action );
text = na_utils_boolean_to_schema( target_background );
create_dump_entry( writer, format, NULL, OBJECT_ITEM_TARGET_BACKGROUND_ENTRY, text, doc, list_node, "bool" );
g_free( text );
/* target toolbar */
- target_toolbar = na_object_is_target_toolbar( action );
+ target_toolbar = na_object_action_is_target_toolbar( action );
text = na_utils_boolean_to_schema( target_toolbar );
create_dump_entry( writer, format, NULL, OBJECT_ITEM_TARGET_TOOLBAR_ENTRY, text, doc, list_node, "bool" );
g_free( text );
diff --git a/src/nact/nact-iaction-tab.c b/src/nact/nact-iaction-tab.c
index 9c32da3..bbf172f 100644
--- a/src/nact/nact-iaction-tab.c
+++ b/src/nact/nact-iaction-tab.c
@@ -332,14 +332,15 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
{
static const gchar *thisfn = "nact_iaction_tab_on_tab_updatable_selection_changed";
NAObjectItem *item;
+ gboolean enable_tab;
GtkWidget *label_widget, *tooltip_widget, *icon_widget, *title_widget;
gchar *label, *tooltip, *icon;
GtkButton *enabled_button;
gboolean enabled_item;
- gboolean enable_tab;
gboolean target_background_active;
gboolean target_toolbar_active;
GtkToggleButton *toggle;
+ GtkWidget *frame;
g_debug( "%s: instance=%p, count_selected=%d", thisfn, ( void * ) instance, count_selected );
g_return_if_fail( BASE_IS_WINDOW( instance ));
@@ -355,10 +356,6 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
g_return_if_fail( !item || NA_IS_OBJECT_ITEM( item ));
enable_tab = ( count_selected == 1 );
- if( item && !enable_tab ){
- g_warning( "%s:item=%p (%s), but count_selected=%d",
- thisfn, ( void * ) item, G_OBJECT_TYPE_NAME( item ), count_selected );
- }
nact_main_tab_enable_page( NACT_MAIN_WINDOW( instance ), TAB_ACTION, enable_tab );
label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionItemID" );
@@ -391,18 +388,27 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
gtk_label_set_markup( GTK_LABEL( title_widget ), _( "<b>Action targets</b>" ));
}
+ frame = base_window_get_widget( BASE_WINDOW( instance ), "ActionTargetFrame" );
+ gtk_widget_set_sensitive( frame, item && NA_IS_OBJECT_ACTION( item ));
+
toggle = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "ActionTargetSelectionButton" ));
- gtk_toggle_button_set_active( toggle, item ? na_object_is_target_selection( item ) : FALSE );
+ gtk_toggle_button_set_active( toggle,
+ item && NA_IS_OBJECT_ACTION( item )
+ ? na_object_action_is_target_selection( NA_OBJECT_ACTION( item ))
+ : FALSE );
toggle = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "ActionTargetBackgroundButton" ));
- target_background_active = ( item ? na_object_is_target_background( item ) : FALSE );
+ target_background_active = (
+ item && NA_IS_OBJECT_ACTION( item )
+ ? na_object_action_is_target_background( NA_OBJECT_ACTION( item ))
+ : FALSE );
gtk_toggle_button_set_active( toggle, target_background_active );
toggle = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "ActionTargetToolbarButton" ));
- target_toolbar_active = ( item ? na_object_is_target_toolbar( item ) : FALSE );
- if( target_toolbar_active && item && NA_IS_OBJECT_MENU( item )){
- g_warning( "%s: targeting toolbar is irrelevant for a menu", thisfn );
- }
+ target_toolbar_active = (
+ item && NA_IS_OBJECT_ACTION( item )
+ ? na_object_action_is_target_toolbar( NA_OBJECT_ACTION( item ))
+ : FALSE );
gtk_toggle_button_set_active( toggle, target_toolbar_active );
gtk_widget_set_sensitive( GTK_WIDGET( toggle ), item && NA_IS_OBJECT_ACTION( item ));
@@ -474,7 +480,7 @@ on_label_changed( GtkEntry *entry, NactIActionTab *instance )
check_for_label( instance, entry, label );
if( NA_IS_OBJECT_ACTION( edited )){
- target_toolbar = na_object_is_target_toolbar( edited );
+ target_toolbar = na_object_action_is_target_toolbar( NA_OBJECT_ACTION( edited ));
if( target_toolbar ){
toolbar_same_label = na_object_action_toolbar_use_same_label( NA_OBJECT_ACTION( edited ));
if( toolbar_same_label ){
@@ -597,12 +603,15 @@ static void
on_icon_browse( GtkButton *button, NactIActionTab *instance )
{
GtkWidget *dialog;
+ GtkWindow *toplevel;
gchar *filename;
GtkWidget *icon_widget;
+ toplevel = base_window_get_toplevel( BASE_WINDOW( instance ));
+
dialog = gtk_file_chooser_dialog_new(
_( "Choosing an icon" ),
- NULL,
+ toplevel,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
@@ -706,22 +715,24 @@ static void
on_target_selection_toggled( GtkToggleButton *button, NactIActionTab *instance )
{
static const gchar *thisfn = "nact_iaction_tab_on_target_selection_toggled";
- NAObjectItem *item;
+ NAObjectAction *action;
gboolean is_target;
g_debug( "%s: button=%p, instance=%p", thisfn, ( void * ) button, ( void * ) instance );
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_EDITED_ACTION, &item,
+ TAB_UPDATABLE_PROP_EDITED_ACTION, &action,
NULL );
- if( item ){
+ g_return_if_fail( !action || NA_IS_OBJECT_ACTION( action ));
+
+ if( action ){
is_target = gtk_toggle_button_get_active( button );
- na_object_set_target_selection( item, is_target );
+ na_object_action_set_target_selection( action, is_target );
- g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ENABLE_TAB, item );
- g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, item, FALSE );
+ g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ENABLE_TAB, action );
+ g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, action, FALSE );
}
}
@@ -729,26 +740,24 @@ static void
on_target_background_toggled( GtkToggleButton *button, NactIActionTab *instance )
{
static const gchar *thisfn = "nact_iaction_tab_on_target_background_toggled";
- NAObjectItem *item;
+ NAObjectAction *action;
gboolean is_target;
- GtkWidget *toolbar;
g_debug( "%s: button=%p, instance=%p", thisfn, ( void * ) button, ( void * ) instance );
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_EDITED_ACTION, &item,
+ TAB_UPDATABLE_PROP_EDITED_ACTION, &action,
NULL );
- if( item ){
- is_target = gtk_toggle_button_get_active( button );
- na_object_set_target_background( item, is_target );
+ g_return_if_fail( !action || NA_IS_OBJECT_ACTION( action ));
- toolbar = base_window_get_widget( BASE_WINDOW( instance ), "ActionTargetToolbarButton" );
- gtk_widget_set_sensitive( toolbar, is_target && NA_IS_OBJECT_ACTION( item ));
+ if( action ){
+ is_target = gtk_toggle_button_get_active( button );
+ na_object_action_set_target_background( action, is_target );
- g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ENABLE_TAB, item );
- g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, item, FALSE );
+ g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ENABLE_TAB, action );
+ g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, action, FALSE );
}
}
@@ -756,22 +765,24 @@ static void
on_target_toolbar_toggled( GtkToggleButton *button, NactIActionTab *instance )
{
static const gchar *thisfn = "nact_iaction_tab_on_target_toolbar_toggled";
- NAObjectItem *item;
+ NAObjectAction *action;
gboolean is_target;
g_debug( "%s: button=%p, instance=%p", thisfn, ( void * ) button, ( void * ) instance );
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_EDITED_ACTION, &item,
+ TAB_UPDATABLE_PROP_EDITED_ACTION, &action,
NULL );
- if( item ){
+ g_return_if_fail( !action || NA_IS_OBJECT_ACTION( action ));
+
+ if( action ){
is_target = gtk_toggle_button_get_active( button );
- na_object_set_target_toolbar( item, is_target );
+ na_object_action_set_target_toolbar( action, is_target );
- g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ENABLE_TAB, item );
- g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, item, FALSE );
+ g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ENABLE_TAB, action );
+ g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, action, FALSE );
}
}
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index 1302986..6bba5e8 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -841,7 +841,9 @@ nact_iactions_list_fill( NactIActionsList *instance, GList *items )
ialid->selection_changed_send_allowed = FALSE;
nact_tree_model_fill( model, items, only_actions );
+
ialid->selection_changed_send_allowed = TRUE;
+ select_first_row( instance );
ialid->menus = 0;
ialid->actions = 0;
@@ -851,8 +853,6 @@ nact_iactions_list_fill( NactIActionsList *instance, GList *items )
na_object_item_count_items( items, &ialid->menus, &ialid->actions, &ialid->profiles, TRUE );
send_list_count_updated_signal( instance, ialid );
}
-
- select_first_row( instance );
}
}
@@ -2026,18 +2026,16 @@ on_edition_status_changed( NactIActionsList *instance, NAIDuplicable *object )
IActionsListInstanceData *ialid;
ialid = get_instance_data( instance );
- /*if( ialid->selection_changed_send_allowed ){*/
- g_debug( "nact_iactions_list_on_edition_status_changed: instance=%p, object=%p (%s)",
- ( void * ) instance,
- ( void * ) object, G_OBJECT_TYPE_NAME( object ));
+ g_debug( "nact_iactions_list_on_edition_status_changed: instance=%p, object=%p (%s)",
+ ( void * ) instance,
+ ( void * ) object, G_OBJECT_TYPE_NAME( object ));
- g_return_if_fail( NA_IS_OBJECT( object ));
+ g_return_if_fail( NA_IS_OBJECT( object ));
- treeview = get_actions_list_treeview( instance );
- model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
- nact_tree_model_display( model, NA_OBJECT( object ));
- /*}*/
+ treeview = get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+ nact_tree_model_display( model, NA_OBJECT( object ));
if( na_object_is_modified( object )){
if( !g_list_find( ialid->modified_items, object )){
@@ -2047,7 +2045,11 @@ on_edition_status_changed( NactIActionsList *instance, NAIDuplicable *object )
ialid->modified_items = g_list_remove( ialid->modified_items, object );
}
- g_signal_emit_by_name( instance, IACTIONS_LIST_SIGNAL_STATUS_CHANGED, NULL );
+ /* do not send status-changed signal while filling the tree
+ */
+ if( ialid->selection_changed_send_allowed ){
+ g_signal_emit_by_name( instance, IACTIONS_LIST_SIGNAL_STATUS_CHANGED, NULL );
+ }
}
/*
diff --git a/src/nact/nact-iadvanced-tab.c b/src/nact/nact-iadvanced-tab.c
index eb5a6ca..b4f69e6 100644
--- a/src/nact/nact-iadvanced-tab.c
+++ b/src/nact/nact-iadvanced-tab.c
@@ -219,6 +219,8 @@ initial_load_create_schemes_selection_list( NactIAdvancedTab *instance )
"text", SCHEMES_DESC_COLUMN,
NULL );
gtk_tree_view_append_column( listview, column );
+
+ gtk_tree_view_set_headers_visible( listview, FALSE );
}
}
@@ -449,7 +451,7 @@ tab_set_sensitive( NactIAdvancedTab *instance )
TAB_UPDATABLE_PROP_EDITED_PROFILE, &profile,
NULL );
- enable_tab = ( profile != NULL && na_object_is_target_selection( item ));
+ enable_tab = ( profile != NULL && na_object_action_is_target_selection( NA_OBJECT_ACTION( item )));
nact_main_tab_enable_page( NACT_MAIN_WINDOW( instance ), TAB_ADVANCED, enable_tab );
return( enable_tab );
diff --git a/src/nact/nact-ibackground-tab.c b/src/nact/nact-ibackground-tab.c
index 16beb04..83aca76 100644
--- a/src/nact/nact-ibackground-tab.c
+++ b/src/nact/nact-ibackground-tab.c
@@ -35,11 +35,15 @@
#include <glib/gi18n.h>
#include <string.h>
+#include <common/na-iprefs.h>
#include <common/na-object-api.h>
#include <common/na-utils.h>
+#include <runtime/na-pivot.h>
+
#include "base-iprefs.h"
#include "base-window.h"
+#include "nact-application.h"
#include "nact-main-tab.h"
#include "nact-ibackground-tab.h"
@@ -49,20 +53,41 @@ struct NactIBackgroundTabInterfacePrivate {
void *empty; /* so that gcc -pedantic is happy */
};
+/* column ordering
+ */
+enum {
+ BACKGROUND_URI_COLUMN = 0,
+ BACKGROUND_N_COLUMN
+};
+
+#define IPREFS_BACKGROUND_DIALOG "ibackground-chooser"
+#define IPREFS_BACKGROUND_URI "ibackground-uri"
+
static gboolean st_initialized = FALSE;
static gboolean st_finalized = FALSE;
-static GType register_type( void );
-static void interface_base_init( NactIBackgroundTabInterface *klass );
-static void interface_base_finalize( NactIBackgroundTabInterface *klass );
+static GType register_type( void );
+static void interface_base_init( NactIBackgroundTabInterface *klass );
+static void interface_base_finalize( NactIBackgroundTabInterface *klass );
+
+static void on_tab_updatable_selection_changed( NactIBackgroundTab *instance, gint count_selected );
+static void on_tab_updatable_enable_tab( NactIBackgroundTab *instance, NAObjectItem *item );
+static gboolean tab_set_sensitive( NactIBackgroundTab *instance );
-static void on_tab_updatable_selection_changed( NactIBackgroundTab *instance, gint count_selected );
-static void on_tab_updatable_enable_tab( NactIBackgroundTab *instance, NAObjectItem *item );
-static gboolean tab_set_sensitive( NactIBackgroundTab *instance );
+static void add_row( NactIBackgroundTab *instance, GtkTreeView *listview, const gchar *uri );
+static void add_uri_to_folders( NactIBackgroundTab *instance, const gchar *uri );
+static GtkTreeView *get_folders_treeview( NactIBackgroundTab *instance );
+static void on_folder_uri_edited( GtkCellRendererText *renderer, const gchar *path, const gchar *text, NactIBackgroundTab *instance );
+static void on_folders_selection_changed( GtkTreeSelection *selection, NactIBackgroundTab *instance );
+static void on_add_folder_clicked( GtkButton *button, NactIBackgroundTab *instance );
+static void on_remove_folder_clicked( GtkButton *button, NactIBackgroundTab *instance );
+static void reset_folders( NactIBackgroundTab *instance );
+static void setup_folders( NactIBackgroundTab *instance );
+static void treeview_cell_edited( NactIBackgroundTab *instance, const gchar *path_string, const gchar *text, gint column, gboolean *state, gchar **old_text );
-static void on_toolbar_same_label_toggled( GtkToggleButton *button, NactIBackgroundTab *instance );
+static void on_toolbar_same_label_toggled( GtkToggleButton *button, NactIBackgroundTab *instance );
-static void on_toolbar_label_changed( GtkEntry *entry, NactIBackgroundTab *instance );
+static void on_toolbar_label_changed( GtkEntry *entry, NactIBackgroundTab *instance );
GType
nact_ibackground_tab_get_type( void )
@@ -135,11 +160,32 @@ void
nact_ibackground_tab_initial_load_toplevel( NactIBackgroundTab *instance )
{
static const gchar *thisfn = "nact_ibackground_tab_initial_load_toplevel";
+ GtkTreeView *listview;
+ GtkListStore *model;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *text_cell;
g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
g_return_if_fail( NACT_IS_IBACKGROUND_TAB( instance ));
if( st_initialized && !st_finalized ){
+
+ model = gtk_list_store_new( BACKGROUND_N_COLUMN, G_TYPE_STRING );
+ gtk_tree_sortable_set_sort_column_id( GTK_TREE_SORTABLE( model ), BACKGROUND_URI_COLUMN, GTK_SORT_ASCENDING );
+ listview = get_folders_treeview( instance );
+ gtk_tree_view_set_model( listview, GTK_TREE_MODEL( model ));
+ g_object_unref( model );
+
+ text_cell = gtk_cell_renderer_text_new();
+ g_object_set( G_OBJECT( text_cell ), "editable", TRUE, NULL );
+ column = gtk_tree_view_column_new_with_attributes(
+ "folder-uri",
+ text_cell,
+ "text", BACKGROUND_URI_COLUMN,
+ NULL );
+ gtk_tree_view_append_column( listview, column );
+
+ gtk_tree_view_set_headers_visible( listview, FALSE );
}
}
@@ -147,6 +193,10 @@ void
nact_ibackground_tab_runtime_init_toplevel( NactIBackgroundTab *instance )
{
static const gchar *thisfn = "nact_ibackground_tab_runtime_init_toplevel";
+ GtkTreeView *listview;
+ GtkTreeViewColumn *column;
+ GList *renderers;
+ GtkWidget *add_button, *remove_button;
GtkWidget *label_widget;
GtkWidget *toolbar_same_label_button;
@@ -167,6 +217,35 @@ nact_ibackground_tab_runtime_init_toplevel( NactIBackgroundTab *instance )
G_CALLBACK( on_tab_updatable_enable_tab ),
instance );
+ listview = get_folders_treeview( instance );
+ column = gtk_tree_view_get_column( listview, BACKGROUND_URI_COLUMN );
+ renderers = gtk_tree_view_column_get_cell_renderers( column );
+ g_signal_connect(
+ G_OBJECT( renderers->data ),
+ "edited",
+ G_CALLBACK( on_folder_uri_edited ),
+ instance );
+
+ add_button = base_window_get_widget( BASE_WINDOW( instance ), "AddFolderButton");
+ g_signal_connect(
+ G_OBJECT( add_button ),
+ "clicked",
+ G_CALLBACK( on_add_folder_clicked ),
+ instance );
+
+ remove_button = base_window_get_widget( BASE_WINDOW( instance ), "RemoveFolderButton");
+ g_signal_connect(
+ G_OBJECT( remove_button ),
+ "clicked",
+ G_CALLBACK( on_remove_folder_clicked ),
+ instance );
+
+ g_signal_connect(
+ G_OBJECT( gtk_tree_view_get_selection( listview )),
+ "changed",
+ G_CALLBACK( on_folders_selection_changed ),
+ instance );
+
toolbar_same_label_button = base_window_get_widget( BASE_WINDOW( instance ), "ToolbarSameLabelButton" );
g_signal_connect(
G_OBJECT( toolbar_same_label_button ),
@@ -204,6 +283,8 @@ nact_ibackground_tab_dispose( NactIBackgroundTab *instance )
g_return_if_fail( NACT_IS_IBACKGROUND_TAB( instance ));
if( st_initialized && !st_finalized ){
+
+ reset_folders( instance );
}
}
@@ -223,6 +304,8 @@ on_tab_updatable_selection_changed( NactIBackgroundTab *instance, gint count_sel
if( st_initialized && !st_finalized ){
+ reset_folders( instance );
+
g_object_get(
G_OBJECT( instance ),
TAB_UPDATABLE_PROP_EDITED_ACTION, &item,
@@ -232,6 +315,11 @@ on_tab_updatable_selection_changed( NactIBackgroundTab *instance, gint count_sel
enable_tab = tab_set_sensitive( instance );
+ if( enable_tab ){
+ setup_folders( instance );
+ }
+
+ /* only actions go to toolbar */
same_label_button = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "ToolbarSameLabelButton" ));
same_label = enable_tab && NA_IS_OBJECT_ACTION( item ) ? na_object_action_toolbar_use_same_label( NA_OBJECT_ACTION( item )) : FALSE;
gtk_toggle_button_set_active( same_label_button, same_label );
@@ -260,29 +348,32 @@ on_tab_updatable_enable_tab( NactIBackgroundTab *instance, NAObjectItem *item )
static gboolean
tab_set_sensitive( NactIBackgroundTab *instance )
{
- NAObjectItem *item;
- gboolean enable_tab;
- gboolean target_toolbar;
- gboolean enable_toolbar_frame;
+ NAObjectAction *action;
+ NAObjectProfile *profile;
+ gboolean is_action;
+ gboolean enable_tab, enable_folders_frame, enable_toolbar_frame;
GtkWidget *toolbar_frame_widget;
gboolean enable_toolbar_label_entry;
GtkWidget *toolbar_label_entry;
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_EDITED_ACTION, &item,
+ TAB_UPDATABLE_PROP_EDITED_ACTION, &action,
+ TAB_UPDATABLE_PROP_EDITED_PROFILE, &profile,
NULL );
- target_toolbar = ( item && na_object_is_target_toolbar( item ));
- enable_tab = ( item &&
- ( na_object_is_target_background( item ) || target_toolbar ));
+ is_action = ( action && NA_IS_OBJECT_ACTION( action ));
+ enable_toolbar_frame = ( is_action && na_object_action_is_target_toolbar( action ));
+ enable_folders_frame = ( profile != NULL &&
+ ( na_object_action_is_target_background( action ) || enable_toolbar_frame ));
+ enable_tab = enable_folders_frame || enable_toolbar_frame;
+
nact_main_tab_enable_page( NACT_MAIN_WINDOW( instance ), TAB_BACKGROUND, enable_tab );
- enable_toolbar_frame = ( enable_tab && NA_IS_OBJECT_ACTION( item ) && target_toolbar );
toolbar_frame_widget = base_window_get_widget( BASE_WINDOW( instance ), "BackgroundToolbarFrame" );
gtk_widget_set_sensitive( toolbar_frame_widget, enable_toolbar_frame );
- enable_toolbar_label_entry = ( enable_toolbar_frame && !na_object_action_toolbar_use_same_label( NA_OBJECT_ACTION( item )));
+ enable_toolbar_label_entry = ( enable_toolbar_frame && !na_object_action_toolbar_use_same_label( action ));
toolbar_label_entry = base_window_get_widget( BASE_WINDOW( instance ), "ToolbarLabelEntry" );
gtk_widget_set_sensitive( toolbar_label_entry, enable_toolbar_label_entry );
@@ -290,6 +381,231 @@ tab_set_sensitive( NactIBackgroundTab *instance )
}
static void
+add_row( NactIBackgroundTab *instance, GtkTreeView *listview, const gchar *uri )
+{
+ GtkTreeModel *model;
+ GtkTreeIter row;
+
+ model = gtk_tree_view_get_model( listview );
+
+ gtk_list_store_append(
+ GTK_LIST_STORE( model ),
+ &row );
+
+ gtk_list_store_set(
+ GTK_LIST_STORE( model ),
+ &row,
+ BACKGROUND_URI_COLUMN, uri,
+ -1 );
+}
+
+static void
+add_uri_to_folders( NactIBackgroundTab *instance, const gchar *uri )
+{
+ NAObjectAction *action;
+ NAObjectProfile *edited;
+ GSList *folders;
+
+ g_object_get(
+ G_OBJECT( instance ),
+ TAB_UPDATABLE_PROP_EDITED_ACTION, &action,
+ TAB_UPDATABLE_PROP_EDITED_PROFILE, &edited,
+ NULL );
+
+ folders = na_object_profile_get_folders( edited );
+ folders = g_slist_prepend( folders, ( gpointer ) g_strdup( uri ));
+ na_object_profile_set_folders( edited, folders );
+ na_utils_free_string_list( folders );
+
+ g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, action, FALSE );
+}
+
+static GtkTreeView *
+get_folders_treeview( NactIBackgroundTab *instance )
+{
+ GtkWidget *treeview;
+
+ treeview = base_window_get_widget( BASE_WINDOW( instance ), "FoldersTreeview" );
+ g_assert( GTK_IS_TREE_VIEW( treeview ));
+
+ return( GTK_TREE_VIEW( treeview ));
+}
+
+static void
+on_add_folder_clicked( GtkButton *button, NactIBackgroundTab *instance )
+{
+ GtkWidget *dialog;
+ GtkWindow *toplevel;
+ NactApplication *application;
+ NAPivot *pivot;
+ gchar *uri;
+ GtkTreeView *listview;
+
+ uri = NULL;
+ listview = get_folders_treeview( instance );
+ toplevel = base_window_get_toplevel( BASE_WINDOW( instance ));
+
+ /* i18n: title of the FileChoose dialog when selecting an URI which
+ * will be comparent to Nautilus 'current_folder'
+ */
+ dialog = gtk_file_chooser_dialog_new( _( "Select a folder" ),
+ toplevel,
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL );
+
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( instance )));
+ pivot = nact_application_get_pivot( application );
+
+ base_iprefs_position_named_window( BASE_WINDOW( instance ), GTK_WINDOW( dialog ), IPREFS_BACKGROUND_DIALOG );
+
+ uri = na_iprefs_read_string( NA_IPREFS( pivot ), IPREFS_BACKGROUND_URI, "x-nautilus-desktop:///" );
+ if( uri && strlen( uri )){
+ gtk_file_chooser_set_uri( GTK_FILE_CHOOSER( dialog ), uri );
+ }
+ g_free( uri );
+
+ if( gtk_dialog_run( GTK_DIALOG( dialog )) == GTK_RESPONSE_ACCEPT ){
+ uri = gtk_file_chooser_get_uri( GTK_FILE_CHOOSER( dialog ));
+ na_iprefs_write_string( NA_IPREFS( pivot ), IPREFS_BACKGROUND_URI, uri );
+ add_row( instance, listview, uri );
+ add_uri_to_folders( instance, uri );
+ g_free( uri );
+ }
+
+ base_iprefs_save_named_window_position( BASE_WINDOW( instance ), GTK_WINDOW( dialog ), IPREFS_BACKGROUND_DIALOG );
+
+ gtk_widget_destroy( dialog );
+}
+
+static void
+on_folder_uri_edited( GtkCellRendererText *renderer, const gchar *path, const gchar *text, NactIBackgroundTab *instance )
+{
+ treeview_cell_edited( instance, path, text, BACKGROUND_URI_COLUMN, NULL, NULL );
+}
+
+static void
+on_folders_selection_changed( GtkTreeSelection *selection, NactIBackgroundTab *instance )
+{
+ GtkWidget *button;
+
+ button = base_window_get_widget( BASE_WINDOW( instance ), "RemoveFolderButton");
+
+ gtk_widget_set_sensitive( button, gtk_tree_selection_count_selected_rows( selection ) > 0 );
+}
+
+static void
+on_remove_folder_clicked( GtkButton *button, NactIBackgroundTab *instance )
+{
+ GtkTreeView *listview;
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GList *selected_path, *isp;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ gchar *uri;
+ NAObjectAction *action;
+ NAObjectProfile *edited;
+ GSList *folders;
+
+ listview = get_folders_treeview( instance );
+ model = gtk_tree_view_get_model( listview );
+ selection = gtk_tree_view_get_selection( listview );
+ selected_path = gtk_tree_selection_get_selected_rows( selection, NULL );
+
+ for( isp = selected_path ; isp ; isp = isp->next ){
+ path = ( GtkTreePath * ) isp->data;
+ gtk_tree_model_get_iter( model, &iter, path );
+ gtk_tree_model_get( model, &iter, BACKGROUND_URI_COLUMN, &uri, -1 );
+ gtk_list_store_remove( GTK_LIST_STORE( model ), &iter );
+
+ g_object_get(
+ G_OBJECT( instance ),
+ TAB_UPDATABLE_PROP_EDITED_ACTION, &action,
+ TAB_UPDATABLE_PROP_EDITED_PROFILE, &edited,
+ NULL );
+
+ folders = na_object_profile_get_folders( edited );
+ folders = na_utils_remove_from_string_list( folders, uri );
+ na_object_profile_set_folders( edited, folders );
+
+ na_utils_free_string_list( folders );
+ g_free( uri );
+
+ g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, action, FALSE );
+ }
+
+ g_list_foreach( selected_path, ( GFunc ) gtk_tree_path_free, NULL );
+ g_list_free( selected_path );
+}
+
+static void
+reset_folders( NactIBackgroundTab *instance )
+{
+ GtkTreeView *listview;
+ GtkTreeModel *model;
+
+ listview = get_folders_treeview( instance );
+ model = gtk_tree_view_get_model( listview );
+ gtk_list_store_clear( GTK_LIST_STORE( model ));
+}
+
+static void
+setup_folders( NactIBackgroundTab *instance )
+{
+ NAObjectProfile *edited;
+ GSList *folders, *is;
+ GtkTreeView *listview;
+
+ listview = get_folders_treeview( instance );
+
+ g_object_get(
+ G_OBJECT( instance ),
+ TAB_UPDATABLE_PROP_EDITED_PROFILE, &edited,
+ NULL );
+
+ folders = na_object_profile_get_folders( edited );
+ for( is = folders ; is ; is = is->next ){
+ add_row( instance, listview, ( const gchar * ) is->data );
+ }
+ na_utils_free_string_list( folders );
+}
+
+static void
+treeview_cell_edited( NactIBackgroundTab *instance, const gchar *path_string, const gchar *text, gint column, gboolean *state, gchar **old_text )
+{
+ GtkTreeView *listview;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ NAObjectAction *action;
+ NAObjectProfile *edited;
+
+ listview = get_folders_treeview( instance );
+ model = gtk_tree_view_get_model( listview );
+ path = gtk_tree_path_new_from_string( path_string );
+ gtk_tree_model_get_iter( model, &iter, path );
+ gtk_tree_path_free( path );
+
+ if( state && old_text ){
+ gtk_tree_model_get( model, &iter, BACKGROUND_URI_COLUMN, old_text, -1 );
+ }
+
+ gtk_list_store_set( GTK_LIST_STORE( model ), &iter, column, text, -1 );
+
+ g_object_get(
+ G_OBJECT( instance ),
+ TAB_UPDATABLE_PROP_EDITED_ACTION, &action,
+ TAB_UPDATABLE_PROP_EDITED_PROFILE, &edited,
+ NULL );
+
+ na_object_profile_replace_folder_uri( edited, *old_text, text );
+
+ g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, action, FALSE );
+}
+
+static void
on_toolbar_same_label_toggled( GtkToggleButton *button, NactIBackgroundTab *instance )
{
NAObjectItem *edited;
diff --git a/src/nact/nact-icommand-tab.c b/src/nact/nact-icommand-tab.c
index bd76350..0520e95 100644
--- a/src/nact/nact-icommand-tab.c
+++ b/src/nact/nact-icommand-tab.c
@@ -375,13 +375,11 @@ on_tab_updatable_selection_changed( NactICommandTab *instance, gint count_select
static gboolean
tab_set_sensitive( NactICommandTab *instance )
{
- 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 );
@@ -554,6 +552,7 @@ on_path_browse( GtkButton *button, NactICommandTab *instance )
gchar *uri = NULL;
NactApplication *application;
NAPivot *pivot;
+ GtkWindow *toplevel;
GtkWidget *dialog;
GtkWidget *path_entry;
const gchar *path;
@@ -561,10 +560,11 @@ on_path_browse( GtkButton *button, NactICommandTab *instance )
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( instance )));
pivot = nact_application_get_pivot( application );
+ toplevel = base_window_get_toplevel( BASE_WINDOW( instance ));
dialog = gtk_file_chooser_dialog_new(
_( "Choosing a command" ),
- NULL,
+ toplevel,
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
diff --git a/src/nact/nact-iconditions-tab.c b/src/nact/nact-iconditions-tab.c
index aaec312..e728fc9 100644
--- a/src/nact/nact-iconditions-tab.c
+++ b/src/nact/nact-iconditions-tab.c
@@ -376,7 +376,7 @@ tab_set_sensitive( NactIConditionsTab *instance )
TAB_UPDATABLE_PROP_EDITED_PROFILE, &profile,
NULL );
- enable_tab = ( profile != NULL && na_object_is_target_selection( item ));
+ enable_tab = ( profile != NULL && na_object_action_is_target_selection( NA_OBJECT_ACTION( item )));
nact_main_tab_enable_page( NACT_MAIN_WINDOW( instance ), TAB_CONDITIONS, enable_tab );
return( enable_tab );
diff --git a/src/nact/nact-main-menubar.c b/src/nact/nact-main-menubar.c
index d18d49f..f141a24 100644
--- a/src/nact/nact-main-menubar.c
+++ b/src/nact/nact-main-menubar.c
@@ -682,6 +682,7 @@ on_new_menu_activated( GtkAction *gtk_action, NactMainWindow *window )
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
menu = na_object_menu_new();
+ na_object_check_status( menu );
items = g_list_prepend( NULL, menu );
nact_iactions_list_insert_items( NACT_IACTIONS_LIST( window ), items, NULL );
na_object_free_items_list( items );
@@ -697,6 +698,7 @@ on_new_action_activated( GtkAction *gtk_action, NactMainWindow *window )
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
action = na_object_action_new_with_profile();
+ na_object_check_status( action );
items = g_list_prepend( NULL, action );
nact_iactions_list_insert_items( NACT_IACTIONS_LIST( window ), items, NULL );
na_object_free_items_list( items );
diff --git a/src/nact/nact-xml-reader.c b/src/nact/nact-xml-reader.c
index 0d6cfbb..c5d538d 100644
--- a/src/nact/nact-xml-reader.c
+++ b/src/nact/nact-xml-reader.c
@@ -1153,13 +1153,13 @@ apply_values( NactXMLReader *reader )
;
} else if( !strcmp( reader->private->entry, OBJECT_ITEM_TARGET_SELECTION_ENTRY )){
- na_object_set_target_selection( reader->private->action, na_utils_schema_to_boolean( reader->private->value, TRUE ));
+ na_object_action_set_target_selection( reader->private->action, na_utils_schema_to_boolean( reader->private->value, TRUE ));
} else if( !strcmp( reader->private->entry, OBJECT_ITEM_TARGET_BACKGROUND_ENTRY )){
- na_object_set_target_background( reader->private->action, na_utils_schema_to_boolean( reader->private->value, FALSE ));
+ na_object_action_set_target_background( reader->private->action, na_utils_schema_to_boolean( reader->private->value, FALSE ));
} else if( !strcmp( reader->private->entry, OBJECT_ITEM_TARGET_TOOLBAR_ENTRY )){
- na_object_set_target_toolbar( reader->private->action, na_utils_schema_to_boolean( reader->private->value, FALSE ));
+ na_object_action_set_target_toolbar( reader->private->action, na_utils_schema_to_boolean( reader->private->value, FALSE ));
} else if( !strcmp( reader->private->entry, OBJECT_ITEM_TOOLBAR_SAME_LABEL_ENTRY )){
na_object_action_toolbar_set_same_label( reader->private->action, na_utils_schema_to_boolean( reader->private->value, FALSE ));
diff --git a/src/nact/nautilus-actions-config-tool.ui b/src/nact/nautilus-actions-config-tool.ui
index 59073e0..f3a2944 100644
--- a/src/nact/nautilus-actions-config-tool.ui
+++ b/src/nact/nautilus-actions-config-tool.ui
@@ -280,7 +280,7 @@
<property name="visible">True</property>
<property name="spacing">10</property>
<child>
- <object class="GtkFrame" id="frame13">
+ <object class="GtkFrame" id="ActionTargetFrame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
@@ -294,7 +294,6 @@
<child>
<object class="GtkVBox" id="vbox7">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
<child>
<object class="GtkCheckButton" id="ActionTargetSelectionButton">
<property name="label" translatable="yes">Targets _selection menus</property>
@@ -371,7 +370,6 @@ Note that this only applies for now to actions which target background menus.</p
<child>
<object class="GtkVBox" id="vbox43">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
<child>
<object class="GtkCheckButton" id="ActionEnabledButton">
<property name="label" translatable="yes">E_nabled</property>
@@ -666,93 +664,198 @@ Defining several profiles lets you have several commands, each applying with a d
<child>
<object class="GtkVBox" id="vbox6">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <child>
- <placeholder/>
- </child>
+ <property name="border_width">6</property>
+ <property name="spacing">10</property>
<child>
- <object class="GtkFrame" id="BackgroundToolbarFrame">
+ <object class="GtkVBox" id="vbox10">
<property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">in</property>
<child>
- <object class="GtkAlignment" id="alignment6">
+ <object class="GtkLabel" id="label2">
<property name="visible">True</property>
- <property name="top_padding">6</property>
- <property name="bottom_padding">6</property>
- <property name="left_padding">12</property>
- <property name="right_padding">6</property>
+ <property name="xalign">0</property>
+ <property name="ypad">10</property>
+ <property name="label" translatable="yes"><b>Appears if URI is one or inside one of these :</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox9">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkTable" id="table4">
+ <object class="GtkVBox" id="vbox11">
<property name="visible">True</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">6</property>
+ <property name="spacing">10</property>
<child>
- <object class="GtkCheckButton" id="ToolbarSameLabelButton">
- <property name="label" translatable="yes">Use _same label for icon in the toolbar</property>
+ <object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="tooltip_text" translatable="yes">When checked, the text besides the icon in the toolbar will be the same that those of the action itself.
-You shouldn't do this as text in toolbars should be really short.</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="FoldersTreeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="tooltip_text" translatable="yes">List of URIs for which the current item will be displayed.
+"*" means "all the URIs".</property>
+ </object>
+ </child>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="ActionShortLabelLabel">
+ <object class="GtkFrame" id="BackgroundToolbarFrame">
<property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">S_hort label :</property>
- <property name="use_underline">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkAlignment" id="alignment6">
+ <property name="visible">True</property>
+ <property name="top_padding">6</property>
+ <property name="bottom_padding">6</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">6</property>
+ <child>
+ <object class="GtkTable" id="table4">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkCheckButton" id="ToolbarSameLabelButton">
+ <property name="label" translatable="yes">Use _same label for icon in the toolbar</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="ActionShortLabelLabel">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">S_hort label :</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="ToolbarLabelEntry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="max_length">32</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label51">
+ <property name="visible">True</property>
+ <property name="xpad">5</property>
+ <property name="label" translatable="yes"><b>Nautilus toolbar</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
</object>
<packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
+ <property name="expand">False</property>
+ <property name="position">1</property>
</packing>
</child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox8">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkEntry" id="ToolbarLabelEntry">
+ <object class="GtkButton" id="AddFolderButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="tooltip_text" translatable="yes">Text which will be displayed in the toolbar besides of the icon.
-The actual display may depend of your Gnome preferences.</property>
- <property name="max_length">32</property>
- <property name="invisible_char">●</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Click to add a new folder URI.</property>
+ <child>
+ <object class="GtkImage" id="image4">
+ <property name="visible">True</property>
+ <property name="stock">gtk-add</property>
+ <property name="icon-size">4</property>
+ </object>
+ </child>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkButton" id="RemoveFolderButton">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Click to remove the selected folder URI.</property>
+ <child>
+ <object class="GtkImage" id="image5">
+ <property name="visible">True</property>
+ <property name="stock">gtk-remove</property>
+ <property name="icon-size">4</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label51">
- <property name="visible">True</property>
- <property name="xpad">5</property>
- <property name="label" translatable="yes"><b>Nautilus toolbar</b></property>
- <property name="use_markup">True</property>
- </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
@@ -903,7 +1006,6 @@ The actual display may depend of your Gnome preferences.</property>
<child>
<object class="GtkVBox" id="vbox4">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkHBox" id="hbox4">
@@ -1017,7 +1119,7 @@ The actual display may depend of your Gnome preferences.</property>
<child>
<object class="GtkVBox" id="vbox340">
<property name="visible">True</property>
- <property name="border_width">12</property>
+ <property name="border_width">6</property>
<property name="spacing">10</property>
<child>
<object class="GtkLabel" id="label46">
@@ -1187,8 +1289,8 @@ The actual display may depend of your Gnome preferences.</property>
<property name="visible">True</property>
<property name="select_multiple">True</property>
<property name="local_only">False</property>
- <property name="use_preview_label">False</property>
<property name="preview_widget_active">False</property>
+ <property name="use_preview_label">False</property>
</object>
<packing>
<property name="position">0</property>
@@ -2591,15 +2693,15 @@ Be warned: this mode may be dangerous. You will not be prompted another time.</p
</object>
<object class="GtkSizeGroup" id="CommandLabelSizeGroup">
<widgets>
- <widget name="CommandParametersLabel"/>
- <widget name="CommandPathLabel"/>
<widget name="ProfileLabelLabel"/>
+ <widget name="CommandPathLabel"/>
+ <widget name="CommandParametersLabel"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="CommandButtonSizeGroup">
<widgets>
- <widget name="CommandLegendButton"/>
<widget name="CommandPathButton"/>
+ <widget name="CommandLegendButton"/>
</widgets>
</object>
</interface>
diff --git a/src/runtime/na-gconf-provider.c b/src/runtime/na-gconf-provider.c
index d45dc30..60ad27f 100644
--- a/src/runtime/na-gconf-provider.c
+++ b/src/runtime/na-gconf-provider.c
@@ -585,6 +585,7 @@ static void
read_item_action_properties( NAGConfProvider *provider, GSList *entries, NAObjectAction *action )
{
gchar *version;
+ gboolean target_selection, target_background, target_toolbar;
gboolean toolbar_same_label;
gchar *toolbar_label;
@@ -595,6 +596,18 @@ read_item_action_properties( NAGConfProvider *provider, GSList *entries, NAObjec
g_free( version );
}
+ if( na_gconf_utils_get_bool_from_entries( entries, OBJECT_ITEM_TARGET_SELECTION_ENTRY, &target_selection )){
+ na_object_action_set_target_selection( action, target_selection );
+ }
+
+ if( na_gconf_utils_get_bool_from_entries( entries, OBJECT_ITEM_TARGET_BACKGROUND_ENTRY, &target_background )){
+ na_object_action_set_target_background( action, target_background );
+ }
+
+ if( na_gconf_utils_get_bool_from_entries( entries, OBJECT_ITEM_TARGET_TOOLBAR_ENTRY, &target_toolbar )){
+ na_object_action_set_target_toolbar( action, target_toolbar );
+ }
+
if( na_gconf_utils_get_bool_from_entries( entries, OBJECT_ITEM_TOOLBAR_SAME_LABEL_ENTRY, &toolbar_same_label )){
na_object_action_toolbar_set_same_label( action, toolbar_same_label );
}
@@ -744,7 +757,6 @@ read_object_item_properties( NAGConfProvider *provider, GSList *entries, NAObjec
gchar *id, *label, *tooltip, *icon;
gboolean enabled;
GSList *subitems;
- gboolean target_selection, target_background, target_toolbar;
if( !na_gconf_utils_get_string_from_entries( entries, OBJECT_ITEM_LABEL_ENTRY, &label )){
id = na_object_get_id( item );
@@ -773,18 +785,6 @@ read_object_item_properties( NAGConfProvider *provider, GSList *entries, NAObjec
na_object_item_set_items_string_list( item, subitems );
na_utils_free_string_list( subitems );
}
-
- if( na_gconf_utils_get_bool_from_entries( entries, OBJECT_ITEM_TARGET_SELECTION_ENTRY, &target_selection )){
- na_object_set_target_selection( item, target_selection );
- }
-
- if( na_gconf_utils_get_bool_from_entries( entries, OBJECT_ITEM_TARGET_BACKGROUND_ENTRY, &target_background )){
- na_object_set_target_background( item, target_background );
- }
-
- if( na_gconf_utils_get_bool_from_entries( entries, OBJECT_ITEM_TARGET_TOOLBAR_ENTRY, &target_toolbar )){
- na_object_set_target_toolbar( item, target_toolbar );
- }
}
static gboolean
@@ -879,6 +879,9 @@ write_item_action( NAGConfProvider *provider, const NAObjectAction *action, gcha
ret =
write_object_item( provider, NA_OBJECT_ITEM( action ), message ) &&
write_str( provider, uuid, NULL, ACTION_VERSION_ENTRY, na_object_action_get_version( action ), message ) &&
+ write_bool( provider, uuid, NULL, OBJECT_ITEM_TARGET_SELECTION_ENTRY, na_object_action_is_target_selection( action ), message ) &&
+ write_bool( provider, uuid, NULL, OBJECT_ITEM_TARGET_BACKGROUND_ENTRY, na_object_action_is_target_background( action ), message ) &&
+ write_bool( provider, uuid, NULL, OBJECT_ITEM_TARGET_TOOLBAR_ENTRY, na_object_action_is_target_toolbar( action ), message ) &&
write_bool( provider, uuid, NULL, OBJECT_ITEM_TOOLBAR_SAME_LABEL_ENTRY, na_object_action_toolbar_use_same_label( action ), message ) &&
write_str( provider, uuid, NULL, OBJECT_ITEM_TOOLBAR_LABEL_ENTRY, na_object_action_toolbar_get_label( action ), message ) &&
write_str( provider, uuid, NULL, OBJECT_ITEM_TYPE_ENTRY, g_strdup( OBJECT_ITEM_TYPE_ACTION ), message );
@@ -941,9 +944,6 @@ write_object_item( NAGConfProvider *provider, const NAObjectItem *item, gchar **
write_str( provider, uuid, NULL, OBJECT_ITEM_TOOLTIP_ENTRY, na_object_get_tooltip( item ), message ) &&
write_str( provider, uuid, NULL, OBJECT_ITEM_ICON_ENTRY, na_object_get_icon( item ), message ) &&
write_bool( provider, uuid, NULL, OBJECT_ITEM_ENABLED_ENTRY, na_object_is_enabled( item ), message ) &&
- write_bool( provider, uuid, NULL, OBJECT_ITEM_TARGET_SELECTION_ENTRY, na_object_is_target_selection( item ), message ) &&
- write_bool( provider, uuid, NULL, OBJECT_ITEM_TARGET_BACKGROUND_ENTRY, na_object_is_target_background( item ), message ) &&
- write_bool( provider, uuid, NULL, OBJECT_ITEM_TARGET_TOOLBAR_ENTRY, na_object_is_target_toolbar( item ), message ) &&
write_list( provider, uuid, NULL, OBJECT_ITEM_LIST_ENTRY, na_object_item_rebuild_items_list( item ), message );
g_free( uuid );
diff --git a/src/runtime/na-object-action-fn.h b/src/runtime/na-object-action-fn.h
index 738bb81..6de1b35 100644
--- a/src/runtime/na-object-action-fn.h
+++ b/src/runtime/na-object-action-fn.h
@@ -51,21 +51,37 @@ G_BEGIN_DECLS
#define NAACTION_PROP_LAST_ALLOCATED "na-action-last-allocated"
#define NAACTION_PROP_TOOLBAR_SAME_LABEL "na-action-toolbar-use-same-label"
#define NAACTION_PROP_TOOLBAR_LABEL "na-action-toolbar-label"
+#define NAACTION_PROP_TARGET_SELECTION "na-action-target-selection"
+#define NAACTION_PROP_TARGET_BACKGROUND "na-action-target-background"
+#define NAACTION_PROP_TARGET_TOOLBAR "na-action-target-toolbar"
/* i18n: default label for a newly created action */
#define NA_OBJECT_ACTION_DEFAULT_LABEL _( "New Nautilus action" )
#define NAUTILUS_ACTIONS_CONFIG_VERSION "2.0"
+/* targets
+ */
+enum {
+ ITEM_TARGET_SELECTION = 1,
+ ITEM_TARGET_BACKGROUND,
+ ITEM_TARGET_TOOLBAR
+};
NAObjectAction *na_object_action_new( void );
gchar *na_object_action_get_version( const NAObjectAction *action );
+gboolean na_object_action_is_target_selection( const NAObjectAction *action );
+gboolean na_object_action_is_target_background( const NAObjectAction *action );
+gboolean na_object_action_is_target_toolbar( const NAObjectAction *action );
gboolean na_object_action_toolbar_use_same_label( const NAObjectAction *action );
gchar *na_object_action_toolbar_get_label( const NAObjectAction *action );
void na_object_action_set_version( NAObjectAction *action, const gchar *version );
void na_object_action_set_readonly( NAObjectAction *action, gboolean readonly );
+void na_object_action_set_target_selection( NAObjectAction *action, gboolean targeting );
+void na_object_action_set_target_background( NAObjectAction *action, gboolean targeting );
+void na_object_action_set_target_toolbar( NAObjectAction *action, gboolean targeting );
void na_object_action_toolbar_set_same_label( NAObjectAction *action, gboolean same_label );
void na_object_action_toolbar_set_label( NAObjectAction *action, const gchar *label );
diff --git a/src/runtime/na-object-action-priv.h b/src/runtime/na-object-action-priv.h
index 5378952..5d0bd80 100644
--- a/src/runtime/na-object-action-priv.h
+++ b/src/runtime/na-object-action-priv.h
@@ -55,9 +55,13 @@ struct NAObjectActionPrivate {
*/
gint last_allocated;
+ /* which targets does this item target ?
+ */
+ gboolean target_selection;
+ gboolean target_background;
+ gboolean target_toolbar;
+
/* toolbar display
- * only for actions as of Nautilus-2.26
- * note that 'use_same_label' is just a NACT preference
*/
gboolean use_same_label;
gchar *toolbar_label;
diff --git a/src/runtime/na-object-action.c b/src/runtime/na-object-action.c
index 0ca2948..04fe2d6 100644
--- a/src/runtime/na-object-action.c
+++ b/src/runtime/na-object-action.c
@@ -51,6 +51,9 @@ enum {
NAACTION_PROP_VERSION_ID = 1,
NAACTION_PROP_READONLY_ID,
NAACTION_PROP_LAST_ALLOCATED_ID,
+ NAACTION_PROP_TARGET_SELECTION_ID,
+ NAACTION_PROP_TARGET_BACKGROUND_ID,
+ NAACTION_PROP_TARGET_TOOLBAR_ID,
NAACTION_PROP_TOOLBAR_SAME_LABEL_ID,
NAACTION_PROP_TOOLBAR_LABEL_ID
};
@@ -147,6 +150,27 @@ class_init( NAObjectActionClass *klass )
g_object_class_install_property( object_class, NAACTION_PROP_LAST_ALLOCATED_ID, spec );
spec = g_param_spec_boolean(
+ NAACTION_PROP_TARGET_SELECTION,
+ "Target file selection",
+ "Whether the NAObjectAction is candidate on file selection menus", TRUE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
+ g_object_class_install_property( object_class, NAACTION_PROP_TARGET_SELECTION_ID, spec );
+
+ spec = g_param_spec_boolean(
+ NAACTION_PROP_TARGET_BACKGROUND,
+ "Target background",
+ "Whether the NAObjectAction is candidate on background menus", FALSE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
+ g_object_class_install_property( object_class, NAACTION_PROP_TARGET_BACKGROUND_ID, spec );
+
+ spec = g_param_spec_boolean(
+ NAACTION_PROP_TARGET_TOOLBAR,
+ "Target toolbar",
+ "Whether the NAObjectAction is candidate on toolbar display", TRUE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
+ g_object_class_install_property( object_class, NAACTION_PROP_TARGET_TOOLBAR_ID, spec );
+
+ spec = g_param_spec_boolean(
NAACTION_PROP_TOOLBAR_SAME_LABEL,
"Use same label",
"Whether the icon label in the toolbar is the same that the action main label", FALSE,
@@ -190,7 +214,10 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private->version = g_strdup( NAUTILUS_ACTIONS_CONFIG_VERSION );
self->private->read_only = FALSE;
self->private->last_allocated = 0;
- self->private->use_same_label = FALSE;
+ self->private->target_selection = TRUE;
+ self->private->target_background = FALSE;
+ self->private->target_toolbar = FALSE;
+ self->private->use_same_label = TRUE;
self->private->toolbar_label = g_strdup( "" );
}
@@ -217,6 +244,18 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
g_value_set_int( value, self->private->last_allocated );
break;
+ case NAACTION_PROP_TARGET_SELECTION_ID:
+ g_value_set_boolean( value, self->private->target_selection );
+ break;
+
+ case NAACTION_PROP_TARGET_BACKGROUND_ID:
+ g_value_set_boolean( value, self->private->target_background );
+ break;
+
+ case NAACTION_PROP_TARGET_TOOLBAR_ID:
+ g_value_set_boolean( value, self->private->target_toolbar );
+ break;
+
case NAACTION_PROP_TOOLBAR_SAME_LABEL_ID:
g_value_set_boolean( value, self->private->use_same_label );
break;
@@ -256,6 +295,18 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
self->private->last_allocated = g_value_get_int( value );
break;
+ case NAACTION_PROP_TARGET_SELECTION_ID:
+ self->private->target_selection = g_value_get_boolean( value );
+ break;
+
+ case NAACTION_PROP_TARGET_BACKGROUND_ID:
+ self->private->target_background = g_value_get_boolean( value );
+ break;
+
+ case NAACTION_PROP_TARGET_TOOLBAR_ID:
+ self->private->target_toolbar = g_value_get_boolean( value );
+ break;
+
case NAACTION_PROP_TOOLBAR_SAME_LABEL_ID:
self->private->use_same_label = g_value_get_boolean( value );
break;
@@ -368,6 +419,75 @@ na_object_action_get_version( const NAObjectAction *action )
}
/**
+ * na_object_action_is_target_selection:
+ * @action: the #NAObjectAction to be requested.
+ *
+ * Returns: %TRUE if @action is candidate for being displayed in file
+ * selection menus, %FALSE else.
+ *
+ * This was the historical only target of Nautilus-Actions actions.
+ * It so defaults to %TRUE at object creation.
+ */
+gboolean
+na_object_action_is_target_selection( const NAObjectAction *action )
+{
+ gboolean is_target = FALSE;
+
+ g_return_val_if_fail( NA_IS_OBJECT_ACTION( action ), 0 );
+
+ if( !action->private->dispose_has_run ){
+
+ is_target = action->private->target_selection;
+ }
+
+ return( is_target );
+}
+
+/**
+ * na_object_action_is_target_background:
+ * @action: the #NAObjectAction to be requested.
+ *
+ * Returns: %TRUE if @item is candidate for being displayed in
+ * background menus, %FALSE else.
+ */
+gboolean
+na_object_action_is_target_background( const NAObjectAction *action )
+{
+ gboolean is_target = FALSE;
+
+ g_return_val_if_fail( NA_IS_OBJECT_ACTION( action ), 0 );
+
+ if( !action->private->dispose_has_run ){
+
+ is_target = action->private->target_background;
+ }
+
+ return( is_target );
+}
+
+/**
+ * na_object_action_is_target_toolbar:
+ * @action: the #NAObjectAction to be requested.
+ *
+ * Returns: %TRUE if @item is candidate for being displayed in file
+ * toolbar menus, %FALSE else.
+ */
+gboolean
+na_object_action_is_target_toolbar( const NAObjectAction *action )
+{
+ gboolean is_target = FALSE;
+
+ g_return_val_if_fail( NA_IS_OBJECT_ACTION( action ), 0 );
+
+ if( !action->private->dispose_has_run ){
+
+ is_target = action->private->target_toolbar;
+ }
+
+ return( is_target );
+}
+
+/**
* na_object_action_toolbar_use_same_label:
* @action: the #NAObjectAction object to be requested.
*
@@ -464,6 +584,60 @@ na_object_action_set_readonly( NAObjectAction *action, gboolean readonly )
}
/**
+ * na_object_action_set_target_selection:
+ * @action: the #NAObjectAction to be updated.
+ * @targeting: whether @action targets selection menus.
+ *
+ * Set the flag for this target.
+ */
+void
+na_object_action_set_target_selection( NAObjectAction *action, gboolean targeting )
+{
+ g_return_if_fail( NA_IS_OBJECT_ITEM( action ));
+
+ if( !action->private->dispose_has_run ){
+
+ g_object_set( G_OBJECT( action ), NAACTION_PROP_TARGET_SELECTION, targeting, NULL );
+ }
+}
+
+/**
+ * na_object_action_set_target_background:
+ * @action: the #NAObjectAction to be updated.
+ * @targeting: whether @action targets background menus.
+ *
+ * Set the flag for this target.
+ */
+void
+na_object_action_set_target_background( NAObjectAction *action, gboolean targeting )
+{
+ g_return_if_fail( NA_IS_OBJECT_ITEM( action ));
+
+ if( !action->private->dispose_has_run ){
+
+ g_object_set( G_OBJECT( action ), NAACTION_PROP_TARGET_BACKGROUND, targeting, NULL );
+ }
+}
+
+/**
+ * na_object_action_set_target_toolbar:
+ * @action: the #NAObjectAction to be updated.
+ * @targeting: whether @action targets toolbar display.
+ *
+ * Set the flag for this target.
+ */
+void
+na_object_action_set_target_toolbar( NAObjectAction *action, gboolean targeting )
+{
+ g_return_if_fail( NA_IS_OBJECT_ITEM( action ));
+
+ if( !action->private->dispose_has_run ){
+
+ g_object_set( G_OBJECT( action ), NAACTION_PROP_TARGET_TOOLBAR, targeting, NULL );
+ }
+}
+
+/**
* na_object_action_toolbar_set_same_label:
* @action: the #NAObjectAction object to be updated.
* @use_same_label: whether the icon label is the same that the action label.
@@ -585,11 +759,14 @@ object_dump( const NAObject *action )
if( !self->private->dispose_has_run ){
- g_debug( "%s: version='%s'", thisfn, self->private->version );
- g_debug( "%s: read-only='%s'", thisfn, self->private->read_only ? "True" : "False" );
- g_debug( "%s: last-allocated=%d", thisfn, self->private->last_allocated );
- g_debug( "%s: use-same-label='%s'", thisfn, self->private->use_same_label ? "True" : "False" );
- g_debug( "%s: toolbar-label='%s'", thisfn, self->private->toolbar_label );
+ g_debug( "%s: version='%s'", thisfn, self->private->version );
+ g_debug( "%s: read-only='%s'", thisfn, self->private->read_only ? "True" : "False" );
+ g_debug( "%s: last-allocated=%d", thisfn, self->private->last_allocated );
+ g_debug( "%s: target-selection='%s'", thisfn, self->private->target_selection ? "True" : "False" );
+ g_debug( "%s: target-background='%s'", thisfn, self->private->target_background ? "True" : "False" );
+ g_debug( "%s: target-toolbar='%s'", thisfn, self->private->target_toolbar ? "True" : "False" );
+ g_debug( "%s: use-same-label='%s'", thisfn, self->private->use_same_label ? "True" : "False" );
+ g_debug( "%s: toolbar-label='%s'", thisfn, self->private->toolbar_label );
}
}
@@ -606,6 +783,7 @@ object_copy( NAObject *target, const NAObject *source )
gboolean readonly;
gint last_allocated;
GList *profiles, *ip;
+ gboolean target_selection, target_background, target_toolbar;
gboolean toolbar_same_label;
gchar *toolbar_label;
@@ -619,6 +797,9 @@ object_copy( NAObject *target, const NAObject *source )
NAACTION_PROP_VERSION, &version,
NAACTION_PROP_READONLY, &readonly,
NAACTION_PROP_LAST_ALLOCATED, &last_allocated,
+ NAACTION_PROP_TARGET_SELECTION, &target_selection,
+ NAACTION_PROP_TARGET_BACKGROUND, &target_background,
+ NAACTION_PROP_TARGET_TOOLBAR, &target_toolbar,
NAACTION_PROP_TOOLBAR_SAME_LABEL, &toolbar_same_label,
NAACTION_PROP_TOOLBAR_LABEL, &toolbar_label,
NULL );
@@ -627,6 +808,9 @@ object_copy( NAObject *target, const NAObject *source )
NAACTION_PROP_VERSION, version,
NAACTION_PROP_READONLY, readonly,
NAACTION_PROP_LAST_ALLOCATED, last_allocated,
+ NAACTION_PROP_TARGET_SELECTION, target_selection,
+ NAACTION_PROP_TARGET_BACKGROUND, target_background,
+ NAACTION_PROP_TARGET_TOOLBAR, target_toolbar,
NAACTION_PROP_TOOLBAR_SAME_LABEL, toolbar_same_label,
NAACTION_PROP_TOOLBAR_LABEL, toolbar_label,
NULL );
@@ -675,6 +859,21 @@ object_are_equal( const NAObject *a, const NAObject *b )
}
if( equal ){
+ equal = ( NA_OBJECT_ACTION( a )->private->target_selection && NA_OBJECT_ACTION( b )->private->target_selection ) ||
+ ( !NA_OBJECT_ACTION( a )->private->target_selection && !NA_OBJECT_ACTION( b )->private->target_selection );
+ }
+
+ if( equal ){
+ equal = ( NA_OBJECT_ACTION( a )->private->target_background && NA_OBJECT_ACTION( b )->private->target_background ) ||
+ ( !NA_OBJECT_ACTION( a )->private->target_background && !NA_OBJECT_ACTION( b )->private->target_background );
+ }
+
+ if( equal ){
+ equal = ( NA_OBJECT_ACTION( a )->private->target_toolbar && NA_OBJECT_ACTION( b )->private->target_toolbar ) ||
+ ( !NA_OBJECT_ACTION( a )->private->target_toolbar && !NA_OBJECT_ACTION( b )->private->target_toolbar );
+ }
+
+ if( equal ){
equal = ( NA_OBJECT_ACTION( a )->private->use_same_label && NA_OBJECT_ACTION( b )->private->use_same_label ) ||
( !NA_OBJECT_ACTION( a )->private->use_same_label && !NA_OBJECT_ACTION( b )->private->use_same_label );
}
@@ -730,7 +929,7 @@ object_is_valid( const NAObject *action )
if( !NA_OBJECT_ACTION( action )->private->dispose_has_run ){
- if( na_object_is_target_toolbar( action )){
+ if( na_object_action_is_target_toolbar( NA_OBJECT_ACTION( action ))){
is_valid =
is_valid_short_label( NA_OBJECT_ACTION( action ));
diff --git a/src/runtime/na-object-api.h b/src/runtime/na-object-api.h
index a087530..1ea604f 100644
--- a/src/runtime/na-object-api.h
+++ b/src/runtime/na-object-api.h
@@ -92,18 +92,12 @@ G_BEGIN_DECLS
#define na_object_get_item( object, id ) na_object_item_get_item( NA_OBJECT_ITEM( object ), id )
#define na_object_get_items_list( object ) na_object_item_get_items_list( NA_OBJECT_ITEM( object ))
#define na_object_get_items_count( object ) na_object_item_get_items_count( NA_OBJECT_ITEM( object ))
-#define na_object_is_target_selection( object ) na_object_item_is_target_selection( NA_OBJECT_ITEM( object ))
-#define na_object_is_target_background( object ) na_object_item_is_target_background( NA_OBJECT_ITEM( object ))
-#define na_object_is_target_toolbar( object ) na_object_item_is_target_toolbar( NA_OBJECT_ITEM( object ))
#define na_object_set_tooltip( object, tooltip ) na_object_item_set_tooltip( NA_OBJECT_ITEM( object ), tooltip )
#define na_object_set_icon( object, icon ) na_object_item_set_icon( NA_OBJECT_ITEM( object ), icon )
#define na_object_set_provider( object, provider ) na_object_item_set_provider( NA_OBJECT_ITEM( object ), provider )
#define na_object_set_enabled( object, enabled ) na_object_item_set_enabled( NA_OBJECT_ITEM( object ), enabled )
#define na_object_set_items_list( object, list ) na_object_item_set_items_list( NA_OBJECT_ITEM( object ), list )
-#define na_object_set_target_selection( object, b ) na_object_item_set_target_selection( NA_OBJECT_ITEM( object ), b )
-#define na_object_set_target_background( object, b ) na_object_item_set_target_background( NA_OBJECT_ITEM( object ), b )
-#define na_object_set_target_toolbar( object, b ) na_object_item_set_target_toolbar( NA_OBJECT_ITEM( object ), b )
#define na_object_append_item( object, item ) na_object_item_append_item( NA_OBJECT_ITEM( object ), NA_OBJECT( item ))
#define na_object_remove_item( object, item ) na_object_item_remove_item( NA_OBJECT_ITEM( object ), NA_OBJECT( item ))
diff --git a/src/runtime/na-object-item-fn.h b/src/runtime/na-object-item-fn.h
index 3264f07..630da50 100644
--- a/src/runtime/na-object-item-fn.h
+++ b/src/runtime/na-object-item-fn.h
@@ -56,18 +56,12 @@ gboolean na_object_item_is_enabled( const NAObjectItem *item );
NAObject *na_object_item_get_item( const NAObjectItem *item, const gchar *id );
GList *na_object_item_get_items_list( const NAObjectItem *item );
guint na_object_item_get_items_count( const NAObjectItem *item );
-gboolean na_object_item_is_target_selection( const NAObjectItem *item );
-gboolean na_object_item_is_target_background( const NAObjectItem *item );
-gboolean na_object_item_is_target_toolbar( const NAObjectItem *item );
void na_object_item_set_tooltip( NAObjectItem *item, const gchar *tooltip );
void na_object_item_set_icon( NAObjectItem *item, const gchar *icon_name );
void na_object_item_set_provider( NAObjectItem *item, const NAIIOProvider *provider );
void na_object_item_set_enabled( NAObjectItem *item, gboolean enabled );
void na_object_item_set_items_list( NAObjectItem *item, GList *items );
-void na_object_item_set_target_selection( NAObjectItem *item, gboolean targeting );
-void na_object_item_set_target_background( NAObjectItem *item, gboolean targeting );
-void na_object_item_set_target_toolbar( NAObjectItem *item, gboolean targeting );
void na_object_item_append_item( NAObjectItem *object, const NAObject *item );
void na_object_item_remove_item( NAObjectItem *object, const NAObject *item );
diff --git a/src/runtime/na-object-item-priv.h b/src/runtime/na-object-item-priv.h
index 4327f15..7a9e823 100644
--- a/src/runtime/na-object-item-priv.h
+++ b/src/runtime/na-object-item-priv.h
@@ -46,21 +46,10 @@ struct NAObjectItemPrivate {
gchar *icon;
gboolean enabled;
- /* which targets does this item target ?
- * note that targeting toolbar is (as of Nautilus 2.26) an
- * action-only attribute
- */
- gboolean target_selection;
- gboolean target_background;
- gboolean target_toolbar;
-
/* list of NAObjectId subitems
+ * + list of id strings as readen from IIOProviders
*/
GList *items;
-
- /* this is the list of subitems as a list of id strings
- * as readen from IIOProviders
- */
GSList *items_ids;
/* the original provider
diff --git a/src/runtime/na-object-item.c b/src/runtime/na-object-item.c
index 4f81815..ad08994 100644
--- a/src/runtime/na-object-item.c
+++ b/src/runtime/na-object-item.c
@@ -54,9 +54,6 @@ enum {
NAOBJECT_ITEM_PROP_ENABLED_ID,
NAOBJECT_ITEM_PROP_PROVIDER_ID,
NAOBJECT_ITEM_PROP_ITEMS_ID,
- NAOBJECT_ITEM_PROP_TARGET_SELECTION_ID,
- NAOBJECT_ITEM_PROP_TARGET_BACKGROUND_ID,
- NAOBJECT_ITEM_PROP_TARGET_TOOLBAR_ID,
};
#define NAOBJECT_ITEM_PROP_TOOLTIP "na-object-item-tooltip"
@@ -64,9 +61,6 @@ enum {
#define NAOBJECT_ITEM_PROP_ENABLED "na-object-item-enabled"
#define NAOBJECT_ITEM_PROP_PROVIDER "na-object-item-provider"
#define NAOBJECT_ITEM_PROP_ITEMS "na-object-item-items"
-#define NAOBJECT_ITEM_PROP_TARGET_SELECTION "na-object-item-target-selection"
-#define NAOBJECT_ITEM_PROP_TARGET_BACKGROUND "na-object-item-target-background"
-#define NAOBJECT_ITEM_PROP_TARGET_TOOLBAR "na-object-item-target-toolbar"
static NAObjectIdClass *st_parent_class = NULL;
@@ -169,27 +163,6 @@ class_init( NAObjectItemClass *klass )
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
g_object_class_install_property( object_class, NAOBJECT_ITEM_PROP_PROVIDER_ID, spec );
- spec = g_param_spec_boolean(
- NAOBJECT_ITEM_PROP_TARGET_SELECTION,
- "Target file selection",
- "Whether the NAObjectItem is candidate on file selection menus", TRUE,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, NAOBJECT_ITEM_PROP_TARGET_SELECTION_ID, spec );
-
- spec = g_param_spec_boolean(
- NAOBJECT_ITEM_PROP_TARGET_BACKGROUND,
- "Target background",
- "Whether the NAObjectItem is candidate on background menus", FALSE,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, NAOBJECT_ITEM_PROP_TARGET_BACKGROUND_ID, spec );
-
- spec = g_param_spec_boolean(
- NAOBJECT_ITEM_PROP_TARGET_TOOLBAR,
- "Target toolbar",
- "Whether the NAObjectItem is candidate on toolbar display", TRUE,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, NAOBJECT_ITEM_PROP_TARGET_TOOLBAR_ID, spec );
-
klass->private = g_new0( NAObjectItemClassPrivate, 1 );
naobject_class = NA_OBJECT_CLASS( klass );
@@ -225,9 +198,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private->tooltip = g_strdup( "" );
self->private->icon = g_strdup( "" );
self->private->enabled = TRUE;
- self->private->target_selection = TRUE;
- self->private->target_background = FALSE;
- self->private->target_toolbar = FALSE;
self->private->provider = NULL;
}
@@ -258,18 +228,6 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
g_value_set_pointer( value, self->private->provider );
break;
- case NAOBJECT_ITEM_PROP_TARGET_SELECTION_ID:
- g_value_set_boolean( value, self->private->target_selection );
- break;
-
- case NAOBJECT_ITEM_PROP_TARGET_BACKGROUND_ID:
- g_value_set_boolean( value, self->private->target_background );
- break;
-
- case NAOBJECT_ITEM_PROP_TARGET_TOOLBAR_ID:
- g_value_set_boolean( value, self->private->target_toolbar );
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
break;
@@ -306,18 +264,6 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
self->private->provider = g_value_get_pointer( value );
break;
- case NAOBJECT_ITEM_PROP_TARGET_SELECTION_ID:
- self->private->target_selection = g_value_get_boolean( value );
- break;
-
- case NAOBJECT_ITEM_PROP_TARGET_BACKGROUND_ID:
- self->private->target_background = g_value_get_boolean( value );
- break;
-
- case NAOBJECT_ITEM_PROP_TARGET_TOOLBAR_ID:
- self->private->target_toolbar = g_value_get_boolean( value );
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
break;
@@ -569,80 +515,6 @@ na_object_item_get_items_count( const NAObjectItem *item )
}
/**
- * na_object_item_is_target_selection:
- * @item: the #NAObjectItem to be requested.
- *
- * Returns: %TRUE if @item is candidate for being displayed in file
- * selection menus, %FALSE else.
- *
- * This was the historical only target of Nautilus-Actions actions.
- * It so defaults to %TRUE at object creation.
- */
-gboolean
-na_object_item_is_target_selection( const NAObjectItem *item )
-{
- gboolean is_target = FALSE;
-
- g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), 0 );
-
- if( !item->private->dispose_has_run ){
-
- is_target = item->private->target_selection;
- }
-
- return( is_target );
-}
-
-/**
- * na_object_item_is_target_background:
- * @item: the #NAObjectItem to be requested.
- *
- * Returns: %TRUE if @item is candidate for being displayed in
- * background menus, %FALSE else.
- */
-gboolean
-na_object_item_is_target_background( const NAObjectItem *item )
-{
- gboolean is_target = FALSE;
-
- g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), 0 );
-
- if( !item->private->dispose_has_run ){
-
- is_target = item->private->target_background;
- }
-
- return( is_target );
-}
-
-/**
- * na_object_item_is_target_toolbar:
- * @item: the #NAObjectItem to be requested.
- *
- * Returns: %TRUE if @item is candidate for being displayed in file
- * toolbar menus, %FALSE else.
- *
- * As of Nautilus 2.26, targeting toolbar is only available to the
- * #NAObjectAction, as Nautilus doesn't care of displaying menus in
- * its toolbar. Also, toolbar display uses same profile properties
- * (folders) that background (cf. Nautilus API).
- */
-gboolean
-na_object_item_is_target_toolbar( const NAObjectItem *item )
-{
- gboolean is_target = FALSE;
-
- g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), 0 );
-
- if( !item->private->dispose_has_run ){
-
- is_target = item->private->target_toolbar;
- }
-
- return( is_target );
-}
-
-/**
* na_object_item_set_tooltip:
* @item: the #NAObjectItem object to be updated.
* @tooltip: the tooltip to be set.
@@ -745,60 +617,6 @@ na_object_item_set_items_list( NAObjectItem *item, GList *items )
}
/**
- * na_object_item_set_target_selection:
- * @item: the #NAObjectItem to be updated.
- * @targeting: whether @item targets selection menus.
- *
- * Set the flag for this target.
- */
-void
-na_object_item_set_target_selection( NAObjectItem *item, gboolean targeting )
-{
- g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
-
- if( !item->private->dispose_has_run ){
-
- g_object_set( G_OBJECT( item ), NAOBJECT_ITEM_PROP_TARGET_SELECTION, targeting, NULL );
- }
-}
-
-/**
- * na_object_item_set_target_background:
- * @item: the #NAObjectItem to be updated.
- * @targeting: whether @item targets background menus.
- *
- * Set the flag for this target.
- */
-void
-na_object_item_set_target_background( NAObjectItem *item, gboolean targeting )
-{
- g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
-
- if( !item->private->dispose_has_run ){
-
- g_object_set( G_OBJECT( item ), NAOBJECT_ITEM_PROP_TARGET_BACKGROUND, targeting, NULL );
- }
-}
-
-/**
- * na_object_item_set_target_toolbar:
- * @item: the #NAObjectItem to be updated.
- * @targeting: whether @item targets toolbar display.
- *
- * Set the flag for this target.
- */
-void
-na_object_item_set_target_toolbar( NAObjectItem *item, gboolean targeting )
-{
- g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
-
- if( !item->private->dispose_has_run ){
-
- g_object_set( G_OBJECT( item ), NAOBJECT_ITEM_PROP_TARGET_TOOLBAR, targeting, NULL );
- }
-}
-
-/**
* na_object_item_append_item:
* @item: the #NAObjectItem to which add the subitem.
* @object: a #NAObject to be added to list of subitems.
@@ -932,13 +750,10 @@ object_dump( const NAObject *item )
if( !NA_OBJECT_ITEM( item )->private->dispose_has_run ){
- g_debug( "%s: tooltip='%s'", thisfn, NA_OBJECT_ITEM( item )->private->tooltip );
- g_debug( "%s: icon='%s'", thisfn, NA_OBJECT_ITEM( item )->private->icon );
- g_debug( "%s: enabled='%s'", thisfn, NA_OBJECT_ITEM( item )->private->enabled ? "True" : "False" );
- g_debug( "%s: target-selection='%s'", thisfn, NA_OBJECT_ITEM( item )->private->target_selection ? "True" : "False" );
- g_debug( "%s: target-background='%s'", thisfn, NA_OBJECT_ITEM( item )->private->target_background ? "True" : "False" );
- g_debug( "%s: target-toolbar='%s'", thisfn, NA_OBJECT_ITEM( item )->private->target_toolbar ? "True" : "False" );
- g_debug( "%s: provider=%p", thisfn, ( void * ) NA_OBJECT_ITEM( item )->private->provider );
+ g_debug( "%s: tooltip='%s'", thisfn, NA_OBJECT_ITEM( item )->private->tooltip );
+ g_debug( "%s: icon='%s'", thisfn, NA_OBJECT_ITEM( item )->private->icon );
+ g_debug( "%s: enabled='%s'", thisfn, NA_OBJECT_ITEM( item )->private->enabled ? "True" : "False" );
+ g_debug( "%s: provider=%p", thisfn, ( void * ) NA_OBJECT_ITEM( item )->private->provider );
/* dump subitems */
g_debug( "%s: %d subitem(s) at %p",
@@ -960,7 +775,6 @@ object_copy( NAObject *target, const NAObject *source )
gboolean enabled;
gpointer provider;
GList *subitems, *it;
- gboolean target_selection, target_background, target_toolbar;
g_return_if_fail( NA_IS_OBJECT_ITEM( target ));
g_return_if_fail( NA_IS_OBJECT_ITEM( source ));
@@ -972,9 +786,6 @@ object_copy( NAObject *target, const NAObject *source )
NAOBJECT_ITEM_PROP_TOOLTIP, &tooltip,
NAOBJECT_ITEM_PROP_ICON, &icon,
NAOBJECT_ITEM_PROP_ENABLED, &enabled,
- NAOBJECT_ITEM_PROP_TARGET_SELECTION, &target_selection,
- NAOBJECT_ITEM_PROP_TARGET_BACKGROUND, &target_background,
- NAOBJECT_ITEM_PROP_TARGET_TOOLBAR, &target_toolbar,
NAOBJECT_ITEM_PROP_PROVIDER, &provider,
NULL );
@@ -982,9 +793,6 @@ object_copy( NAObject *target, const NAObject *source )
NAOBJECT_ITEM_PROP_TOOLTIP, tooltip,
NAOBJECT_ITEM_PROP_ICON, icon,
NAOBJECT_ITEM_PROP_ENABLED, enabled,
- NAOBJECT_ITEM_PROP_TARGET_SELECTION, target_selection,
- NAOBJECT_ITEM_PROP_TARGET_BACKGROUND, target_background,
- NAOBJECT_ITEM_PROP_TARGET_TOOLBAR, target_toolbar,
NAOBJECT_ITEM_PROP_PROVIDER, provider,
NULL );
@@ -1055,21 +863,6 @@ object_are_equal( const NAObject *a, const NAObject *b )
}
if( equal ){
- equal = ( NA_OBJECT_ITEM( a )->private->target_selection && NA_OBJECT_ITEM( b )->private->target_selection ) ||
- ( !NA_OBJECT_ITEM( a )->private->target_selection && !NA_OBJECT_ITEM( b )->private->target_selection );
- }
-
- if( equal ){
- equal = ( NA_OBJECT_ITEM( a )->private->target_background && NA_OBJECT_ITEM( b )->private->target_background ) ||
- ( !NA_OBJECT_ITEM( a )->private->target_background && !NA_OBJECT_ITEM( b )->private->target_background );
- }
-
- if( equal ){
- equal = ( NA_OBJECT_ITEM( a )->private->target_toolbar && NA_OBJECT_ITEM( b )->private->target_toolbar ) ||
- ( !NA_OBJECT_ITEM( a )->private->target_toolbar && !NA_OBJECT_ITEM( b )->private->target_toolbar );
- }
-
- if( equal ){
equal = ( g_list_length( NA_OBJECT_ITEM( a )->private->items ) == g_list_length( NA_OBJECT_ITEM( b )->private->items ));
if( !equal ){
g_debug( "length: a=%d, b=%d", g_list_length( NA_OBJECT_ITEM( a )->private->items ), g_list_length( NA_OBJECT_ITEM( b )->private->items ));
@@ -1140,8 +933,7 @@ object_is_valid( const NAObject *object )
g_return_val_if_fail( NA_IS_OBJECT_ITEM( object ), FALSE );
if( !NA_OBJECT_ITEM( object )->private->dispose_has_run ){
-
- /* nothing to check here */
+ ;
}
return( valid );
diff --git a/src/runtime/na-object-profile-fn.h b/src/runtime/na-object-profile-fn.h
index b730875..6a74373 100644
--- a/src/runtime/na-object-profile-fn.h
+++ b/src/runtime/na-object-profile-fn.h
@@ -44,14 +44,6 @@
G_BEGIN_DECLS
-/* targets
- */
-enum {
- ITEM_TARGET_SELECTION = 1,
- ITEM_TARGET_BACKGROUND,
- ITEM_TARGET_TOOLBAR
-};
-
/* internal identifier of profiles must begin with the following prefix
* this let us identify a profile key versus an action key
* corollarily, no action entry must begin with this same prefix
@@ -84,6 +76,7 @@ void na_object_profile_set_isdir( NAObjectProfile *profile, gboolean
void na_object_profile_set_isfiledir( NAObjectProfile *profile, gboolean isfile, gboolean isdir );
void na_object_profile_set_multiple( NAObjectProfile *profile, gboolean multiple );
void na_object_profile_set_schemes( NAObjectProfile *profile, GSList *schemes );
+void na_object_profile_replace_folder_uri( NAObjectProfile *profile, const gchar *old, const gchar *new );
void na_object_profile_set_folders( NAObjectProfile *profile, GSList *folders );
gboolean na_object_profile_is_candidate( const NAObjectProfile *profile, gint target, GList *files );
diff --git a/src/runtime/na-object-profile-priv.h b/src/runtime/na-object-profile-priv.h
index 4483067..f074701 100644
--- a/src/runtime/na-object-profile-priv.h
+++ b/src/runtime/na-object-profile-priv.h
@@ -45,7 +45,7 @@ struct NAObjectProfilePrivate {
gchar *path;
gchar *parameters;
- /* ... for nature 'FileSelection'
+ /* ... for target 'FileSelection'
*/
GSList *basenames;
gboolean match_case;
@@ -55,7 +55,7 @@ struct NAObjectProfilePrivate {
gboolean accept_multiple;
GSList *schemes;
- /* ... for nature 'Background'
+ /* ... for targets 'Background' and 'Toolbar'
*/
GSList *folders;
};
diff --git a/src/runtime/na-object-profile.c b/src/runtime/na-object-profile.c
index 5075dfd..43748b4 100644
--- a/src/runtime/na-object-profile.c
+++ b/src/runtime/na-object-profile.c
@@ -221,7 +221,7 @@ class_init( NAObjectProfileClass *klass )
spec = g_param_spec_pointer(
NAPROFILE_PROP_FOLDERS,
"Folders",
- "List of folders to which a Background profile applies",
+ "List of folders to which the item applies",
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
g_object_class_install_property( object_class, NAPROFILE_PROP_FOLDERS_ID, spec );
@@ -688,7 +688,7 @@ na_object_profile_get_schemes( const NAObjectProfile *profile )
* na_object_profile_get_folders:
* @profile: the #NAObjectProfile to be requested.
*
- * Returns the list of folders this profile applies to.
+ * Returns the list of folders this item applies to.
*
* Returns: a GSList of newly allocated strings. The list must be
* na_utils_free_string_list() by the caller.
@@ -704,6 +704,7 @@ na_object_profile_get_folders( const NAObjectProfile *profile )
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
if( !profile->private->dispose_has_run ){
+
g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_FOLDERS, &folders, NULL );
}
@@ -921,6 +922,26 @@ na_object_profile_set_schemes( NAObjectProfile *profile, GSList *schemes )
}
/**
+ * na_object_profile_replace_folder_uri:
+ * @profile: the #NAObjectProfile to be updated.
+ * @old: the old uri.
+ * @new: the new uri.
+ *
+ * Replaces the @old URI by the @new one.
+ */
+void
+na_object_profile_replace_folder_uri( NAObjectProfile *profile, const gchar *old, const gchar *new )
+{
+ g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
+
+ if( !profile->private->dispose_has_run ){
+
+ profile->private->folders = na_utils_remove_from_string_list( profile->private->folders, old );
+ profile->private->folders = g_slist_append( profile->private->folders, ( gpointer ) new );
+ }
+}
+
+/**
* na_object_profile_set_folders:
* @profile: the #NAObjectProfile to be updated.
* @folders: list of folders which apply.
@@ -937,6 +958,7 @@ na_object_profile_set_folders( NAObjectProfile *profile, GSList *folders )
g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
if( !profile->private->dispose_has_run ){
+
g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_FOLDERS, folders, NULL );
}
}
@@ -1467,6 +1489,7 @@ object_dump( const NAObject *object )
object_dump_list( thisfn, "basenames", self->private->basenames );
object_dump_list( thisfn, "mimetypes", self->private->mimetypes );
object_dump_list( thisfn, " schemes", self->private->schemes );
+ object_dump_list( thisfn, " folders", self->private->folders );
}
}
@@ -1490,6 +1513,7 @@ object_copy( NAObject *target, const NAObject *source )
gchar *path, *parameters;
gboolean matchcase, isfile, isdir, multiple;
GSList *basenames, *mimetypes, *schemes;
+ GSList *folders;
g_return_if_fail( NA_IS_OBJECT_PROFILE( target ));
g_return_if_fail( NA_IS_OBJECT_PROFILE( source ));
@@ -1507,6 +1531,7 @@ object_copy( NAObject *target, const NAObject *source )
NAPROFILE_PROP_ISDIR, &isdir,
NAPROFILE_PROP_ACCEPT_MULTIPLE, &multiple,
NAPROFILE_PROP_SCHEMES, &schemes,
+ NAPROFILE_PROP_FOLDERS, &folders,
NULL );
g_object_set( G_OBJECT( target ),
@@ -1519,6 +1544,7 @@ object_copy( NAObject *target, const NAObject *source )
NAPROFILE_PROP_ISDIR, isdir,
NAPROFILE_PROP_ACCEPT_MULTIPLE, multiple,
NAPROFILE_PROP_SCHEMES, schemes,
+ NAPROFILE_PROP_FOLDERS, folders,
NULL );
g_free( path );
@@ -1566,7 +1592,8 @@ object_are_equal( const NAObject *a, const NAObject *b )
if( equal ){
equal = na_utils_string_lists_are_equal( first->private->basenames, second->private->basenames ) &&
na_utils_string_lists_are_equal( first->private->mimetypes, second->private->mimetypes ) &&
- na_utils_string_lists_are_equal( first->private->schemes, second->private->schemes );
+ na_utils_string_lists_are_equal( first->private->schemes, second->private->schemes ) &&
+ na_utils_string_lists_are_equal( first->private->folders, second->private->folders );
}
#if NA_IDUPLICABLE_EDITION_STATUS_DEBUG
@@ -1598,27 +1625,22 @@ object_is_valid( const NAObject *profile )
if( !NA_OBJECT_PROFILE( profile )->private->dispose_has_run ){
- is_valid =
- is_valid_path_parameters( NA_OBJECT_PROFILE( profile ));
+ parent = na_object_get_parent( profile );
- if( is_valid ){
- parent = na_object_get_parent( profile );
+ if( na_object_action_is_target_background( NA_OBJECT_ACTION( parent )) ||
+ na_object_action_is_target_toolbar( NA_OBJECT_ACTION( parent ))){
- if( na_object_is_target_background( parent )){
- is_valid =
- is_valid_folders( NA_OBJECT_PROFILE( profile ));
+ is_valid =
+ is_valid_folders( NA_OBJECT_PROFILE( profile ));
- } else if( na_object_is_target_toolbar( parent )){
- is_valid =
- is_valid_folders( NA_OBJECT_PROFILE( profile ));
+ } else {
- } else {
- is_valid =
- is_valid_filenames( NA_OBJECT_PROFILE( profile )) &&
- is_valid_mimetypes( NA_OBJECT_PROFILE( profile )) &&
- is_valid_isfiledir( NA_OBJECT_PROFILE( profile )) &&
- is_valid_schemes( NA_OBJECT_PROFILE( profile ));
- }
+ is_valid =
+ is_valid_path_parameters( NA_OBJECT_PROFILE( profile )) &&
+ is_valid_filenames( NA_OBJECT_PROFILE( profile )) &&
+ is_valid_mimetypes( NA_OBJECT_PROFILE( profile )) &&
+ is_valid_isfiledir( NA_OBJECT_PROFILE( profile )) &&
+ is_valid_schemes( NA_OBJECT_PROFILE( profile ));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]