[nautilus-actions] Adding NAFO_DATA_SELECTION_COUNT elementary data



commit 7ff2ca45b72e617715a6863e0b585f2a8646d66b
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Apr 14 01:32:29 2010 +0200

    Adding NAFO_DATA_SELECTION_COUNT elementary data

 ChangeLog                                |   15 ++++-
 NEWS                                     |    2 +
 TODO                                     |    9 +++-
 po/POTFILES.in                           |    1 +
 src/api/na-ifactory-object-data.h        |    1 +
 src/core/na-icontext-factory.c           |   39 +++++++++++--
 src/nact/nact-iconditions-tab.c          |   78 +++++++++++++++++++++++++++
 src/nact/nautilus-actions-config-tool.ui |   86 +++++++++++++++++++++++++-----
 8 files changed, 208 insertions(+), 23 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a6ff03a..3224e12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -78,10 +78,19 @@
 	* src/plugin-tracker/na-tracker-dbus.c
 	(na_tracker_dbus_get_selected_paths): Also sends the mimetype.
 
-	* src/utils/nautilus-actions-run.c (targets_from_selection):
-	Get the mimetype from DBus interface.
+2009-04-13 Pierre Wieser <pwieser trychlos org>
 
-2010-04-12 Pierre Wieser <pwieser trychlos org>
+	* po/POTFILES.in: Adding src/nact/nact-iconditions-tab.c file.
+
+	* src/api/na-ifactory-object-data.h:
+	* src/core/na-icontext-factory.c:
+	Adding NAFO_DATA_SELECTION_COUNT data, obsoleting NAFO_DATA_MULTIPLE.
+
+	* src/nact/nact-iconditions-tab.c:
+	* src/nact/nautilus-actions-config-tool.ui:
+	Adding required entries for SelectionCount data.
+
+2009-04-12 Pierre Wieser <pwieser trychlos org>
 
 	* src/plugin-menu/Makefile.am:
 	* src/plugin-tracker/Makefile.am: Fix incorrect log domains.
diff --git a/NEWS b/NEWS
index 4803416..bbc6e35 100644
--- a/NEWS
+++ b/NEWS
@@ -65,6 +65,8 @@ Version 2.30.2
 		- Implement new properties, both in GConf and .desktop files:
 		  . a description of the item
 
+		- The 'accept multiple files' flag is replaced with a count selector
+
 	UI modifications:
 
 		- Item properties have now their own 'Properties' tab
diff --git a/TODO b/TODO
index f22c4ed..28337ca 100644
--- a/TODO
+++ b/TODO
@@ -102,12 +102,19 @@
 	ExecuteAs
 	OnlyShowIn
 	NotShowIn
-	Hidden
 	TryExec
 	ShowIfRegistered
 	ShowIfTrue
 	ShowIfRunning
 	SelectionCount
+
+	existing: [x] boolean: accept multiple
+		we so only test if selection is unique or not
+
+	next: a string 
+		accept-multiple = FALSE -> '=1'
+		accept-multiple = TRUE  -> '>0'
+
 	Capabilities
 
 - profile path and parameters should be set together as only one variable ?
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 26a7e50..5da5653 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -30,6 +30,7 @@ src/nact/nact-export-ask.c
 src/nact/nact-export-format.c
 src/nact/nact-iaction-tab.c
 src/nact/nact-icommand-tab.c
+src/nact/nact-iconditions-tab.c
 src/nact/nact-ifolders-tab.c
 src/nact/nact-iproperties-tab.c
 src/nact/nact-main-menubar.c
diff --git a/src/api/na-ifactory-object-data.h b/src/api/na-ifactory-object-data.h
index 94aeb97..e279be0 100644
--- a/src/api/na-ifactory-object-data.h
+++ b/src/api/na-ifactory-object-data.h
@@ -86,6 +86,7 @@ G_BEGIN_DECLS
 #define NAFO_DATA_MULTIPLE					"na-factory-data-multiple"
 #define NAFO_DATA_SCHEMES					"na-factory-data-schemes"
 #define NAFO_DATA_FOLDERS					"na-factory-data-folders"
+#define NAFO_DATA_SELECTION_COUNT			"na-factory-data-selection-count"
 
 G_END_DECLS
 
diff --git a/src/core/na-icontext-factory.c b/src/core/na-icontext-factory.c
index dd90793..f06cf07 100644
--- a/src/core/na-icontext-factory.c
+++ b/src/core/na-icontext-factory.c
@@ -179,10 +179,13 @@ NADataDef data_def_conditions [] = {
 				NULL,
 				NULL },
 
+	/* this is obsoleted starting with 2.30-newdata (released as 2.31.x serie)
+	 * and replaced by count-sign and count-number
+	 */
 	{ NAFO_DATA_MULTIPLE,
 				TRUE,
-				TRUE,
-				TRUE,
+				FALSE,
+				FALSE,
 				N_( "Whether the selection may be multiple" ),
 				N_( "If you need more than one files or folders to be selected, set this " \
 					"key to 'true'. If you want just one file or folder, set it to 'false'.\n" \
@@ -190,14 +193,14 @@ NADataDef data_def_conditions [] = {
 					"Defaults to 'false'." ),
 				NAFD_TYPE_BOOLEAN,
 				"false",
-				TRUE,
-				TRUE,
+				FALSE,
+				FALSE,
 				FALSE,
 				FALSE,
 				"accept-multiple-files",
 				NULL,
-				'u',
-				"accept-multiple",
+				0,
+				NULL,
 				0,
 				G_OPTION_ARG_NONE,
 				NULL,
@@ -265,5 +268,29 @@ NADataDef data_def_conditions [] = {
 					"You must set one option for each folder you need" ),
 				N_( "<PATH>" ) },
 
+	{ NAFO_DATA_SELECTION_COUNT,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Operator of the selection count relation" ),
+				N_( "Whether this profile may be selected depending of the count of the selection.\n" \
+					"This is a string of the form \"{'<'|'='|'>'} number\".\n" \
+					"Examples of valid strings are: \"=0\", \"> 1\", \"< 10\".\n" \
+					"Defaults to \">0\"." ),
+				NAFD_TYPE_STRING,
+				">0",
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"selection-count",
+				"SelectionCount",
+				0,
+				NULL,
+				0,
+				G_OPTION_ARG_NONE,
+				NULL,
+				NULL },
+
 	{ NULL },
 };
diff --git a/src/nact/nact-iconditions-tab.c b/src/nact/nact-iconditions-tab.c
index 4efca56..6e26c54 100644
--- a/src/nact/nact-iconditions-tab.c
+++ b/src/nact/nact-iconditions-tab.c
@@ -32,6 +32,7 @@
 #include <config.h>
 #endif
 
+#include <glib/gi18n.h>
 #include <string.h>
 
 #include <api/na-core-utils.h>
@@ -49,6 +50,28 @@ struct NactIConditionsTabInterfacePrivate {
 	void *empty;						/* so that gcc -pedantic is happy */
 };
 
+/* columns in the selection count combobox
+ */
+enum {
+	COUNT_SIGN_COLUMN = 0,
+	COUNT_LABEL_COLUMN,
+	COUNT_N_COLUMN
+};
+
+typedef struct {
+	gchar *sign;
+	gchar *label;
+}
+	SelectionCountStruct;
+
+/* i18n notes: selection count symbol, respectively 'less than', 'equal to' and 'greater than' */
+static SelectionCountStruct st_counts[] = {
+		{ N_( "<" ), N_( "(strictly lesser than)" ) },
+		{ N_( "=" ), N_( "(equal to)" ) },
+		{ N_( ">" ), N_( "(strictly greater than)" ) },
+		{ NULL }
+};
+
 static gboolean st_initialized = FALSE;
 static gboolean st_finalized = FALSE;
 static gboolean st_on_selection_change = FALSE;
@@ -72,7 +95,11 @@ static void       on_basenames_changed( GtkEntry *entry, NactIConditionsTab *ins
 static void       on_isfiledir_toggled( GtkToggleButton *button, NactIConditionsTab *instance );
 static void       on_matchcase_toggled( GtkToggleButton *button, NactIConditionsTab *instance );
 static void       on_mimetypes_changed( GtkEntry *entry, NactIConditionsTab *instance );
+
 static void       on_multiple_toggled( GtkToggleButton *button, NactIConditionsTab *instance );
+static void       init_count_combobox( NactIConditionsTab *instance );
+static void       dispose_count_combobox( NactIConditionsTab *instance );
+
 static void       set_isfiledir( NactIConditionsTab *instance, gboolean isfile, gboolean isdir, gboolean readonly );
 
 GType
@@ -153,6 +180,8 @@ nact_iconditions_tab_initial_load_toplevel( NactIConditionsTab *instance )
 	g_return_if_fail( NACT_IS_ICONDITIONS_TAB( instance ));
 
 	if( st_initialized && !st_finalized ){
+
+		init_count_combobox( instance );
 	}
 }
 
@@ -255,6 +284,8 @@ nact_iconditions_tab_dispose( NactIConditionsTab *instance )
 	g_return_if_fail( NACT_IS_ICONDITIONS_TAB( instance ));
 
 	if( st_initialized && !st_finalized ){
+
+		dispose_count_combobox( instance );
 	}
 }
 
@@ -591,6 +622,53 @@ on_multiple_toggled( GtkToggleButton *button, NactIConditionsTab *instance )
 }
 
 static void
+init_count_combobox( NactIConditionsTab *instance )
+{
+	GtkTreeModel *model;
+	guint i;
+	GtkTreeIter row;
+	GtkComboBox *combo;
+	GtkCellRenderer *cell_renderer_text;
+
+	model = GTK_TREE_MODEL( gtk_list_store_new( COUNT_N_COLUMN, G_TYPE_STRING, G_TYPE_STRING ));
+	i = 0;
+	while( st_counts[i].sign ){
+		gtk_list_store_append( GTK_LIST_STORE( model ), &row );
+		gtk_list_store_set( GTK_LIST_STORE( model ), &row, COUNT_SIGN_COLUMN, st_counts[i].sign, -1 );
+		gtk_list_store_set( GTK_LIST_STORE( model ), &row, COUNT_LABEL_COLUMN, st_counts[i].label, -1 );
+		i += 1;
+	}
+
+	combo = GTK_COMBO_BOX( base_window_get_widget( BASE_WINDOW( instance ), "ConditionsCountSigneCombobox" ));
+	gtk_combo_box_set_model( combo, model );
+	g_object_unref( model );
+
+	gtk_cell_layout_clear( GTK_CELL_LAYOUT( combo ));
+
+	cell_renderer_text = gtk_cell_renderer_text_new();
+	gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( combo ), cell_renderer_text, FALSE );
+	gtk_cell_layout_add_attribute( GTK_CELL_LAYOUT( combo ), cell_renderer_text, "text", COUNT_SIGN_COLUMN );
+
+	cell_renderer_text = gtk_cell_renderer_text_new();
+	gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( combo ), cell_renderer_text, TRUE );
+	g_object_set( G_OBJECT( cell_renderer_text ), "xalign", ( gdouble ) 0.0, "style", PANGO_STYLE_ITALIC, "style-set", TRUE, NULL );
+	gtk_cell_layout_add_attribute( GTK_CELL_LAYOUT( combo ), cell_renderer_text, "text", COUNT_LABEL_COLUMN );
+
+	gtk_combo_box_set_active( GTK_COMBO_BOX( combo ), 0 );
+}
+
+static void
+dispose_count_combobox( NactIConditionsTab *instance )
+{
+	GtkComboBox *combo;
+	GtkTreeModel *model;
+
+	combo = GTK_COMBO_BOX( base_window_get_widget( BASE_WINDOW( instance ), "ConditionsCountSigneCombobox" ));
+	model = gtk_combo_box_get_model( combo );
+	gtk_list_store_clear( GTK_LIST_STORE( model ));
+}
+
+static void
 set_isfiledir( NactIConditionsTab *instance, gboolean isfile, gboolean isdir, gboolean readonly )
 {
 	GtkButton *both_button;
diff --git a/src/nact/nautilus-actions-config-tool.ui b/src/nact/nautilus-actions-config-tool.ui
index 06d70f6..5cad068 100644
--- a/src/nact/nautilus-actions-config-tool.ui
+++ b/src/nact/nautilus-actions-config-tool.ui
@@ -1038,6 +1038,56 @@ Defining several profiles lets you have several commands, each applying with a d
                                         <property name="position">1</property>
                                       </packing>
                                     </child>
+                                    <child>
+                                      <object class="GtkHBox" id="hbox10">
+                                        <property name="visible">True</property>
+                                        <property name="tooltip_text" translatable="yes">Item will appear in Nautilus context menu if the count of the selection satisfies this relation.</property>
+                                        <property name="spacing">6</property>
+                                        <child>
+                                          <object class="GtkLabel" id="label17">
+                                            <property name="visible">True</property>
+                                            <property name="xalign">1</property>
+                                            <property name="label" translatable="yes">_Count :</property>
+                                            <property name="use_underline">True</property>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkHBox" id="hbox12">
+                                            <property name="visible">True</property>
+                                            <child>
+                                              <object class="GtkComboBox" id="ConditionsCountSigneCombobox">
+                                                <property name="visible">True</property>
+                                              </object>
+                                              <packing>
+                                                <property name="expand">False</property>
+                                                <property name="position">0</property>
+                                              </packing>
+                                            </child>
+                                            <child>
+                                              <object class="GtkEntry" id="ConditionsCountNumberEntry">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">True</property>
+                                                <property name="invisible_char">&#x25CF;</property>
+                                              </object>
+                                              <packing>
+                                                <property name="expand">False</property>
+                                                <property name="position">1</property>
+                                              </packing>
+                                            </child>
+                                          </object>
+                                          <packing>
+                                            <property name="position">1</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                      <packing>
+                                        <property name="position">2</property>
+                                      </packing>
+                                    </child>
                                   </object>
                                 </child>
                               </object>
@@ -1326,12 +1376,6 @@ Defining several profiles lets you have several commands, each applying with a d
                                       </packing>
                                     </child>
                                     <child>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
                                       <object class="GtkCheckButton" id="ActionReadonlyButton">
                                         <property name="label" translatable="yes">Read-only</property>
                                         <property name="visible">True</property>
@@ -1347,6 +1391,12 @@ Defining several profiles lets you have several commands, each applying with a d
                                         <property name="bottom_attach">3</property>
                                       </packing>
                                     </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
                                   </object>
                                 </child>
                               </object>
@@ -1494,6 +1544,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>
@@ -2306,24 +2359,31 @@ Be warned: this mode may be dangerous. You will not be prompted another time.</p
   </object>
   <object class="GtkSizeGroup" id="CommandLabelSizeGroup">
     <widgets>
-      <widget name="CommandParametersLabel"/>
-      <widget name="CommandPathLabel"/>
       <widget name="ProfileLabelLabel"/>
+      <widget name="CommandPathLabel"/>
+      <widget name="CommandParametersLabel"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup" id="CommandButtonSizeGroup">
     <widgets>
-      <widget name="CommandLegendButton"/>
       <widget name="CommandPathButton"/>
+      <widget name="CommandLegendButton"/>
     </widgets>
   </object>
   <object class="GtkSizeGroup" id="ActionLabelSizeGroup">
     <widgets>
-      <widget name="ActionIconLabel"/>
-      <widget name="ActionTooltipLabel"/>
-      <widget name="ActionIdLabel"/>
-      <widget name="ActionMenuLabelLabel"/>
       <widget name="ActionToolbarLabelLabel"/>
+      <widget name="ActionMenuLabelLabel"/>
+      <widget name="ActionIdLabel"/>
+      <widget name="ActionTooltipLabel"/>
+      <widget name="ActionIconLabel"/>
+    </widgets>
+  </object>
+  <object class="GtkSizeGroup" id="ConditionsLabelSizeGroup">
+    <widgets>
+      <widget name="label17"/>
+      <widget name="ConditionsMimetypesLabel"/>
+      <widget name="ConditionsFilenamesLabel"/>
     </widgets>
   </object>
 </interface>



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