Commit 5f711de0 authored by Pierre Wieser's avatar Pierre Wieser

No more record the 'toolbar-same-label' key

parent 244f09a0
2009-01-30 Pierre Wieser <pwieser@trychlos.org>
No more record the toolbar_same_label indicator.
* nautilus-actions.schemas.in:
Remove schema for 'toolbar-same-label' key.
* nautilus-actions/io-provider-gconf/nagp-read.c
(read_item_action_properties):
No more read the 'toolbar-same-label' entry.
* nautilus-actions/io-provider-gconf/nagp-write.c (write_item_action):
No more write the 'toolbar-same-label' entry.
Remove the key if undeeded.
* nautilus-actions/nact/nact-iaction-tab.c
(on_toolbar_same_label_toggled): Fix toolbar label setup.
* nautilus-actions/nact/nact-xml-reader.c (apply_values):
No more read OBJECT_ITEM_TOOLBAR_SAME_LABEL_ENTRY node.
* nautilus-actions/runtime/na-gconf-utils.c:
* nautilus-actions/runtime/na-gconf-utils.h
(na_gconf_utils_remove_entry): New function.
* nautilus-actions/runtime/na-xml-writer.c
(create_schema_entry, create_dump_entry):
No more write the 'toolbar-same-label' entry.
* nautilus-actions/nact/nact-iaction-tab.c
(on_tab_updatable_selection_changed):
Update tab label depending on the currently selected item.
......
......@@ -123,17 +123,6 @@ The value is case sensitive and must not be localized.</long>
<default>Action</default>
</schema>
<schema>
<key>/schemas/apps/nautilus-actions/configurations/toolbar-same-label</key>
<owner>nautilus-actions</owner>
<type>bool</type>
<locale name="C">
<short>Whether the labels are the sames</short>
<long>Whether the label displayed in the Nautilus toolbar besides of the icon is the same that the main item label.</long>
</locale>
<default>true</default>
</schema>
<schema>
<key>/schemas/apps/nautilus-actions/configurations/toolbar-label</key>
<owner>nautilus-actions</owner>
......@@ -141,7 +130,8 @@ The value is case sensitive and must not be localized.</long>
<locale name="C">
<short>Label of the item in the toolbar</short>
<long>The label displayed besides of the icon in the Nautilus toolbar.
Note that actual display may depend of your own Gnome preferences.</long>
An empty label here defaults to the item label.
Note that actual display (only icon, only label or both) may depend of your own Gnome preferences.</long>
</locale>
<default></default>
</schema>
......
......@@ -224,6 +224,7 @@ read_item_action_properties( NagpGConfProvider *provider, GSList *entries, NAObj
gchar *version;
gboolean target_selection, target_background, target_toolbar;
gboolean toolbar_same_label;
gchar *action_label;
gchar *toolbar_label;
read_object_item_properties( provider, entries, NA_OBJECT_ITEM( action ) );
......@@ -245,22 +246,21 @@ read_item_action_properties( NagpGConfProvider *provider, GSList *entries, NAObj
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 );
} else {
toolbar_same_label = na_object_action_toolbar_use_same_label( action );
/* toolbar label is the same that action if empty */
action_label = na_object_get_label( action );
toolbar_same_label = FALSE;
na_gconf_utils_get_string_from_entries( entries, OBJECT_ITEM_TOOLBAR_LABEL_ENTRY, &toolbar_label );
if( !toolbar_label || !g_utf8_strlen( toolbar_label, -1 ) || !g_utf8_collate( toolbar_label, action_label )){
toolbar_same_label = TRUE;
}
if( na_gconf_utils_get_string_from_entries( entries, OBJECT_ITEM_TOOLBAR_LABEL_ENTRY, &toolbar_label )){
na_object_action_toolbar_set_label( action, toolbar_label );
if( toolbar_same_label ){
g_free( toolbar_label );
} else if( toolbar_same_label ){
toolbar_label = na_object_get_label( action );
toolbar_label = g_strdup( action_label );
}
na_object_action_toolbar_set_label( action, toolbar_label );
na_object_action_toolbar_set_same_label( action, toolbar_same_label );
g_free( action_label );
g_free( toolbar_label );
}
}
/*
......
......@@ -46,6 +46,9 @@ static gboolean write_object_item( NagpGConfProvider *gconf, const NAObjec
static gboolean write_str( NagpGConfProvider *gconf, const gchar *uuid, const gchar *name, const gchar *key, gchar *value, GSList **message );
static gboolean write_bool( NagpGConfProvider *gconf, const gchar *uuid, const gchar *name, const gchar *key, gboolean value, GSList **message );
static gboolean write_list( NagpGConfProvider *gconf, const gchar *uuid, const gchar *name, const gchar *key, GSList *value, GSList **message );
static gboolean remove_key( NagpGConfProvider *provider, const gchar *uuid, const gchar *key, GSList **messages );
static void free_gslist( GSList *list );
/*
......@@ -165,10 +168,20 @@ write_item_action( NagpGConfProvider *provider, const NAObjectAction *action, GS
write_bool( provider, uuid, NULL, OBJECT_ITEM_TARGET_SELECTION_ENTRY, na_object_action_is_target_selection( action ), messages ) &&
write_bool( provider, uuid, NULL, OBJECT_ITEM_TARGET_BACKGROUND_ENTRY, na_object_action_is_target_background( action ), messages ) &&
write_bool( provider, uuid, NULL, OBJECT_ITEM_TARGET_TOOLBAR_ENTRY, na_object_action_is_target_toolbar( action ), messages ) &&
write_bool( provider, uuid, NULL, OBJECT_ITEM_TOOLBAR_SAME_LABEL_ENTRY, na_object_action_toolbar_use_same_label( action ), messages ) &&
write_str( provider, uuid, NULL, OBJECT_ITEM_TOOLBAR_LABEL_ENTRY, na_object_action_toolbar_get_label( action ), messages ) &&
write_str( provider, uuid, NULL, OBJECT_ITEM_TYPE_ENTRY, g_strdup( OBJECT_ITEM_TYPE_ACTION ), messages );
/* key was used between 2.29.1 and 2.29.4, but is removed since 2.29.5 */
remove_key( provider, uuid, OBJECT_ITEM_TOOLBAR_SAME_LABEL_ENTRY, messages );
/* only write toolbar_label if not same label than action itself */
if( ret ){
if( na_object_action_toolbar_use_same_label( action )){
remove_key( provider, uuid, OBJECT_ITEM_TOOLBAR_LABEL_ENTRY, messages );
} else {
ret = write_str( provider, uuid, NULL, OBJECT_ITEM_TOOLBAR_LABEL_ENTRY, na_object_action_toolbar_get_label( action ), messages );
}
}
profiles = na_object_get_items_list( action );
for( ip = profiles ; ip && ret ; ip = ip->next ){
......@@ -375,6 +388,28 @@ write_list( NagpGConfProvider *provider, const gchar *uuid, const gchar *name, c
return( ret );
}
static gboolean
remove_key( NagpGConfProvider *provider, const gchar *uuid, const gchar *key, GSList **messages )
{
gboolean ret;
gchar *path;
gchar *msg;
path = g_strdup_printf( "%s/%s/%s", NA_GCONF_CONFIG_PATH, uuid, key );
msg = NULL;
ret = na_gconf_utils_remove_entry( provider->private->gconf, path, &msg );
if( msg ){
*messages = g_slist_append( *messages, g_strdup( msg ));
g_free( msg );
}
g_free( path );
return( ret );
}
/*
* free_gslist:
* @list: the GSList to be freed.
......
......@@ -760,6 +760,8 @@ on_toolbar_same_label_toggled( GtkToggleButton *button, NactIActionTab *instance
NAObjectItem *edited;
gboolean same_label;
gboolean editable;
gchar *label;
GtkWidget *label_widget;
if( !st_on_selection_change ){
g_debug( "%s: button=%p, instance=%p", thisfn, ( void * ) button, ( void * ) instance );
......@@ -776,6 +778,12 @@ on_toolbar_same_label_toggled( GtkToggleButton *button, NactIActionTab *instance
if( editable ){
na_object_action_toolbar_set_same_label( NA_OBJECT_ACTION( edited ), same_label );
if( same_label ){
label = na_object_get_label( edited );
label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconLabelEntry" );
gtk_entry_set_text( GTK_ENTRY( label_widget ), label );
g_free( label );
}
g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, edited, FALSE );
toolbar_same_label_set_sensitive( instance, NA_OBJECT_ITEM( edited ));
toolbar_label_set_sensitive( instance, NA_OBJECT_ITEM( edited ));
......
......@@ -72,7 +72,6 @@ struct NactXMLReaderPrivate {
NAObjectAction *action; /* the action that we will return, or NULL */
GSList *messages;
gboolean uuid_set; /* set at first uuid, then checked against */
gboolean toolbar_label_set;
/* following values are reset at each schema/entry node
*/
......@@ -251,7 +250,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private->locale_waited = FALSE;
self->private->entry = NULL;
self->private->value = NULL;
self->private->toolbar_label_set = FALSE;
}
static void
......@@ -1167,10 +1165,12 @@ apply_values( NactXMLReader *reader )
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 )){
/* only used between 2.29.1 and 2.29.4, removed starting with 2.29.5
na_object_action_toolbar_set_same_label( reader->private->action, na_utils_schema_to_boolean( reader->private->value, TRUE ));
*/
;
} else if( !strcmp( reader->private->entry, OBJECT_ITEM_TOOLBAR_LABEL_ENTRY )){
reader->private->toolbar_label_set = TRUE;
na_object_action_toolbar_set_label( reader->private->action, reader->private->value );
} else if( !strcmp( reader->private->entry, ACTION_PROFILE_LABEL_ENTRY )){
......@@ -1373,13 +1373,22 @@ manage_import_mode( NactXMLReader *reader )
static void
propagate_default_values( NactXMLReader *reader )
{
gchar *label;
gchar *action_label, *toolbar_label;
gboolean same_label;
if( !reader->private->toolbar_label_set ){
label = na_object_get_label( reader->private->action );
na_object_action_toolbar_set_label( reader->private->action, label );
g_free( label );
}
/* between 2.29.1 and 2.29.4, we use to have a toolbar_same_label indicator
* starting with 2.29.5, we no more have this flag
*/
same_label = FALSE;
action_label = na_object_get_label( reader->private->action );
toolbar_label = na_object_action_toolbar_get_label( reader->private->action );
if( !toolbar_label || !g_utf8_strlen( toolbar_label, -1 ) || !g_utf8_collate( toolbar_label, action_label )){
same_label = TRUE;
na_object_action_toolbar_set_label( reader->private->action, action_label );
}
na_object_action_toolbar_set_same_label( reader->private->action, same_label );
g_free( toolbar_label );
g_free( action_label );
}
static NAObjectItem *
......
......@@ -464,7 +464,7 @@ na_gconf_utils_write_int( GConfClient *gconf, const gchar *path, gint value, gch
if( message ){
*message = g_strdup( error->message );
}
g_warning( "%s: path=%s, value=%s, error=%s", thisfn, path, value ? "True":"False", error->message );
g_warning( "%s: path=%s, value=%d, error=%s", thisfn, path, value, error->message );
g_error_free( error );
ret = FALSE;
}
......@@ -499,7 +499,7 @@ na_gconf_utils_write_string( GConfClient *gconf, const gchar *path, const gchar
if( message ){
*message = g_strdup( error->message );
}
g_warning( "%s: path=%s, value=%s, error=%s", thisfn, path, value ? "True":"False", error->message );
g_warning( "%s: path=%s, value=%s, error=%s", thisfn, path, value, error->message );
g_error_free( error );
ret = FALSE;
}
......@@ -534,7 +534,8 @@ na_gconf_utils_write_string_list( GConfClient *gconf, const gchar *path, GSList
if( message ){
*message = g_strdup( error->message );
}
g_warning( "%s: path=%s, value=%s, error=%s", thisfn, path, value ? "True":"False", error->message );
g_warning( "%s: path=%s, value=%p (count=%d), error=%s",
thisfn, path, ( void * ) value, g_slist_length( value ), error->message );
g_error_free( error );
ret = FALSE;
}
......@@ -546,6 +547,39 @@ na_gconf_utils_write_string_list( GConfClient *gconf, const gchar *path, GSList
return( ret );
}
/**
* na_gconf_utils_remove_entry:
* @gconf: a #GConfClient instance.
* @path: the full path to the entry.
* @message: a pointer to a gchar * which will be allocated if needed.
*
* Removes an entry from user preferences.
*/
gboolean
na_gconf_utils_remove_entry( GConfClient *gconf, const gchar *path, gchar **message )
{
static const gchar *thisfn = "na_gconf_utils_remove_entry";
gboolean ret;
GError *error = NULL;
g_return_val_if_fail( GCONF_IS_CLIENT( gconf ), FALSE );
ret = gconf_client_unset( gconf, path, &error );
if( !ret ){
if( message ){
*message = g_strdup( error->message );
}
g_warning( "%s: path=%s, error=%s", thisfn, path, error->message );
g_error_free( error );
}
if( ret ){
ret = sync_gconf( gconf, message );
}
return( ret );
}
static GConfValue *
read_value( GConfClient *gconf, const gchar *path, gboolean use_schema, GConfValueType type )
{
......
......@@ -61,6 +61,8 @@ gboolean na_gconf_utils_write_int( GConfClient *gconf, const gchar *path, gint v
gboolean na_gconf_utils_write_string( GConfClient *gconf, const gchar *path, const gchar *value, gchar **message );
gboolean na_gconf_utils_write_string_list( GConfClient *gconf, const gchar *path, GSList *value, gchar **message );
gboolean na_gconf_utils_remove_entry( GConfClient *gconf, const gchar *path, gchar **message );
G_END_DECLS
#endif /* __NA_RUNTIME_GCONF_UTILS_H__ */
......@@ -559,7 +559,6 @@ create_xml_schema( NAXMLWriter *writer, gint format, const NAObjectAction *actio
gchar *type;
GSList *items;
gboolean target_selection, target_background, target_toolbar;
gboolean toolbar_same_label;
gchar *toolbar_label;
GSList *folders;
......@@ -624,13 +623,17 @@ create_xml_schema( NAXMLWriter *writer, gint format, const NAObjectAction *actio
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 );
/* toolbar same label */
toolbar_same_label = na_object_action_toolbar_use_same_label( action );
/* toolbar same label
* only used between 2.29.1 and 2.29.4 - removed starting with 2.29.5
*/
/*toolbar_same_label = na_object_action_toolbar_use_same_label( action );
text = na_utils_boolean_to_schema( toolbar_same_label );
create_schema_entry( writer, format, NULL, OBJECT_ITEM_TOOLBAR_SAME_LABEL_ENTRY, text, doc, list_node, "bool", FALSE, ACTION_TOOLBAR_SAME_LABEL_DESC_SHORT, ACTION_TOOLBAR_SAME_LABEL_DESC_LONG );
g_free( text );
g_free( text );*/
/* toolbar label */
/* toolbar label
* starting with 2.29.5: we always export the toolbar label
*/
toolbar_label = na_object_action_toolbar_get_label( action );
create_schema_entry( writer, format, NULL, OBJECT_ITEM_TOOLBAR_LABEL_ENTRY, toolbar_label, doc, list_node, "string", TRUE, ACTION_TOOLBAR_LABEL_DESC_SHORT, ACTION_TOOLBAR_LABEL_DESC_LONG );
g_free( toolbar_label );
......@@ -793,7 +796,6 @@ create_xml_dump( NAXMLWriter *writer, gint format, const NAObjectAction *action
gchar *type;
GSList *items;
gboolean target_selection, target_background, target_toolbar;
gboolean toolbar_same_label;
gchar *toolbar_label;
GSList *folders;
......@@ -862,13 +864,17 @@ create_xml_dump( NAXMLWriter *writer, gint format, const NAObjectAction *action
create_dump_entry( writer, format, NULL, OBJECT_ITEM_TARGET_TOOLBAR_ENTRY, text, doc, list_node, "bool" );
g_free( text );
/* toolbar same label */
toolbar_same_label = na_object_action_toolbar_use_same_label( action );
/* toolbar same label
* only used between 2.29.1 and 2.29.4 - removed starting with 2.29.5
*/
/*toolbar_same_label = na_object_action_toolbar_use_same_label( action );
text = na_utils_boolean_to_schema( toolbar_same_label );
create_dump_entry( writer, format, NULL, OBJECT_ITEM_TOOLBAR_SAME_LABEL_ENTRY, text, doc, list_node, "bool" );
g_free( text );
g_free( text );*/
/* toolbar label */
/* toolbar label
* starting with 2.29.5: we always export the toolbar label
*/
toolbar_label = na_object_action_toolbar_get_label( action );
create_dump_entry( writer, format, NULL, OBJECT_ITEM_TOOLBAR_LABEL_ENTRY, toolbar_label, doc, list_node, "string" );
g_free( toolbar_label );
......@@ -1016,7 +1022,7 @@ create_gconf_schema( NAXMLWriter *writer )
create_gconf_schema_entry( writer, OBJECT_ITEM_TARGET_SELECTION_ENTRY , doc, list_node, "bool", ACTION_TARGET_SELECTION_DESC_SHORT , ACTION_TARGET_SELECTION_DESC_LONG , "true", FALSE );
create_gconf_schema_entry( writer, OBJECT_ITEM_TARGET_BACKGROUND_ENTRY , doc, list_node, "bool", ACTION_TARGET_BACKGROUND_DESC_SHORT , ACTION_TARGET_BACKGROUND_DESC_LONG , "false", FALSE );
create_gconf_schema_entry( writer, OBJECT_ITEM_TARGET_TOOLBAR_ENTRY , doc, list_node, "bool", ACTION_TARGET_TOOLBAR_DESC_SHORT , ACTION_TARGET_TOOLBAR_DESC_LONG , "false", FALSE );
create_gconf_schema_entry( writer, OBJECT_ITEM_TOOLBAR_SAME_LABEL_ENTRY, doc, list_node, "bool", ACTION_TOOLBAR_SAME_LABEL_DESC_SHORT, ACTION_TOOLBAR_SAME_LABEL_DESC_LONG, "true", FALSE );
/*create_gconf_schema_entry( writer, OBJECT_ITEM_TOOLBAR_SAME_LABEL_ENTRY, doc, list_node, "bool", ACTION_TOOLBAR_SAME_LABEL_DESC_SHORT, ACTION_TOOLBAR_SAME_LABEL_DESC_LONG, "true", FALSE );*/
create_gconf_schema_entry( writer, OBJECT_ITEM_TOOLBAR_LABEL_ENTRY , doc, list_node, "string", ACTION_TOOLBAR_LABEL_DESC_SHORT , ACTION_TOOLBAR_LABEL_DESC_LONG , "", TRUE );
create_gconf_schema_entry( writer, ACTION_PROFILE_LABEL_ENTRY , doc, list_node, "string", ACTION_PROFILE_NAME_DESC_SHORT, ACTION_PROFILE_NAME_DESC_LONG, NA_OBJECT_PROFILE_DEFAULT_LABEL, TRUE );
create_gconf_schema_entry( writer, ACTION_PATH_ENTRY , doc, list_node, "string", ACTION_PATH_DESC_SHORT , ACTION_PATH_DESC_LONG , "", FALSE );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment