2
GNOME Commander - A GNOME based file manager
3
Copyright (C) 2001-2006 Marcus Bjurman
4
Copyright (C) 2007-2009 Piotr Eljasiak
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
23
#include <libgcmd/libgcmd.h>
24
#include "test-plugin.h"
25
#include "test-plugin.xpm"
27
#define NAME "Example"
28
#define COPYRIGHT "Copyright \xc2\xa9 2003-2006 Marcus Bjurman"
29
#define AUTHOR "Marcus Bjurman <marbj499@student.liu.se>"
30
#define WEBPAGE "http://www.nongnu.org/gcmd"
33
static PluginInfo plugin_nfo = {
34
GNOME_CMD_PLUGIN_SYSTEM_CURRENT_VERSION,
45
struct _TestPluginPrivate
48
gchar dummy; // Sun's forte compiler does not like empty structs
52
static GnomeCmdPluginClass *parent_class = NULL;
55
static void on_dummy (GtkMenuItem *item, gpointer data)
57
gnome_ok_dialog ("Test plugin dummy operation");
61
static GtkWidget *create_menu_item (const gchar *name, gboolean show_pixmap, GtkSignalFunc callback, gpointer data)
63
GtkWidget *item, *label;
67
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) test_plugin_xpm);
68
GtkWidget *pixmap = gtk_image_new_from_pixbuf (pixbuf);
69
g_object_unref (G_OBJECT (pixbuf));
70
item = gtk_image_menu_item_new ();
73
gtk_widget_show (pixmap);
74
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), pixmap);
78
item = gtk_menu_item_new ();
80
gtk_widget_show (item);
82
// Create the contents of the menu item
83
label = gtk_label_new (name);
84
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
85
gtk_widget_show (label);
86
gtk_container_add (GTK_CONTAINER (item), label);
88
// Connect to the signal and set user data
89
gtk_object_set_data (GTK_OBJECT (item), GNOMEUIINFO_KEY_UIDATA, data);
92
gtk_signal_connect (GTK_OBJECT (item), "activate", callback, data);
98
static GtkWidget *create_main_menu (GnomeCmdPlugin *plugin, GnomeCmdState *state)
100
GtkWidget *item, *child;
103
submenu = GTK_MENU (gtk_menu_new ());
104
item = create_menu_item ("Test", FALSE, NULL, NULL);
105
gtk_menu_item_set_submenu (GTK_MENU_ITEM (item),
106
GTK_WIDGET (submenu));
108
child = create_menu_item ("Test plugin dummy operation", FALSE, GTK_SIGNAL_FUNC (on_dummy), state);
109
gtk_menu_append (submenu, child);
115
static GList *create_popup_menu_items (GnomeCmdPlugin *plugin, GnomeCmdState *state)
117
GtkWidget *item = create_menu_item ("Test plugin dummy operation", TRUE, GTK_SIGNAL_FUNC (on_dummy), state);
119
return g_list_append (NULL, item);
123
static void update_main_menu_state (GnomeCmdPlugin *plugin, GnomeCmdState *state)
128
static void configure (GnomeCmdPlugin *plugin)
130
gnome_ok_dialog ("Test plugin configuration dialog");
136
/*******************************
137
* Gtk class implementation
138
*******************************/
140
static void destroy (GtkObject *object)
142
//TestPlugin *plugin = TEST_PLUGIN (object);
144
if (GTK_OBJECT_CLASS (parent_class)->destroy)
145
(*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
149
static void class_init (TestPluginClass *klass)
151
GtkObjectClass *object_class;
152
GnomeCmdPluginClass *plugin_class;
154
object_class = GTK_OBJECT_CLASS (klass);
155
plugin_class = GNOME_CMD_PLUGIN_CLASS (klass);
156
parent_class = gtk_type_class (gnome_cmd_plugin_get_type ());
158
object_class->destroy = destroy;
160
plugin_class->create_main_menu = create_main_menu;
161
plugin_class->create_popup_menu_items = create_popup_menu_items;
162
plugin_class->update_main_menu_state = update_main_menu_state;
163
plugin_class->configure = configure;
167
static void init (TestPlugin *plugin)
169
plugin->priv = g_new (TestPluginPrivate, 1);
174
/***********************************
176
***********************************/
178
GtkType test_plugin_get_type ()
180
static GtkType type = 0;
188
sizeof (TestPluginClass),
189
(GtkClassInitFunc) class_init,
190
(GtkObjectInitFunc) init,
191
/* reserved_1 */ NULL,
192
/* reserved_2 */ NULL,
193
(GtkClassInitFunc) NULL
196
type = gtk_type_unique (gnome_cmd_plugin_get_type (), &info);
202
GnomeCmdPlugin *test_plugin_new ()
204
TestPlugin *plugin = gtk_type_new (test_plugin_get_type ());
206
return GNOME_CMD_PLUGIN (plugin);
210
GnomeCmdPlugin *create_plugin ()
212
return test_plugin_new ();
216
PluginInfo *get_plugin_info ()
218
if (!plugin_nfo.authors)
220
plugin_nfo.authors = g_new0 (gchar *, 2);
221
plugin_nfo.authors[0] = AUTHOR;
222
plugin_nfo.authors[1] = NULL;
223
plugin_nfo.comments = g_strdup (_("This is an example plugin that is mostly useful as a "
224
"simple example for aspiring plugin hackers"));