README: add deprecation notice
[nautilus-actions.git] / src / io-desktop / fma-desktop-formats.c
blob57ec11336b0f40b3df110a0cc36cd0f8da0ecfdc
1 /*
2 * FileManager-Actions
3 * A file-manager extension which offers configurable context menu actions.
5 * Copyright (C) 2005 The GNOME Foundation
6 * Copyright (C) 2006-2008 Frederic Ruaudel and others (see AUTHORS)
7 * Copyright (C) 2009-2015 Pierre Wieser and others (see AUTHORS)
9 * FileManager-Actions is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * FileManager-Actions is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with FileManager-Actions; see the file COPYING. If not, see
21 * <http://www.gnu.org/licenses/>.
23 * Authors:
24 * Frederic Ruaudel <grumz@grumz.net>
25 * Rodrigo Moya <rodrigo@gnome-db.org>
26 * Pierre Wieser <pwieser@trychlos.org>
27 * ... and many others (see AUTHORS)
30 #ifdef HAVE_CONFIG_H
31 #include <config.h>
32 #endif
34 #include <glib/gi18n.h>
35 #include <gtk/gtk.h>
36 #include <libintl.h>
38 #include <api/fma-iexporter.h>
40 #include "fma-desktop-formats.h"
42 typedef struct {
43 gchar *format;
44 gchar *label;
45 gchar *description;
46 gchar *image;
48 sExportFormat;
50 static sExportFormat st_desktop_formats[] = {
52 /* DESKTOP_V1: the initial desktop format as described in
53 * http://www.filemanager-actions.org/?q=node/377
55 { FMA_DESKTOP_FORMAT_V1,
56 N_( "Export as a ._desktop file" ),
57 N_( "This format has been introduced with v 3.0 serie, " \
58 "and should be your newly preferred format when exporting items.\n" \
59 "It let you easily share your actions with the whole world, " \
60 "including with users of other desktop environments, " \
61 "as long as their own application implements the DES-EMA specification " \
62 "which describes this format.\n" \
63 "The exported .desktop file may later be imported via :\n" \
64 "- Import assistant of the FileManager-Actions Configuration Tool,\n" \
65 "- drag-n-drop into the FileManager-Actions Configuration Tool,\n" \
66 "- or by copying it into a XDG_DATA_DIRS/file-manager/actions directory." ),
67 "fma-desktop-export.png" },
69 { NULL }
72 #if 0
73 static void on_pixbuf_finalized( const FMAIExporter* exporter, GObject *pixbuf );
74 #endif
76 /**
77 * fma_desktop_formats_get_formats:
78 * @exporter: this #FMAIExporter provider.
80 * Returns: a #GList of the #FMAIExporterFormatv2 supported export formats.
82 * This list should be fma_desktop_formats_free_formats() by the caller.
84 * Since: 3.2
86 GList *
87 fma_desktop_formats_get_formats( const FMAIExporter* exporter )
89 #if 0
90 static const gchar *thisfn = "fma_desktop_formats_get_formats";
91 #endif
92 GList *str_list;
93 FMAIExporterFormatv2 *str;
94 guint i;
95 gint width, height;
96 gchar *fname;
98 str_list = NULL;
100 if( !gtk_icon_size_lookup( GTK_ICON_SIZE_DIALOG, &width, &height )){
101 width = height = 48;
104 for( i = 0 ; st_desktop_formats[i].format ; ++i ){
105 str = g_new0( FMAIExporterFormatv2, 1 );
106 str->version = 2;
107 str->provider = FMA_IEXPORTER( exporter );
108 str->format = g_strdup( st_desktop_formats[i].format );
109 str->label = g_strdup( gettext( st_desktop_formats[i].label ));
110 str->description = g_strdup( gettext( st_desktop_formats[i].description ));
111 if( st_desktop_formats[i].image ){
112 fname = g_strdup_printf( "%s/%s", PROVIDER_DATADIR, st_desktop_formats[i].image );
113 str->pixbuf = gdk_pixbuf_new_from_file_at_size( fname, width, height, NULL );
114 g_free( fname );
115 #if 0
116 /* do not set weak reference on a graphical object provided by a plugin
117 * if the windows does not have its own builder, it may happens that the
118 * graphical object be finalized when destroying toplevels at common
119 * builder finalization time, and so after the plugins have been shutdown
121 if( str->pixbuf ){
122 g_debug( "%s: allocating pixbuf at %p", thisfn, str->pixbuf );
123 g_object_weak_ref( G_OBJECT( str->pixbuf ), ( GWeakNotify ) on_pixbuf_finalized, ( gpointer ) exporter );
125 #endif
127 str_list = g_list_prepend( str_list, str );
130 return( str_list );
133 #if 0
134 static void
135 on_pixbuf_finalized( const FMAIExporter* exporter, GObject *pixbuf )
137 g_debug( "fma_desktop_formats_on_pixbuf_finalized: exporter=%p, pixbuf=%p", ( void * ) exporter, ( void * ) pixbuf );
139 #endif
142 * fma_desktop_formats_free_formats:
143 * @formats: a #GList to be freed.
145 * Returns: a #GList of the #FMAIExporterFormatv2 supported export formats.
147 * This list should be nadp_format_free_formats() by the caller.
149 * Since: 3.2
151 void
152 fma_desktop_formats_free_formats( GList *formats )
154 GList *is;
155 FMAIExporterFormatv2 *str;
157 for( is = formats ; is ; is = is->next ){
158 str = ( FMAIExporterFormatv2 * ) is->data;
159 g_free( str->format );
160 g_free( str->label );
161 g_free( str->description );
162 if( str->pixbuf ){
163 g_object_unref( str->pixbuf );
165 g_free( str );
168 g_list_free( formats );