Mercurial > pidgin
changeset 11740:7e0ad3b6882a
[gaim-migrate @ 14031]
Moved Plugins to Tools > Plugins
Made iChat Timestamp plugin instant apply
Made Proxy options visible only when needed.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sun, 23 Oct 2005 07:12:12 +0000 |
parents | a25be0e70a67 |
children | 8034f752feae |
files | plugins/timestamp.c src/gtkblist.c src/gtkplugin.c src/gtkplugin.h src/gtkprefs.c |
diffstat | 5 files changed, 288 insertions(+), 395 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/timestamp.c Sun Oct 23 06:46:07 2005 +0000 +++ b/plugins/timestamp.c Sun Oct 23 07:12:12 2005 +0000 @@ -170,7 +170,7 @@ -static void set_timestamp(GtkWidget *button, GtkWidget *spinner) { +static void set_timestamp(GtkWidget *spinner, void *null) { int tm; tm = 0; @@ -194,7 +194,7 @@ GtkWidget *frame, *label; GtkWidget *vbox, *hbox; GtkAdjustment *adj; - GtkWidget *spinner, *button; + GtkWidget *spinner; ret = gtk_vbox_new(FALSE, 18); gtk_container_set_border_width (GTK_CONTAINER (ret), 12); @@ -212,18 +212,10 @@ adj = (GtkAdjustment *)gtk_adjustment_new(interval/(60*1000), 1, G_MAXINT, 1, 0, 0); spinner = gtk_spin_button_new(adj, 0, 0); gtk_box_pack_start(GTK_BOX(hbox), spinner, TRUE, TRUE, 0); - + g_signal_connect(G_OBJECT(spinner), "value-changed", G_CALLBACK(set_timestamp), NULL); label = gtk_label_new(_("minutes.")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); - hbox = gtk_hbox_new(TRUE, 5); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); - - button = gtk_button_new_with_mnemonic(_("_Apply")); - gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5); - g_signal_connect(G_OBJECT(button), "clicked", - G_CALLBACK(set_timestamp), spinner); - gtk_widget_show_all(ret); return ret; }
--- a/src/gtkblist.c Sun Oct 23 06:46:07 2005 +0000 +++ b/src/gtkblist.c Sun Oct 23 07:12:12 2005 +0000 @@ -47,6 +47,7 @@ #include "gtkft.h" #include "gtklog.h" #include "gtkpounce.h" +#include "gtkplugin.h" #include "gtkprefs.h" #include "gtkprivacy.h" #include "gtkroomlist.h" @@ -2338,10 +2339,10 @@ { N_("/_Tools"), NULL, NULL, 0, "<Branch>" }, { N_("/Tools/Buddy _Pounce"), NULL, NULL, 0, "<Branch>" }, { N_("/Tools/Account Ac_tions"), NULL, NULL, 0, "<Branch>" }, - { N_("/Tools/Pl_ugin Actions"), NULL, NULL, 0, "<Branch>" }, { "/Tools/sep1", NULL, NULL, 0, "<Separator>" }, { N_("/Tools/A_ccounts"), "<CTL>A", gaim_gtk_accounts_window_show, 0, "<StockItem>", GAIM_STOCK_ACCOUNTS }, { N_("/Tools/Pr_eferences"), "<CTL>P", gaim_gtk_prefs_show, 0, "<StockItem>", GTK_STOCK_PREFERENCES }, + { N_("/Tools/P_lugins"), NULL, gaim_gtk_plugin_dialog_show, 0, NULL }, { N_("/Tools/Pr_ivacy"), NULL, gaim_gtk_privacy_dialog_show, 0, "<StockItem>", GTK_STOCK_DIALOG_ERROR }, { N_("/Tools/_File Transfers"), "<CTL>T", gaim_show_xfer_dialog, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, { N_("/Tools/R_oom List"), NULL, gaim_gtk_roomlist_dialog_show, 0, "<StockItem>", GTK_STOCK_INDEX },
--- a/src/gtkplugin.c Sun Oct 23 06:46:07 2005 +0000 +++ b/src/gtkplugin.c Sun Oct 23 07:12:12 2005 +0000 @@ -22,6 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "internal.h" #include "gtkgaim.h" #include "gtkplugin.h" #include "debug.h" @@ -29,6 +30,9 @@ #include <string.h> +static GtkWidget *plugin_dialog = NULL; +static GtkWidget *plugin_details = NULL; +static GtkWidget *pref_button = NULL; GtkWidget * gaim_gtk_plugin_get_config_frame(GaimPlugin *plugin) { @@ -68,3 +72,268 @@ gaim_prefs_set_string_list("/gaim/gtk/plugins/loaded", files); g_list_free(files); } + +static void +update_plugin_list(void *data) +{ + GtkListStore *ls = GTK_LIST_STORE(data); + GtkTreeIter iter; + GList *probes; + GaimPlugin *plug; + + gtk_list_store_clear(ls); + gaim_plugins_probe(GAIM_PLUGIN_EXT); + + for (probes = gaim_plugins_get_all(); + probes != NULL; + probes = probes->next) + { + char *desc; + plug = probes->data; + + if (plug->info->type != GAIM_PLUGIN_STANDARD || + (plug->info->flags & GAIM_PLUGIN_FLAG_INVISIBLE)) + { + continue; + } + + gtk_list_store_append (ls, &iter); + desc = g_strdup_printf("<b>%s</b> %s\n%s", plug->info->name ? _(plug->info->name) : g_basename(plug->path), + plug->info->version, + plug->info->summary); + gtk_list_store_set(ls, &iter, + 0, gaim_plugin_is_loaded(plug), + 1, desc, + 2, plug, -1); + g_free(desc); + } +} + +static void plugin_load (GtkCellRendererToggle *cell, gchar *pth, gpointer data) +{ + GtkTreeModel *model = (GtkTreeModel *)data; + GtkTreeIter iter; + GtkTreePath *path = gtk_tree_path_new_from_string(pth); + GaimPlugin *plug; + gchar buf[1024]; + gchar *name = NULL, *description = NULL; + + GdkCursor *wait = gdk_cursor_new (GDK_WATCH); + gdk_window_set_cursor(plugin_dialog, wait); + gdk_cursor_unref(wait); + + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get (model, &iter, 2, &plug, -1); + + if (!gaim_plugin_is_loaded(plug)) + gaim_plugin_load(plug); + else + gaim_plugin_unload(plug); + + + gdk_window_set_cursor(plugin_dialog, NULL); + + name = g_markup_escape_text(_(plug->info->name), -1); + description = g_markup_escape_text(_(plug->info->description), -1); + + if (plug->error != NULL) { + gchar *error = g_markup_escape_text(plug->error, -1); + gchar *desc; + g_snprintf(buf, sizeof(buf), + "<span size=\"larger\">%s %s</span>\n\n" + "<span weight=\"bold\" color=\"red\">%s</span>\n\n" + "%s", + name, plug->info->version, error, description); + desc = g_strdup_printf("<b>%s</b> %s\n<span weight=\"bold\" color=\"red\"%s</span>", + plug->info->name, plug->info->version, error); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + 1, desc, + -1); + g_free(desc); + g_free(error); + } else { + g_snprintf(buf, sizeof(buf), + "<span size=\"larger\">%s %s</span>\n\n%s", + name, plug->info->version, description); + } + g_free(name); + g_free(description); + + + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + 0, gaim_plugin_is_loaded(plug), + -1); + + gtk_label_set_markup(GTK_LABEL(plugin_details), buf); + gtk_tree_path_free(path); + gaim_gtk_plugins_save(); +} + +static void prefs_plugin_sel (GtkTreeSelection *sel, GtkTreeModel *model) +{ + gchar *buf, *pname, *perr, *pdesc, *pauth, *pweb; + GtkTreeIter iter; + GValue val = { 0, }; + GaimPlugin *plug; + GaimGtkPluginUiInfo *ui_info; + + if (! gtk_tree_selection_get_selected (sel, &model, &iter)) + return; + gtk_tree_model_get_value (model, &iter, 2, &val); + plug = g_value_get_pointer(&val); + + pname = g_markup_escape_text(_(plug->info->name), -1); + pdesc = (plug->info->description) ? + g_markup_escape_text(_(plug->info->description), -1) : NULL; + pauth = (plug->info->author) ? + g_markup_escape_text(_(plug->info->author), -1) : NULL; + pweb = (plug->info->homepage) ? + g_markup_escape_text(_(plug->info->homepage), -1) : NULL; + buf = g_strdup_printf( +#ifndef _WIN32 + _("<span size=\"larger\">%s %s</span>\n\n" + "%s%s" + "<span weight=\"bold\">Written by:</span>\t%s\n" + "<span weight=\"bold\">Web site:</span>\t\t%s\n" + "<span weight=\"bold\">File name:</span>\t%s"), +#else + _("<span size=\"larger\">%s %s</span>\n\n" + "%s%s" + "<span weight=\"bold\">Written by:</span> %s\n" + "<span weight=\"bold\">Web site:</span> %s\n" + "<span weight=\"bold\">File name:</span> %s"), +#endif + pname, plug->info->version, pdesc ? pdesc : "", pdesc ? "\n\n" : "", + pauth ? pauth : "", pweb ? pweb : "", plug->path); + + gtk_widget_set_sensitive(pref_button, + plug->info->ui_info != NULL && + GAIM_GTK_PLUGIN_UI_INFO(plug)->get_config_frame != NULL); + gtk_label_set_markup(GTK_LABEL(plugin_details), buf); + g_value_unset(&val); + g_free(buf); + g_free(pname); + g_free(pdesc); + g_free(pauth); + g_free(pweb); +} + +static void pref_dialog_response_cb(GtkDialog *d, int response, void *null) +{ + switch (response) { + case GTK_RESPONSE_CLOSE: + case GTK_RESPONSE_DELETE_EVENT: + gtk_widget_destroy(d); + plugin_dialog = NULL; + break; + } +} +static void plugin_dialog_response_cb(GtkDialog *d, int response, GtkTreeSelection *sel) +{ + GaimPlugin *plug; + GtkWidget *dialog, *box; + GtkTreeModel *model; + GValue val; + GtkTreeIter iter; + + switch (response) { + case GTK_RESPONSE_CLOSE: + case GTK_RESPONSE_DELETE_EVENT: + gtk_widget_destroy(d); + plugin_dialog = NULL; + break; + case 98121: + if (! gtk_tree_selection_get_selected (sel, &model, &iter)) + return; + gtk_tree_model_get_value (model, &iter, 2, &val); + plug = g_value_get_pointer(&val); + if (plug == NULL) + break; + box = gaim_gtk_plugin_get_config_frame(plug); + if (box == NULL) + break; + + dialog = gtk_dialog_new_with_buttons(GAIM_ALERT_TITLE, d, + GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_MODAL, + GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, + NULL); + g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(pref_dialog_response_cb), NULL); + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), box); + gtk_widget_show_all(dialog); + break; + } +} + +void gaim_gtk_plugin_dialog_show() +{ + GtkWidget *sw, *vp; + GtkWidget *event_view; + GtkListStore *ls; + GtkCellRenderer *rend, *rendt; + GtkTreeViewColumn *col; + GtkTreeSelection *sel; + GtkTreePath *path; + GtkWidget *expander; + + if (plugin_dialog != NULL) { + gtk_window_present(GTK_WINDOW(plugin_dialog)); + return; + } + + plugin_dialog = gtk_dialog_new_with_buttons(_("Plugins"), + NULL, + GTK_DIALOG_NO_SEPARATOR, + NULL); + pref_button = gtk_dialog_add_button(GTK_DIALOG(plugin_dialog), GTK_STOCK_PREFERENCES, 98121); + gtk_dialog_add_button(GTK_DIALOG(plugin_dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); + + sw = gtk_scrolled_window_new(NULL,NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); + + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(plugin_dialog)->vbox), sw, TRUE, TRUE, 0); + + ls = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER); + gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), + 1, GTK_SORT_ASCENDING); + + update_plugin_list(ls); + + event_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(ls)); + + rend = gtk_cell_renderer_toggle_new(); + sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (event_view)); + + col = gtk_tree_view_column_new_with_attributes (_("Enabled"), + rend, + "active", 0, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col); + g_signal_connect (G_OBJECT(rend), "toggled", + G_CALLBACK(plugin_load), ls); + + rendt = gtk_cell_renderer_text_new(); + col = gtk_tree_view_column_new_with_attributes (_("Name"), + rendt, + "markup", 1, + NULL); +#if GTK_CHECK_VERSION(2,6,0) + gtk_tree_view_column_set_expand (col, TRUE); + g_object_set(rendt, "ellipsize", PANGO_ELLIPSIZE_END, NULL); +#endif + gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col); + g_object_unref(G_OBJECT(ls)); + gtk_container_add(GTK_CONTAINER(sw), event_view); + + expander = gtk_expander_new(_("<b>Plugin Details</b>")); + gtk_expander_set_use_markup(GTK_EXPANDER(expander), TRUE); + plugin_details = gtk_label_new(NULL); + gtk_label_set_line_wrap(GTK_LABEL(plugin_details), TRUE); + gtk_container_add(GTK_CONTAINER(expander), plugin_details); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(plugin_dialog)->vbox), expander, FALSE, FALSE, 0); + + g_signal_connect (G_OBJECT (sel), "changed", G_CALLBACK (prefs_plugin_sel), NULL); + g_signal_connect(G_OBJECT(plugin_dialog), "response", G_CALLBACK(plugin_dialog_response_cb), sel); + gtk_window_set_default_size(GTK_WINDOW(plugin_dialog), 430, 430); + gtk_widget_show_all(plugin_dialog); +}
--- a/src/gtkplugin.h Sun Oct 23 06:46:07 2005 +0000 +++ b/src/gtkplugin.h Sun Oct 23 07:12:12 2005 +0000 @@ -65,4 +65,9 @@ */ void gaim_gtk_plugins_save(void); +/** + * Shows the Plugins dialog + */ +void gaim_gtk_plugin_dialog_show(); + #endif /* _GAIM_GTKPLUGIN_H_ */
--- a/src/gtkprefs.c Sun Oct 23 06:46:07 2005 +0000 +++ b/src/gtkprefs.c Sun Oct 23 07:12:12 2005 +0000 @@ -42,8 +42,6 @@ #include "gtkdialogs.h" #include "gtkimhtml.h" #include "gtkimhtmltoolbar.h" -#include "gtkplugin.h" -#include "gtkpluginpref.h" #include "gtkprefs.h" #include "gtksound.h" #include "gtkthemes.h" @@ -65,7 +63,6 @@ static GtkWidget *prefs = NULL; static GtkWidget *debugbutton = NULL; static int notebook_page = 0; -static GtkTreeIter plugin_iter; static GtkTreeRowReference *previous_smiley_row = NULL; /* @@ -75,7 +72,6 @@ GtkWidget*, GtkTreeIter*, GtkTreeIter*, int); static void delete_prefs(GtkWidget *, void *); -static void update_plugin_list(void *data); static void update_spin_value(GtkWidget *w, GtkWidget *spin) @@ -345,104 +341,11 @@ } static void -add_plugin_prefs(GaimPlugin *plugin) -{ - /* - * NOTE: This is basically the same check as before - * (plug->type == plugin), but now there aren't plugin types. - * Not yet, anyway. I want to do a V2 of the plugin API. - * The thing is, we should have a flag specifying the UI type, - * or just whether it's a general plugin or a UI-specific - * plugin. We should only load this if it's UI-specific. - * - * -- ChipX86 - */ - if (GAIM_IS_GTK_PLUGIN(plugin)) - { - GtkWidget *config_frame; - GaimGtkPluginUiInfo *ui_info; - - ui_info = GAIM_GTK_PLUGIN_UI_INFO(plugin); - config_frame = gaim_gtk_plugin_get_config_frame(plugin); - - if (config_frame != NULL) - { - ui_info->page_num = - prefs_notebook_add_page(_(plugin->info->name), NULL, - config_frame, NULL, - &plugin_iter, notebook_page++); - } - } - - if (GAIM_PLUGIN_HAS_PREF_FRAME(plugin)) - { - GtkWidget *gtk_frame; - GaimPluginUiInfo *prefs_info; - - prefs_info = GAIM_PLUGIN_UI_INFO(plugin); - prefs_info->frame = prefs_info->get_plugin_pref_frame(plugin); - gtk_frame = gaim_gtk_plugin_pref_create_frame(prefs_info->frame); - - if (GTK_IS_WIDGET(gtk_frame)) - { - prefs_info->page_num = - prefs_notebook_add_page(_(plugin->info->name), NULL, - gtk_frame, NULL, - (plugin->info->type == GAIM_PLUGIN_PROTOCOL) ? NULL : &plugin_iter, - notebook_page++); - } else if(prefs_info->frame) { - /* in the event that there is a pref frame and we can - * not make a widget out of it, we free the - * pluginpref frame --Gary - */ - gaim_plugin_pref_frame_destroy(prefs_info->frame); - } - } -} - -static void -delete_plugin_prefs(GaimPlugin *plugin) -{ - if (GAIM_IS_GTK_PLUGIN(plugin)) - { - GaimGtkPluginUiInfo *ui_info; - - ui_info = GAIM_GTK_PLUGIN_UI_INFO(plugin); - - if (ui_info != NULL && ui_info->page_num > 0) { - gtk_notebook_remove_page(GTK_NOTEBOOK(prefsnotebook), - ui_info->page_num); - } - } - - if (GAIM_PLUGIN_HAS_PREF_FRAME(plugin)) - { - GaimPluginUiInfo *prefs_info; - - prefs_info = GAIM_PLUGIN_UI_INFO(plugin); - - if (prefs_info->frame != NULL) { - gaim_plugin_pref_frame_destroy(prefs_info->frame); - prefs_info->frame = NULL; - } - - if (prefs_info->page_num > 0) { - gtk_notebook_remove_page(GTK_NOTEBOOK(prefsnotebook), - prefs_info->page_num); - } - } -} - -static void delete_prefs(GtkWidget *asdf, void *gdsa) { - GList *l; - /* Close any "select sound" request dialogs */ gaim_request_close_with_handle(prefs); - gaim_plugins_unregister_probe_notify_cb(update_plugin_list); - /* Unregister callbacks. */ gaim_prefs_disconnect_by_handle(prefs); @@ -455,10 +358,6 @@ gtk_tree_row_reference_free(previous_smiley_row); previous_smiley_row = NULL; - for (l = gaim_plugins_get_loaded(); l != NULL; l = l->next) - { - delete_plugin_prefs(l->data); - } } static void smiley_sel(GtkTreeSelection *sel, GtkTreeModel *model) { @@ -1045,9 +944,9 @@ const char *proxy = value; if (strcmp(proxy, "none") && strcmp(proxy, "envvar")) - gtk_widget_set_sensitive(frame, TRUE); + gtk_widget_show(frame); else - gtk_widget_set_sensitive(frame, FALSE); + gtk_widget_hide(frame); } static void proxy_print_option(GtkEntry *entry, int entrynum) @@ -1144,14 +1043,8 @@ gtk_box_pack_start(GTK_BOX(vbox), prefs_proxy_frame, 0, 0, 0); proxy_info = gaim_global_proxy_get_info(); - if (proxy_info == NULL || - gaim_proxy_info_get_type(proxy_info) == GAIM_PROXY_NONE || - gaim_proxy_info_get_type(proxy_info) == GAIM_PROXY_USE_ENVVAR) { - - gtk_widget_set_sensitive(GTK_WIDGET(prefs_proxy_frame), FALSE); - } gaim_prefs_connect_callback(prefs, "/core/proxy/type", - proxy_changed_cb, prefs_proxy_frame); + proxy_changed_cb, prefs_proxy_frame); table = gtk_table_new(4, 2, FALSE); gtk_container_set_border_width(GTK_CONTAINER(table), 0); @@ -1232,6 +1125,10 @@ gaim_set_accessible_label (entry, label); gtk_widget_show_all(ret); + if (proxy_info == NULL || + gaim_proxy_info_get_type(proxy_info) == GAIM_PROXY_NONE || + gaim_proxy_info_get_type(proxy_info) == GAIM_PROXY_USE_ENVVAR) + gtk_widget_hide(table); return ret; } @@ -1829,268 +1726,6 @@ return ret; } -static GtkWidget *plugin_description=NULL, *plugin_details=NULL; - -static void prefs_plugin_sel (GtkTreeSelection *sel, GtkTreeModel *model) -{ - gchar *buf, *pname, *perr, *pdesc, *pauth, *pweb; - GtkTreeIter iter; - GValue val = { 0, }; - GaimPlugin *plug; - - if (! gtk_tree_selection_get_selected (sel, &model, &iter)) - return; - gtk_tree_model_get_value (model, &iter, 3, &val); - plug = g_value_get_pointer(&val); - - pname = g_markup_escape_text(_(plug->info->name), -1); - pdesc = (plug->info->description) ? - g_markup_escape_text(_(plug->info->description), -1) : NULL; - pauth = (plug->info->author) ? - g_markup_escape_text(_(plug->info->author), -1) : NULL; - pweb = (plug->info->homepage) ? - g_markup_escape_text(_(plug->info->homepage), -1) : NULL; - - if (plug->error != NULL) { - perr = g_markup_escape_text(_(plug->error), -1); - buf = g_strdup_printf( - "<span size=\"larger\">%s %s</span>\n\n" - "<span weight=\"bold\" color=\"red\">%s</span>\n\n" - "%s", - pname, plug->info->version, perr, pdesc ? pdesc : ""); - g_free(perr); - } - else { - buf = g_strdup_printf( - "<span size=\"larger\">%s %s</span>\n\n%s", - pname, plug->info->version, pdesc ? pdesc : ""); - } - gtk_label_set_markup(GTK_LABEL(plugin_description), buf); - g_free(buf); - - buf = g_strdup_printf( -#ifndef _WIN32 - _("<span size=\"larger\">%s %s</span>\n\n" - "<span weight=\"bold\">Written by:</span>\t%s\n" - "<span weight=\"bold\">Web site:</span>\t\t%s\n" - "<span weight=\"bold\">File name:</span>\t%s"), -#else - _("<span size=\"larger\">%s %s</span>\n\n" - "<span weight=\"bold\">Written by:</span> %s\n" - "<span weight=\"bold\">URL:</span> %s\n" - "<span weight=\"bold\">File name:</span> %s"), -#endif - pname, plug->info->version, pauth ? pauth : "", pweb ? pweb : "", plug->path); - - gtk_label_set_markup(GTK_LABEL(plugin_details), buf); - g_value_unset(&val); - g_free(buf); - g_free(pname); - g_free(pdesc); - g_free(pauth); - g_free(pweb); -} - -static void plugin_load (GtkCellRendererToggle *cell, gchar *pth, gpointer data) -{ - GtkTreeModel *model = (GtkTreeModel *)data; - GtkTreeIter iter; - GtkTreePath *path = gtk_tree_path_new_from_string(pth); - GaimPlugin *plug; - gchar buf[1024]; - gchar *name = NULL, *description = NULL; - - GdkCursor *wait = gdk_cursor_new (GDK_WATCH); - gdk_window_set_cursor(prefs->window, wait); - gdk_cursor_unref(wait); - - gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_model_get (model, &iter, 3, &plug, -1); - - if (!gaim_plugin_is_loaded(plug)) { - gaim_plugin_load(plug); - add_plugin_prefs(plug); - } - else { - delete_plugin_prefs(plug); - gaim_plugin_unload(plug); - } - - gdk_window_set_cursor(prefs->window, NULL); - - name = g_markup_escape_text(_(plug->info->name), -1); - description = g_markup_escape_text(_(plug->info->description), -1); - if (plug->error != NULL) { - gchar *error = g_markup_escape_text(plug->error, -1); - g_snprintf(buf, sizeof(buf), - "<span size=\"larger\">%s %s</span>\n\n" - "<span weight=\"bold\" color=\"red\">%s</span>\n\n" - "%s", - name, plug->info->version, error, description); - g_free(error); - } else { - g_snprintf(buf, sizeof(buf), - "<span size=\"larger\">%s %s</span>\n\n%s", - name, plug->info->version, description); - } - g_free(name); - g_free(description); - - gtk_label_set_markup(GTK_LABEL(plugin_description), buf); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, - gaim_plugin_is_loaded(plug), -1); - - gtk_label_set_markup(GTK_LABEL(plugin_description), buf); - gtk_tree_path_free(path); - - gaim_gtk_plugins_save(); -} - -static void -update_plugin_list(void *data) -{ - GtkListStore *ls = GTK_LIST_STORE(data); - GtkTreeIter iter; - GList *probes; - GaimPlugin *plug; - - gtk_list_store_clear(ls); - gaim_plugins_probe(GAIM_PLUGIN_EXT); - - for (probes = gaim_plugins_get_all(); - probes != NULL; - probes = probes->next) - { - plug = probes->data; - - if (plug->info->type != GAIM_PLUGIN_STANDARD || - (plug->info->flags & GAIM_PLUGIN_FLAG_INVISIBLE)) - { - continue; - } - - gtk_list_store_append (ls, &iter); - gtk_list_store_set(ls, &iter, - 0, gaim_plugin_is_loaded(plug), - 1, plug->info->name ? _(plug->info->name) : plug->path, - 2, _(plug->info->summary), - 3, plug, -1); - } -} - -static GtkWidget *plugin_page () -{ - GtkWidget *ret; - GtkWidget *sw, *vp; - GtkWidget *event_view; - GtkListStore *ls; - GtkCellRenderer *rend, *rendt; - GtkTreeViewColumn *col; - GtkTreeSelection *sel; - GtkTreePath *path; - GtkWidget *nb; - - ret = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE); - gtk_container_set_border_width (GTK_CONTAINER (ret), GAIM_HIG_BORDER); - - sw = gtk_scrolled_window_new(NULL,NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); - - gtk_box_pack_start(GTK_BOX(ret), sw, TRUE, TRUE, 0); - - ls = gtk_list_store_new (4, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); - gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), - 1, GTK_SORT_ASCENDING); - - update_plugin_list(ls); - - event_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(ls)); - - rend = gtk_cell_renderer_toggle_new(); - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (event_view)); - - col = gtk_tree_view_column_new_with_attributes (_("Load"), - rend, - "active", 0, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col); - - rendt = gtk_cell_renderer_text_new(); - col = gtk_tree_view_column_new_with_attributes (_("Name"), - rendt, - "text", 1, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col); - - rendt = gtk_cell_renderer_text_new(); - col = gtk_tree_view_column_new_with_attributes(_("Summary"), - rendt, - "text", 2, - NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(event_view), col); - - g_object_unref(G_OBJECT(ls)); - gtk_container_add(GTK_CONTAINER(sw), event_view); - - - nb = gtk_notebook_new(); - gtk_notebook_set_tab_pos (GTK_NOTEBOOK(nb), GTK_POS_BOTTOM); - gtk_notebook_popup_disable(GTK_NOTEBOOK(nb)); - - /* Description */ - sw = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - plugin_description = gtk_label_new(NULL); - - vp = gtk_viewport_new(NULL, NULL); - gtk_viewport_set_shadow_type(GTK_VIEWPORT(vp), GTK_SHADOW_NONE); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_NONE); - - gtk_container_add(GTK_CONTAINER(vp), plugin_description); - gtk_container_add(GTK_CONTAINER(sw), vp); - - gtk_label_set_selectable(GTK_LABEL(plugin_description), TRUE); - gtk_label_set_line_wrap(GTK_LABEL(plugin_description), TRUE); - gtk_misc_set_alignment(GTK_MISC(plugin_description), 0, 0); - gtk_misc_set_padding(GTK_MISC(plugin_description), GAIM_HIG_BOX_SPACE, GAIM_HIG_BOX_SPACE); - gtk_notebook_append_page(GTK_NOTEBOOK(nb), sw, gtk_label_new(_("Description"))); - - /* Details */ - sw = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - plugin_details = gtk_label_new(NULL); - - vp = gtk_viewport_new(NULL, NULL); - gtk_viewport_set_shadow_type(GTK_VIEWPORT(vp), GTK_SHADOW_NONE); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_NONE); - - gtk_container_add(GTK_CONTAINER(vp), plugin_details); - gtk_container_add(GTK_CONTAINER(sw), vp); - - gtk_label_set_selectable(GTK_LABEL(plugin_details), TRUE); - gtk_label_set_line_wrap(GTK_LABEL(plugin_details), TRUE); - gtk_misc_set_alignment(GTK_MISC(plugin_details), 0, 0); - gtk_misc_set_padding(GTK_MISC(plugin_details), GAIM_HIG_BOX_SPACE, GAIM_HIG_BOX_SPACE); - gtk_notebook_append_page(GTK_NOTEBOOK(nb), sw, gtk_label_new(_("Details"))); - gtk_box_pack_start(GTK_BOX(ret), nb, TRUE, TRUE, 0); - - g_signal_connect (G_OBJECT (sel), "changed", - G_CALLBACK (prefs_plugin_sel), - NULL); - g_signal_connect (G_OBJECT(rend), "toggled", - G_CALLBACK(plugin_load), ls); - - path = gtk_tree_path_new_first(); - gtk_tree_selection_select_path(sel, path); - gtk_tree_path_free(path); - - gaim_plugins_register_probe_notify_cb(update_plugin_list, ls); - - gtk_widget_show_all(ret); - return ret; -} - int prefs_notebook_add_page(const char *text, GdkPixbuf *pixbuf, GtkWidget *page, @@ -2117,7 +1752,6 @@ static void prefs_notebook_init() { GtkTreeIter p, c, c2; - GList *l; prefs_notebook_add_page(_("Buddy List"), NULL, list_page(), &c, &p, notebook_page++); prefs_notebook_add_page(_("Conversations"), NULL, conv_page(), &c, &p, notebook_page++); prefs_notebook_add_page(_("Smiley Themes"), NULL, theme_page(), &c2, &c, notebook_page++); @@ -2132,14 +1766,6 @@ #endif prefs_notebook_add_page(_("Logging"), NULL, logging_page(), &p, NULL, notebook_page++); prefs_notebook_add_page(_("Away / Idle"), NULL, away_page(), &p, NULL, notebook_page++); - - if (gaim_plugins_enabled()) { - prefs_notebook_add_page(_("Plugins"), NULL, plugin_page(), &plugin_iter, NULL, notebook_page++); - - for (l = gaim_plugins_get_loaded(); l != NULL; l = l->next) { - add_plugin_prefs(l->data); - } - } } void gaim_gtk_prefs_show(void) @@ -2176,7 +1802,7 @@ /* The notebook */ prefsnotebook = notebook = gtk_notebook_new (); gtk_box_pack_start (GTK_BOX (vbox), notebook, FALSE, FALSE, 0); - + gtk_widget_show(prefsnotebook); /* The buttons to press! */ bbox = gtk_hbutton_box_new(); @@ -2194,7 +1820,7 @@ prefs_notebook_init(); /* Show everything. */ - gtk_widget_show_all(prefs); + gtk_widget_show(prefs); } static void