[nautilus-actions] Fix description entry



commit f192fe9bd4272430f8f5dbe84879dac9c5f26493
Author: Pierre Wieser <pwieser trychlos org>
Date:   Mon Mar 29 21:30:41 2010 +0200

    Fix description entry

 ChangeLog                                |   16 +++++++
 TODO                                     |    2 +-
 src/io-desktop/nadp-desktop-file.c       |   27 +++++++++++-
 src/io-desktop/nadp-desktop-file.h       |    1 +
 src/io-desktop/nadp-reader.c             |    3 +
 src/io-desktop/nadp-writer.c             |   19 +++++++-
 src/nact/nact-gtk-utils.c                |   10 ++++
 src/nact/nact-iaction-tab.c              |   23 +++++++---
 src/nact/nautilus-actions-config-tool.ui |   67 ++++++++++++++++--------------
 9 files changed, 123 insertions(+), 45 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5877b6b..d4f0216 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -211,6 +211,22 @@
 
 2010-03-29 Pierre Wieser <pwieser trychlos org>
 
+	* src/nact/nact-gtk-utils.c (nact_gtk_utils_set_editable):
+	Take into account new GtktextView widget.
+
+	* src/io-desktop/nadp-writer.c (nadp_iio_provider_write_item):
+	Remove groups which no longer exist.
+
+	* src/io-desktop/nadp-reader.c (read_done_load_profiles):
+	Free string lists.
+
+	* src/io-desktop/nadp-desktop-file.c:
+	* src/io-desktop/nadp-desktop-file.h (nadp_desktop_file_remove_profile):
+	New function.
+
+	* src/io-desktop/nadp-desktop-file.c (nadp_desktop_file_get_profiles):
+	Fix allocation of profile id.
+
 	* src/io-desktop/nadp-desktop-file.c:
 	* src/io-desktop/nadp-desktop-file.h (nadp_desktop_file_remove_key):
 	New function.
diff --git a/TODO b/TODO
index f082237..173bfa1 100644
--- a/TODO
+++ b/TODO
@@ -92,8 +92,8 @@
   what we should do: compute once, and monitor to only change when needed
 
 - Implement:
-	Description
 	SuggestedShortcut (see gnome-keybinding-properties)
+	GetItemsList
 	Path
 	ExecutionMode
 	StartupNotify
diff --git a/src/io-desktop/nadp-desktop-file.c b/src/io-desktop/nadp-desktop-file.c
index aa26f30..193aee1 100644
--- a/src/io-desktop/nadp-desktop-file.c
+++ b/src/io-desktop/nadp-desktop-file.c
@@ -450,10 +450,9 @@ nadp_desktop_file_get_profiles( const NadpDesktopFile *ndf )
 			pfx_len = strlen( profile_pfx );
 
 			while( *ig ){
-
 				if( !strncmp( *ig, profile_pfx, pfx_len )){
-					profile_id = g_strdup( *ig );
-					list = g_slist_prepend( list, profile_id+pfx_len );
+					profile_id = g_strdup( *ig+pfx_len );
+					list = g_slist_prepend( list, profile_id );
 				}
 
 				ig++;
@@ -509,6 +508,28 @@ nadp_desktop_file_remove_key( const NadpDesktopFile *ndf, const gchar *group, co
 }
 
 /**
+ * nadp_desktop_file_remove_profile:
+ * @ndf: this #NadpDesktopFile instance.
+ * @profile_id: the id of the profile.
+ *
+ * Removes the group which describes the specified profile.
+ */
+void
+nadp_desktop_file_remove_profile( const NadpDesktopFile *ndf, const gchar *profile_id )
+{
+	gchar *group_name;
+
+	g_return_if_fail( NADP_IS_DESKTOP_FILE( ndf ));
+
+	if( !ndf->private->dispose_has_run ){
+
+		group_name = g_strdup_printf( "%s %s", NADP_GROUP_PROFILE, profile_id );
+		g_key_file_remove_group( ndf->private->key_file, group_name, NULL );
+		g_free( group_name );
+	}
+}
+
+/**
  * nadp_desktop_file_get_boolean:
  * @ndf: this #NadpDesktopFile instance.
  * @group: the searched group.
diff --git a/src/io-desktop/nadp-desktop-file.h b/src/io-desktop/nadp-desktop-file.h
index f42ce44..e2bcf3b 100644
--- a/src/io-desktop/nadp-desktop-file.h
+++ b/src/io-desktop/nadp-desktop-file.h
@@ -85,6 +85,7 @@ gchar           *nadp_desktop_file_get_id           ( const NadpDesktopFile *ndf
 GSList          *nadp_desktop_file_get_profiles     ( const NadpDesktopFile *ndf );
 
 void             nadp_desktop_file_remove_key       ( const NadpDesktopFile *ndf, const gchar *group, const gchar *key );
+void             nadp_desktop_file_remove_profile   ( const NadpDesktopFile *ndf, const gchar *profile_id );
 
 gboolean         nadp_desktop_file_get_boolean      ( const NadpDesktopFile *ndf, const gchar *group, const gchar *key, gboolean *key_found, gboolean default_value );
 gchar           *nadp_desktop_file_get_locale_string( const NadpDesktopFile *ndf, const gchar *group, const gchar *key, gboolean *key_found, const gchar *default_value );
diff --git a/src/io-desktop/nadp-reader.c b/src/io-desktop/nadp-reader.c
index a598d37..43a8139 100644
--- a/src/io-desktop/nadp-reader.c
+++ b/src/io-desktop/nadp-reader.c
@@ -552,6 +552,9 @@ read_done_load_profiles( const NAIFactoryProvider *provider, NAObjectAction *act
 			read_done_action_load_profile( provider, reader_data, profile_id, messages );
 		}
 	}
+
+	na_core_utils_slist_free( list_profiles );
+	na_core_utils_slist_free( order );
 }
 
 static void
diff --git a/src/io-desktop/nadp-writer.c b/src/io-desktop/nadp-writer.c
index 5db875c..994d827 100644
--- a/src/io-desktop/nadp-writer.c
+++ b/src/io-desktop/nadp-writer.c
@@ -173,9 +173,8 @@ nadp_iio_provider_write_item( const NAIIOProvider *provider, const NAObjectItem
  *
  * As we want keep comments between through multiple updates, we cannot
  * just delete the .desktop file and recreate it as we are doing for GConf.
- * Instead of that, we delete each group before updating it, then deleting
- * last groups (not updated ones) at end.
- * -> as a side effect, we lose comments inside of groups :(
+ * Instead of that, we delete at end groups that have not been walked through
+ * -> as a side effect, we lose comments inside of these groups :(
  */
 static guint
 write_item( const NAIIOProvider *provider, const NAObjectItem *item, NadpDesktopFile *ndf, GSList **messages )
@@ -419,9 +418,12 @@ nadp_writer_ifactory_provider_write_done( const NAIFactoryProvider *provider, vo
 							const NAIFactoryObject *object, GSList **messages  )
 {
 	GSList *subitems;
+	GSList *profile_groups;
+	GSList *ip;
 
 	if( NA_IS_OBJECT_ITEM( object )){
 		subitems = na_object_get_items_slist( object );
+		na_core_utils_slist_dump( subitems );
 
 		nadp_desktop_file_set_string_list(
 				NADP_DESKTOP_FILE( writer_data ),
@@ -429,6 +431,17 @@ nadp_writer_ifactory_provider_write_done( const NAIFactoryProvider *provider, vo
 				NA_IS_OBJECT_ACTION( object ) ? NADP_KEY_PROFILES : NADP_KEY_ITEMS_LIST,
 				subitems );
 
+		profile_groups = nadp_desktop_file_get_profiles( NADP_DESKTOP_FILE( writer_data ));
+		na_core_utils_slist_dump( profile_groups );
+
+		for( ip = profile_groups ; ip ; ip = ip->next ){
+			if( !na_core_utils_slist_find( subitems, ( const gchar * ) ip->data )){
+				g_debug( "nadp_writer_ifactory_provider_write_done: deleting (removed) profile %s", ( const gchar * ) ip->data );
+				nadp_desktop_file_remove_profile( NADP_DESKTOP_FILE( writer_data ), ( const gchar * ) ip->data );
+			}
+		}
+
+		na_core_utils_slist_free( profile_groups );
 		na_core_utils_slist_free( subitems );
 	}
 
diff --git a/src/nact/nact-gtk-utils.c b/src/nact/nact-gtk-utils.c
index c35f140..36e9e55 100644
--- a/src/nact/nact-gtk-utils.c
+++ b/src/nact/nact-gtk-utils.c
@@ -48,6 +48,8 @@ void
 nact_gtk_utils_set_editable( GtkObject *widget, gboolean editable )
 {
 	GList *renderers, *irender;
+	GtkTextBuffer *buffer;
+	GtkTextTag *tag;
 
 	if( GTK_IS_ENTRY( widget )){
 		gtk_editable_set_editable( GTK_EDITABLE( widget ), editable );
@@ -57,6 +59,14 @@ nact_gtk_utils_set_editable( GtkObject *widget, gboolean editable )
 		/* this prevents the caret to be displayed when we click in the entry */
 		g_object_set( G_OBJECT( widget ), "can-focus", editable, NULL );
 
+	} else if( GTK_IS_TEXT_VIEW( widget )){
+		buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( widget ));
+		tag = gtk_text_buffer_create_tag( buffer,
+				"nact-tag",
+				"editable", editable,
+				"editable-set", TRUE,
+				NULL );
+
 	} else if( GTK_IS_TOGGLE_BUTTON( widget )){
 		/* transforms to a quasi standard GtkButton */
 		/*g_object_set( G_OBJECT( widget ), "draw-indicator", editable, NULL );*/
diff --git a/src/nact/nact-iaction-tab.c b/src/nact/nact-iaction-tab.c
index 2608c97..7109943 100644
--- a/src/nact/nact-iaction-tab.c
+++ b/src/nact/nact-iaction-tab.c
@@ -112,7 +112,7 @@ static void          release_icon_combobox( NactIActionTab *instance );
 static GtkButton    *get_enabled_button( NactIActionTab *instance );
 static void          on_enabled_toggled( GtkToggleButton *button, NactIActionTab *instance );
 static void          on_readonly_toggled( GtkToggleButton *button, NactIActionTab *instance );
-static void          on_description_changed( GtkEntry *entry, NactIActionTab *instance );
+static void          on_description_changed( GtkTextBuffer *buffer, NactIActionTab *instance );
 
 static void          display_provider_name( NactIActionTab *instance, NAObjectItem *item );
 
@@ -234,6 +234,7 @@ nact_iaction_tab_runtime_init_toplevel( NactIActionTab *instance )
 	GtkWidget *label_widget, *tooltip_widget, *icon_widget;
 	GtkButton *enabled_button;
 	GtkWidget *button;
+	GtkTextBuffer *buffer;
 
 	g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
 	g_return_if_fail( NACT_IS_IACTION_TAB( instance ));
@@ -335,10 +336,11 @@ nact_iaction_tab_runtime_init_toplevel( NactIActionTab *instance )
 				"toggled",
 				G_CALLBACK( on_readonly_toggled ));
 
-		label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionDescriptionEntry" );
+		label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionDescriptionText" );
+		buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( label_widget ));
 		base_window_signal_connect(
 				BASE_WINDOW( instance ),
-				G_OBJECT( label_widget ),
+				G_OBJECT( buffer ),
 				"changed",
 				G_CALLBACK( on_description_changed ));
 	}
@@ -432,6 +434,7 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
 	gboolean editable;
 	GtkNotebook *notebook;
 	GtkWidget *page;
+	GtkTextBuffer *buffer;
 
 	g_debug( "%s: instance=%p, count_selected=%d", thisfn, ( void * ) instance, count_selected );
 	g_return_if_fail( BASE_IS_WINDOW( instance ));
@@ -551,9 +554,10 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
 		gtk_widget_set_sensitive( GTK_WIDGET( readonly_button ), item != NULL );
 		nact_gtk_utils_set_editable( GTK_OBJECT( readonly_button ), FALSE );
 
-		label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionDescriptionEntry" );
+		label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionDescriptionText" );
+		buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( label_widget ));
 		label = item ? na_object_get_description( item ) : g_strdup( "" );
-		gtk_entry_set_text( GTK_ENTRY( label_widget ), label );
+		gtk_text_buffer_set_text( buffer, label, -1 );
 		g_free( label );
 		gtk_widget_set_sensitive( label_widget, item != NULL );
 
@@ -1147,9 +1151,11 @@ on_readonly_toggled( GtkToggleButton *button, NactIActionTab *instance )
 }
 
 static void
-on_description_changed( GtkEntry *entry, NactIActionTab *instance )
+on_description_changed( GtkTextBuffer *buffer, NactIActionTab *instance )
 {
 	NAObjectItem *edited;
+	GtkTextIter start, end;
+	gchar *text;
 
 	g_object_get(
 			G_OBJECT( instance ),
@@ -1157,7 +1163,10 @@ on_description_changed( GtkEntry *entry, NactIActionTab *instance )
 			NULL );
 
 	if( edited ){
-		na_object_set_description( edited, gtk_entry_get_text( entry ));
+		gtk_text_buffer_get_start_iter( buffer, &start );
+		gtk_text_buffer_get_end_iter( buffer, &end );
+		text = gtk_text_buffer_get_text( buffer, &start, &end, TRUE );
+		na_object_set_description( edited, text );
 		g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, edited, FALSE );
 	}
 }
diff --git a/src/nact/nautilus-actions-config-tool.ui b/src/nact/nautilus-actions-config-tool.ui
index 452abd4..151a900 100644
--- a/src/nact/nautilus-actions-config-tool.ui
+++ b/src/nact/nautilus-actions-config-tool.ui
@@ -472,7 +472,7 @@ Menus are never displayed in the toolbar.</property>
                                 <child>
                                   <object class="GtkTable" id="table4">
                                     <property name="visible">True</property>
-                                    <property name="n_rows">4</property>
+                                    <property name="n_rows">5</property>
                                     <property name="n_columns">2</property>
                                     <property name="column_spacing">5</property>
                                     <child>
@@ -485,8 +485,8 @@ Menus are never displayed in the toolbar.</property>
                                       <packing>
                                         <property name="left_attach">1</property>
                                         <property name="right_attach">2</property>
-                                        <property name="top_attach">2</property>
-                                        <property name="bottom_attach">3</property>
+                                        <property name="top_attach">3</property>
+                                        <property name="bottom_attach">4</property>
                                         <property name="y_options">GTK_FILL</property>
                                       </packing>
                                     </child>
@@ -497,8 +497,8 @@ Menus are never displayed in the toolbar.</property>
                                         <property name="label" translatable="yes">Id. :</property>
                                       </object>
                                       <packing>
-                                        <property name="top_attach">2</property>
-                                        <property name="bottom_attach">3</property>
+                                        <property name="top_attach">3</property>
+                                        <property name="bottom_attach">4</property>
                                         <property name="x_options">GTK_FILL</property>
                                       </packing>
                                     </child>
@@ -509,8 +509,8 @@ Menus are never displayed in the toolbar.</property>
                                         <property name="label" translatable="yes">I/O provider :</property>
                                       </object>
                                       <packing>
-                                        <property name="top_attach">3</property>
-                                        <property name="bottom_attach">4</property>
+                                        <property name="top_attach">4</property>
+                                        <property name="bottom_attach">5</property>
                                         <property name="x_options">GTK_FILL</property>
                                       </packing>
                                     </child>
@@ -522,39 +522,36 @@ Menus are never displayed in the toolbar.</property>
                                       <packing>
                                         <property name="left_attach">1</property>
                                         <property name="right_attach">2</property>
-                                        <property name="top_attach">3</property>
-                                        <property name="bottom_attach">4</property>
+                                        <property name="top_attach">4</property>
+                                        <property name="bottom_attach">5</property>
                                       </packing>
                                     </child>
                                     <child>
                                       <object class="GtkLabel" id="ActionDescriptionLabel">
                                         <property name="visible">True</property>
                                         <property name="xalign">1</property>
-                                        <property name="label" translatable="yes">Description :</property>
+                                        <property name="yalign">0</property>
+                                        <property name="label" translatable="yes">_Description :</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="ActionDescriptionEntry">
+                                      <object class="GtkTextView" id="ActionDescriptionText">
                                         <property name="visible">True</property>
                                         <property name="can_focus">True</property>
-                                        <property name="invisible_char">&#x25CF;</property>
+                                        <property name="tooltip_text" translatable="yes">This description may be used when presenting your menu or action in a web site.</property>
+                                        <property name="wrap_mode">word</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>
                                       </packing>
                                     </child>
                                     <child>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
                                       <object class="GtkHBox" id="hbox10">
                                         <property name="visible">True</property>
                                         <property name="homogeneous">True</property>
@@ -564,8 +561,6 @@ Menus are never displayed in the toolbar.</property>
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="receives_default">False</property>
-                                            <property name="tooltip_text" translatable="yes">The item, action or menu, needs to be enabled to be candidate to be displayed in the Nautilus context menu or the Nautilus toolbar.
-When disabled, the item is only available in Nautilus-Actions Configuration Tool.</property>
                                             <property name="use_underline">True</property>
                                             <property name="draw_indicator">True</property>
                                           </object>
@@ -577,9 +572,8 @@ When disabled, the item is only available in Nautilus-Actions Configuration Tool
                                           <object class="GtkCheckButton" id="ActionReadonlyButton">
                                             <property name="label" translatable="yes">Read-only</property>
                                             <property name="visible">True</property>
-                                            <property name="can_focus">False</property>
+                                            <property name="can_focus">True</property>
                                             <property name="receives_default">False</property>
-                                            <property name="tooltip_text" translatable="yes">An indicator of the intrinsic writability status of this item.</property>
                                             <property name="focus_on_click">False</property>
                                             <property name="draw_indicator">True</property>
                                           </object>
@@ -591,8 +585,16 @@ When disabled, the item is only available in Nautilus-Actions Configuration Tool
                                       <packing>
                                         <property name="left_attach">1</property>
                                         <property name="right_attach">2</property>
+                                        <property name="top_attach">2</property>
+                                        <property name="bottom_attach">3</property>
                                       </packing>
                                     </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
                                   </object>
                                 </child>
                               </object>
@@ -1441,6 +1443,9 @@ Defining several profiles lets you have several commands, each applying with a d
       <placeholder/>
     </child>
     <child>
+      <placeholder/>
+    </child>
+    <child>
       <object class="GtkLabel" id="label3">
         <property name="visible">True</property>
         <property name="label" translatable="yes">This assistant will guide you through the process of importing items, actions or menus.</property>
@@ -1457,9 +1462,9 @@ Defining several profiles lets you have several commands, each applying with a d
           <object class="GtkFileChooserWidget" id="ImportFileChooser">
             <property name="visible">True</property>
             <property name="use_preview_label">False</property>
-            <property name="preview_widget_active">False</property>
-            <property name="local_only">False</property>
             <property name="select_multiple">True</property>
+            <property name="local_only">False</property>
+            <property name="preview_widget_active">False</property>
           </object>
           <packing>
             <property name="position">0</property>
@@ -2253,24 +2258,24 @@ Be warned: this mode may be dangerous. You will not be prompted another time.</p
   </object>
   <object class="GtkSizeGroup" id="CommandLabelSizeGroup">
     <widgets>
-      <widget name="ProfileLabelLabel"/>
-      <widget name="CommandPathLabel"/>
       <widget name="CommandParametersLabel"/>
+      <widget name="CommandPathLabel"/>
+      <widget name="ProfileLabelLabel"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup" id="CommandButtonSizeGroup">
     <widgets>
-      <widget name="CommandPathButton"/>
       <widget name="CommandLegendButton"/>
+      <widget name="CommandPathButton"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup" id="ActionLabelSizeGroup">
     <widgets>
-      <widget name="ActionToolbarLabelLabel"/>
-      <widget name="ActionMenuLabelLabel"/>
-      <widget name="ActionIdLabel"/>
-      <widget name="ActionTooltipLabel"/>
       <widget name="ActionIconLabel"/>
+      <widget name="ActionTooltipLabel"/>
+      <widget name="ActionIdLabel"/>
+      <widget name="ActionMenuLabelLabel"/>
+      <widget name="ActionToolbarLabelLabel"/>
     </widgets>
   </object>
 </interface>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]