[nautilus-actions: 10/45] Define IConditionsTab and IAdvancedTab interfaces
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions: 10/45] Define IConditionsTab and IAdvancedTab interfaces
- Date: Wed, 29 Jul 2009 21:18:36 +0000 (UTC)
commit 760dd39035c25879c499e3c4e6d56f1c1d879b23
Author: Pierre Wieser <pwieser trychlos org>
Date: Sun Jul 19 00:25:58 2009 +0200
Define IConditionsTab and IAdvancedTab interfaces
ChangeLog | 9 +
src/nact/Makefile.am | 4 +
src/nact/nact-iactions-list.c | 1 +
src/nact/nact-iadvanced-tab.c | 574 ++++++++++++++++++
src/nact/nact-iadvanced-tab.h | 75 +++
src/nact/nact-icommand-tab.c | 120 ++--
src/nact/nact-icommand-tab.h | 2 -
src/nact/nact-iconditions-tab.c | 409 +++++++++++++
src/nact/nact-iconditions-tab.h | 75 +++
src/nact/nact-iconditions.c | 1134 -----------------------------------
src/nact/nact-iconditions.h | 79 ---
src/nact/nact-main-window.c | 138 ++++-
src/nact/nautilus-actions-config.ui | 108 ++--
13 files changed, 1397 insertions(+), 1331 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 813b649..2a4ed20 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,11 +13,20 @@
New virtual function: advertise the implementer of the interface
of the new address of the sorted list.
Use GtkTreeModelFilter to display actions and profiles.
+ Enable connecting lines in tree view.
* src/nact/nact-icommand-tab.c:
* src/nact/nact-icommand-tab.h:
New files which define NactICommandTab interface.
+ * src/nact/nact-iconditions-tab.c:
+ * src/nact/nact-iconditions-tab.h:
+ New files which define NactIConditionsTab interface.
+
+ * src/nact/nact-iadvanced-tab.c:
+ * src/nact/nact-iadvanced-tab.h:
+ New files which define NactIAdvancedTab interface.
+
* src/nact/nact-iprofile-item.c:
* src/nact/nact-iprofile-item.h:
* src/nact/nact-iprofiles-list.c:
diff --git a/src/nact/Makefile.am b/src/nact/Makefile.am
index 97b5abc..ae442d6 100644
--- a/src/nact/Makefile.am
+++ b/src/nact/Makefile.am
@@ -61,8 +61,12 @@ nautilus_actions_config_SOURCES = \
nact-iaction-tab.h \
nact-iactions-list.c \
nact-iactions-list.h \
+ nact-iadvanced-tab.c \
+ nact-iadvanced-tab.h \
nact-icommand-tab.c \
nact-icommand-tab.h \
+ nact-iconditions-tab.c \
+ nact-iconditions-tab.h \
nact-iprefs.c \
nact-iprefs.h \
nact-main.c \
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index cdfa9ed..0c68d5f 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -167,6 +167,7 @@ nact_iactions_list_initial_load( NactWindow *window )
GTK_TREE_MODEL_FILTER( tmf_model ), ( GtkTreeModelFilterVisibleFunc ) filter_visible, window, NULL );
gtk_tree_view_set_model( GTK_TREE_VIEW( widget ), tmf_model );
+ gtk_tree_view_set_enable_tree_lines( GTK_TREE_VIEW( widget ), TRUE );
/*g_object_unref( tmf_model );*/
g_object_unref( ts_model );
diff --git a/src/nact/nact-iadvanced-tab.c b/src/nact/nact-iadvanced-tab.c
new file mode 100644
index 0000000..cd294f2
--- /dev/null
+++ b/src/nact/nact-iadvanced-tab.c
@@ -0,0 +1,574 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
+ *
+ * This Program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib/gi18n.h>
+#include <string.h>
+
+#include <common/na-utils.h>
+
+#include "nact-iadvanced-tab.h"
+#include "nact-iprefs.h"
+
+/* private interface data
+ */
+struct NactIAdvancedTabInterfacePrivate {
+};
+
+/* column ordering
+ */
+enum {
+ SCHEMES_CHECKBOX_COLUMN = 0,
+ SCHEMES_KEYWORD_COLUMN,
+ SCHEMES_DESC_COLUMN,
+ SCHEMES_N_COLUMN
+};
+
+static GType register_type( void );
+static void interface_base_init( NactIAdvancedTabInterface *klass );
+static void interface_base_finalize( NactIAdvancedTabInterface *klass );
+
+static NAActionProfile *v_get_edited_profile( NactWindow *window );
+static void v_field_modified( NactWindow *window );
+
+static void on_scheme_selection_toggled( GtkCellRendererToggle *renderer, gchar *path, gpointer user_data );
+static void on_scheme_keyword_edited( GtkCellRendererText *renderer, const gchar *path, const gchar *text, gpointer user_data );
+static void on_scheme_desc_edited( GtkCellRendererText *renderer, const gchar *path, const gchar *text, gpointer user_data );
+static void on_scheme_list_selection_changed( GtkTreeSelection *selection, gpointer user_data );
+static void on_add_scheme_clicked( GtkButton *button, gpointer user_data );
+static void on_remove_scheme_clicked( GtkButton *button, gpointer user_data );
+static void scheme_cell_edited( NactWindow *window, const gchar *path_string, const gchar *text, gint column, gboolean *state, gchar **old_text );
+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 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 );
+static GtkButton *get_add_button( NactWindow *window );
+static GtkButton *get_remove_button( NactWindow *window );
+
+GType
+nact_iadvanced_tab_get_type( void )
+{
+ static GType iface_type = 0;
+
+ if( !iface_type ){
+ iface_type = register_type();
+ }
+
+ return( iface_type );
+}
+
+static GType
+register_type( void )
+{
+ static const gchar *thisfn = "nact_iadvanced_tab_register_type";
+ g_debug( "%s", thisfn );
+
+ static const GTypeInfo info = {
+ sizeof( NactIAdvancedTabInterface ),
+ ( GBaseInitFunc ) interface_base_init,
+ ( GBaseFinalizeFunc ) interface_base_finalize,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ 0,
+ NULL
+ };
+
+ GType type = g_type_register_static( G_TYPE_INTERFACE, "NactIAdvancedTab", &info, 0 );
+
+ g_type_interface_add_prerequisite( type, G_TYPE_OBJECT );
+
+ return( type );
+}
+
+static void
+interface_base_init( NactIAdvancedTabInterface *klass )
+{
+ static const gchar *thisfn = "nact_iadvanced_tab_interface_base_init";
+ static gboolean initialized = FALSE;
+
+ if( !initialized ){
+ g_debug( "%s: klass=%p", thisfn, klass );
+
+ klass->private = g_new0( NactIAdvancedTabInterfacePrivate, 1 );
+
+ klass->get_edited_profile = NULL;
+ klass->field_modified = NULL;
+
+ initialized = TRUE;
+ }
+}
+
+static void
+interface_base_finalize( NactIAdvancedTabInterface *klass )
+{
+ static const gchar *thisfn = "nact_iadvanced_tab_interface_base_finalize";
+ static gboolean finalized = FALSE ;
+
+ if( !finalized ){
+ g_debug( "%s: klass=%p", thisfn, klass );
+
+ g_free( klass->private );
+
+ finalized = TRUE;
+ }
+}
+
+void
+nact_iadvanced_tab_initial_load( NactWindow *dialog )
+{
+ static const gchar *thisfn = "nact_iadvanced_tab_initial_load";
+ g_debug( "%s: dialog=%p", thisfn, dialog );
+
+ create_schemes_selection_list( dialog );
+}
+
+void
+nact_iadvanced_tab_runtime_init( NactWindow *dialog )
+{
+ static const gchar *thisfn = "nact_iadvanced_tab_runtime_init";
+ g_debug( "%s: dialog=%p", thisfn, dialog );
+
+ GtkTreeView *scheme_widget = get_schemes_tree_view( dialog );
+
+ GtkTreeViewColumn *column = gtk_tree_view_get_column( scheme_widget, SCHEMES_CHECKBOX_COLUMN );
+ GList *renderers = gtk_tree_view_column_get_cell_renderers( column );
+ nact_window_signal_connect( dialog, G_OBJECT( renderers->data ), "toggled", G_CALLBACK( on_scheme_selection_toggled ));
+
+ column = gtk_tree_view_get_column( scheme_widget, SCHEMES_KEYWORD_COLUMN );
+ renderers = gtk_tree_view_column_get_cell_renderers( column );
+ nact_window_signal_connect( dialog, G_OBJECT( renderers->data ), "edited", G_CALLBACK( on_scheme_keyword_edited ));
+
+ column = gtk_tree_view_get_column( scheme_widget, SCHEMES_DESC_COLUMN );
+ renderers = gtk_tree_view_column_get_cell_renderers( column );
+ nact_window_signal_connect( dialog, G_OBJECT( renderers->data ), "edited", G_CALLBACK( on_scheme_desc_edited ));
+
+ GtkButton *button = get_add_button( dialog );
+ nact_window_signal_connect( dialog, G_OBJECT( button ), "clicked", G_CALLBACK( on_add_scheme_clicked ));
+ GtkButton *remove_button = get_remove_button( dialog );
+ nact_window_signal_connect( dialog, G_OBJECT( remove_button ), "clicked", G_CALLBACK( on_remove_scheme_clicked ));
+
+ nact_window_signal_connect( dialog, G_OBJECT( gtk_tree_view_get_selection( scheme_widget )), "changed", G_CALLBACK( on_scheme_list_selection_changed ));
+}
+
+void
+nact_iadvanced_tab_all_widgets_showed( NactWindow *dialog )
+{
+ static const gchar *thisfn = "nact_iadvanced_tab_all_widgets_showed";
+ g_debug( "%s: dialog=%p", thisfn, dialog );
+}
+
+void
+nact_iadvanced_tab_dispose( NactWindow *dialog )
+{
+ static const gchar *thisfn = "nact_iadvanced_tab_dispose";
+ g_debug( "%s: dialog=%p", thisfn, dialog );
+}
+
+void
+nact_iadvanced_tab_set_profile( NactWindow *dialog, NAActionProfile *profile )
+{
+ static const gchar *thisfn = "nact_iadvanced_tab_runtime_init";
+ g_debug( "%s: dialog=%p, profile=%p", thisfn, dialog, profile );
+
+ GtkTreeModel *scheme_model = get_schemes_tree_model( dialog );
+ gtk_tree_model_foreach( scheme_model, ( GtkTreeModelForeachFunc ) reset_schemes_list, NULL );
+
+ if( profile ){
+ GSList *schemes = na_action_profile_get_schemes( profile );
+ g_slist_foreach( schemes, ( GFunc ) set_action_schemes, scheme_model );
+ }
+
+ GtkTreeView *scheme_widget = get_schemes_tree_view( dialog );
+ gtk_widget_set_sensitive( GTK_WIDGET( scheme_widget ), profile != NULL );
+
+ GtkButton *add = get_add_button( dialog );
+ gtk_widget_set_sensitive( GTK_WIDGET( add ), profile != NULL );
+
+ GtkButton *remove = get_remove_button( dialog );
+ gtk_widget_set_sensitive( GTK_WIDGET( remove ), profile != NULL );
+}
+
+static NAActionProfile *
+v_get_edited_profile( NactWindow *window )
+{
+ g_assert( NACT_IS_IADVANCED_TAB( window ));
+
+ if( NACT_IADVANCED_TAB_GET_INTERFACE( window )->get_edited_profile ){
+ return( NACT_IADVANCED_TAB_GET_INTERFACE( window )->get_edited_profile( window ));
+ }
+
+ return( NULL );
+}
+
+static void
+v_field_modified( NactWindow *window )
+{
+ g_assert( NACT_IS_IADVANCED_TAB( window ));
+
+ if( NACT_IADVANCED_TAB_GET_INTERFACE( window )->field_modified ){
+ NACT_IADVANCED_TAB_GET_INTERFACE( window )->field_modified( window );
+ }
+}
+
+static void
+on_scheme_selection_toggled( GtkCellRendererToggle *renderer, gchar *path, gpointer user_data )
+{
+ /*static const gchar *thisfn = "nact_iadvanced_tab_on_scheme_selection_toggled";*/
+ /*g_debug( "%s: renderer=%p, path=%s, user_data=%p", thisfn, renderer, path, user_data );*/
+ g_assert( NACT_IS_WINDOW( user_data ));
+ NactWindow *dialog = NACT_WINDOW( user_data );
+
+ NAActionProfile *edited = NA_ACTION_PROFILE( v_get_edited_profile( dialog ));
+ if( edited ){
+ GtkTreeModel *model = get_schemes_tree_model( dialog );
+ GtkTreeIter iter;
+
+ GtkTreePath *tree_path = gtk_tree_path_new_from_string( path );
+ gtk_tree_model_get_iter( model, &iter, tree_path );
+ gtk_tree_path_free( tree_path );
+
+ gboolean state;
+ gchar *scheme;
+ gtk_tree_model_get( model, &iter, SCHEMES_CHECKBOX_COLUMN, &state, SCHEMES_KEYWORD_COLUMN, &scheme, -1 );
+
+ /* gtk_tree_model_get: returns the previous state
+ g_debug( "%s: gtk_tree_model_get returns keyword=%s state=%s", thisfn, scheme, state ? "True":"False" );*/
+
+ gtk_list_store_set( GTK_LIST_STORE( model ), &iter, SCHEMES_CHECKBOX_COLUMN, !state, -1 );
+
+ na_action_profile_set_scheme( edited, scheme, !state );
+
+ g_free( scheme );
+ }
+
+ v_field_modified( dialog );
+}
+
+static void
+on_scheme_keyword_edited( GtkCellRendererText *renderer, const gchar *path, const gchar *text, gpointer user_data )
+{
+ /*static const gchar *thisfn = "nact_iadvanced_tab_on_scheme_keyword_edited";*/
+ /*g_debug( "%s: renderer=%p, path=%s, text=%s, user_data=%p", thisfn, renderer, path, text, user_data );*/
+
+ g_assert( NACT_IS_WINDOW( user_data ));
+ NactWindow *dialog = NACT_WINDOW( user_data );
+
+ gboolean state = FALSE;
+ gchar *old_text = NULL;
+ scheme_cell_edited( dialog, path, text, SCHEMES_KEYWORD_COLUMN, &state, &old_text );
+
+ if( state ){
+ /*g_debug( "%s: old_scheme=%s", thisfn, old_text );*/
+ NAActionProfile *edited = NA_ACTION_PROFILE( v_get_edited_profile( dialog ));
+ na_action_profile_set_scheme( edited, old_text, FALSE );
+ na_action_profile_set_scheme( edited, text, TRUE );
+ }
+
+ g_free( old_text );
+ v_field_modified( dialog );
+}
+
+static void
+on_scheme_desc_edited( GtkCellRendererText *renderer, const gchar *path, const gchar *text, gpointer user_data )
+{
+ /*static const gchar *thisfn = "nact_iadvanced_tab_on_scheme_desc_edited";
+ g_debug( "%s: renderer=%p, path=%s, text=%s, user_data=%p", thisfn, renderer, path, text, user_data );*/
+
+ g_assert( NACT_IS_WINDOW( user_data ));
+ NactWindow *dialog = NACT_WINDOW( user_data );
+
+ scheme_cell_edited( dialog, path, text, SCHEMES_DESC_COLUMN, NULL, NULL );
+}
+
+static void
+on_scheme_list_selection_changed( GtkTreeSelection *selection, gpointer user_data )
+{
+ /*static const gchar *thisfn = "nact_iadvanced_tab_on_scheme_list_selection_changed";
+ g_debug( "%s: selection=%p, user_data=%p", thisfn, selection, user_data );*/
+
+ g_assert( NACT_IS_WINDOW( user_data ));
+ NactWindow *dialog = NACT_WINDOW( user_data );
+
+ GtkWidget *button = GTK_WIDGET( get_remove_button( dialog ));
+
+ if( gtk_tree_selection_count_selected_rows( selection )){
+ gtk_widget_set_sensitive( button, TRUE );
+ } else {
+ gtk_widget_set_sensitive( button, FALSE );
+ }
+}
+
+/* TODO: set the selection on the newly created scheme */
+static void
+on_add_scheme_clicked( GtkButton *button, gpointer user_data )
+{
+ GtkTreeModel *model = get_schemes_tree_model( NACT_WINDOW( user_data ));
+ GtkTreeIter row;
+ gtk_list_store_append( GTK_LIST_STORE( model ), &row );
+ gtk_list_store_set(
+ GTK_LIST_STORE( model ),
+ &row,
+ SCHEMES_CHECKBOX_COLUMN, FALSE,
+ /* i18n notes : scheme name set for a new entry in the scheme list */
+ SCHEMES_KEYWORD_COLUMN, _( "new-scheme" ),
+ SCHEMES_DESC_COLUMN, _( "New scheme description" ),
+ -1 );
+}
+
+static void
+on_remove_scheme_clicked( GtkButton *button, gpointer user_data )
+{
+ g_assert( NACT_IS_WINDOW( user_data ));
+ NactWindow *dialog = NACT_WINDOW( user_data );
+
+ GtkTreeView *listview = get_schemes_tree_view( dialog );
+ GtkTreeSelection *selection = gtk_tree_view_get_selection( listview );
+ GtkTreeModel *model = get_schemes_tree_model( dialog );
+
+ GList *selected_values_path = NULL;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GList *il;
+ gboolean toggle_state;
+ gchar *scheme;
+
+ selected_values_path = gtk_tree_selection_get_selected_rows( selection, &model );
+
+ for( il = selected_values_path ; il ; il = il->next ){
+ path = ( GtkTreePath * ) il->data;
+ gtk_tree_model_get_iter( model, &iter, path );
+ gtk_tree_model_get( model, &iter, SCHEMES_CHECKBOX_COLUMN, &toggle_state, SCHEMES_KEYWORD_COLUMN, &scheme, -1 );
+ gtk_list_store_remove( GTK_LIST_STORE( model ), &iter );
+
+ if( toggle_state ){
+ NAActionProfile *edited = NA_ACTION_PROFILE( v_get_edited_profile( dialog ));
+ na_action_profile_set_scheme( edited, scheme, FALSE );
+ }
+ }
+
+ g_list_foreach( selected_values_path, ( GFunc ) gtk_tree_path_free, NULL );
+ g_list_free( selected_values_path );
+
+ v_field_modified( dialog );
+}
+
+static void
+scheme_cell_edited( NactWindow *window, const gchar *path_string, const gchar *text, gint column, gboolean *state, gchar **old_text )
+{
+ GtkTreeModel *model = get_schemes_tree_model( window );
+ GtkTreeIter iter;
+
+ GtkTreePath *path = gtk_tree_path_new_from_string( path_string );
+ gtk_tree_model_get_iter( model, &iter, path );
+ gtk_tree_path_free( path );
+
+ if( state && old_text ){
+ gtk_tree_model_get( model, &iter, SCHEMES_CHECKBOX_COLUMN, state, SCHEMES_KEYWORD_COLUMN, old_text, -1 );
+ }
+
+ gtk_list_store_set( GTK_LIST_STORE( model ), &iter, column, g_strdup( text ), -1 );
+
+}
+
+static GtkTreeView *
+get_schemes_tree_view( NactWindow *window )
+{
+ return( GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( window ), "SchemesTreeView" )));
+}
+
+static GtkTreeModel *
+get_schemes_tree_model( NactWindow *window )
+{
+ GtkTreeView *schemes_view = get_schemes_tree_view( window );
+ return( gtk_tree_view_get_model( schemes_view ));
+}
+
+static void
+create_schemes_selection_list( NactWindow *window )
+{
+ static const char *thisfn = "nact_iadvanced_tab_create_schemes_selection_list";
+ g_debug( "%s: window=%p", thisfn, window );
+ g_assert( NACT_IS_IADVANCED_TAB( window ));
+
+ GtkWidget *listview = GTK_WIDGET( get_schemes_tree_view( window ));
+ GSList* schemes_list = get_schemes_default_list( window );
+ GtkListStore *model = gtk_list_store_new( SCHEMES_N_COLUMN, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING );
+
+ GSList *iter;
+ GtkTreeIter row;
+ for( iter = schemes_list ; iter ; iter = iter->next ){
+
+ gchar **tokens = g_strsplit(( gchar * ) iter->data, "|", 2 );
+ gtk_list_store_append( model, &row );
+ gtk_list_store_set( model, &row,
+ SCHEMES_CHECKBOX_COLUMN, FALSE,
+ SCHEMES_KEYWORD_COLUMN, tokens[0],
+ SCHEMES_DESC_COLUMN, tokens[1],
+ -1 );
+ g_strfreev( tokens );
+ }
+
+ na_utils_free_string_list( schemes_list );
+
+ gtk_tree_view_set_model( GTK_TREE_VIEW( listview ), GTK_TREE_MODEL( model ));
+ g_object_unref( model );
+
+ GtkCellRenderer *toggled_cell = gtk_cell_renderer_toggle_new();
+ GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes(
+ "scheme-selected",
+ toggled_cell,
+ "active", SCHEMES_CHECKBOX_COLUMN,
+ NULL );
+ gtk_tree_view_append_column( GTK_TREE_VIEW( listview ), column );
+ /*g_debug( "%s: toggled_cell=%p", thisfn, toggled_cell );*/
+
+ GtkCellRenderer *text_cell = gtk_cell_renderer_text_new();
+ g_object_set( G_OBJECT( text_cell ), "editable", TRUE, NULL );
+ column = gtk_tree_view_column_new_with_attributes(
+ "scheme-code",
+ text_cell,
+ "text", SCHEMES_KEYWORD_COLUMN,
+ NULL );
+ gtk_tree_view_append_column( GTK_TREE_VIEW( listview ), column );
+
+ text_cell = gtk_cell_renderer_text_new();
+ g_object_set( G_OBJECT( text_cell ), "editable", TRUE, NULL );
+ column = gtk_tree_view_column_new_with_attributes(
+ "scheme-description",
+ text_cell,
+ "text", SCHEMES_DESC_COLUMN,
+ NULL );
+ gtk_tree_view_append_column( GTK_TREE_VIEW( listview ), column );
+}
+
+/*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";
+
+ 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);
+
+ 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 *//*
+}*/
+
+static GSList *
+get_schemes_default_list( NactWindow *window )
+{
+ GSList *list = NULL;
+
+ /* i18n notes : description of 'file' scheme */
+ list = g_slist_append( list, g_strdup( _( "file|Local files")));
+ /* i18n notes : description of 'sftp' scheme */
+ list = g_slist_append( list, g_strdup( _( "sftp|SSH files")));
+ /* i18n notes : description of 'smb' scheme */
+ list = g_slist_append( list, g_strdup( _( "smb|Windows files")));
+ /* i18n notes : description of 'ftp' scheme */
+ list = g_slist_append( list, g_strdup( _( "ftp|FTP files")));
+ /* i18n notes : description of 'dav' scheme */
+ list = g_slist_append( list, g_strdup( _( "dav|WebDAV files")));
+
+ return( list );
+}
+
+static gboolean
+reset_schemes_list( GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data )
+{
+ gtk_list_store_set( GTK_LIST_STORE( model ), iter, SCHEMES_CHECKBOX_COLUMN, FALSE, -1 );
+
+ return( FALSE ); /* don't stop looping */
+}
+
+static void
+set_action_schemes( gchar *scheme, GtkTreeModel *model )
+{
+ GtkTreeIter iter;
+ gboolean iter_ok = FALSE;
+ gboolean found = FALSE;
+ gchar *i_scheme;
+
+ iter_ok = gtk_tree_model_get_iter_first( model, &iter );
+
+ while( iter_ok && !found ){
+ gtk_tree_model_get( model, &iter, SCHEMES_KEYWORD_COLUMN, &i_scheme, -1 );
+
+ if( g_ascii_strcasecmp( scheme, i_scheme) == 0 ){
+ gtk_list_store_set( GTK_LIST_STORE( model ), &iter, SCHEMES_CHECKBOX_COLUMN, TRUE, -1 );
+ found = TRUE;
+ }
+
+ g_free( i_scheme );
+ iter_ok = gtk_tree_model_iter_next( model, &iter );
+ }
+
+ if( !found ){
+ gtk_list_store_append( GTK_LIST_STORE( model ), &iter );
+ gtk_list_store_set(
+ GTK_LIST_STORE( model ),
+ &iter,
+ SCHEMES_CHECKBOX_COLUMN, TRUE,
+ SCHEMES_KEYWORD_COLUMN, scheme,
+ SCHEMES_DESC_COLUMN, "",
+ -1 );
+ }
+}
+
+static GtkButton *
+get_add_button( NactWindow *window )
+{
+ return( GTK_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "AddSchemeButton" )));
+}
+
+static GtkButton *
+get_remove_button( NactWindow *window )
+{
+ return( GTK_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "RemoveSchemeButton" )));
+}
diff --git a/src/nact/nact-iadvanced-tab.h b/src/nact/nact-iadvanced-tab.h
new file mode 100644
index 0000000..d9170d3
--- /dev/null
+++ b/src/nact/nact-iadvanced-tab.h
@@ -0,0 +1,75 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
+ *
+ * This Program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifndef __NACT_IADVANCED_TAB_H__
+#define __NACT_IADVANCED_TAB_H__
+
+/*
+ * NactIAdvancedTab interface definition.
+ *
+ * This interface implements all the widgets which define the
+ * conditions for the action.
+ */
+
+#include "nact-window.h"
+
+G_BEGIN_DECLS
+
+#define NACT_IADVANCED_TAB_TYPE ( nact_iadvanced_tab_get_type())
+#define NACT_IADVANCED_TAB( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NACT_IADVANCED_TAB_TYPE, NactIAdvancedTab ))
+#define NACT_IS_IADVANCED_TAB( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NACT_IADVANCED_TAB_TYPE ))
+#define NACT_IADVANCED_TAB_GET_INTERFACE( instance ) ( G_TYPE_INSTANCE_GET_INTERFACE(( instance ), NACT_IADVANCED_TAB_TYPE, NactIAdvancedTabInterface ))
+
+typedef struct NactIAdvancedTab NactIAdvancedTab;
+
+typedef struct NactIAdvancedTabInterfacePrivate NactIAdvancedTabInterfacePrivate;
+
+typedef struct {
+ GTypeInterface parent;
+ NactIAdvancedTabInterfacePrivate *private;
+
+ /* api */
+ NAActionProfile * ( *get_edited_profile )( NactWindow *window );
+ void ( *field_modified ) ( NactWindow *window );
+}
+ NactIAdvancedTabInterface;
+
+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_set_profile( NactWindow *window, NAActionProfile *profile );
+
+G_END_DECLS
+
+#endif /* __NACT_IADVANCED_TAB_H__ */
diff --git a/src/nact/nact-icommand-tab.c b/src/nact/nact-icommand-tab.c
index 33ea5fb..93bb7bb 100644
--- a/src/nact/nact-icommand-tab.c
+++ b/src/nact/nact-icommand-tab.c
@@ -66,11 +66,13 @@ static gboolean v_get_multiple( NactWindow *window );
static GSList *v_get_schemes( NactWindow *window );
static void on_label_changed( GtkEntry *entry, gpointer user_data );
+static GtkWidget *get_label_entry( NactWindow *window );
static void on_path_changed( GtkEntry *entry, gpointer user_data );
static void on_path_browse( GtkButton *button, gpointer user_data );
-static GtkWidget *get_path_widget( NactWindow *window );
+static GtkWidget *get_path_entry( NactWindow *window );
+static GtkButton *get_path_button( NactWindow *window );
static void on_parameters_changed( GtkEntry *entry, gpointer user_data );
-static GtkWidget *get_parameters_widget( NactWindow *window );
+static GtkWidget *get_parameters_entry( NactWindow *window );
static void update_example_label( NactWindow *window );
static gchar *parse_parameters( NactWindow *window );
static void on_legend_clicked( GtkButton *button, gpointer user_data );
@@ -157,42 +159,25 @@ nact_icommand_tab_initial_load( NactWindow *dialog )
}
void
-nact_icommand_tab_size_labels( NactWindow *window, GObject *size_group )
-{
- g_assert( NACT_IS_WINDOW( window ));
- g_assert( GTK_IS_SIZE_GROUP( size_group ));
-
- GtkWidget *label = base_window_get_widget( BASE_WINDOW( window ), "ProfileLabelLabel" );
- gtk_size_group_add_widget( GTK_SIZE_GROUP( size_group ), label );
-}
-
-void
-nact_icommand_tab_size_buttons( NactWindow *window, GObject *size_group )
-{
- g_assert( NACT_IS_WINDOW( window ));
- g_assert( GTK_IS_SIZE_GROUP( size_group ));
-}
-
-void
nact_icommand_tab_runtime_init( NactWindow *dialog )
{
static const gchar *thisfn = "nact_icommand_tab_runtime_init";
g_debug( "%s: dialog=%p", thisfn, dialog );
- GtkWidget *label_widget = base_window_get_widget( BASE_WINDOW( dialog ), "CommandProfileLabelEntry" );
- nact_window_signal_connect( dialog, G_OBJECT( label_widget ), "changed", G_CALLBACK( on_label_changed ));
+ GtkWidget *label_entry = get_label_entry( dialog );
+ nact_window_signal_connect( dialog, G_OBJECT( label_entry ), "changed", G_CALLBACK( on_label_changed ));
- GtkWidget *path_widget = get_path_widget( dialog );
- nact_window_signal_connect( dialog, G_OBJECT( path_widget ), "changed", G_CALLBACK( on_path_changed ));
+ GtkWidget *path_entry = get_path_entry( dialog );
+ nact_window_signal_connect( dialog, G_OBJECT( path_entry ), "changed", G_CALLBACK( on_path_changed ));
- GtkWidget *button = base_window_get_widget( BASE_WINDOW( dialog ), "CommandPathButton" );
- nact_window_signal_connect( dialog, G_OBJECT( button ), "clicked", G_CALLBACK( on_path_browse ));
+ GtkButton *path_button = get_path_button( dialog );
+ nact_window_signal_connect( dialog, G_OBJECT( path_button ), "clicked", G_CALLBACK( on_path_browse ));
- GtkWidget *parameters_widget = get_parameters_widget( dialog );
- nact_window_signal_connect( dialog, G_OBJECT( parameters_widget ), "changed", G_CALLBACK( on_parameters_changed ));
+ GtkWidget *parameters_entry = get_parameters_entry( dialog );
+ nact_window_signal_connect( dialog, G_OBJECT( parameters_entry ), "changed", G_CALLBACK( on_parameters_changed ));
- button = GTK_WIDGET( get_legend_button( dialog ));
- nact_window_signal_connect( dialog, G_OBJECT( button ), "clicked", G_CALLBACK( on_legend_clicked ));
+ GtkButton *legend_button = get_legend_button( dialog );
+ nact_window_signal_connect( dialog, G_OBJECT( legend_button ), "clicked", G_CALLBACK( on_legend_clicked ));
}
/**
@@ -201,8 +186,8 @@ nact_icommand_tab_runtime_init( NactWindow *dialog )
void
nact_icommand_tab_all_widgets_showed( NactWindow *dialog )
{
- GtkWidget *label_widget = base_window_get_widget( BASE_WINDOW( dialog ), "ProfileLabelEntry" );
- gtk_widget_grab_focus( label_widget );
+ static const gchar *thisfn = "nact_icommand_tab_all_widgets_showed";
+ g_debug( "%s: dialog=%p", thisfn, dialog );
}
void
@@ -211,10 +196,7 @@ nact_icommand_tab_dispose( NactWindow *dialog )
static const gchar *thisfn = "nact_icommand_tab_dispose";
g_debug( "%s: dialog=%p", thisfn, dialog );
- /*BaseApplication *appli = BASE_APPLICATION( base_window_get_application( BASE_WINDOW( dialog )));
- GtkWindow *toplevel = base_application_get_dialog( appli, "MenuItemWindow" );
- GtkWidget *vbox = base_application_get_widget( appli, BASE_WINDOW( dialog ), "MenuItemVBox" );
- gtk_widget_reparent( vbox, GTK_WIDGET( toplevel ));*/
+ hide_legend_dialog( dialog );
}
void
@@ -223,20 +205,29 @@ nact_icommand_tab_set_profile( NactWindow *dialog, const NAActionProfile *profil
static const gchar *thisfn = "nact_icommand_tab_set_profile";
g_debug( "%s: dialog=%p, profile=%p", thisfn, dialog, profile );
- GtkWidget *label_widget = base_window_get_widget( BASE_WINDOW( dialog ), "CommandProfileLabelEntry" );
+ GtkWidget *label_entry = get_label_entry( dialog );
gchar *label = profile ? na_action_profile_get_label( profile ) : g_strdup( "" );
- gtk_entry_set_text( GTK_ENTRY( label_widget ), label );
+ gtk_entry_set_text( GTK_ENTRY( label_entry ), label );
+ gtk_widget_set_sensitive( label_entry, profile != NULL );
g_free( label );
- GtkWidget *path_widget = get_path_widget( dialog );
+ GtkWidget *path_entry = get_path_entry( dialog );
gchar *path = profile ? na_action_profile_get_path( profile ) : g_strdup( "" );
- gtk_entry_set_text( GTK_ENTRY( path_widget ), path );
+ gtk_entry_set_text( GTK_ENTRY( path_entry ), path );
+ gtk_widget_set_sensitive( path_entry, profile != NULL );
g_free( path );
- GtkWidget *parameters_widget = get_parameters_widget( dialog );
+ GtkWidget *parameters_entry = get_parameters_entry( dialog );
gchar *parameters = profile ? na_action_profile_get_parameters( profile ) : g_strdup( "" );
- gtk_entry_set_text( GTK_ENTRY( parameters_widget ), parameters );
+ gtk_entry_set_text( GTK_ENTRY( parameters_entry ), parameters );
+ gtk_widget_set_sensitive( parameters_entry, profile != NULL );
g_free( parameters );
+
+ GtkButton *path_button = get_path_button( dialog );
+ gtk_widget_set_sensitive( GTK_WIDGET( path_button ), profile != NULL );
+
+ GtkButton *legend_button = get_legend_button( dialog );
+ gtk_widget_set_sensitive( GTK_WIDGET( legend_button ), profile != NULL );
}
/**
@@ -246,8 +237,8 @@ nact_icommand_tab_set_profile( NactWindow *dialog, const NAActionProfile *profil
gboolean
nact_icommand_tab_has_label( NactWindow *window )
{
- GtkWidget *label_widget = base_window_get_widget( BASE_WINDOW( window ), "ProfileLabelEntry" );
- const gchar *label = gtk_entry_get_text( GTK_ENTRY( label_widget ));
+ GtkWidget *label_entry = get_label_entry( window );
+ const gchar *label = gtk_entry_get_text( GTK_ENTRY( label_entry ));
return( g_utf8_strlen( label, -1 ) > 0 );
}
@@ -318,9 +309,16 @@ on_label_changed( GtkEntry *entry, gpointer user_data )
NactWindow *dialog = NACT_WINDOW( user_data );
NAActionProfile *edited = NA_ACTION_PROFILE( v_get_edited_profile( dialog ));
- na_action_profile_set_label( edited, gtk_entry_get_text( entry ));
+ if( edited ){
+ na_action_profile_set_label( edited, gtk_entry_get_text( entry ));
+ v_field_modified( dialog );
+ }
+}
- v_field_modified( dialog );
+static GtkWidget *
+get_label_entry( NactWindow *window )
+{
+ return( base_window_get_widget( BASE_WINDOW( window ), "ProfileLabelEntry" ));
}
static void
@@ -330,10 +328,12 @@ on_path_changed( GtkEntry *entry, gpointer user_data )
NactWindow *dialog = NACT_WINDOW( user_data );
NAActionProfile *edited = NA_ACTION_PROFILE( v_get_edited_profile( dialog ));
- na_action_profile_set_path( edited, gtk_entry_get_text( entry ));
+ if( edited ){
+ na_action_profile_set_path( edited, gtk_entry_get_text( entry ));
+ v_field_modified( dialog );
+ }
update_example_label( dialog );
- v_field_modified( dialog );
}
static void
@@ -354,8 +354,8 @@ on_path_browse( GtkButton *button, gpointer user_data )
nact_iprefs_position_named_window( NACT_WINDOW( user_data ), GTK_WINDOW( dialog ), IPREFS_COMMAND_CHOOSER );
- GtkWidget *path_widget = get_path_widget( NACT_WINDOW( user_data ));
- const gchar *path = gtk_entry_get_text( GTK_ENTRY( path_widget ));
+ GtkWidget *path_entry = get_path_entry( NACT_WINDOW( user_data ));
+ const gchar *path = gtk_entry_get_text( GTK_ENTRY( path_entry ));
if( path && strlen( path )){
set_current_location = gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( dialog ), path );
@@ -368,7 +368,7 @@ on_path_browse( GtkButton *button, gpointer user_data )
if( gtk_dialog_run( GTK_DIALOG( dialog )) == GTK_RESPONSE_ACCEPT ){
gchar *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( dialog ));
- gtk_entry_set_text( GTK_ENTRY( path_widget ), filename );
+ gtk_entry_set_text( GTK_ENTRY( path_entry ), filename );
g_free (filename);
}
@@ -382,11 +382,17 @@ on_path_browse( GtkButton *button, gpointer user_data )
}
static GtkWidget *
-get_path_widget( NactWindow *window )
+get_path_entry( NactWindow *window )
{
return( base_window_get_widget( BASE_WINDOW( window ), "CommandPathEntry" ));
}
+static GtkButton *
+get_path_button( NactWindow *window )
+{
+ return( GTK_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "CommandPathButton" )));
+}
+
static void
on_parameters_changed( GtkEntry *entry, gpointer user_data )
{
@@ -394,14 +400,16 @@ on_parameters_changed( GtkEntry *entry, gpointer user_data )
NactWindow *dialog = NACT_WINDOW( user_data );
NAActionProfile *edited = NA_ACTION_PROFILE( v_get_edited_profile( dialog ));
- na_action_profile_set_parameters( edited, gtk_entry_get_text( entry ));
+ if( edited ){
+ na_action_profile_set_parameters( edited, gtk_entry_get_text( entry ));
+ v_field_modified( dialog );
+ }
update_example_label( dialog );
- v_field_modified( dialog );
}
static GtkWidget *
-get_parameters_widget( NactWindow *window )
+get_parameters_entry( NactWindow *window )
{
return( base_window_get_widget( BASE_WINDOW( window ), "CommandParametersEntry" ));
}
@@ -461,8 +469,8 @@ parse_parameters( NactWindow *window )
gchar* ex_scheme;
gchar* ex_host;
- const gchar* command = gtk_entry_get_text( GTK_ENTRY( get_path_widget( window )));
- const gchar* param_template = gtk_entry_get_text( GTK_ENTRY( get_parameters_widget( window )));
+ const gchar* command = gtk_entry_get_text( GTK_ENTRY( get_path_entry( window )));
+ const gchar* param_template = gtk_entry_get_text( GTK_ENTRY( get_parameters_entry( window )));
gchar* iter = g_strdup( param_template );
gchar* old_iter = iter;
diff --git a/src/nact/nact-icommand-tab.h b/src/nact/nact-icommand-tab.h
index 4c54f44..18895c3 100644
--- a/src/nact/nact-icommand-tab.h
+++ b/src/nact/nact-icommand-tab.h
@@ -66,8 +66,6 @@ typedef struct {
GType nact_icommand_tab_get_type( void );
void nact_icommand_tab_initial_load( NactWindow *window );
-void nact_icommand_tab_size_labels( NactWindow *window, GObject *size_group );
-void nact_icommand_tab_size_buttons( NactWindow *window, GObject *size_group );
void nact_icommand_tab_runtime_init( NactWindow *window );
void nact_icommand_tab_all_widgets_showed( NactWindow *window );
void nact_icommand_tab_dispose( NactWindow *window );
diff --git a/src/nact/nact-iconditions-tab.c b/src/nact/nact-iconditions-tab.c
new file mode 100644
index 0000000..890c422
--- /dev/null
+++ b/src/nact/nact-iconditions-tab.c
@@ -0,0 +1,409 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
+ *
+ * This Program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib/gi18n.h>
+#include <string.h>
+
+#include <common/na-utils.h>
+
+#include "nact-iconditions-tab.h"
+#include "nact-iprefs.h"
+
+/* private interface data
+ */
+struct NactIConditionsTabInterfacePrivate {
+};
+
+static GType register_type( void );
+static void interface_base_init( NactIConditionsTabInterface *klass );
+static void interface_base_finalize( NactIConditionsTabInterface *klass );
+
+static NAActionProfile *v_get_edited_profile( NactWindow *window );
+static void v_field_modified( NactWindow *window );
+
+static void on_basenames_changed( GtkEntry *entry, gpointer user_data );
+static GtkWidget *get_basenames_entry( NactWindow *window );
+static void on_matchcase_toggled( GtkToggleButton *button, gpointer user_data );
+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 );
+static GtkButton *get_both_button( NactWindow *window );
+static void on_multiple_toggled( GtkToggleButton *button, gpointer user_data );
+static GtkButton *get_multiple_button( NactWindow *window );
+
+GType
+nact_iconditions_tab_get_type( void )
+{
+ static GType iface_type = 0;
+
+ if( !iface_type ){
+ iface_type = register_type();
+ }
+
+ return( iface_type );
+}
+
+static GType
+register_type( void )
+{
+ static const gchar *thisfn = "nact_iconditions_tab_register_type";
+ g_debug( "%s", thisfn );
+
+ static const GTypeInfo info = {
+ sizeof( NactIConditionsTabInterface ),
+ ( GBaseInitFunc ) interface_base_init,
+ ( GBaseFinalizeFunc ) interface_base_finalize,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ 0,
+ NULL
+ };
+
+ GType type = g_type_register_static( G_TYPE_INTERFACE, "NactIConditionsTab", &info, 0 );
+
+ g_type_interface_add_prerequisite( type, G_TYPE_OBJECT );
+
+ return( type );
+}
+
+static void
+interface_base_init( NactIConditionsTabInterface *klass )
+{
+ static const gchar *thisfn = "nact_iconditions_tab_interface_base_init";
+ static gboolean initialized = FALSE;
+
+ if( !initialized ){
+ g_debug( "%s: klass=%p", thisfn, klass );
+
+ klass->private = g_new0( NactIConditionsTabInterfacePrivate, 1 );
+
+ klass->get_edited_profile = NULL;
+ klass->field_modified = NULL;
+
+ initialized = TRUE;
+ }
+}
+
+static void
+interface_base_finalize( NactIConditionsTabInterface *klass )
+{
+ static const gchar *thisfn = "nact_iconditions_tab_interface_base_finalize";
+ static gboolean finalized = FALSE ;
+
+ if( !finalized ){
+ g_debug( "%s: klass=%p", thisfn, klass );
+
+ g_free( klass->private );
+
+ finalized = TRUE;
+ }
+}
+
+void
+nact_iconditions_tab_initial_load( NactWindow *dialog )
+{
+ static const gchar *thisfn = "nact_iconditions_tab_initial_load";
+ g_debug( "%s: dialog=%p", thisfn, dialog );
+}
+
+void
+nact_iconditions_tab_runtime_init( NactWindow *dialog )
+{
+ static const gchar *thisfn = "nact_iconditions_tab_runtime_init";
+ g_debug( "%s: dialog=%p", thisfn, dialog );
+
+ GtkWidget *basenames_widget = get_basenames_entry( dialog );
+ nact_window_signal_connect( dialog, G_OBJECT( basenames_widget ), "changed", G_CALLBACK( on_basenames_changed ));
+
+ GtkButton *matchcase_button = get_matchcase_button( dialog );
+ nact_window_signal_connect( dialog, G_OBJECT( matchcase_button ), "toggled", G_CALLBACK( on_matchcase_toggled ));
+
+ GtkWidget *mimetypes_widget = get_mimetypes_entry( dialog );
+ nact_window_signal_connect( dialog, G_OBJECT( mimetypes_widget ), "changed", G_CALLBACK( on_mimetypes_changed ));
+
+ GtkButton *isfile_button = get_isfile_button( dialog );
+ nact_window_signal_connect( dialog, G_OBJECT( isfile_button ), "toggled", G_CALLBACK( on_isfiledir_toggled ));
+ GtkButton *isdir_button = get_isdir_button( dialog );
+ nact_window_signal_connect( dialog, G_OBJECT( isdir_button ), "toggled", G_CALLBACK( on_isfiledir_toggled ));
+ GtkButton *both_button = get_both_button( dialog );
+ nact_window_signal_connect( dialog, G_OBJECT( both_button ), "toggled", G_CALLBACK( on_isfiledir_toggled ));
+
+ GtkButton *multiple_button = get_multiple_button( dialog );
+ nact_window_signal_connect( dialog, G_OBJECT( multiple_button ), "toggled", G_CALLBACK( on_multiple_toggled ));
+}
+
+void
+nact_iconditions_tab_all_widgets_showed( NactWindow *dialog )
+{
+ static const gchar *thisfn = "nact_iconditions_tab_all_widgets_showed";
+ g_debug( "%s: dialog=%p", thisfn, dialog );
+}
+
+void
+nact_iconditions_tab_dispose( NactWindow *dialog )
+{
+ static const gchar *thisfn = "nact_iconditions_tab_dispose";
+ g_debug( "%s: dialog=%p", thisfn, dialog );
+}
+
+void
+nact_iconditions_tab_set_profile( NactWindow *dialog, NAActionProfile *profile )
+{
+ static const gchar *thisfn = "nact_iconditions_tab_runtime_init";
+ g_debug( "%s: dialog=%p, profile=%p", thisfn, dialog, profile );
+
+ GtkWidget *basenames_widget = get_basenames_entry( dialog );
+ GSList *basenames = profile ? na_action_profile_get_basenames( profile ) : NULL;
+ gchar *basenames_text = profile ? na_utils_string_list_to_text( basenames ) : g_strdup( "" );
+ gtk_entry_set_text( GTK_ENTRY( basenames_widget ), basenames_text );
+ g_free( basenames_text );
+ na_utils_free_string_list( basenames );
+ gtk_widget_set_sensitive( basenames_widget, profile != NULL );
+
+ GtkButton *matchcase_button = get_matchcase_button( dialog );
+ gboolean matchcase = profile ? na_action_profile_get_matchcase( profile ) : FALSE;
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( matchcase_button ), matchcase );
+ gtk_widget_set_sensitive( GTK_WIDGET( matchcase_button ), profile != NULL );
+
+ GtkWidget *mimetypes_widget = get_mimetypes_entry( dialog );
+ GSList *mimetypes = profile ? na_action_profile_get_mimetypes( profile ) : NULL;
+ gchar *mimetypes_text = profile ? na_utils_string_list_to_text( mimetypes ) : g_strdup( "" );
+ gtk_entry_set_text( GTK_ENTRY( mimetypes_widget ), mimetypes_text );
+ g_free( mimetypes_text );
+ na_utils_free_string_list( mimetypes );
+ gtk_widget_set_sensitive( mimetypes_widget, profile != NULL );
+
+ gboolean isfile = profile ? na_action_profile_get_is_file( profile ) : FALSE;
+ gboolean isdir = profile ? na_action_profile_get_is_dir( profile ) : FALSE;
+ set_isfiledir( dialog, isfile, isdir );
+ GtkButton *files_button = get_isfile_button( dialog );
+ gtk_widget_set_sensitive( GTK_WIDGET( files_button ), profile != NULL );
+ GtkButton *dir_button = get_isdir_button( dialog );
+ gtk_widget_set_sensitive( GTK_WIDGET( dir_button ), profile != NULL );
+ GtkButton *both_button = get_both_button( dialog );
+ gtk_widget_set_sensitive( GTK_WIDGET( both_button ), profile != NULL );
+
+ GtkButton *multiple_button = get_multiple_button( dialog );
+ gboolean multiple = profile ? na_action_profile_get_multiple( profile ) : FALSE;
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( multiple_button ), multiple );
+ gtk_widget_set_sensitive( GTK_WIDGET( multiple_button ), profile != NULL );
+}
+
+static NAActionProfile *
+v_get_edited_profile( NactWindow *window )
+{
+ g_assert( NACT_IS_ICONDITIONS_TAB( window ));
+
+ if( NACT_ICONDITIONS_TAB_GET_INTERFACE( window )->get_edited_profile ){
+ return( NACT_ICONDITIONS_TAB_GET_INTERFACE( window )->get_edited_profile( window ));
+ }
+
+ return( NULL );
+}
+
+static void
+v_field_modified( NactWindow *window )
+{
+ g_assert( NACT_IS_ICONDITIONS_TAB( window ));
+
+ if( NACT_ICONDITIONS_TAB_GET_INTERFACE( window )->field_modified ){
+ NACT_ICONDITIONS_TAB_GET_INTERFACE( window )->field_modified( window );
+ }
+}
+
+static void
+on_basenames_changed( GtkEntry *entry, gpointer user_data )
+{
+ g_assert( NACT_IS_WINDOW( user_data ));
+ NactWindow *dialog = NACT_WINDOW( user_data );
+
+ NAActionProfile *edited = NA_ACTION_PROFILE( v_get_edited_profile( dialog ));
+ if( edited ){
+ const gchar *text = gtk_entry_get_text( entry );
+ 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 );
+}
+
+static GtkWidget *
+get_basenames_entry( NactWindow *window )
+{
+ return( base_window_get_widget( BASE_WINDOW( window ), "ConditionsFilenamesEntry" ));
+}
+
+static void
+on_matchcase_toggled( GtkToggleButton *button, gpointer user_data )
+{
+ g_assert( NACT_IS_WINDOW( user_data ));
+ NactWindow *dialog = NACT_WINDOW( user_data );
+
+ NAActionProfile *edited = NA_ACTION_PROFILE( v_get_edited_profile( dialog ));
+ if( edited ){
+ gboolean matchcase = gtk_toggle_button_get_active( button );
+ na_action_profile_set_matchcase( edited, matchcase );
+ }
+
+ v_field_modified( dialog );
+}
+
+static GtkButton *
+get_matchcase_button( NactWindow *window )
+{
+ return( GTK_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "ConditionsMatchcaseButton" )));
+}
+
+static void
+on_mimetypes_changed( GtkEntry *entry, gpointer user_data )
+{
+ g_assert( NACT_IS_WINDOW( user_data ));
+ NactWindow *dialog = NACT_WINDOW( user_data );
+
+ NAActionProfile *edited = NA_ACTION_PROFILE( v_get_edited_profile( dialog ));
+ if( edited ){
+ const gchar *text = gtk_entry_get_text( entry );
+ 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 );
+}
+
+static GtkWidget *
+get_mimetypes_entry( NactWindow *window )
+{
+ return( base_window_get_widget( BASE_WINDOW( window ), "ConditionsMimetypesEntry" ));
+}
+
+/*
+ * Note that this callback is triggered twice: first, for the
+ * deactivated button, then a second time for the newly activated one.
+ * I don't know what to do to be triggered only once..?
+ */
+static void
+on_isfiledir_toggled( GtkToggleButton *button, gpointer user_data )
+{
+ /*static const gchar *thisfn = "nact_iconditions_tab_on_isfiledir_toggled";*/
+
+ g_assert( NACT_IS_WINDOW( user_data ));
+ NactWindow *dialog = NACT_WINDOW( user_data );
+
+ NAActionProfile *edited = NA_ACTION_PROFILE( v_get_edited_profile( dialog ));
+ if( edited ){
+ gboolean isfile, isdir;
+ get_isfiledir( dialog, &isfile, &isdir );
+ na_action_profile_set_isfiledir( edited, isfile, isdir );
+ }
+
+ v_field_modified( dialog );
+}
+
+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 ){
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( get_both_button( window )), TRUE );
+
+ } else if( isfile ){
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( get_isfile_button( window )), TRUE );
+
+ } else if( isdir ){
+ gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( get_isdir_button( window )), TRUE );
+ }
+}
+
+static GtkButton *
+get_isfile_button( NactWindow *window )
+{
+ return( GTK_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "ConditionsOnlyFilesButton" )));
+}
+
+static GtkButton *
+get_isdir_button( NactWindow *window )
+{
+ return( GTK_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "ConditionsOnlyFoldersButton" )));
+}
+
+static GtkButton *
+get_both_button( NactWindow *window )
+{
+ return( GTK_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "ConditionsBothButton" )));
+}
+
+static void
+on_multiple_toggled( GtkToggleButton *button, gpointer user_data )
+{
+ g_assert( NACT_IS_WINDOW( user_data ));
+ NactWindow *dialog = NACT_WINDOW( user_data );
+
+ NAActionProfile *edited = NA_ACTION_PROFILE( v_get_edited_profile( dialog ));
+ if( edited ){
+ gboolean multiple = gtk_toggle_button_get_active( button );
+ na_action_profile_set_multiple( edited, multiple );
+ }
+
+ v_field_modified( dialog );
+}
+
+static GtkButton *
+get_multiple_button( NactWindow *window )
+{
+ return( GTK_BUTTON( base_window_get_widget( BASE_WINDOW( window ), "ConditionsMultipleButton" )));
+}
diff --git a/src/nact/nact-iconditions-tab.h b/src/nact/nact-iconditions-tab.h
new file mode 100644
index 0000000..46de255
--- /dev/null
+++ b/src/nact/nact-iconditions-tab.h
@@ -0,0 +1,75 @@
+/*
+ * Nautilus Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
+ *
+ * This Program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifndef __NACT_ICONDITIONS_TAB_H__
+#define __NACT_ICONDITIONS_TAB_H__
+
+/*
+ * NactIConditions_Tab interface definition.
+ *
+ * This interface implements all the widgets which define the
+ * conditions for the action.
+ */
+
+#include "nact-window.h"
+
+G_BEGIN_DECLS
+
+#define NACT_ICONDITIONS_TAB_TYPE ( nact_iconditions_tab_get_type())
+#define NACT_ICONDITIONS_TAB( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NACT_ICONDITIONS_TAB_TYPE, NactIConditions_Tab ))
+#define NACT_IS_ICONDITIONS_TAB( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NACT_ICONDITIONS_TAB_TYPE ))
+#define NACT_ICONDITIONS_TAB_GET_INTERFACE( instance ) ( G_TYPE_INSTANCE_GET_INTERFACE(( instance ), NACT_ICONDITIONS_TAB_TYPE, NactIConditionsTabInterface ))
+
+typedef struct NactIConditionsTab NactIConditionsTab;
+
+typedef struct NactIConditionsTabInterfacePrivate NactIConditionsTabInterfacePrivate;
+
+typedef struct {
+ GTypeInterface parent;
+ NactIConditionsTabInterfacePrivate *private;
+
+ /* api */
+ NAActionProfile * ( *get_edited_profile )( NactWindow *window );
+ void ( *field_modified ) ( NactWindow *window );
+}
+ NactIConditionsTabInterface;
+
+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_set_profile( NactWindow *window, NAActionProfile *profile );
+
+G_END_DECLS
+
+#endif /* __NACT_ICONDITIONS_TAB_H__ */
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index cb99885..6f21817 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -49,6 +49,8 @@
#include "nact-iactions-list.h"
#include "nact-iaction-tab.h"
#include "nact-icommand-tab.h"
+#include "nact-iconditions-tab.h"
+#include "nact-iadvanced-tab.h"
#include "nact-iprefs.h"
#include "nact-main-window.h"
@@ -63,6 +65,7 @@ struct NactMainWindowPrivate {
gboolean dispose_has_run;
GtkStatusbar *status_bar;
guint status_context;
+ GtkWidget *new_profile_item;
GtkWidget *save_item;
GSList *actions;
NAAction *edited_action;
@@ -80,6 +83,8 @@ static void class_init( NactMainWindowClass *klass );
static void iactions_list_iface_init( NactIActionsListInterface *iface );
static void iaction_tab_iface_init( NactIActionTabInterface *iface );
static void icommand_tab_iface_init( NactICommandTabInterface *iface );
+static void iconditions_tab_iface_init( NactIConditionsTabInterface *iface );
+static void iadvanced_tab_iface_init( NactIAdvancedTabInterface *iface );
static void ipivot_container_iface_init( NAIPivotContainerInterface *iface );
static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *application );
@@ -114,6 +119,11 @@ static void get_isfiledir( NactWindow *window, gboolean *isfile, gbo
static gboolean get_multiple( NactWindow *window );
static GSList *get_schemes( NactWindow *window );
+static void on_new_action_activated( GtkMenuItem *item, gpointer user_data );
+static void on_new_action_selected( GtkItem *item, gpointer user_data );
+static void on_new_profile_activated( GtkMenuItem *item, gpointer user_data );
+static void on_new_profile_selected( GtkItem *item, gpointer user_data );
+
static void on_import_activated( GtkMenuItem *item, gpointer user_data );
static void on_import_selected( GtkItem *item, gpointer user_data );
static void on_export_activated( GtkMenuItem *item, gpointer user_data );
@@ -190,6 +200,24 @@ register_type( void )
};
g_type_add_interface_static( type, NACT_ICOMMAND_TAB_TYPE, &icommand_tab_iface_info );
+ /* implement IConditionsTab interface
+ */
+ static const GInterfaceInfo iconditions_tab_iface_info = {
+ ( GInterfaceInitFunc ) iconditions_tab_iface_init,
+ NULL,
+ NULL
+ };
+ g_type_add_interface_static( type, NACT_ICONDITIONS_TAB_TYPE, &iconditions_tab_iface_info );
+
+ /* implement IAdvancedTab interface
+ */
+ static const GInterfaceInfo iadvanced_tab_iface_info = {
+ ( GInterfaceInitFunc ) iadvanced_tab_iface_init,
+ NULL,
+ NULL
+ };
+ g_type_add_interface_static( type, NACT_IADVANCED_TAB_TYPE, &iadvanced_tab_iface_info );
+
/* implement IPivotContainer interface
*/
static const GInterfaceInfo pivot_container_iface_info = {
@@ -263,6 +291,26 @@ icommand_tab_iface_init( NactICommandTabInterface *iface )
}
static void
+iconditions_tab_iface_init( NactIConditionsTabInterface *iface )
+{
+ static const gchar *thisfn = "nact_main_window_iconditions_tab_iface_init";
+ g_debug( "%s: iface=%p", thisfn, iface );
+
+ iface->get_edited_profile = get_edited_profile;
+ iface->field_modified = on_modified_field;
+}
+
+static void
+iadvanced_tab_iface_init( NactIAdvancedTabInterface *iface )
+{
+ static const gchar *thisfn = "nact_main_window_iadvanced_tab_iface_init";
+ g_debug( "%s: iface=%p", thisfn, iface );
+
+ iface->get_edited_profile = get_edited_profile;
+ iface->field_modified = on_modified_field;
+}
+
+static void
ipivot_container_iface_init( NAIPivotContainerInterface *iface )
{
static const gchar *thisfn = "nact_main_window_ipivot_container_iface_init";
@@ -308,6 +356,11 @@ instance_dispose( GObject *window )
}
g_slist_free( self->private->actions );
+ nact_iaction_tab_dispose( NACT_WINDOW( window ));
+ nact_icommand_tab_dispose( NACT_WINDOW( window ));
+ nact_iconditions_tab_dispose( NACT_WINDOW( window ));
+ nact_iadvanced_tab_dispose( NACT_WINDOW( window ));
+
/* chain up to the parent class */
G_OBJECT_CLASS( st_parent_class )->dispose( window );
}
@@ -420,11 +473,11 @@ on_initial_load_toplevel( BaseWindow *window )
g_assert( NACT_IS_ICOMMAND_TAB( window ));
nact_icommand_tab_initial_load( NACT_WINDOW( window ));
- /*g_assert( NACT_IS_CONDITIONS_TAB( window ));
- nact_iconditions_tab_initial_load( window );
+ g_assert( NACT_IS_ICONDITIONS_TAB( window ));
+ nact_iconditions_tab_initial_load( NACT_WINDOW( window ));
- g_assert( NACT_IS_ADVANCED_TAB( window ));
- nact_iadvanced_tab_initial_load( window );*/
+ g_assert( NACT_IS_IADVANCED_TAB( window ));
+ nact_iadvanced_tab_initial_load( NACT_WINDOW( window ));
gint pos = nact_iprefs_get_int( NACT_WINDOW( window ), "main-paned" );
if( pos ){
@@ -443,8 +496,22 @@ create_file_menu( BaseWindow *window, GtkMenuBar *menubar )
GtkWidget *menu = gtk_menu_new();
gtk_menu_item_set_submenu( GTK_MENU_ITEM( file ), menu );
- GtkWidget *item = gtk_image_menu_item_new_from_stock( GTK_STOCK_NEW, NULL );
+ /* i18n: 'New action' item in 'File' menu */
+ GtkWidget *item = gtk_image_menu_item_new_with_label( _( "New _action" ));
+ gtk_menu_shell_append( GTK_MENU_SHELL( menu ), item );
+ gtk_menu_item_set_use_underline( GTK_MENU_ITEM( item ), TRUE );
+ nact_window_signal_connect( NACT_WINDOW( window ), G_OBJECT( item ), "activate", G_CALLBACK( on_new_action_activated ));
+ nact_window_signal_connect( NACT_WINDOW( window ), G_OBJECT( item ), "select", G_CALLBACK( on_new_action_selected ));
+ nact_window_signal_connect( NACT_WINDOW( window ), G_OBJECT( item ), "deselect", G_CALLBACK( on_menu_item_deselected ));
+
+ /* i18n: 'New profile' item in 'File' menu */
+ item = gtk_image_menu_item_new_with_label( _( "New _profile" ));
gtk_menu_shell_append( GTK_MENU_SHELL( menu ), item );
+ gtk_menu_item_set_use_underline( GTK_MENU_ITEM( item ), TRUE );
+ NACT_MAIN_WINDOW( window )->private->new_profile_item = item;
+ nact_window_signal_connect( NACT_WINDOW( window ), G_OBJECT( item ), "activate", G_CALLBACK( on_new_profile_activated ));
+ nact_window_signal_connect( NACT_WINDOW( window ), G_OBJECT( item ), "select", G_CALLBACK( on_new_profile_selected ));
+ nact_window_signal_connect( NACT_WINDOW( window ), G_OBJECT( item ), "deselect", G_CALLBACK( on_menu_item_deselected ));
item = gtk_image_menu_item_new_from_stock( GTK_STOCK_SAVE, NULL );
gtk_menu_shell_append( GTK_MENU_SHELL( menu ), item );
@@ -525,12 +592,11 @@ on_runtime_init_toplevel( BaseWindow *window )
g_assert( NACT_IS_ICOMMAND_TAB( window ));
nact_icommand_tab_runtime_init( NACT_WINDOW( window ));
- /*nact_window_signal_connect_by_name( NACT_WINDOW( window ), "NewActionButton", "clicked", G_CALLBACK( on_new_button_clicked ));
- nact_window_signal_connect_by_name( NACT_WINDOW( window ), "EditActionButton", "clicked", G_CALLBACK( on_edit_button_clicked ));
- nact_window_signal_connect_by_name( NACT_WINDOW( window ), "DuplicateActionButton", "clicked", G_CALLBACK( on_duplicate_button_clicked ));
- nact_window_signal_connect_by_name( NACT_WINDOW( window ), "DeleteActionButton", "clicked", G_CALLBACK( on_delete_button_clicked ));
- nact_window_signal_connect_by_name( NACT_WINDOW( window ), "ImportButton", "clicked", G_CALLBACK( on_import_button_clicked ));
- nact_window_signal_connect_by_name( NACT_WINDOW( window ), "ExportButton", "clicked", G_CALLBACK( on_export_button_clicked ));*/
+ g_assert( NACT_IS_ICONDITIONS_TAB( window ));
+ nact_iconditions_tab_runtime_init( NACT_WINDOW( window ));
+
+ g_assert( NACT_IS_IADVANCED_TAB( window ));
+ nact_iadvanced_tab_runtime_init( NACT_WINDOW( window ));
}
static void
@@ -569,7 +635,9 @@ setup_dialog_menu( NactMainWindow *window )
to_save |= elt_to_save;
}
- gtk_widget_set_sensitive( NACT_MAIN_WINDOW( window )->private->save_item, to_save );
+ gtk_widget_set_sensitive( window->private->new_profile_item, window->private->edited_action != NULL );
+
+ gtk_widget_set_sensitive( window->private->save_item, to_save );
}
/*
@@ -634,7 +702,17 @@ set_current_action( NactMainWindow *window )
static void
set_current_profile( NactMainWindow *window )
{
+ if( window->private->edited_profile ){
+ NAAction *action = NA_ACTION( na_action_profile_get_action( window->private->edited_profile ));
+ if( action != window->private->edited_action ){
+ window->private->edited_action = action;
+ nact_iaction_tab_set_action( NACT_WINDOW( window ), window->private->edited_action );
+ }
+ }
+
nact_icommand_tab_set_profile( NACT_WINDOW( window ), window->private->edited_profile );
+ nact_iconditions_tab_set_profile( NACT_WINDOW( window ), window->private->edited_profile );
+ nact_iadvanced_tab_set_profile( NACT_WINDOW( window ), window->private->edited_profile );
}
/*
@@ -738,6 +816,42 @@ get_schemes( NactWindow *window )
}
static void
+on_new_action_activated( GtkMenuItem *item, gpointer user_data )
+{
+
+}
+
+static void
+on_new_action_selected( GtkItem *item, gpointer user_data )
+{
+ g_assert( NACT_IS_MAIN_WINDOW( user_data ));
+ NactMainWindow *window = NACT_MAIN_WINDOW( user_data );
+ gtk_statusbar_push(
+ window->private->status_bar,
+ window->private->status_context,
+ /* i18n: tooltip displayed in the status bar when selecting the 'New action' item */
+ _( "Define a new action" ));
+}
+
+static void
+on_new_profile_activated( GtkMenuItem *item, gpointer user_data )
+{
+
+}
+
+static void
+on_new_profile_selected( GtkItem *item, gpointer user_data )
+{
+ g_assert( NACT_IS_MAIN_WINDOW( user_data ));
+ NactMainWindow *window = NACT_MAIN_WINDOW( user_data );
+ gtk_statusbar_push(
+ window->private->status_bar,
+ window->private->status_context,
+ /* i18n: tooltip displayed in the status bar when selecting the 'New profile' item */
+ _( "Define a new profile attached to the current action" ));
+}
+
+static void
on_import_activated( GtkMenuItem *item, gpointer user_data )
{
static const gchar *thisfn = "nact_main_window_on_import_activated";
diff --git a/src/nact/nautilus-actions-config.ui b/src/nact/nautilus-actions-config.ui
index 4da416d..9a06018 100644
--- a/src/nact/nautilus-actions-config.ui
+++ b/src/nact/nautilus-actions-config.ui
@@ -266,7 +266,7 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
- <object class="GtkLabel" id="CommandProfileLabel">
+ <object class="GtkLabel" id="ProfileLabelLabel">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Label :</property>
@@ -277,7 +277,7 @@
</packing>
</child>
<child>
- <object class="GtkEntry" id="CommandProfileLabelEntry">
+ <object class="GtkEntry" id="ProfileLabelEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
@@ -403,6 +403,7 @@
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="use_markup">True</property>
+ <property name="wrap">True</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -419,6 +420,7 @@
</child>
</object>
<packing>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
@@ -694,73 +696,84 @@
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox5">
+ <object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
- <property name="spacing">6</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow2">
+ <object class="GtkHBox" id="hbox5">
<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="spacing">6</property>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow4">
+ <object class="GtkScrolledWindow" id="scrolledwindow2">
<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">
+ <object class="GtkScrolledWindow" id="scrolledwindow4">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="headers_visible">False</property>
- <property name="rules_hint">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>
</child>
</object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVButtonBox" id="vbuttonbox1">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <property name="layout_style">start</property>
<child>
- <object class="GtkButton" id="AddSchemeButton">
+ <object class="GtkVButtonBox" id="vbuttonbox1">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
+ <property name="spacing">6</property>
+ <property name="layout_style">start</property>
<child>
- <object class="GtkImage" id="image16">
+ <object class="GtkButton" id="AddSchemeButton">
<property name="visible">True</property>
- <property name="stock">gtk-add</property>
- <property name="icon-size">4</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>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="RemoveSchemeButton">
- <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">
+ <object class="GtkButton" id="RemoveSchemeButton">
<property name="visible">True</property>
- <property name="stock">gtk-remove</property>
- <property name="icon-size">4</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>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
<packing>
@@ -772,8 +785,7 @@
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
@@ -1189,7 +1201,7 @@ file(s)/folder(s)</property>
</object>
<object class="GtkSizeGroup" id="CommandLabelSizeGroup">
<widgets>
- <widget name="CommandProfileLabel"/>
+ <widget name="ProfileLabelLabel"/>
<widget name="CommandPathLabel"/>
<widget name="CommandParametersLabel"/>
</widgets>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]