[nautilus-actions] Refactoring: rename src/nact/nact-assistant-export-ask.{c, h} to src/nact/nact-export-ask.{c, h}



commit ce13a923019468e0428c65ccb5772781afeb3d6b
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Feb 17 10:28:13 2010 +0100

    Refactoring: rename src/nact/nact-assistant-export-ask.{c,h} to src/nact/nact-export-ask.{c,h}

 ChangeLog                                          |    5 +
 src/nact/nact-assistant-export-ask.h               |   79 --------
 ...ct-assistant-export-ask.c => nact-export-ask.c} |  199 ++++++++++----------
 src/nact/nact-export-ask.h                         |   79 ++++++++
 4 files changed, 181 insertions(+), 181 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0a21e40..4219375 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-02-17 Pierre Wieser <pwieser trychlos org>
+
+	Rename src/nact/nact-assistant-export-ask.{c,h} to
+	src/nact/nact-export-ask.{c,h}
+
 2009-02-15 Pierre Wieser <pwieser trychlos org>
 
 	Now install defined ids in docdir.
diff --git a/src/nact/nact-assistant-export-ask.c b/src/nact/nact-export-ask.c
similarity index 59%
rename from src/nact/nact-assistant-export-ask.c
rename to src/nact/nact-export-ask.c
index f67af93..a978b36 100644
--- a/src/nact/nact-assistant-export-ask.c
+++ b/src/nact/nact-export-ask.c
@@ -36,47 +36,49 @@
 
 #include <api/na-object-api.h>
 
+#include <core/na-exporter.h>
+
 #include "nact-iprefs.h"
-#include "nact-assistant-export-ask.h"
+#include "nact-export-ask.h"
 
 /* private class data
  */
-struct NactAssistantExportAskClassPrivate {
+struct NactExportAskClassPrivate {
 	void *empty;						/* so that gcc -pedantic is happy */
 };
 
 /* private instance data
  */
-struct NactAssistantExportAskPrivate {
+struct NactExportAskPrivate {
 	gboolean      dispose_has_run;
 	BaseWindow   *parent;
 	NAObjectItem *item;
-	gint          format;
+	GQuark        format;
 };
 
 static BaseDialogClass *st_parent_class = NULL;
 
 static GType    register_type( void );
-static void     class_init( NactAssistantExportAskClass *klass );
+static void     class_init( NactExportAskClass *klass );
 static void     instance_init( GTypeInstance *instance, gpointer klass );
 static void     instance_dispose( GObject *dialog );
 static void     instance_finalize( GObject *dialog );
 
-static NactAssistantExportAsk *assistant_export_ask_new( BaseWindow *parent );
+static NactExportAsk *export_ask_new( BaseWindow *parent );
 
 static gchar   *base_get_iprefs_window_id( const BaseWindow *window );
 static gchar   *base_get_dialog_name( const BaseWindow *window );
 static gchar   *base_get_ui_filename( const BaseWindow *dialog );
-static void     on_base_initial_load_dialog( NactAssistantExportAsk *editor, gpointer user_data );
-static void     on_base_runtime_init_dialog( NactAssistantExportAsk *editor, gpointer user_data );
-static void     on_base_all_widgets_showed( NactAssistantExportAsk *editor, gpointer user_data );
-static void     on_cancel_clicked( GtkButton *button, NactAssistantExportAsk *editor );
-static void     on_ok_clicked( GtkButton *button, NactAssistantExportAsk *editor );
-static gint     get_format( NactAssistantExportAsk *editor );
+static void     on_base_initial_load_dialog( NactExportAsk *editor, gpointer user_data );
+static void     on_base_runtime_init_dialog( NactExportAsk *editor, gpointer user_data );
+static void     on_base_all_widgets_showed( NactExportAsk *editor, gpointer user_data );
+static void     on_cancel_clicked( GtkButton *button, NactExportAsk *editor );
+static void     on_ok_clicked( GtkButton *button, NactExportAsk *editor );
+static GQuark   get_format( NactExportAsk *editor );
 static gboolean base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window );
 
 GType
-nact_assistant_export_ask_get_type( void )
+nact_export_ask_get_type( void )
 {
 	static GType dialog_type = 0;
 
@@ -90,32 +92,32 @@ nact_assistant_export_ask_get_type( void )
 static GType
 register_type( void )
 {
-	static const gchar *thisfn = "nact_assistant_export_ask_register_type";
+	static const gchar *thisfn = "nact_export_ask_register_type";
 	GType type;
 
 	static GTypeInfo info = {
-		sizeof( NactAssistantExportAskClass ),
+		sizeof( NactExportAskClass ),
 		( GBaseInitFunc ) NULL,
 		( GBaseFinalizeFunc ) NULL,
 		( GClassInitFunc ) class_init,
 		NULL,
 		NULL,
-		sizeof( NactAssistantExportAsk ),
+		sizeof( NactExportAsk ),
 		0,
 		( GInstanceInitFunc ) instance_init
 	};
 
 	g_debug( "%s", thisfn );
 
-	type = g_type_register_static( BASE_DIALOG_TYPE, "NactAssistantExportAsk", &info, 0 );
+	type = g_type_register_static( BASE_DIALOG_TYPE, "NactExportAsk", &info, 0 );
 
 	return( type );
 }
 
 static void
-class_init( NactAssistantExportAskClass *klass )
+class_init( NactExportAskClass *klass )
 {
-	static const gchar *thisfn = "nact_assistant_export_ask_class_init";
+	static const gchar *thisfn = "nact_export_ask_class_init";
 	GObjectClass *object_class;
 	BaseWindowClass *base_class;
 
@@ -127,7 +129,7 @@ class_init( NactAssistantExportAskClass *klass )
 	object_class->dispose = instance_dispose;
 	object_class->finalize = instance_finalize;
 
-	klass->private = g_new0( NactAssistantExportAskClassPrivate, 1 );
+	klass->private = g_new0( NactExportAskClassPrivate, 1 );
 
 	base_class = BASE_WINDOW_CLASS( klass );
 	base_class->dialog_response = base_dialog_response;
@@ -139,15 +141,15 @@ class_init( NactAssistantExportAskClass *klass )
 static void
 instance_init( GTypeInstance *instance, gpointer klass )
 {
-	static const gchar *thisfn = "nact_assistant_export_ask_instance_init";
-	NactAssistantExportAsk *self;
+	static const gchar *thisfn = "nact_export_ask_instance_init";
+	NactExportAsk *self;
 
 	g_debug( "%s: instance=%p (%s), klass=%p",
 			thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ), ( void * ) klass );
-	g_return_if_fail( NACT_IS_ASSISTANT_EXPORT_ASK( instance ));
-	self = NACT_ASSISTANT_EXPORT_ASK( instance );
+	g_return_if_fail( NACT_IS_EXPORT_ASK( instance ));
+	self = NACT_EXPORT_ASK( instance );
 
-	self->private = g_new0( NactAssistantExportAskPrivate, 1 );
+	self->private = g_new0( NactExportAskPrivate, 1 );
 
 	base_window_signal_connect(
 			BASE_WINDOW( instance ),
@@ -173,12 +175,12 @@ instance_init( GTypeInstance *instance, gpointer klass )
 static void
 instance_dispose( GObject *dialog )
 {
-	static const gchar *thisfn = "nact_assistant_export_ask_instance_dispose";
-	NactAssistantExportAsk *self;
+	static const gchar *thisfn = "nact_export_ask_instance_dispose";
+	NactExportAsk *self;
 
 	g_debug( "%s: dialog=%p (%s)", thisfn, ( void * ) dialog, G_OBJECT_TYPE_NAME( dialog ));
-	g_return_if_fail( NACT_IS_ASSISTANT_EXPORT_ASK( dialog ));
-	self = NACT_ASSISTANT_EXPORT_ASK( dialog );
+	g_return_if_fail( NACT_IS_EXPORT_ASK( dialog ));
+	self = NACT_EXPORT_ASK( dialog );
 
 	if( !self->private->dispose_has_run ){
 
@@ -194,12 +196,12 @@ instance_dispose( GObject *dialog )
 static void
 instance_finalize( GObject *dialog )
 {
-	static const gchar *thisfn = "nact_assistant_export_ask_instance_finalize";
-	NactAssistantExportAsk *self;
+	static const gchar *thisfn = "nact_export_ask_instance_finalize";
+	NactExportAsk *self;
 
 	g_debug( "%s: dialog=%p", thisfn, ( void * ) dialog );
-	g_return_if_fail( NACT_IS_ASSISTANT_EXPORT_ASK( dialog ));
-	self = NACT_ASSISTANT_EXPORT_ASK( dialog );
+	g_return_if_fail( NACT_IS_EXPORT_ASK( dialog ));
+	self = NACT_EXPORT_ASK( dialog );
 
 	g_free( self->private );
 
@@ -210,39 +212,45 @@ instance_finalize( GObject *dialog )
 }
 
 /*
- * Returns a newly allocated NactAssistantExportAsk object.
+ * Returns a newly allocated NactExportAsk object.
  */
-static NactAssistantExportAsk *
-assistant_export_ask_new( BaseWindow *parent )
+static NactExportAsk *
+export_ask_new( BaseWindow *parent )
 {
-	return( g_object_new( NACT_ASSISTANT_EXPORT_ASK_TYPE, BASE_WINDOW_PROP_PARENT, parent, NULL ));
+	return( g_object_new( NACT_EXPORT_ASK_TYPE, BASE_WINDOW_PROP_PARENT, parent, NULL ));
 }
 
 /**
- * nact_assistant_export_ask_run:
+ * nact_export_ask_run:
  * @parent: the NactAssistant parent of this dialog.
  *
  * Initializes and runs the dialog.
  *
- * Returns: the mode choosen by the user ; it defaults to 'none' (no export).
+ * This is a small dialog which is to be ran during export operations,
+ * when the set export format is 'Ask me'. Each exported file runs this
+ * dialog, unless the user selects the 'keep same choice' box.
+ *
+ * Returns: the mode choosen by the user as a #GQuark which identifies
+ * the export mode.
+ * The function defaults to returning IPREFS_EXPORT_NO_EXPORT.
  *
  * When the user selects 'Keep same choice without asking me', this choice
- * becomes his preference export format.
+ * becomes his new preferred export format.
  */
-gint
-nact_assistant_export_ask_user( BaseWindow *parent, NAObjectItem *item )
+GQuark
+nact_export_ask_user( BaseWindow *parent, NAObjectItem *item )
 {
-	static const gchar *thisfn = "nact_assistant_export_ask_run";
-	NactAssistantExportAsk *editor;
-	gint format;
+	static const gchar *thisfn = "nact_export_ask_run";
+	NactExportAsk *editor;
+	GQuark format;
 
 	g_debug( "%s: parent=%p", thisfn, ( void * ) parent );
 
-	format = IPREFS_EXPORT_NO_EXPORT;
+	format = ( GQuark ) IPREFS_EXPORT_NO_EXPORT;
 
 	g_return_val_if_fail( BASE_IS_WINDOW( parent ), format );
 
-	editor = assistant_export_ask_new( parent );
+	editor = export_ask_new( parent );
 
 	editor->private->parent = parent;
 	editor->private->item = item;
@@ -250,8 +258,11 @@ nact_assistant_export_ask_user( BaseWindow *parent, NAObjectItem *item )
 
 	if( base_window_run( BASE_WINDOW( editor ))){
 
-		format = editor->private->format;
-		nact_iprefs_set_export_format( BASE_WINDOW( parent ), IPREFS_EXPORT_ASK_LAST_FORMAT, format );
+		if( editor->private->format ){
+
+			format = editor->private->format;
+			nact_iprefs_set_export_format( BASE_WINDOW( parent ), IPREFS_EXPORT_ASK_LAST_FORMAT, format );
+		}
 	}
 
 	g_object_unref( editor );
@@ -268,7 +279,7 @@ base_get_iprefs_window_id( const BaseWindow *window )
 static gchar *
 base_get_dialog_name( const BaseWindow *window )
 {
-	return( g_strdup( "AssistantExportAsk" ));
+	return( g_strdup( "ExportAsk" ));
 }
 
 static gchar *
@@ -278,25 +289,30 @@ base_get_ui_filename( const BaseWindow *dialog )
 }
 
 static void
-on_base_initial_load_dialog( NactAssistantExportAsk *editor, gpointer user_data )
+on_base_initial_load_dialog( NactExportAsk *editor, gpointer user_data )
 {
-	static const gchar *thisfn = "nact_assistant_export_ask_on_initial_load_dialog";
+	static const gchar *thisfn = "nact_export_ask_on_initial_load_dialog";
+	NactApplication *application;
+	NAUpdater *updater;
+	GtkWidget *container;
 
 	g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
-	g_return_if_fail( NACT_IS_ASSISTANT_EXPORT_ASK( editor ));
+	g_return_if_fail( NACT_IS_EXPORT_ASK( editor ));
+
+	application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
+	updater = nact_application_get_updater( application );
+	container = base_window_get_widget( BASE_WINDOW( editor ), "ExportFormatAskVBox" );
+	nact_export_format_display( NA_PIVOT( updater ), container, EXPORT_FORMAT_DISPLAY_ASK );
 }
 
 static void
-on_base_runtime_init_dialog( NactAssistantExportAsk *editor, gpointer user_data )
+on_base_runtime_init_dialog( NactExportAsk *editor, gpointer user_data )
 {
-	static const gchar *thisfn = "nact_assistant_export_ask_on_runtime_init_dialog";
-	gchar *item_label;
-	gchar *label;
-	GtkWidget *widget;
-	GtkWidget *button;
+	static const gchar *thisfn = "nact_export_ask_on_runtime_init_dialog";
+	GtkWidget *container;
 
 	g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
-	g_return_if_fail( NACT_IS_ASSISTANT_EXPORT_ASK( editor ));
+	g_return_if_fail( NACT_IS_EXPORT_ASK( editor ));
 
 	item_label = na_object_get_label( editor->private->item );
 
@@ -306,26 +322,14 @@ on_base_runtime_init_dialog( NactAssistantExportAsk *editor, gpointer user_data
 	widget = base_window_get_widget( BASE_WINDOW( editor ), "ExportAskLabel1" );
 	gtk_label_set_text( GTK_LABEL( widget ), label );
 	g_free( label );
-
-	switch( editor->private->format ){
-		case IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V1:
-			button = base_window_get_widget( BASE_WINDOW( editor ), "AskGConfSchemaV1Button" );
-			break;
-
-		case IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V2:
-			button = base_window_get_widget( BASE_WINDOW( editor ), "AskGConfSchemaV2Button" );
-			break;
-
-		case IPREFS_EXPORT_FORMAT_GCONF_ENTRY:
-		default:
-			button = base_window_get_widget( BASE_WINDOW( editor ), "AskGConfEntryButton" );
-			break;
-	}
-	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), TRUE );
+	g_free( item_label );
 
 	button = base_window_get_widget( BASE_WINDOW( editor ), "AskKeepChoiceButton" );
 	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( button ), FALSE );
 
+	container = base_window_get_widget( BASE_WINDOW( editor ), "ExportFormatAskVBox" );
+	nact_export_format_select( container, editor->private->format );
+
 	base_window_signal_connect_by_name(
 			BASE_WINDOW( editor ),
 			"CancelButton",
@@ -340,45 +344,36 @@ on_base_runtime_init_dialog( NactAssistantExportAsk *editor, gpointer user_data
 }
 
 static void
-on_base_all_widgets_showed( NactAssistantExportAsk *editor, gpointer user_data )
+on_base_all_widgets_showed( NactExportAsk *editor, gpointer user_data )
 {
-	static const gchar *thisfn = "nact_assistant_export_ask_on_all_widgets_showed";
+	static const gchar *thisfn = "nact_export_ask_on_all_widgets_showed";
 
 	g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
-	g_return_if_fail( NACT_IS_ASSISTANT_EXPORT_ASK( editor ));
+	g_return_if_fail( NACT_IS_EXPORT_ASK( editor ));
 }
 
 static void
-on_cancel_clicked( GtkButton *button, NactAssistantExportAsk *editor )
+on_cancel_clicked( GtkButton *button, NactExportAsk *editor )
 {
 	GtkWindow *toplevel = base_window_get_toplevel( BASE_WINDOW( editor ));
 	gtk_dialog_response( GTK_DIALOG( toplevel ), GTK_RESPONSE_CLOSE );
 }
 
 static void
-on_ok_clicked( GtkButton *button, NactAssistantExportAsk *editor )
+on_ok_clicked( GtkButton *button, NactExportAsk *editor )
 {
 	GtkWindow *toplevel = base_window_get_toplevel( BASE_WINDOW( editor ));
 	gtk_dialog_response( GTK_DIALOG( toplevel ), GTK_RESPONSE_OK );
 }
 
-static gint
-get_format( NactAssistantExportAsk *editor )
+static GQuark
+get_format( NactExportAsk *editor )
 {
-	gint export_format;
-	GtkWidget *button;
-	gboolean keep;
-
-	export_format = IPREFS_EXPORT_FORMAT_GCONF_ENTRY;
-	button = base_window_get_widget( BASE_WINDOW( editor ), "AskGConfSchemaV1Button" );
-	if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ))){
-		export_format = IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V1;
-	} else {
-		button = base_window_get_widget( BASE_WINDOW( editor ), "AskGConfSchemaV2Button" );
-		if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ))){
-			export_format = IPREFS_EXPORT_FORMAT_GCONF_SCHEMA_V2;
-		}
-	}
+	GtkWidget *container;
+	GQuark export_format;
+
+	container = base_window_get_widget( BASE_WINDOW( editor ), "ExportFormatAskVBox" );
+	export_format = nact_export_format_get_select( container );
 
 	button = base_window_get_widget( BASE_WINDOW( editor ), "AskKeepChoiceButton" );
 	keep = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
@@ -392,12 +387,12 @@ get_format( NactAssistantExportAsk *editor )
 static gboolean
 base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
 {
-	static const gchar *thisfn = "nact_assistant_export_ask_on_dialog_response";
-	NactAssistantExportAsk *editor;
+	static const gchar *thisfn = "nact_export_ask_on_dialog_response";
+	NactExportAsk *editor;
 
 	g_debug( "%s: dialog=%p, code=%d, window=%p", thisfn, ( void * ) dialog, code, ( void * ) window );
-	g_assert( NACT_IS_ASSISTANT_EXPORT_ASK( window ));
-	editor = NACT_ASSISTANT_EXPORT_ASK( window );
+	g_assert( NACT_IS_EXPORT_ASK( window ));
+	editor = NACT_EXPORT_ASK( window );
 
 	switch( code ){
 		case GTK_RESPONSE_NONE:
@@ -405,7 +400,7 @@ base_dialog_response( GtkDialog *dialog, gint code, BaseWindow *window )
 		case GTK_RESPONSE_CLOSE:
 		case GTK_RESPONSE_CANCEL:
 
-			editor->private->format = IPREFS_EXPORT_NO_EXPORT;
+			editor->private->format = 0;
 			return( TRUE );
 			break;
 
diff --git a/src/nact/nact-export-ask.h b/src/nact/nact-export-ask.h
new file mode 100644
index 0000000..d2f2574
--- /dev/null
+++ b/src/nact/nact-export-ask.h
@@ -0,0 +1,79 @@
+/*
+ * 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, 2010 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_EXPORT_ASK_H__
+#define __NACT_EXPORT_ASK_H__
+
+/**
+ * SECTION: nact_export_ask
+ * @short_description: #NactExportAsk class definition.
+ * @include: nact/nact-export-ask.h
+ *
+ * This class is derived from BaseDialog.
+ * It is ran each time an action is to be exported, and the user want
+ * to be ask to choose the export format.
+ */
+
+#include <api/na-object-item.h>
+
+#include "base-dialog.h"
+
+G_BEGIN_DECLS
+
+#define NACT_EXPORT_ASK_TYPE				( nact_export_ask_get_type())
+#define NACT_EXPORT_ASK( object )			( G_TYPE_CHECK_INSTANCE_CAST( object, NACT_EXPORT_ASK_TYPE, NactExportAsk ))
+#define NACT_EXPORT_ASK_CLASS( klass )		( G_TYPE_CHECK_CLASS_CAST( klass, NACT_EXPORT_ASK_TYPE, NactExportAskClass ))
+#define NACT_IS_EXPORT_ASK( object )		( G_TYPE_CHECK_INSTANCE_TYPE( object, NACT_EXPORT_ASK_TYPE ))
+#define NACT_IS_EXPORT_ASK_CLASS( klass )	( G_TYPE_CHECK_CLASS_TYPE(( klass ), NACT_EXPORT_ASK_TYPE ))
+#define NACT_EXPORT_ASK_GET_CLASS( object )	( G_TYPE_INSTANCE_GET_CLASS(( object ), NACT_EXPORT_ASK_TYPE, NactExportAskClass ))
+
+typedef struct NactExportAskPrivate      NactExportAskPrivate;
+
+typedef struct {
+	BaseDialog            parent;
+	NactExportAskPrivate *private;
+}
+	NactExportAsk;
+
+typedef struct NactExportAskClassPrivate NactExportAskClassPrivate;
+
+typedef struct {
+	BaseDialogClass            parent;
+	NactExportAskClassPrivate *private;
+}
+	NactExportAskClass;
+
+GType  nact_export_ask_get_type( void );
+
+GQuark nact_export_ask_user( BaseWindow *window, NAObjectItem *item );
+
+G_END_DECLS
+
+#endif /* __NACT_EXPORT_ASK_H__ */



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