[nautilus-actions: 11/45] Fix expansion of widgets in the UI



commit a6661853ed1d59ec5ff2596953724717744b2647
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sun Jul 19 13:45:44 2009 +0200

    Fix expansion of widgets in the UI

 ChangeLog                                 |   27 ++
 src/nact/nact-action-conditions-editor.c  |  517 --------------------------
 src/nact/nact-action-conditions-editor.h  |   74 ----
 src/nact/nact-action-profiles-editor.c    |  577 -----------------------------
 src/nact/nact-action-profiles-editor.h    |   74 ----
 src/nact/nact-iadvanced-tab.c             |   44 ++-
 src/nact/nact-iadvanced-tab.h             |   13 +-
 src/nact/nact-icommand-tab.c              |   28 +-
 src/nact/nact-iconditions-tab.c           |   42 ++-
 src/nact/nact-iconditions-tab.h           |   14 +-
 src/nact/nact-main-window.c               |    8 +-
 src/nact/nact-profile-conditions-editor.c |  503 -------------------------
 src/nact/nact-profile-conditions-editor.h |   74 ----
 src/nact/nautilus-actions-config.ui       |  142 ++++----
 14 files changed, 185 insertions(+), 1952 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2a4ed20..c318404 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2009-07-19 Pierre Wieser <pwieser trychlos org>
+
+	* src/nact/nact-action-conditions-editor.c:
+	* src/nact/nact-action-conditions-editor.h:
+	* src/nact/nact-action-profiles-editor.c:
+	* src/nact/nact-action-profiles-editor.h:
+	* src/nact/nact-profile-conditions-editor.c:
+	* src/nact/nact-profile-conditions-editor.h: Removed files.
+
+	* src/nact/Makefile.am: Updated accordingly.
+
+	* src/nact/nact-icommand-tab.c:
+	Disable the example label when there is no current profile.
+
+	* src/nact/nact-iconditions-tab.c:
+	* src/nact/nact-iconditions-tab.h
+	(nact_iconditions_tab_get_isfiledir,
+	nact_iconditions_tab_get_multiple): New functions.
+
+	* src/nact/nact-iadvanced-tab.c:
+	* src/nact/nact-iadvanced-tab.h (nact_iadvanced_tab_get_schemes):
+	New function.
+
+	* src/nact/nautilus-actions-config.ui:
+	Example label now wraps on more than two lines.
+	Scheme lists now is more than four rows.
+
 2009-07-18 Pierre Wieser <pwieser trychlos org>
 
 	* src/common/na-action.c:
diff --git a/src/nact/nact-iadvanced-tab.c b/src/nact/nact-iadvanced-tab.c
index cd294f2..0f368d1 100644
--- a/src/nact/nact-iadvanced-tab.c
+++ b/src/nact/nact-iadvanced-tab.c
@@ -71,7 +71,7 @@ static void             scheme_cell_edited( NactWindow *window, const gchar *pat
 static GtkTreeView     *get_schemes_tree_view( NactWindow *window );
 static GtkTreeModel    *get_schemes_tree_model( NactWindow *window );
 static void             create_schemes_selection_list( NactWindow *window );
-/*static gboolean         get_action_schemes_list( GtkTreeModel* scheme_model, GtkTreePath *path, GtkTreeIter* iter, gpointer data );*/
+static gboolean         get_action_schemes_list( GtkTreeModel* scheme_model, GtkTreePath *path, GtkTreeIter* iter, gpointer data );
 static GSList          *get_schemes_default_list( NactWindow *window );
 static gboolean         reset_schemes_list( GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data );
 static void             set_action_schemes( gchar *scheme, GtkTreeModel *model );
@@ -223,6 +223,19 @@ nact_iadvanced_tab_set_profile( NactWindow *dialog, NAActionProfile *profile )
 	gtk_widget_set_sensitive( GTK_WIDGET( remove ), profile != NULL );
 }
 
+/**
+ * Returns selected schemes as a list of strings.
+ * The caller should call na_utils_free_string_list after use.
+ */
+GSList *
+nact_iadvanced_tab_get_schemes( NactWindow *window )
+{
+	GSList *list = NULL;
+	GtkTreeModel* scheme_model = get_schemes_tree_model( window );
+	gtk_tree_model_foreach( scheme_model, ( GtkTreeModelForeachFunc ) get_action_schemes_list, &list );
+	return( list );
+}
+
 static NAActionProfile *
 v_get_edited_profile( NactWindow *window )
 {
@@ -476,29 +489,32 @@ create_schemes_selection_list( NactWindow *window )
 	gtk_tree_view_append_column( GTK_TREE_VIEW( listview ), column );
 }
 
-/*static gboolean
+/*
+ * CommandExampleLabel is updated each time a field is modified
+ * And at each time, we need the list of selected schemes
+ */
+static gboolean
 get_action_schemes_list( GtkTreeModel* scheme_model, GtkTreePath *path, GtkTreeIter* iter, gpointer data )
 {
-	static const char *thisfn = "nact_iadvanced_tab_get_action_schemes_list";
+	/*static const char *thisfn = "nact_iadvanced_tab_get_action_schemes_list";*/
 
 	GSList** list = data;
 	gboolean toggle_state;
 	gchar* scheme;
 
-	gtk_tree_model_get (scheme_model, iter, SCHEMES_CHECKBOX_COLUMN, &toggle_state, SCHEMES_KEYWORD_COLUMN, &scheme, -1);
+	gtk_tree_model_get( scheme_model, iter, SCHEMES_CHECKBOX_COLUMN, &toggle_state, SCHEMES_KEYWORD_COLUMN, &scheme, -1 );
 
-	if (toggle_state)
-	{
-		g_debug( "%s: adding '%s' scheme", thisfn, scheme );
-		(*list) = g_slist_append ((*list), scheme);
-	}
-	else
-	{
-		g_free (scheme);
+	if( toggle_state ){
+		/*g_debug( "%s: adding '%s' scheme", thisfn, scheme );*/
+		( *list ) = g_slist_append(( *list ), scheme );
+
+	} else {
+		g_free( scheme );
 	}
 
-	return FALSE; *//* Don't stop looping *//*
-}*/
+	 /* don't stop looping */
+	return( FALSE );
+}
 
 static GSList *
 get_schemes_default_list( NactWindow *window )
diff --git a/src/nact/nact-iadvanced-tab.h b/src/nact/nact-iadvanced-tab.h
index d9170d3..7e50656 100644
--- a/src/nact/nact-iadvanced-tab.h
+++ b/src/nact/nact-iadvanced-tab.h
@@ -61,14 +61,15 @@ typedef struct {
 }
 	NactIAdvancedTabInterface;
 
-GType nact_iadvanced_tab_get_type( void );
+GType   nact_iadvanced_tab_get_type( void );
 
-void  nact_iadvanced_tab_initial_load( NactWindow *dialog );
-void  nact_iadvanced_tab_runtime_init( NactWindow *dialog );
-void  nact_iadvanced_tab_all_widgets_showed( NactWindow *dialog );
-void  nact_iadvanced_tab_dispose( NactWindow *dialog );
+void    nact_iadvanced_tab_initial_load( NactWindow *dialog );
+void    nact_iadvanced_tab_runtime_init( NactWindow *dialog );
+void    nact_iadvanced_tab_all_widgets_showed( NactWindow *dialog );
+void    nact_iadvanced_tab_dispose( NactWindow *dialog );
 
-void  nact_iadvanced_tab_set_profile( NactWindow *window, NAActionProfile *profile );
+void    nact_iadvanced_tab_set_profile( NactWindow *window, NAActionProfile *profile );
+GSList *nact_iadvanced_tab_get_schemes( NactWindow *window );
 
 G_END_DECLS
 
diff --git a/src/nact/nact-icommand-tab.c b/src/nact/nact-icommand-tab.c
index 93bb7bb..c62317c 100644
--- a/src/nact/nact-icommand-tab.c
+++ b/src/nact/nact-icommand-tab.c
@@ -422,18 +422,26 @@ update_example_label( NactWindow *window )
 	static const gchar *original_label = N_( "<i><b><span size=\"small\">e.g., %s</span></b></i>" );
 
 	GtkWidget *example_widget = base_window_get_widget( BASE_WINDOW( window ), "CommandExampleLabel" );
+	gchar *newlabel;
 
-	gchar *parameters = parse_parameters( window );
-	/*g_debug( "%s: parameters=%s", thisfn, parameters );*/
+	if( v_get_edited_profile( window )){
 
-	/* convert special xml chars (&, <, >,...) to avoid warnings
-	 * generated by Pango parser
-	 */
-	gchar *new_label = g_markup_printf_escaped( original_label, parameters );
+		gchar *parameters = parse_parameters( window );
+		/*g_debug( "%s: parameters=%s", thisfn, parameters );*/
 
-	gtk_label_set_label( GTK_LABEL( example_widget ), new_label );
-	g_free( new_label );
-	g_free( parameters );
+		/* convert special xml chars (&, <, >,...) to avoid warnings
+		 * generated by Pango parser
+		 */
+		newlabel = g_markup_printf_escaped( original_label, parameters );
+
+		g_free( parameters );
+
+	} else {
+		newlabel = g_strdup( "" );
+	}
+
+	gtk_label_set_label( GTK_LABEL( example_widget ), newlabel );
+	g_free( newlabel );
 }
 
 /*
@@ -583,6 +591,8 @@ parse_parameters( NactWindow *window )
 	}
 	tmp_string = g_string_append_len( tmp_string, old_iter, strlen( old_iter ));
 
+	na_utils_free_string_list( scheme_list );
+
 	g_free( ex_list );
 	g_free( ex_path_list );
 	g_free( iter );
diff --git a/src/nact/nact-iconditions-tab.c b/src/nact/nact-iconditions-tab.c
index 890c422..27a3bd7 100644
--- a/src/nact/nact-iconditions-tab.c
+++ b/src/nact/nact-iconditions-tab.c
@@ -59,7 +59,6 @@ static GtkButton       *get_matchcase_button( NactWindow *window );
 static void             on_mimetypes_changed( GtkEntry *entry, gpointer user_data );
 static GtkWidget       *get_mimetypes_entry( NactWindow *window );
 static void             on_isfiledir_toggled( GtkToggleButton *button, gpointer user_data );
-static void             get_isfiledir( NactWindow *window, gboolean *isfile, gboolean *isdir );
 static void             set_isfiledir( NactWindow *window, gboolean isfile, gboolean isdir );
 static GtkButton       *get_isfile_button( NactWindow *window );
 static GtkButton       *get_isdir_button( NactWindow *window );
@@ -227,6 +226,29 @@ nact_iconditions_tab_set_profile( NactWindow *dialog, NAActionProfile *profile )
 	gtk_widget_set_sensitive( GTK_WIDGET( multiple_button ), profile != NULL );
 }
 
+void
+nact_iconditions_tab_get_isfiledir( NactWindow *window, gboolean *isfile, gboolean *isdir )
+{
+	g_assert( isfile );
+	g_assert( isdir );
+
+	gboolean both = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_both_button( window )));
+	if( both ){
+		*isfile = TRUE;
+		*isdir = TRUE;
+	} else {
+		*isfile = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_isfile_button( window )));
+		*isdir = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_isdir_button( window )));
+	}
+}
+
+gboolean
+nact_iconditions_tab_get_multiple( NactWindow *window )
+{
+	GtkButton *button = get_multiple_button( window );
+	return( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button )));
+}
+
 static NAActionProfile *
 v_get_edited_profile( NactWindow *window )
 {
@@ -332,7 +354,7 @@ on_isfiledir_toggled( GtkToggleButton *button, gpointer user_data )
 	NAActionProfile *edited = NA_ACTION_PROFILE( v_get_edited_profile( dialog ));
 	if( edited ){
 		gboolean isfile, isdir;
-		get_isfiledir( dialog, &isfile, &isdir );
+		nact_iconditions_tab_get_isfiledir( dialog, &isfile, &isdir );
 		na_action_profile_set_isfiledir( edited, isfile, isdir );
 	}
 
@@ -340,22 +362,6 @@ on_isfiledir_toggled( GtkToggleButton *button, gpointer user_data )
 }
 
 static void
-get_isfiledir( NactWindow *window, gboolean *isfile, gboolean *isdir )
-{
-	g_assert( isfile );
-	g_assert( isdir );
-
-	gboolean both = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_both_button( window )));
-	if( both ){
-		*isfile = TRUE;
-		*isdir = TRUE;
-	} else {
-		*isfile = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_isfile_button( window )));
-		*isdir = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( get_isdir_button( window )));
-	}
-}
-
-static void
 set_isfiledir( NactWindow *window, gboolean isfile, gboolean isdir )
 {
 	if( isfile && isdir ){
diff --git a/src/nact/nact-iconditions-tab.h b/src/nact/nact-iconditions-tab.h
index 46de255..91136cb 100644
--- a/src/nact/nact-iconditions-tab.h
+++ b/src/nact/nact-iconditions-tab.h
@@ -61,14 +61,16 @@ typedef struct {
 }
 	NactIConditionsTabInterface;
 
-GType nact_iconditions_tab_get_type( void );
+GType    nact_iconditions_tab_get_type( void );
 
-void  nact_iconditions_tab_initial_load( NactWindow *dialog );
-void  nact_iconditions_tab_runtime_init( NactWindow *dialog );
-void  nact_iconditions_tab_all_widgets_showed( NactWindow *dialog );
-void  nact_iconditions_tab_dispose( NactWindow *dialog );
+void     nact_iconditions_tab_initial_load( NactWindow *dialog );
+void     nact_iconditions_tab_runtime_init( NactWindow *dialog );
+void     nact_iconditions_tab_all_widgets_showed( NactWindow *dialog );
+void     nact_iconditions_tab_dispose( NactWindow *dialog );
 
-void  nact_iconditions_tab_set_profile( NactWindow *window, NAActionProfile *profile );
+void     nact_iconditions_tab_set_profile( NactWindow *window, NAActionProfile *profile );
+void     nact_iconditions_tab_get_isfiledir( NactWindow *window, gboolean *isfile, gboolean *isdir );
+gboolean nact_iconditions_tab_get_multiple( NactWindow *window );
 
 G_END_DECLS
 
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 6f21817..b9a30d5 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -42,8 +42,6 @@
 #include <common/na-ipivot-container.h>
 
 #include "nact-application.h"
-#include "nact-action-conditions-editor.h"
-#include "nact-action-profiles-editor.h"
 #include "nact-assist-export.h"
 #include "nact-assist-import.h"
 #include "nact-iactions-list.h"
@@ -800,19 +798,19 @@ is_action_to_save( const NAAction *action )
 static void
 get_isfiledir( NactWindow *window, gboolean *isfile, gboolean *isdir )
 {
-
+	nact_iconditions_tab_get_isfiledir( window, isfile, isdir );
 }
 
 static gboolean
 get_multiple( NactWindow *window )
 {
-	return( FALSE );
+	return( nact_iconditions_tab_get_multiple( window ));
 }
 
 static GSList *
 get_schemes( NactWindow *window )
 {
-	return( NULL );
+	return( nact_iadvanced_tab_get_schemes( window ));
 }
 
 static void
diff --git a/src/nact/nautilus-actions-config.ui b/src/nact/nautilus-actions-config.ui
index 9a06018..8f5175b 100644
--- a/src/nact/nautilus-actions-config.ui
+++ b/src/nact/nautilus-actions-config.ui
@@ -315,7 +315,7 @@
                                 <child>
                                   <object class="GtkTable" id="table2">
                                     <property name="visible">True</property>
-                                    <property name="n_rows">3</property>
+                                    <property name="n_rows">2</property>
                                     <property name="n_columns">3</property>
                                     <property name="column_spacing">6</property>
                                     <property name="row_spacing">6</property>
@@ -398,6 +398,24 @@
                                         <property name="y_options"></property>
                                       </packing>
                                     </child>
+                                  </object>
+                                  <packing>
+                                    <property name="fill">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkHBox" id="hbox1">
+                                    <property name="visible">True</property>
+                                    <child>
+                                      <object class="GtkLabel" id="CommandExamplePreLabel">
+                                        <property name="visible">True</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
                                     <child>
                                       <object class="GtkLabel" id="CommandExampleLabel">
                                         <property name="visible">True</property>
@@ -406,22 +424,12 @@
                                         <property name="wrap">True</property>
                                       </object>
                                       <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="position">1</property>
                                       </packing>
                                     </child>
-                                    <child>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
-                                      <placeholder/>
-                                    </child>
                                   </object>
                                   <packing>
-                                    <property name="fill">False</property>
-                                    <property name="position">1</property>
+                                    <property name="position">2</property>
                                   </packing>
                                 </child>
                               </object>
@@ -680,100 +688,84 @@
                         <property name="border_width">6</property>
                         <property name="orientation">vertical</property>
                         <child>
-                          <object class="GtkVBox" id="vbox15">
+                          <object class="GtkVBox" id="vbox340">
                             <property name="visible">True</property>
+                            <property name="border_width">12</property>
                             <property name="orientation">vertical</property>
                             <property name="spacing">10</property>
                             <child>
-                              <object class="GtkLabel" id="label20">
+                              <object class="GtkLabel" id="label46">
                                 <property name="visible">True</property>
                                 <property name="xalign">0</property>
                                 <property name="label" translatable="yes">&lt;b&gt;Appears if scheme is in this list&lt;/b&gt;</property>
                                 <property name="use_markup">True</property>
                               </object>
                               <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
                                 <property name="position">0</property>
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkVBox" id="vbox2">
+                              <object class="GtkHBox" id="hbox38">
                                 <property name="visible">True</property>
-                                <property name="orientation">vertical</property>
+                                <property name="spacing">6</property>
                                 <child>
-                                  <object class="GtkHBox" id="hbox5">
+                                  <object class="GtkScrolledWindow" id="scrolledwindow4">
                                     <property name="visible">True</property>
+                                    <property name="can_focus">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="SchemesTreeView">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="headers_visible">False</property>
+                                        <property name="rules_hint">True</property>
+                                      </object>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkVBox" id="vbox345">
+                                    <property name="visible">True</property>
+                                    <property name="orientation">vertical</property>
                                     <property name="spacing">6</property>
                                     <child>
-                                      <object class="GtkScrolledWindow" id="scrolledwindow2">
+                                      <object class="GtkButton" id="AddSchemeButton">
                                         <property name="visible">True</property>
                                         <property name="can_focus">True</property>
-                                        <property name="hscrollbar_policy">automatic</property>
-                                        <property name="vscrollbar_policy">automatic</property>
+                                        <property name="receives_default">True</property>
                                         <child>
-                                          <object class="GtkScrolledWindow" id="scrolledwindow4">
+                                          <object class="GtkImage" id="image16">
                                             <property name="visible">True</property>
-                                            <property name="can_focus">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="SchemesTreeView">
-                                                <property name="visible">True</property>
-                                                <property name="can_focus">True</property>
-                                                <property name="headers_visible">False</property>
-                                                <property name="rules_hint">True</property>
-                                              </object>
-                                            </child>
+                                            <property name="stock">gtk-add</property>
+                                            <property name="icon-size">4</property>
                                           </object>
                                         </child>
                                       </object>
                                       <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
                                         <property name="position">0</property>
                                       </packing>
                                     </child>
                                     <child>
-                                      <object class="GtkVButtonBox" id="vbuttonbox1">
+                                      <object class="GtkButton" id="RemoveSchemeButton">
                                         <property name="visible">True</property>
-                                        <property name="spacing">6</property>
-                                        <property name="layout_style">start</property>
-                                        <child>
-                                          <object class="GtkButton" id="AddSchemeButton">
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="receives_default">True</property>
-                                            <child>
-                                              <object class="GtkImage" id="image16">
-                                                <property name="visible">True</property>
-                                                <property name="stock">gtk-add</property>
-                                                <property name="icon-size">4</property>
-                                              </object>
-                                            </child>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                            <property name="fill">False</property>
-                                            <property name="position">0</property>
-                                          </packing>
-                                        </child>
+                                        <property name="sensitive">False</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="receives_default">True</property>
                                         <child>
-                                          <object class="GtkButton" id="RemoveSchemeButton">
+                                          <object class="GtkImage" id="image17">
                                             <property name="visible">True</property>
-                                            <property name="sensitive">False</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="receives_default">True</property>
-                                            <child>
-                                              <object class="GtkImage" id="image17">
-                                                <property name="visible">True</property>
-                                                <property name="stock">gtk-remove</property>
-                                                <property name="icon-size">4</property>
-                                              </object>
-                                            </child>
+                                            <property name="stock">gtk-remove</property>
+                                            <property name="icon-size">4</property>
                                           </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                            <property name="fill">False</property>
-                                            <property name="position">1</property>
-                                          </packing>
                                         </child>
                                       </object>
                                       <packing>
@@ -785,7 +777,8 @@
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
-                                    <property name="position">0</property>
+                                    <property name="fill">False</property>
+                                    <property name="position">1</property>
                                   </packing>
                                 </child>
                               </object>
@@ -795,8 +788,6 @@
                             </child>
                           </object>
                           <packing>
-                            <property name="expand">False</property>
-                            <property name="padding">10</property>
                             <property name="position">0</property>
                           </packing>
                         </child>
@@ -1204,6 +1195,7 @@ file(s)/folder(s)</property>
       <widget name="ProfileLabelLabel"/>
       <widget name="CommandPathLabel"/>
       <widget name="CommandParametersLabel"/>
+      <widget name="CommandExamplePreLabel"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup" id="CommandButtonSizeGroup">



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