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 "fma-xml-formats.h"
48 static NaxmlExportFormat fma_xml_formats
[] = {
50 /* GCONF_SCHEMA_V1: a schema with owner, short and long descriptions;
51 * each action has its own schema addressed by the id
52 * (historical format up to v1.10.x serie)
54 { FMA_XML_FORMAT_GCONF_SCHEMA_V1
,
55 N_( "Export as a _full GConf schema file" ),
56 N_( "This used to be the historical export format.\n" \
57 "The exported schema file may later be imported via :\n" \
58 "- Import assistant of the FileManager-Actions Configuration Tool,\n" \
59 "- drag-n-drop into the FileManager-Actions Configuration Tool,\n" \
60 "- or via the gconftool-2 --import-schema-file command-line tool." ),
61 "fma-xml-export-schemas-v1.png" },
63 /* GCONF_SCHEMA_V2: the lightest schema still compatible with gconftool-2 --install-schema-file
64 * (no owner, no short nor long descriptions) - introduced in v 1.11
66 { FMA_XML_FORMAT_GCONF_SCHEMA_V2
,
67 N_( "Export as a _light GConf schema (v2) file" ),
68 N_( "This format has been introduced in v 1.11 serie.\n" \
69 "This is the lightest schema still compatible with GConf command-line tools, " \
70 "while keeping backward compatibility with the FileManager-Actions Configuration " \
71 "Tool oldest versions.\n"
72 "The exported schema file may later be imported via :\n" \
73 "- Import assistant of the FileManager-Actions Configuration Tool,\n" \
74 "- drag-n-drop into the FileManager-Actions Configuration Tool,\n" \
75 "- or via the gconftool-2 --import-schema-file command-line tool." ),
76 "fma-xml-export-schemas-v2.png" },
78 /* GCONF_ENTRY: not a schema, but a dump of the GConf entry
79 * introduced in v 1.11
81 { FMA_XML_FORMAT_GCONF_ENTRY
,
82 N_( "Export as a GConf _dump file" ),
83 N_( "This format has been introduced in v 1.11 serie.\n" \
84 "Tough not backward compatible with FileManager-Actions " \
85 "Configuration Tool versions previous to 1.11, " \
86 "it may still be imported via standard GConf command-line tools.\n" \
87 "The exported dump file may later be imported via :\n" \
88 "- Import assistant of the FileManager-Actions Configuration Tool (1.11 and above),\n" \
89 "- drag-n-drop into the FileManager-Actions Configuration Tool (1.11 and above),\n" \
90 "- or via the gconftool-2 --load command-line tool." ),
91 "fma-xml-export-dump.png" },
97 static void on_pixbuf_finalized( const FMAIExporter
* exporter
, GObject
*pixbuf
);
101 * fma_xml_formats_get_formats:
102 * @exporter: this #FMAIExporter provider.
104 * Returns: a #GList of the #FMAIExporterFormatv2 supported export formats.
106 * This list should be fma_xml_formats_free_formats() by the caller.
111 fma_xml_formats_get_formats( const FMAIExporter
* exporter
)
114 static const gchar
*thisfn
= "fma_xml_formats_get_formats";
117 FMAIExporterFormatv2
*str
;
124 if( !gtk_icon_size_lookup( GTK_ICON_SIZE_DIALOG
, &width
, &height
)){
128 for( i
= 0 ; fma_xml_formats
[i
].format
; ++i
){
129 str
= g_new0( FMAIExporterFormatv2
, 1 );
131 str
->provider
= FMA_IEXPORTER( exporter
);
132 str
->format
= g_strdup( fma_xml_formats
[i
].format
);
133 str
->label
= g_strdup( gettext( fma_xml_formats
[i
].label
));
134 str
->description
= g_strdup( gettext( fma_xml_formats
[i
].description
));
135 if( fma_xml_formats
[i
].image
){
136 fname
= g_strdup_printf( "%s/%s", PROVIDER_DATADIR
, fma_xml_formats
[i
].image
);
137 str
->pixbuf
= gdk_pixbuf_new_from_file_at_size( fname
, width
, height
, NULL
);
140 /* do not set weak reference on a graphical object provided by a plugin
141 * if the windows does not have its own builder, it may happens that the
142 * graphical object be finalized when destroying toplevels at common
143 * builder finalization time, and so after the plugins have been shutdown
146 g_debug( "%s: allocating pixbuf at %p", thisfn
, str
->pixbuf
);
147 g_object_weak_ref( G_OBJECT( str
->pixbuf
), ( GWeakNotify
) on_pixbuf_finalized
, ( gpointer
) exporter
);
151 str_list
= g_list_prepend( str_list
, str
);
159 on_pixbuf_finalized( const FMAIExporter
* exporter
, GObject
*pixbuf
)
161 g_debug( "fma_xml_formats_on_pixbuf_finalized: exporter=%p, pixbuf=%p", ( void * ) exporter
, ( void * ) pixbuf
);
166 * fma_xml_formats_free_formats:
167 * @formats: a #GList to be freed.
169 * Releases the list of managed formats.
174 fma_xml_formats_free_formats( GList
*formats
)
177 FMAIExporterFormatv2
*str
;
179 for( is
= formats
; is
; is
= is
->next
){
180 str
= ( FMAIExporterFormatv2
* ) is
->data
;
181 g_free( str
->format
);
182 g_free( str
->label
);
183 g_free( str
->description
);
185 g_object_unref( str
->pixbuf
);
190 g_list_free( formats
);