aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugin-manager
diff options
context:
space:
mode:
authorSankar P <psankar@novell.com>2007-05-11 15:04:04 +0800
committerSankarasivasubramanian Pasupathilingam <psankar@src.gnome.org>2007-05-11 15:04:04 +0800
commit679e7a635332391285f8c8c6c89a4d3372c66c2d (patch)
treef98a24895e7aef07044b05138100f7cf69147a6a /plugins/plugin-manager
parente18f01469d382189d9d9365a8c79828081e09d1d (diff)
downloadgsoc2013-evolution-679e7a635332391285f8c8c6c89a4d3372c66c2d.tar.gz
gsoc2013-evolution-679e7a635332391285f8c8c6c89a4d3372c66c2d.tar.zst
gsoc2013-evolution-679e7a635332391285f8c8c6c89a4d3372c66c2d.zip
Committed on behalf of Gilles Dartiguelongue <dartigug@esiee.fr>
2007-05-11 Sankar P <psankar@novell.com> * Committed on behalf of Gilles Dartiguelongue <dartigug@esiee.fr> * plugin-manager.c: (eppm_show_plugin), (eppm_selection_changed), (eppm_enable_toggled), (eppm_free), (org_gnome_plugin_manager_manage): Sort the list of plugins based on name so that it is easy to use svn path=/trunk/; revision=33505
Diffstat (limited to 'plugins/plugin-manager')
-rw-r--r--plugins/plugin-manager/ChangeLog9
-rw-r--r--plugins/plugin-manager/plugin-manager.c171
2 files changed, 127 insertions, 53 deletions
diff --git a/plugins/plugin-manager/ChangeLog b/plugins/plugin-manager/ChangeLog
index 390ec09b2f..b4484ac22a 100644
--- a/plugins/plugin-manager/ChangeLog
+++ b/plugins/plugin-manager/ChangeLog
@@ -1,3 +1,12 @@
+2007-05-11 Sankar P <psankar@novell.com>
+
+ * Committed on behalf of Gilles Dartiguelongue <dartigug@esiee.fr>
+
+ * plugin-manager.c: (eppm_show_plugin), (eppm_selection_changed),
+ (eppm_enable_toggled), (eppm_free),
+ (org_gnome_plugin_manager_manage):
+ Sort the list of plugins based on name so that it is easy to use
+
2006-01-25 Rajeev ramanathan <rajeevramanathan_2004@yahoo.co.in>
** Fixes Bug #314913
diff --git a/plugins/plugin-manager/plugin-manager.c b/plugins/plugin-manager/plugin-manager.c
index d4f59057e8..9e41716b52 100644
--- a/plugins/plugin-manager/plugin-manager.c
+++ b/plugins/plugin-manager/plugin-manager.c
@@ -16,14 +16,17 @@
#include <gtk/gtklabel.h>
#include <gtk/gtktreeview.h>
+#include <gtk/gtktreemodel.h>
+#include <gtk/gtktreesortable.h>
+#include <gtk/gtktreemodelsort.h>
#include <gtk/gtktreeselection.h>
#include <gtk/gtkliststore.h>
#include <gtk/gtkdialog.h>
#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtktable.h>
#include <gtk/gtkcellrenderertoggle.h>
#include <gtk/gtkcellrenderertext.h>
#include <gtk/gtkstock.h>
+#include <gtk/gtkvbox.h>
#include <gtk/gtkhbox.h>
#include "e-util/e-plugin.h"
@@ -36,6 +39,13 @@ enum {
LABEL_LAST
};
+enum
+{
+ COL_PLUGIN_ENABLED = 0,
+ COL_PLUGIN_NAME,
+ COL_PLUGIN_DATA
+};
+
static struct {
const char *label;
} label_info[LABEL_LAST] = {
@@ -47,10 +57,9 @@ static struct {
typedef struct _Manager Manager;
struct _Manager {
GtkDialog *dialog;
- GtkTreeView *tree;
- GtkListStore *model;
+ GtkTreeView *treeview;
+ GtkTreeModel *model;
- GtkTable *table;
GtkLabel *labels[LABEL_LAST];
GtkLabel *items[LABEL_LAST];
@@ -71,8 +80,13 @@ eppm_set_label(GtkLabel *l, const char *v)
static void
eppm_show_plugin(Manager *m, EPlugin *ep)
{
+ char *string = NULL;
+
if (ep) {
- eppm_set_label(m->items[LABEL_NAME], ep->name);
+ string = g_strdup_printf("<span size=\"x-large\">%s</span>", ep->name);
+ gtk_label_set_markup(GTK_LABEL(m->items[LABEL_NAME]), string);
+ g_free(string);
+
if (ep->authors) {
GSList *l = ep->authors;
GString *out = g_string_new("");
@@ -97,13 +111,11 @@ eppm_show_plugin(Manager *m, EPlugin *ep)
}
eppm_set_label(m->items[LABEL_DESCRIPTION], ep->description);
- gtk_widget_set_sensitive((GtkWidget *)m->table, TRUE);
} else {
int i;
for (i=0;i<LABEL_LAST;i++)
gtk_label_set_label(m->items[i], "");
- gtk_widget_set_sensitive((GtkWidget *)m->table, FALSE);
}
}
@@ -116,7 +128,7 @@ eppm_selection_changed(GtkTreeSelection *selection, Manager *m)
if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
EPlugin *ep;
- gtk_tree_model_get(model, &iter, 2, &ep, -1);
+ gtk_tree_model_get(model, &iter, COL_PLUGIN_DATA, &ep, -1);
eppm_show_plugin(m, ep);
} else {
eppm_show_plugin(m, NULL);
@@ -124,18 +136,25 @@ eppm_selection_changed(GtkTreeSelection *selection, Manager *m)
}
static void
-eppm_enable_toggled(GtkCellRendererToggle *renderer, char *arg1, Manager *m)
+eppm_enable_toggled(GtkCellRendererToggle *renderer, const char *path_string, Manager *m)
{
GtkTreePath *path;
GtkTreeIter iter;
EPlugin *plugin;
- path = gtk_tree_path_new_from_string(arg1);
- if (gtk_tree_model_get_iter((GtkTreeModel *)m->model, &iter, path)) {
- gtk_tree_model_get((GtkTreeModel *)m->model, &iter, 2, &plugin, -1);
+ path = gtk_tree_path_new_from_string(path_string);
+
+ if (gtk_tree_model_get_iter(m->model, &iter, path)) {
+ gtk_tree_model_get(m->model, &iter, COL_PLUGIN_DATA, &plugin, -1);
e_plugin_enable(plugin, !plugin->enabled);
- gtk_list_store_set(m->model, &iter, 1, plugin->enabled, -1);
+
+ g_warning( plugin->name );
+
+ gtk_list_store_set(GTK_LIST_STORE(m->model), &iter,
+ COL_PLUGIN_ENABLED, plugin->enabled,
+ -1);
}
+
gtk_tree_path_free(path);
}
@@ -149,6 +168,8 @@ eppm_free(void *data)
g_object_unref(l->data);
g_slist_free(m->plugins);
+ g_object_unref(m->model);
+
g_free(m);
}
@@ -165,6 +186,7 @@ org_gnome_plugin_manager_manage(void *ep, ESMenuTargetShell *t)
Manager *m;
int i;
GtkWidget *hbox, *w;
+ GtkListStore *store;
GtkTreeSelection *selection;
GtkCellRenderer *renderer;
GSList *l;
@@ -180,8 +202,8 @@ org_gnome_plugin_manager_manage(void *ep, ESMenuTargetShell *t)
m->dialog = (GtkDialog *)gtk_dialog_new_with_buttons(_("Plugin Manager"),
(GtkWindow *)gtk_widget_get_toplevel(t->target.widget),
GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
- /* this isn't actually big enough, but oh well, i'll work out resizing later */
+ GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL);
+
gtk_window_set_default_size((GtkWindow *)m->dialog, 640, 400);
g_object_set((GObject *)m->dialog, "has_separator", FALSE, NULL);
@@ -189,77 +211,120 @@ org_gnome_plugin_manager_manage(void *ep, ESMenuTargetShell *t)
gtk_container_set_border_width((GtkContainer *)hbox, 12);
gtk_box_pack_start((GtkBox *)m->dialog->vbox, hbox, TRUE, TRUE, 0);
+ char *string;
+ string = g_strdup_printf("<i>%s</i>", _("Note: Some changes will not take effect until restart"));
+
w = g_object_new(gtk_label_get_type(),
- "label", _("Note: Some changes will not take effect until restart"),
- "wrap", TRUE,
+ "label", string,
+ "wrap", FALSE,
+ "use_markup", TRUE,
NULL);
gtk_widget_show(w);
+
gtk_box_pack_start((GtkBox *)m->dialog->vbox, w, FALSE, TRUE, 6);
- m->tree = (GtkTreeView *)gtk_tree_view_new();
+ store = gtk_list_store_new(3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER);
+
+ /* fill store */
+ m->plugins = e_plugin_list_plugins();
+
+ for (l=m->plugins;l;l=g_slist_next(l)) {
+ EPlugin *ep = l->data;
+ GtkTreeIter iter;
+
+ /* hide ourselves always */
+ if (!strcmp(ep->id, "org.gnome.evolution.plugin.manager"))
+ continue;
+
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ COL_PLUGIN_ENABLED, ep->enabled,
+ COL_PLUGIN_NAME, ep->name?ep->name:ep->id,
+ COL_PLUGIN_DATA, ep,
+ -1);
+ }
+
+ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE (store),
+ COL_PLUGIN_NAME, GTK_SORT_ASCENDING);
+
+ /* setup the treeview */
+ m->treeview = (GtkTreeView *)gtk_tree_view_new();
+ gtk_tree_view_set_reorderable(GTK_TREE_VIEW(m->treeview), FALSE);
+ gtk_tree_view_set_model(m->treeview, GTK_TREE_MODEL (store));
+ gtk_tree_view_set_search_column(m->treeview, COL_PLUGIN_NAME);
+ gtk_tree_view_set_headers_visible(m->treeview, TRUE);
+
+ m->model = GTK_TREE_MODEL(store);
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_insert_column_with_attributes(m->tree, -1, _("Plugin"), renderer, "text", 0, NULL);
renderer = gtk_cell_renderer_toggle_new();
- /*g_object_set((GObject *)renderer, "activatable", TRUE, NULL);*/
- gtk_tree_view_insert_column_with_attributes(m->tree, -1, _("Enabled"), renderer, "active", 1, NULL);
+ gtk_tree_view_insert_column_with_attributes(m->treeview,
+ COL_PLUGIN_ENABLED, _("Enabled"),
+ renderer, "active", COL_PLUGIN_ENABLED,
+ NULL);
g_signal_connect(renderer, "toggled", G_CALLBACK(eppm_enable_toggled), m);
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_insert_column_with_attributes(m->treeview,
+ COL_PLUGIN_NAME, _("Plugin"),
+ renderer, "text", COL_PLUGIN_NAME,
+ NULL);
+
+ /* set sort column */
+ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(m->model), COL_PLUGIN_NAME, GTK_SORT_ASCENDING);
+
w = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy((GtkScrolledWindow *)w, GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
gtk_scrolled_window_set_shadow_type((GtkScrolledWindow *)w, GTK_SHADOW_IN);
- gtk_container_add((GtkContainer *)w, (GtkWidget *)m->tree);
+ gtk_container_add((GtkContainer *)w, (GtkWidget *)m->treeview);
gtk_box_pack_start((GtkBox *)hbox, (GtkWidget *)w, FALSE, TRUE, 6);
- m->table = (GtkTable *)gtk_table_new(LABEL_LAST, 2, FALSE);
- gtk_table_set_col_spacings(m->table, 6);
- gtk_table_set_row_spacings(m->table, 6);
- for (i=0;i<LABEL_LAST;i++) {
+ GtkWidget *vbox;
+ vbox = gtk_vbox_new(FALSE, 0);
+ gtk_box_pack_start((GtkBox *)hbox, vbox, TRUE, TRUE, 6);
+
+ /* this is plugin's name label */
+ GtkWidget *subvbox;
+ subvbox = gtk_vbox_new(FALSE, 0);
+ m->items[0] = g_object_new(gtk_label_get_type(),
+ "wrap", TRUE,
+ "selectable", FALSE,
+ "xalign", 0.0,
+ "yalign", 0.0, NULL);
+ gtk_box_pack_start((GtkBox *)subvbox, (GtkWidget *)m->items[0], TRUE, TRUE, 0);
+ gtk_box_pack_start((GtkBox *)vbox, subvbox, FALSE, TRUE, 6);
+
+ /* this is every other data */
+ for (i=1;i<LABEL_LAST;i++) {
+ subvbox = gtk_vbox_new(FALSE, 0);
+
char *markup;
- markup = g_strdup_printf("<span weight=\"bold\">%s</span>", _(label_info[i].label));
+ markup = g_strdup_printf("<span weight=\"bold\">%s :</span>", _(label_info[i].label));
m->labels[i] = g_object_new(gtk_label_get_type(),
"label", markup,
"use_markup", TRUE,
- "xalign", 1.0,
+ "xalign", 0.0,
"yalign", 0.0, NULL);
+ gtk_box_pack_start((GtkBox *)subvbox, (GtkWidget *)m->labels[i], FALSE, TRUE, 0);
g_free(markup);
- gtk_table_attach(m->table, (GtkWidget *)m->labels[i], 0, 1, i, i+1, GTK_FILL, GTK_FILL, 0, 0);
+
m->items[i] = g_object_new(gtk_label_get_type(),
"wrap", TRUE,
"selectable", TRUE,
"xalign", 0.0,
"yalign", 0.0, NULL);
- gtk_table_attach(m->table, (GtkWidget *)m->items[i], 1, 2, i, i+1, GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0);
+ gtk_box_pack_start((GtkBox *)subvbox, (GtkWidget *)m->items[i], TRUE, TRUE, 0);
+
+ gtk_box_pack_start((GtkBox *)vbox, subvbox, FALSE, TRUE, 6);
}
- gtk_box_pack_start((GtkBox *)hbox, (GtkWidget *)m->table, TRUE, TRUE, 6);
gtk_widget_show_all(hbox);
- selection = gtk_tree_view_get_selection(m->tree);
+ selection = gtk_tree_view_get_selection(m->treeview);
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
g_signal_connect(selection, "changed", G_CALLBACK(eppm_selection_changed), m);
- m->plugins = e_plugin_list_plugins();
- m->model = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_POINTER);
-
- for (l=m->plugins;l;l=g_slist_next(l)) {
- EPlugin *ep = l->data;
- GtkTreeIter iter;
-
- /* hide ourselves always */
- if (!strcmp(ep->id, "org.gnome.evolution.plugin.manager"))
- continue;
-
- gtk_list_store_append(m->model, &iter);
- gtk_list_store_set(m->model, &iter,
- 0, ep->name?ep->name:ep->id,
- 1, ep->enabled,
- 2, ep,
- -1);
- }
- gtk_tree_view_set_model(m->tree, (GtkTreeModel *)m->model);
- atk_object_set_name (gtk_widget_get_accessible ((GtkWidget *)m->tree), _("Plugin"));
+ atk_object_set_name (gtk_widget_get_accessible ((GtkWidget *)m->treeview), _("Plugin"));
g_object_set_data_full((GObject *)m->dialog, "plugin-manager", m, eppm_free);
g_signal_connect(m->dialog, "response", G_CALLBACK(eppm_response), m);