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/>.
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)
34 #include <glib/gi18n.h>
38 #include <api/fma-iexporter.h>
40 #include "fma-desktop-formats.h"
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" },
73 static void on_pixbuf_finalized( const FMAIExporter
* exporter
, GObject
*pixbuf
);
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.
87 fma_desktop_formats_get_formats( const FMAIExporter
* exporter
)
90 static const gchar
*thisfn
= "fma_desktop_formats_get_formats";
93 FMAIExporterFormatv2
*str
;
100 if( !gtk_icon_size_lookup( GTK_ICON_SIZE_DIALOG
, &width
, &height
)){
104 for( i
= 0 ; st_desktop_formats
[i
].format
; ++i
){
105 str
= g_new0( FMAIExporterFormatv2
, 1 );
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
);
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
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
);
127 str_list
= g_list_prepend( str_list
, str
);
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
);
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.
152 fma_desktop_formats_free_formats( GList
*formats
)
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
);
163 g_object_unref( str
->pixbuf
);
168 g_list_free( formats
);