[nautilus-actions: 19/45] Fix #325585
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions: 19/45] Fix #325585
- Date: Wed, 29 Jul 2009 21:19:22 +0000 (UTC)
commit 30f189608fd117d76aca8b9e660bf4523d7ebb35
Author: Pierre Wieser <pwieser trychlos org>
Date: Sun Jul 26 14:47:17 2009 +0200
Fix #325585
ChangeLog | 16 ++++
src/common/na-action.h | 8 --
src/common/na-gconf.c | 16 ++++-
src/nact/nact-assist-export.c | 20 +++++
src/nact/nact-assist-export.h | 25 ++++++
src/nact/nact-iaction-tab.c | 35 ++++++---
src/nact/nact-iactions-list.c | 154 +++++++++++++++------------------------
src/nact/nact-iadvanced-tab.c | 6 +-
src/nact/nact-iconditions-tab.c | 17 ++---
src/nact/nact-imenubar.c | 48 +++++++-----
src/nact/nact-main-window.c | 26 +++++--
11 files changed, 214 insertions(+), 157 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e353996..e5b3ac5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
2009-07-26 Pierre Wieser <pwieser trychlos org>
+ * src/common/na-action.h:
+ Move export format enumeration to src/nact/nact-assist-export.c.
+
+ * src/common/na-gconf.c:
+ Fix #325585 by deleting a schema which may be directly attached
+ to the action.
+
+ * src/nact/nact-iaction-tab.c:
+ * src/nact/nact-iactions-list.c:
+ * src/nact/nact-iadvanced-tab.c:
+ * src/nact/nact-iconditions-tab.c:
+ * src/nact/nact-imenubar.c:
+ * src/nact/nact-main-window.c:
+ Fix selection when removing last action, or entering with
+ no action at all.
+
* src/nact/base-application-class.h:
* src/nact/base-window-class.h: New files.
diff --git a/src/common/na-action.h b/src/common/na-action.h
index 0996d48..08c01a1 100644
--- a/src/common/na-action.h
+++ b/src/common/na-action.h
@@ -46,14 +46,6 @@
G_BEGIN_DECLS
-/* TODO: move this declaration elsewhere */
-/* export formats
- * used to be only GConf schemas ('gconfschemafile' XML document)
- */
-enum {
- EXPORT_FORMAT_GCONFSCHEMAFILE = 1
-};
-
NAAction *na_action_new( void );
NAAction *na_action_new_with_profile( void );
diff --git a/src/common/na-gconf.c b/src/common/na-gconf.c
index ef8b283..f8d8dd3 100644
--- a/src/common/na-gconf.c
+++ b/src/common/na-gconf.c
@@ -468,6 +468,10 @@ iio_provider_write_action( const NAIIOProvider *provider, NAAction *action, gcha
return( NA_IIO_PROVIDER_WRITE_OK );
}
+/*
+ * also delete the schema which may be directly attached to this action
+ * cf. http://bugzilla.gnome.org/show_bug.cgi?id=325585
+ */
static guint
iio_provider_delete_action( const NAIIOProvider *provider, const NAAction *action, gchar **message )
{
@@ -484,9 +488,19 @@ iio_provider_delete_action( const NAIIOProvider *provider, const NAAction *actio
g_assert( NA_IS_ACTION( action ));
gchar *uuid = na_action_get_uuid( action );
- gchar *path = g_strdup_printf( "%s/%s", NA_GCONF_CONFIG_PATH, uuid );
+
GError *error = NULL;
+ gchar *path = g_strdup_printf( "/schemas%s/%s", NA_GCONF_CONFIG_PATH, uuid );
+ gconf_client_recursive_unset( self->private->gconf, path, 0, &error );
+ if( error ){
+ g_debug( "%s: error=%s for path=%s", thisfn, error->message, path );
+ g_error_free( error );
+ error = NULL;
+ }
+ g_free( path );
+
+ path = g_strdup_printf( "%s/%s", NA_GCONF_CONFIG_PATH, uuid );
if( !gconf_client_recursive_unset( self->private->gconf, path, 0, &error )){
g_debug( "%s: error=%s", thisfn, error->message );
*message = g_strdup( error->message );
diff --git a/src/nact/nact-assist-export.c b/src/nact/nact-assist-export.c
index 72d8bda..60e0e31 100644
--- a/src/nact/nact-assist-export.c
+++ b/src/nact/nact-assist-export.c
@@ -81,6 +81,24 @@ struct NactAssistExportPrivate {
gchar *reason;
};
+/* export formats
+ *
+ * EXPORT_FORMAT_GCONFSCHEMAFILE_V1: a schema with owner, short and long
+ * descriptions ; each action has its own schema addressed by the uuid
+ * (historical format)
+ *
+ * EXPORT_FORMAT_GCONFSCHEMAFILE_V2: the lightest schema still compatible
+ * with gconftool-2 --install-schema-file (no owner, no short nor long
+ * descriptions) - introduced in v 1.11
+ *
+ * EXPORT_FORMAT_GCONFENTRY: not a schema, but a dump of the GConf entry
+ */
+enum {
+ EXPORT_FORMAT_GCONFSCHEMAFILE_V1 = 1,
+ EXPORT_FORMAT_GCONFSCHEMAFILE_V2,
+ EXPORT_FORMAT_GCONFENTRY
+};
+
static GObjectClass *st_parent_class = NULL;
static GType register_type( void );
@@ -354,6 +372,8 @@ on_runtime_init_dialog( BaseWindow *dialog )
* apply signal is ran from the confirm page _after_ the prepare signal
* of the summary page ; it is so almost useless to do anything here if
* we want show the result on the summary...
+ *
+ * see http://bugzilla.gnome.org/show_bug.cgi?id=589745
*/
static void
on_apply( NactAssistant *window, GtkAssistant *assistant )
diff --git a/src/nact/nact-assist-export.h b/src/nact/nact-assist-export.h
index f61f001..a0471fe 100644
--- a/src/nact/nact-assist-export.h
+++ b/src/nact/nact-assist-export.h
@@ -33,6 +33,31 @@
/*
* NactAssistExport class definition.
+ *
+ * Rationale:
+ *
+ * Up to v 1.10.x, actions are exported as config_uuid.schemas. These
+ * are actually full GConf schema exports of the form :
+ * <schemalist>
+ * <schema>
+ * <key>/schemas/apps/nautilus-actions/..../uuid/label</key>
+ * <applyto>/apps/..../label</applyto>
+ *
+ * I don't know why Frederic had choosen to export as schema. But this
+ * implies that :
+ * - if all actions are imported via gconftool-2 --install-schema-file,
+ * then the schema will be repeated once for each imported action (as
+ * schema is attached here to the uuid), which is obviously a waste
+ * of resources
+ * - it seems that GConfClient refuses to delete only the 'applyto' key
+ * when there is a corresponding schema key ..? (to be confirmed)
+ *
+ * Considering exporting schemas, we have two goals with this :
+ * - make the files lighter
+ * - keep the compatibility with previous mode
+ *
+ * which means exporting the minimal schema file which can be imported
+ * with v1.10 and previous series, and via gconftool-2 --install-schema-file.
*/
#include "nact-assistant.h"
diff --git a/src/nact/nact-iaction-tab.c b/src/nact/nact-iaction-tab.c
index 034ce9a..29b83b7 100644
--- a/src/nact/nact-iaction-tab.c
+++ b/src/nact/nact-iaction-tab.c
@@ -215,7 +215,7 @@ nact_iaction_tab_set_action( NactWindow *dialog, const NAAction *action )
g_debug( "%s: dialog=%p, action=%p", thisfn, dialog, action );*/
NAObject *current = v_get_selected( dialog );
- gboolean enabled = TRUE;
+ gboolean enabled = ( action != NULL );
if( NA_IS_ACTION_PROFILE( current)){
if( na_action_get_profiles_count( action ) > 1 ){
enabled = FALSE;
@@ -223,20 +223,22 @@ nact_iaction_tab_set_action( NactWindow *dialog, const NAAction *action )
}
GtkWidget *label_widget = base_window_get_widget( BASE_WINDOW( dialog ), "ActionLabelEntry" );
- gchar *label = na_action_get_label( action );
+ gchar *label = action ? na_action_get_label( action ) : g_strdup( "" );
gtk_entry_set_text( GTK_ENTRY( label_widget ), label );
gtk_widget_set_sensitive( label_widget, enabled );
- check_for_label( dialog, GTK_ENTRY( label_widget ), label );
+ if( action ){
+ check_for_label( dialog, GTK_ENTRY( label_widget ), label );
+ }
g_free( label );
GtkWidget *tooltip_widget = base_window_get_widget( BASE_WINDOW( dialog ), "ActionTooltipEntry" );
- gchar *tooltip = na_action_get_tooltip( action );
+ gchar *tooltip = action ? na_action_get_tooltip( action ) : g_strdup( "" );
gtk_entry_set_text( GTK_ENTRY( tooltip_widget ), tooltip );
gtk_widget_set_sensitive( tooltip_widget, enabled );
g_free( tooltip );
GtkWidget *icon_widget = base_window_get_widget( BASE_WINDOW( dialog ), "ActionIconComboBoxEntry" );
- gchar *icon = na_action_get_icon( action );
+ gchar *icon = action ? na_action_get_icon( action ) : g_strdup( "" );
gtk_entry_set_text( GTK_ENTRY( GTK_BIN( icon_widget )->child ), icon );
gtk_widget_set_sensitive( icon_widget, enabled );
g_free( icon );
@@ -308,8 +310,13 @@ on_label_changed( GtkEntry *entry, gpointer user_data )
NactWindow *dialog = NACT_WINDOW( user_data );
NAAction *edited = v_get_edited_action( dialog );
- const gchar *label = gtk_entry_get_text( entry );
- na_action_set_label( edited, label );
+
+ if( edited ){
+ const gchar *label = gtk_entry_get_text( entry );
+ na_action_set_label( edited, label );
+ v_field_modified( dialog );
+ check_for_label( dialog, entry, label );
+ }
/* 2009-07-20: about 900-1200 usec for ten loops */
/*int i;
@@ -321,8 +328,6 @@ on_label_changed( GtkEntry *entry, gpointer user_data )
g_get_current_time( &end );
g_debug( "on_label_changed: %ld usec", ( 1000000 * ( end.tv_sec - begin.tv_sec )) + end.tv_usec - begin.tv_usec );*/
- v_field_modified( dialog );
- check_for_label( dialog, entry, label );
}
static void
@@ -345,9 +350,11 @@ on_tooltip_changed( GtkEntry *entry, gpointer user_data )
NactWindow *dialog = NACT_WINDOW( user_data );
NAAction *edited = v_get_edited_action( dialog );
- na_action_set_tooltip( edited, gtk_entry_get_text( entry ));
- v_field_modified( dialog );
+ if( edited ){
+ na_action_set_tooltip( edited, gtk_entry_get_text( entry ));
+ v_field_modified( dialog );
+ }
}
static void
@@ -396,9 +403,11 @@ on_icon_changed( GtkEntry *icon_entry, gpointer user_data )
}
NAAction *edited = v_get_edited_action( dialog );
- na_action_set_icon( edited, icon_name );
- v_field_modified( dialog );
+ if( edited ){
+ na_action_set_icon( edited, icon_name );
+ v_field_modified( dialog );
+ }
}
/* TODO: replace with a fds-compliant icon chooser */
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index 490d898..7b268de 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -349,115 +349,79 @@ nact_iactions_list_set_selection( NactWindow *window, GType type, const gchar *u
GtkWidget *list = get_actions_list_widget( window );
GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( list ));
- /*GtkTreeModelFilter *tmf_model = GTK_TREE_MODEL_FILTER( gtk_tree_view_get_model( GTK_TREE_VIEW( list )));
- GtkTreeStore *ts_model = GTK_TREE_STORE( gtk_tree_model_filter_get_model( tmf_model ));*/
+
+ if( !uuid || !strlen( uuid )){
+ g_debug( "%s: null or empty uuid: unselect all", thisfn );
+ gtk_tree_selection_unselect_all( selection );
+ v_on_selection_changed( selection, window );
+ return;
+ }
+
+ GtkTreeIter iter;
GtkTreeModel *model = gtk_tree_view_get_model( GTK_TREE_VIEW( list ));
+ gboolean iterok = gtk_tree_model_get_iter_first( model, &iter );
+ if( !iterok ){
+ g_debug( "%s: empty actions list: unselect all", thisfn );
+ gtk_tree_selection_unselect_all( selection );
+ v_on_selection_changed( selection, window );
+ return;
+ }
- if( uuid && strlen( uuid )){
- gboolean found = FALSE;
- GtkTreeIter iter, previous;
- /*gboolean iterok = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( ts_model ), &iter );*/
- gboolean iterok = gtk_tree_model_get_iter_first( model, &iter );
- NAObject *iter_object;
- gchar *iter_uuid, *iter_label;
+ gboolean found = FALSE;
+ GtkTreeIter previous;
+ NAObject *iter_object;
+ gchar *iter_uuid, *iter_label;
+
+ while( iterok && !found ){
+ gtk_tree_model_get( model, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &iter_object, IACTIONS_LIST_LABEL_COLUMN, &iter_label, -1 );
+ g_assert( NA_IS_ACTION( iter_object ));
- while( iterok && !found ){
- /*gtk_tree_model_get( GTK_TREE_MODEL( ts_model ), &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &iter_object, -1 );*/
- gtk_tree_model_get( model, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &iter_object, IACTIONS_LIST_LABEL_COLUMN, &iter_label, -1 );
- g_debug( "%s: iter_object=%p", thisfn, iter_object );
- g_assert( NA_IS_ACTION( iter_object ));
+ iter_uuid = na_action_get_uuid( NA_ACTION( iter_object ));
+ gint ret_uuid = g_ascii_strcasecmp( iter_uuid, uuid );
+ guint nb_profiles = na_action_get_profiles_count( NA_ACTION( iter_object ));
- iter_uuid = na_action_get_uuid( NA_ACTION( iter_object ));
- gint ret_uuid = g_ascii_strcasecmp( iter_uuid, uuid );
- guint nb_profiles = na_action_get_profiles_count( NA_ACTION( iter_object ));
+ if( type == NA_ACTION_TYPE || ( ret_uuid == 0 && nb_profiles == 1 )){
+ gint ret_label = g_utf8_collate( iter_label, label );
+
+ if( ret_uuid == 0 || ret_label > 0 ){
+ g_debug( "%s: selecting action iter_object=%p, ret_uuid=%d, ret_label=%d", thisfn, iter_object, ret_uuid, ret_label );
+ gtk_tree_selection_select_iter( selection, &iter );
+ found = TRUE;
+ break;
+ }
- if( type == NA_ACTION_TYPE || ( ret_uuid == 0 && nb_profiles == 1 )){
+ } else if( ret_uuid == 0 && gtk_tree_model_iter_has_child( model, &iter )){
+ GtkTreeIter iter_child, previous_child;
+ gboolean iter_child_ok = gtk_tree_model_iter_children( model, &iter_child, &iter );
+
+ while( iter_child_ok ){
+ gtk_tree_model_get( model, &iter_child, IACTIONS_LIST_NAOBJECT_COLUMN, &iter_object, IACTIONS_LIST_LABEL_COLUMN, &iter_label, -1 );
gint ret_label = g_utf8_collate( iter_label, label );
- if( ret_uuid == 0 || ret_label > 0 ){
- gtk_tree_selection_select_iter( selection, &iter );
+ if( ret_label >= 0 ){
+ g_debug( "%s: selecting profile iter_object=%p, ret_uuid=%d, ret_label=%d", thisfn, iter_object, ret_uuid, ret_label );
+ gtk_tree_selection_select_iter( selection, &iter_child );
found = TRUE;
break;
}
-
- } else if( ret_uuid == 0 && gtk_tree_model_iter_has_child( model, &iter )){
- GtkTreeIter iter_child, previous_child;
- gboolean iter_child_ok = gtk_tree_model_iter_children( model, &iter_child, &iter );
-
- while( iter_child_ok ){
- gtk_tree_model_get( model, &iter_child, IACTIONS_LIST_NAOBJECT_COLUMN, &iter_object, IACTIONS_LIST_LABEL_COLUMN, &iter_label, -1 );
- gint ret_label = g_utf8_collate( iter_label, label );
-
- if( ret_label >= 0 ){
- gtk_tree_selection_select_iter( selection, &iter_child );
- found = TRUE;
- break;
- }
- previous_child = iter_child;
- iter_child_ok = gtk_tree_model_iter_next( model, &iter_child );
- }
- if( !found ){
- gtk_tree_selection_select_iter( selection, &previous_child );
- found = TRUE;
- }
+ previous_child = iter_child;
+ iter_child_ok = gtk_tree_model_iter_next( model, &iter_child );
}
-
- previous = iter;
- /*iterok = gtk_tree_model_iter_next( GTK_TREE_MODEL( ts_model ), &iter );*/
- iterok = gtk_tree_model_iter_next( model, &iter );
- }
- if( !found ){
- gtk_tree_selection_select_iter( selection, &previous );
- }
-
- } else {
- gtk_tree_selection_unselect_all( selection );
- }
- /*
- static const gchar *thisfn = "nact_iactions_list_set_selection";
- g_debug( "%s: window=%p, uuid=%s, label=%s", thisfn, window, uuid, label );
-
- GtkWidget *list = get_actions_list_widget( window );
- GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( list ));
- GtkTreeModel *model = gtk_tree_view_get_model( GTK_TREE_VIEW( list ));
- GtkTreeIter iter, previous;
-
- gtk_tree_selection_unselect_all( selection );
-
- gboolean iterok = gtk_tree_model_get_iter_first( model, &iter );
- gboolean found = FALSE;
- NAAction *action;
- gchar *iter_uuid, *iter_label;
- gint count = 0;
-
- while( iterok && !found ){
- count += 1;
- gtk_tree_model_get(
- model,
- &iter,
- IACTIONS_LIST_NAOBJECT_COLUMN, &action, IACTIONS_LIST_LABEL_COLUMN, &iter_label,
- -1 );
-
- iter_uuid = na_action_get_uuid( action );
- gint ret_uuid = g_ascii_strcasecmp( iter_uuid, uuid );
- gint ret_label = g_utf8_collate( iter_label, label );
- if(( ret_uuid == 0 && ret_label == 0 ) || ret_label > 0 ){
- gtk_tree_selection_select_iter( selection, &iter );
+ if( !found ){
+ g_debug( "%s: selecting previous profile", thisfn );
+ gtk_tree_selection_select_iter( selection, &previous_child );
found = TRUE;
-
- } else {
- previous = iter;
}
-
- g_free( iter_uuid );
- g_free( iter_label );
- iterok = gtk_tree_model_iter_next( model, &iter );
}
- if( !found && count ){
- gtk_tree_selection_select_iter( selection, &previous );
- }
- */
+ previous = iter;
+ iterok = gtk_tree_model_iter_next( model, &iter );
+ }
+
+ if( !found ){
+ g_debug( "%s: selecting previous action", thisfn );
+ gtk_tree_selection_select_iter( selection, &previous );
+ }
}
/**
diff --git a/src/nact/nact-iadvanced-tab.c b/src/nact/nact-iadvanced-tab.c
index 0f368d1..73b77ee 100644
--- a/src/nact/nact-iadvanced-tab.c
+++ b/src/nact/nact-iadvanced-tab.c
@@ -202,7 +202,7 @@ nact_iadvanced_tab_dispose( NactWindow *dialog )
void
nact_iadvanced_tab_set_profile( NactWindow *dialog, NAActionProfile *profile )
{
- static const gchar *thisfn = "nact_iadvanced_tab_runtime_init";
+ static const gchar *thisfn = "nact_iadvanced_tab_set_profile";
g_debug( "%s: dialog=%p, profile=%p", thisfn, dialog, profile );
GtkTreeModel *scheme_model = get_schemes_tree_model( dialog );
@@ -287,9 +287,9 @@ on_scheme_selection_toggled( GtkCellRendererToggle *renderer, gchar *path, gpoin
na_action_profile_set_scheme( edited, scheme, !state );
g_free( scheme );
- }
- v_field_modified( dialog );
+ v_field_modified( dialog );
+ }
}
static void
diff --git a/src/nact/nact-iconditions-tab.c b/src/nact/nact-iconditions-tab.c
index 27a3bd7..3c1033c 100644
--- a/src/nact/nact-iconditions-tab.c
+++ b/src/nact/nact-iconditions-tab.c
@@ -186,7 +186,7 @@ nact_iconditions_tab_dispose( NactWindow *dialog )
void
nact_iconditions_tab_set_profile( NactWindow *dialog, NAActionProfile *profile )
{
- static const gchar *thisfn = "nact_iconditions_tab_runtime_init";
+ static const gchar *thisfn = "nact_iconditions_tab_set_profile";
g_debug( "%s: dialog=%p, profile=%p", thisfn, dialog, profile );
GtkWidget *basenames_widget = get_basenames_entry( dialog );
@@ -283,9 +283,8 @@ on_basenames_changed( GtkEntry *entry, gpointer user_data )
GSList *basenames = na_utils_text_to_string_list( text );
na_action_profile_set_basenames( edited, basenames );
na_utils_free_string_list( basenames );
+ v_field_modified( dialog );
}
-
- v_field_modified( dialog );
}
static GtkWidget *
@@ -304,9 +303,8 @@ on_matchcase_toggled( GtkToggleButton *button, gpointer user_data )
if( edited ){
gboolean matchcase = gtk_toggle_button_get_active( button );
na_action_profile_set_matchcase( edited, matchcase );
+ v_field_modified( dialog );
}
-
- v_field_modified( dialog );
}
static GtkButton *
@@ -327,9 +325,8 @@ on_mimetypes_changed( GtkEntry *entry, gpointer user_data )
GSList *mimetypes = na_utils_text_to_string_list( text );
na_action_profile_set_mimetypes( edited, mimetypes );
na_utils_free_string_list( mimetypes );
+ v_field_modified( dialog );
}
-
- v_field_modified( dialog );
}
static GtkWidget *
@@ -356,9 +353,8 @@ on_isfiledir_toggled( GtkToggleButton *button, gpointer user_data )
gboolean isfile, isdir;
nact_iconditions_tab_get_isfiledir( dialog, &isfile, &isdir );
na_action_profile_set_isfiledir( edited, isfile, isdir );
+ v_field_modified( dialog );
}
-
- v_field_modified( dialog );
}
static void
@@ -403,9 +399,8 @@ on_multiple_toggled( GtkToggleButton *button, gpointer user_data )
if( edited ){
gboolean multiple = gtk_toggle_button_get_active( button );
na_action_profile_set_multiple( edited, multiple );
+ v_field_modified( dialog );
}
-
- v_field_modified( dialog );
}
static GtkButton *
diff --git a/src/nact/nact-imenubar.c b/src/nact/nact-imenubar.c
index 3cd9320..24a0246 100644
--- a/src/nact/nact-imenubar.c
+++ b/src/nact/nact-imenubar.c
@@ -445,20 +445,24 @@ on_save_activated( GtkMenuItem *item, NactWindow *window )
/* keep the current selection
* to be able to restore it at the end of the operation
*/
+ GType type = 0;
+ gchar *uuid = NULL;
+ gchar *label = NULL;
+
NAObject *current = v_get_selected( window );
- GType type;
- gchar *uuid, *label;
- if( NA_IS_ACTION( current )){
- uuid = na_action_get_uuid( NA_ACTION( current ));
- label = na_action_get_label( NA_ACTION( current ));
- type = NA_ACTION_TYPE;
+ if( current ){
+ if( NA_IS_ACTION( current )){
+ uuid = na_action_get_uuid( NA_ACTION( current ));
+ label = na_action_get_label( NA_ACTION( current ));
+ type = NA_ACTION_TYPE;
- } else {
- g_assert( NA_IS_ACTION_PROFILE( current ));
- NAAction *action = na_action_profile_get_action( NA_ACTION_PROFILE( current ));
- uuid = na_action_get_uuid( action );
- label = na_action_profile_get_label( NA_ACTION_PROFILE( current ));
- type = NA_ACTION_PROFILE_TYPE;
+ } else {
+ g_assert( NA_IS_ACTION_PROFILE( current ));
+ NAAction *action = na_action_profile_get_action( NA_ACTION_PROFILE( current ));
+ uuid = na_action_get_uuid( action );
+ label = na_action_profile_get_label( NA_ACTION_PROFILE( current ));
+ type = NA_ACTION_PROFILE_TYPE;
+ }
}
/* save the modified actions
@@ -508,10 +512,13 @@ on_save_activated( GtkMenuItem *item, NactWindow *window )
v_on_save( window );
v_setup_dialog_title( window );
- v_update_actions_list( window );
- v_select_actions_list( window, type, uuid, label );
- g_free( label );
- g_free( uuid );
+
+ if( current ){
+ v_update_actions_list( window );
+ v_select_actions_list( window, type, uuid, label );
+ g_free( label );
+ g_free( uuid );
+ }
}
static void
@@ -547,13 +554,14 @@ add_action( NactWindow *window, NAAction *action )
v_add_action( window, action );
v_update_actions_list( window );
- v_setup_dialog_title( window );
gchar *uuid = na_action_get_uuid( action );
gchar *label = na_action_get_label( action );
v_select_actions_list( window, NA_ACTION_TYPE, uuid, label );
g_free( label );
g_free( uuid );
+
+ v_setup_dialog_title( window );
}
static void
@@ -564,7 +572,6 @@ add_profile( NactWindow *window, NAAction *action, NAActionProfile *profile )
v_add_profile( window, profile );
- v_setup_dialog_title( window );
v_update_actions_list( window );
gchar *uuid = na_action_get_uuid( action );
@@ -572,6 +579,8 @@ add_profile( NactWindow *window, NAAction *action, NAActionProfile *profile )
v_select_actions_list( window, NA_ACTION_PROFILE_TYPE, uuid, label );
g_free( label );
g_free( uuid );
+
+ v_setup_dialog_title( window );
}
static void
@@ -670,12 +679,13 @@ on_delete_activated( GtkMenuItem *item, NactWindow *window )
na_object_check_edited_status( NA_OBJECT( action ));
}
- v_setup_dialog_title( window );
v_update_actions_list( window );
v_select_actions_list( window, type, uuid, label );
g_free( label );
g_free( uuid );
+
+ v_setup_dialog_title( window );
}
static void
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 016645b..718852f 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -103,7 +103,7 @@ static gboolean on_actions_list_double_click( GtkWidget *widget, GdkEven
static gboolean on_actions_list_delete_key_pressed( GtkWidget *widget, GdkEventKey *event, gpointer data );
static gboolean on_actions_list_enter_key_pressed( GtkWidget *widget, GdkEventKey *event, gpointer data );
static void set_current_action( NactMainWindow *window );
-static void set_current_profile( NactMainWindow *window );
+static void set_current_profile( NactMainWindow *window, gboolean set_action );
static NAAction *get_edited_action( NactWindow *window );
static NAActionProfile *get_edited_profile( NactWindow *window );
static void on_modified_field( NactWindow *window );
@@ -572,6 +572,12 @@ on_runtime_init_toplevel( BaseWindow *window )
g_assert( NACT_IS_IADVANCED_TAB( window ));
nact_iadvanced_tab_runtime_init( NACT_WINDOW( window ));
+
+ /* forces a no-selection when the list is initially empty
+ */
+ if( !g_slist_length( NACT_MAIN_WINDOW( window )->private->actions )){
+ set_current_action( NACT_MAIN_WINDOW( window ));
+ }
}
static void
@@ -638,8 +644,12 @@ on_actions_list_selection_changed( GtkTreeSelection *selection, gpointer user_da
} else {
g_assert( NA_IS_ACTION_PROFILE( object ));
window->private->edited_profile = NA_ACTION_PROFILE( object );
- set_current_profile( window );
+ set_current_profile( window, TRUE );
}
+
+ } else {
+ window->private->edited_action = NULL;
+ set_current_action( window );
}
}
@@ -687,17 +697,19 @@ set_current_action( NactMainWindow *window )
window->private->edited_profile = NULL;
- if( na_action_get_profiles_count( window->private->edited_action ) == 1 ){
- window->private->edited_profile = NA_ACTION_PROFILE( na_action_get_profiles( window->private->edited_action )->data );
+ if( window->private->edited_action ){
+ if( na_action_get_profiles_count( window->private->edited_action ) == 1 ){
+ window->private->edited_profile = NA_ACTION_PROFILE( na_action_get_profiles( window->private->edited_action )->data );
+ }
}
- set_current_profile( window );
+ set_current_profile( window, FALSE );
}
static void
-set_current_profile( NactMainWindow *window )
+set_current_profile( NactMainWindow *window, gboolean set_action )
{
- if( window->private->edited_profile ){
+ if( window->private->edited_profile && set_action ){
NAAction *action = NA_ACTION( na_action_profile_get_action( window->private->edited_profile ));
window->private->edited_action = action;
nact_iaction_tab_set_action( NACT_WINDOW( window ), window->private->edited_action );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]