2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2002 Hiroyuki Yamamoto and the Sylpheed-Claws Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 typedef struct _PluginWindow
34 GtkWidget *plugin_list;
35 GtkWidget *plugin_desc;
37 Plugin *selected_plugin;
40 static void close_cb(GtkButton *button, PluginWindow *pluginwindow)
42 gtk_widget_destroy(pluginwindow->window);
46 static void set_plugin_list(PluginWindow *pluginwindow)
48 GSList *plugins, *cur;
51 GtkCList *clist = GTK_CLIST(pluginwindow->plugin_list);
53 plugins = plugin_get_list();
54 gtk_clist_freeze(clist);
55 gtk_clist_clear(clist);
57 for(cur = plugins; cur != NULL; cur = g_slist_next(cur)) {
58 Plugin *plugin = (Plugin *) cur->data;
60 text[0] = (gchar *) plugin_get_name(plugin);
61 row = gtk_clist_append(clist, text);
62 gtk_clist_set_row_data(clist, row, plugin);
64 gtk_clist_thaw(clist);
67 static void select_row_cb(GtkCList *clist, gint row, gint column,
68 GdkEventButton *event, PluginWindow *pluginwindow)
71 GtkEditable *plugin_desc = GTK_EDITABLE(pluginwindow->plugin_desc);
75 plugin = (Plugin *) gtk_clist_get_row_data(clist, row);
76 pluginwindow->selected_plugin = plugin;
78 gtk_editable_delete_text(plugin_desc, 0, -1);
79 text = plugin_get_desc(plugin);
80 gtk_editable_insert_text(plugin_desc, text, strlen(text), &pos);
83 void pluginwindow_create()
85 PluginWindow *pluginwindow;
86 /* ---------------------- code made by glade ---------------------- */
90 GtkWidget *scrolledwindow2;
91 GtkWidget *plugin_list;
96 GtkWidget *scrolledwindow3;
97 GtkWidget *plugin_desc;
98 GtkWidget *hbuttonbox1;
100 GtkWidget *unload_btn;
101 GtkWidget *close_btn;
103 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
104 gtk_container_set_border_width(GTK_CONTAINER(window), 8);
105 gtk_window_set_default_size(GTK_WINDOW(window), 480, 300);
106 gtk_window_set_title(GTK_WINDOW(window), _("Plugins"));
107 gtk_window_set_position(GTK_WINDOW(window),
109 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
111 vbox1 = gtk_vbox_new(FALSE, 4);
112 gtk_widget_show(vbox1);
113 gtk_container_add(GTK_CONTAINER(window), vbox1);
115 hbox2 = gtk_hbox_new(FALSE, 8);
116 gtk_widget_show(hbox2);
117 gtk_box_pack_start(GTK_BOX(vbox1), hbox2, TRUE, TRUE, 0);
119 scrolledwindow2 = gtk_scrolled_window_new(NULL, NULL);
120 gtk_widget_show(scrolledwindow2);
121 gtk_box_pack_start(GTK_BOX(hbox2), scrolledwindow2, TRUE, TRUE, 0);
122 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
123 (scrolledwindow2), GTK_POLICY_NEVER,
126 plugin_list = gtk_clist_new(1);
127 gtk_widget_show(plugin_list);
128 gtk_container_add(GTK_CONTAINER(scrolledwindow2), plugin_list);
129 gtk_clist_set_column_width(GTK_CLIST(plugin_list), 0, 80);
130 gtk_clist_column_titles_show(GTK_CLIST(plugin_list));
132 label12 = gtk_label_new(_("Plugins"));
133 gtk_widget_show(label12);
134 gtk_clist_set_column_widget(GTK_CLIST(plugin_list), 0, label12);
135 gtk_label_set_justify(GTK_LABEL(label12), GTK_JUSTIFY_LEFT);
136 gtk_misc_set_alignment(GTK_MISC(label12), 7.45058e-09, 0.5);
138 vbox2 = gtk_vbox_new(FALSE, 0);
139 gtk_widget_show(vbox2);
140 gtk_box_pack_start(GTK_BOX(hbox2), vbox2, TRUE, TRUE, 0);
142 frame2 = gtk_frame_new(NULL);
143 gtk_widget_show(frame2);
144 gtk_box_pack_start(GTK_BOX(vbox2), frame2, FALSE, TRUE, 0);
146 label13 = gtk_label_new(_("Description"));
147 gtk_widget_show(label13);
148 gtk_container_add(GTK_CONTAINER(frame2), label13);
149 gtk_misc_set_alignment(GTK_MISC(label13), 7.45058e-09, 0.5);
150 gtk_misc_set_padding(GTK_MISC(label13), 2, 2);
152 scrolledwindow3 = gtk_scrolled_window_new(NULL, NULL);
153 gtk_widget_show(scrolledwindow3);
154 gtk_box_pack_start(GTK_BOX(vbox2), scrolledwindow3, TRUE, TRUE, 0);
155 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
156 (scrolledwindow3), GTK_POLICY_NEVER,
159 plugin_desc = gtk_text_new(NULL, NULL);
160 gtk_widget_show(plugin_desc);
161 gtk_container_add(GTK_CONTAINER(scrolledwindow3), plugin_desc);
163 hbuttonbox1 = gtk_hbutton_box_new();
164 gtk_widget_show(hbuttonbox1);
165 gtk_box_pack_start(GTK_BOX(vbox1), hbuttonbox1, FALSE, FALSE, 0);
166 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox1),
168 gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbuttonbox1), 0);
170 load_btn = gtk_button_new_with_label(_("Load Plugin"));
171 gtk_widget_show(load_btn);
172 gtk_container_add(GTK_CONTAINER(hbuttonbox1), load_btn);
173 GTK_WIDGET_SET_FLAGS(load_btn, GTK_CAN_DEFAULT);
175 unload_btn = gtk_button_new_with_label(_("Unload Plugin"));
176 gtk_widget_show(unload_btn);
177 gtk_container_add(GTK_CONTAINER(hbuttonbox1), unload_btn);
178 GTK_WIDGET_SET_FLAGS(unload_btn, GTK_CAN_DEFAULT);
180 close_btn = gtk_button_new_with_label(_("Close"));
181 gtk_widget_show(close_btn);
182 gtk_container_add(GTK_CONTAINER(hbuttonbox1), close_btn);
183 GTK_WIDGET_SET_FLAGS(close_btn, GTK_CAN_DEFAULT);
184 /* ----------------------------------------------------------- */
186 gtk_text_set_word_wrap(GTK_TEXT(plugin_desc), TRUE);
187 gtk_widget_set_sensitive(GTK_WIDGET(load_btn), FALSE);
188 gtk_widget_set_sensitive(GTK_WIDGET(unload_btn), FALSE);
190 pluginwindow = g_new0(PluginWindow, 1);
192 gtk_signal_connect(GTK_OBJECT(close_btn), "released",
193 GTK_SIGNAL_FUNC(close_cb), pluginwindow);
194 gtk_signal_connect(GTK_OBJECT(plugin_list), "select-row",
195 GTK_SIGNAL_FUNC(select_row_cb), pluginwindow);
197 pluginwindow->window = window;
198 pluginwindow->plugin_list = plugin_list;
199 pluginwindow->plugin_desc = plugin_desc;
200 pluginwindow->selected_plugin = NULL;
202 set_plugin_list(pluginwindow);
204 gtk_widget_show(window);