[nautilus-actions] Move nact_export_format_get_ask_option() to na_exporter_get_ask_option()
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Move nact_export_format_get_ask_option() to na_exporter_get_ask_option()
- Date: Fri, 6 Jan 2012 07:31:55 +0000 (UTC)
commit 25faf225ae2f99ccfdfb0a7319985729465d7700
Author: Pierre Wieser <pwieser trychlos org>
Date: Wed Jan 4 23:50:00 2012 +0100
Move nact_export_format_get_ask_option() to na_exporter_get_ask_option()
+ Move src/nact/export-format-ask.png to src/core/
+ Remove src/nact/nact-export-format.{c,h}.
ChangeLog | 13 +++
po/POTFILES.in | 1 -
src/core/Makefile.am | 1 +
src/core/na-exporter.c | 211 ++++++++++++++++++++++++------------
src/core/na-exporter.h | 17 +++-
src/nact/Makefile.am | 3 -
src/nact/nact-assistant-export.c | 3 +-
src/nact/nact-preferences-editor.c | 3 +-
8 files changed, 171 insertions(+), 81 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2ce3e08..94a6a31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2012-01-04 Pierre Wieser <pwieser trychlos org>
+ Move 'Ask' export format to NAExporter.
+
+ * src/core/Makefile.am:
+ * src/nact/Makefile.am: Move export-format-ask.png to src/core.
+
+ * nact-export-format.c:
+ * nact-export-format.h: Removed files.
+
+ * po/POTFILES.in:
+ * src/nact/nact-assistant-export.c (ioptions_list_get_ask_option):
+ * src/nact/nact-preferences-editor.c (ioptions_list_get_ask_option):
+ Updated accordingly.
+
* src/api/na-iimporter.h: Deprecate NAIImporterImportMode enum.
* src/core/na-importer.h: Define new NAImporterImportMode enum here.
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f7b8f7e..e6ae0bb 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -38,7 +38,6 @@ src/nact/nact-assistant-import.c
[type: gettext/glade] src/nact/nact-assistant-import.ui
src/nact/nact.desktop.in
src/nact/nact-export-ask.c
-src/nact/nact-export-format.c
src/nact/nact-iaction-tab.c
src/nact/nact-ibasenames-tab.c
src/nact/nact-icapabilities-tab.c
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 14ba894..9b8486d 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -139,6 +139,7 @@ libna_core_la_LDFLAGS = \
pkgdata_DATA = \
na-importer-ask.ui \
+ export-format-ask.png \
$(NULL)
CLEANFILES = \
diff --git a/src/core/na-exporter.c b/src/core/na-exporter.c
index 7d5a43f..677de8e 100644
--- a/src/core/na-exporter.c
+++ b/src/core/na-exporter.c
@@ -37,10 +37,28 @@
#include "na-exporter.h"
#include "na-export-format.h"
+typedef struct {
+ const gchar *format; /* export format saved in user's preferences */
+ const gchar *label; /* short label */
+ const gchar *description; /* full description */
+ const gchar *image; /* associated image */
+}
+ NAExporterFormatStr;
+
+static NAExporterFormatStr st_format_ask = {
+
+ "Ask",
+ N_( "_Ask me" ),
+ N_( "You will be asked for the format to choose each time an item " \
+ "is about to be exported." ),
+ "export-format-ask.png"
+};
+
static GList *exporter_get_formats( const NAIExporter *exporter );
static void exporter_free_formats( const NAIExporter *exporter, GList * str_list );
static gchar *exporter_get_name( const NAIExporter *exporter );
static NAIExporter *find_exporter_for_format( const NAPivot *pivot, GQuark format );
+static void on_pixbuf_finalized( gpointer user_data, GObject *pixbuf );
/*
* na_exporter_get_formats:
@@ -82,6 +100,75 @@ na_exporter_get_formats( const NAPivot *pivot )
}
/*
+ * Returns a GList of NAIExporterFormatExt structures which describes
+ * the export formats provided by the exporter
+ * If the provider only implements the v1 interface, we dynamically
+ * allocate a new structure and convert the v1 to the v2.
+ */
+static GList *
+exporter_get_formats( const NAIExporter *exporter )
+{
+ GList *str_list;
+ guint version;
+
+ str_list = NULL;
+
+ version = 1;
+ if( NA_IEXPORTER_GET_INTERFACE( exporter )->get_version ){
+ version = NA_IEXPORTER_GET_INTERFACE( exporter )->get_version( exporter );
+ }
+
+ if( NA_IEXPORTER_GET_INTERFACE( exporter )->get_formats ){
+ if( version == 1 ){
+#ifdef NA_ENABLE_DEPRECATED
+ const NAIExporterFormat * strv1;
+ strv1 = NA_IEXPORTER_GET_INTERFACE( exporter )->get_formats( exporter );
+ while( strv1->format ){
+ NAIExporterFormatExt *strv2 = g_new0( NAIExporterFormatExt, 1 );
+ strv2->version = 1;
+ strv2->provider = ( NAIExporter * ) exporter;
+ strv2->format = strv1->format;
+ strv2->label = strv1->label;
+ strv2->description = strv1->description;
+ strv2->pixbuf = NULL;
+ str_list = g_list_prepend( str_list, strv2 );
+ strv1++;
+ }
+#else
+ ;
+#endif
+ } else {
+ str_list = NA_IEXPORTER_GET_INTERFACE( exporter )->get_formats( exporter );
+ }
+ }
+
+ return( str_list );
+}
+
+/*
+ * Free the list returned by exporter_get_formats() for this provider
+ */
+static void
+exporter_free_formats( const NAIExporter *exporter, GList *str_list )
+{
+ guint version;
+
+ version = 1;
+ if( NA_IEXPORTER_GET_INTERFACE( exporter )->get_version ){
+ version = NA_IEXPORTER_GET_INTERFACE( exporter )->get_version( exporter );
+ }
+
+ if( version == 1 ){
+ g_list_foreach( str_list, ( GFunc ) g_free, NULL );
+ g_list_free( str_list );
+
+ } else {
+ g_return_if_fail( NA_IEXPORTER_GET_INTERFACE( exporter )->free_formats );
+ NA_IEXPORTER_GET_INTERFACE( exporter )->free_formats( exporter, str_list );
+ }
+}
+
+/*
* na_exporter_free_formats:
* @formats: a list of available export formats, as returned by
* na_exporter_get_formats().
@@ -100,6 +187,61 @@ na_exporter_free_formats( GList *formats )
}
/*
+ * na_exporter_get_ask_option:
+ *
+ * Returns the 'Ask me' option.
+ *
+ * Since: 3.2
+ */
+NAIOption *
+na_exporter_get_ask_option( void )
+{
+ static const gchar *thisfn = "na_exporter_get_ask_option";
+ NAIExporterFormatExt *str;
+ gint width, height;
+ gchar *fname;
+ NAExportFormat *format;
+
+ if( !gtk_icon_size_lookup( GTK_ICON_SIZE_DIALOG, &width, &height )){
+ width = height = 48;
+ }
+
+ str = g_new0( NAIExporterFormatExt, 1 );
+ str->version = 2;
+ str->provider = NULL;
+ str->format = g_strdup( st_format_ask.format );
+ str->label = g_strdup( gettext( st_format_ask.label ));
+ str->description = g_strdup( gettext( st_format_ask.description ));
+ if( st_format_ask.image ){
+ fname = g_strdup_printf( "%s/%s", PKGDATADIR, st_format_ask.image );
+ str->pixbuf = gdk_pixbuf_new_from_file_at_size( fname, width, height, NULL );
+ g_free( fname );
+ if( str->pixbuf ){
+ g_debug( "%s: allocating pixbuf at %p", thisfn, str->pixbuf );
+ g_object_weak_ref( G_OBJECT( str->pixbuf ), ( GWeakNotify ) on_pixbuf_finalized, NULL );
+ }
+ }
+
+ format = na_export_format_new( str );
+
+ if( str->pixbuf ){
+ g_object_unref( str->pixbuf );
+ }
+ g_free( str->description );
+ g_free( str->label );
+ g_free( str->format );
+ g_free( str );
+
+ return( NA_IOPTION( format ));
+}
+
+static void
+on_pixbuf_finalized( gpointer user_data /* ==NULL */, GObject *pixbuf )
+{
+ g_debug( "na_exporter_on_pixbuf_finalized: pixbuf=%p", ( void * ) pixbuf );
+}
+
+/*
* na_exporter_to_buffer:
* @pivot: the #NAPivot pivot for the running application.
* @item: a #NAObjectItem-derived object.
@@ -237,75 +379,6 @@ na_exporter_to_file( const NAPivot *pivot, const NAObjectItem *item, const gchar
return( export_uri );
}
-/*
- * Returns a GList of NAIExporterFormatExt structures which describes
- * the export formats provided by the exporter
- * If the provider only implements the v1 interface, we dynamically
- * allocate a new structure and convert the v1 to the v2.
- */
-static GList *
-exporter_get_formats( const NAIExporter *exporter )
-{
- GList *str_list;
- guint version;
-
- str_list = NULL;
-
- version = 1;
- if( NA_IEXPORTER_GET_INTERFACE( exporter )->get_version ){
- version = NA_IEXPORTER_GET_INTERFACE( exporter )->get_version( exporter );
- }
-
- if( NA_IEXPORTER_GET_INTERFACE( exporter )->get_formats ){
- if( version == 1 ){
-#ifdef NA_ENABLE_DEPRECATED
- const NAIExporterFormat * strv1;
- strv1 = NA_IEXPORTER_GET_INTERFACE( exporter )->get_formats( exporter );
- while( strv1->format ){
- NAIExporterFormatExt *strv2 = g_new0( NAIExporterFormatExt, 1 );
- strv2->version = 1;
- strv2->provider = ( NAIExporter * ) exporter;
- strv2->format = strv1->format;
- strv2->label = strv1->label;
- strv2->description = strv1->description;
- strv2->pixbuf = NULL;
- str_list = g_list_prepend( str_list, strv2 );
- strv1++;
- }
-#else
- ;
-#endif
- } else {
- str_list = NA_IEXPORTER_GET_INTERFACE( exporter )->get_formats( exporter );
- }
- }
-
- return( str_list );
-}
-
-/*
- * Free the list returned by exporter_get_formats() for this provider
- */
-static void
-exporter_free_formats( const NAIExporter *exporter, GList *str_list )
-{
- guint version;
-
- version = 1;
- if( NA_IEXPORTER_GET_INTERFACE( exporter )->get_version ){
- version = NA_IEXPORTER_GET_INTERFACE( exporter )->get_version( exporter );
- }
-
- if( version == 1 ){
- g_list_foreach( str_list, ( GFunc ) g_free, NULL );
- g_list_free( str_list );
-
- } else {
- g_return_if_fail( NA_IEXPORTER_GET_INTERFACE( exporter )->free_formats );
- NA_IEXPORTER_GET_INTERFACE( exporter )->free_formats( exporter, str_list );
- }
-}
-
static gchar *
exporter_get_name( const NAIExporter *exporter )
{
diff --git a/src/core/na-exporter.h b/src/core/na-exporter.h
index 59546de..f17d593 100644
--- a/src/core/na-exporter.h
+++ b/src/core/na-exporter.h
@@ -38,15 +38,24 @@
#include <api/na-object-api.h>
+#include "na-ioption.h"
#include "na-pivot.h"
G_BEGIN_DECLS
-GList *na_exporter_get_formats ( const NAPivot *pivot );
-void na_exporter_free_formats( GList *formats );
+typedef enum {
+ EXPORTER_FORMAT_NO_EXPORT = 1,
+ EXPORTER_FORMAT_ASK,
+}
+ NAExporterExportFormat;
-gchar *na_exporter_to_buffer( const NAPivot *pivot, const NAObjectItem *item, GQuark format, GSList **messages );
-gchar *na_exporter_to_file ( const NAPivot *pivot, const NAObjectItem *item, const gchar *folder_uri, GQuark format, GSList **messages );
+GList *na_exporter_get_formats ( const NAPivot *pivot );
+void na_exporter_free_formats ( GList *formats );
+
+NAIOption *na_exporter_get_ask_option( void );
+
+gchar *na_exporter_to_buffer( const NAPivot *pivot, const NAObjectItem *item, GQuark format, GSList **messages );
+gchar *na_exporter_to_file ( const NAPivot *pivot, const NAObjectItem *item, const gchar *folder_uri, GQuark format, GSList **messages );
G_END_DECLS
diff --git a/src/nact/Makefile.am b/src/nact/Makefile.am
index b1f2035..516feb9 100644
--- a/src/nact/Makefile.am
+++ b/src/nact/Makefile.am
@@ -86,8 +86,6 @@ nautilus_actions_config_tool_SOURCES = \
nact-confirm-logout.h \
nact-export-ask.c \
nact-export-ask.h \
- nact-export-format.c \
- nact-export-format.h \
nact-iaction-tab.c \
nact-iaction-tab.h \
nact-ibasenames-tab.c \
@@ -176,7 +174,6 @@ ui_files = \
$(NULL)
images_files = \
- export-format-ask.png \
import-mode-ask.png \
import-mode-no-import.png \
import-mode-override.png \
diff --git a/src/nact/nact-assistant-export.c b/src/nact/nact-assistant-export.c
index d28a903..cb04354 100644
--- a/src/nact/nact-assistant-export.c
+++ b/src/nact/nact-assistant-export.c
@@ -48,7 +48,6 @@
#include "nact-main-window.h"
#include "nact-assistant-export.h"
#include "nact-export-ask.h"
-#include "nact-export-format.h"
#include "nact-tree-view.h"
/* Export Assistant
@@ -234,7 +233,7 @@ ioptions_list_free_formats( const NAIOptionsList *instance, GtkWidget *container
static NAIOption *
ioptions_list_get_ask_option( const NAIOptionsList *instance, GtkWidget *container )
{
- return( nact_export_format_get_ask_option());
+ return( na_exporter_get_ask_option());
}
static void
diff --git a/src/nact/nact-preferences-editor.c b/src/nact/nact-preferences-editor.c
index a3c4e81..b7420df 100644
--- a/src/nact/nact-preferences-editor.c
+++ b/src/nact/nact-preferences-editor.c
@@ -48,7 +48,6 @@
#include <core/na-tokens.h>
#include "nact-application.h"
-#include "nact-export-format.h"
#include "base-gtk-utils.h"
#include "nact-schemes-list.h"
#include "nact-providers-list.h"
@@ -312,7 +311,7 @@ ioptions_list_get_ask_option( const NAIOptionsList *instance, GtkWidget *contain
option = NULL;
if( container == base_window_get_widget( BASE_WINDOW( instance ), "PreferencesExportFormatVBox" )){
- option = nact_export_format_get_ask_option();
+ option = na_exporter_get_ask_option();
} else if( container == base_window_get_widget( BASE_WINDOW( instance ), "PreferencesImportModeVBox" )){
option = na_importer_get_ask_mode();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]