From: <ro...@us...> - 2006-07-29 21:39:13
|
Revision: 16598 Author: roast Date: 2006-07-29 14:38:18 -0700 (Sat, 29 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16598&view=rev Log Message: ----------- merged with svn trunk. 16534:16597. Modified Paths: -------------- branches/soc-2006-file-loggers/COPYRIGHT branches/soc-2006-file-loggers/config.h.mingw branches/soc-2006-file-loggers/configure.ac branches/soc-2006-file-loggers/console/Makefile branches/soc-2006-file-loggers/console/gntaccount.c branches/soc-2006-file-loggers/console/gntaccount.h branches/soc-2006-file-loggers/console/gntconv.c branches/soc-2006-file-loggers/console/gntgaim.c branches/soc-2006-file-loggers/console/gntnotify.c branches/soc-2006-file-loggers/console/gntui.c branches/soc-2006-file-loggers/console/libgnt/Makefile.am branches/soc-2006-file-loggers/console/libgnt/gntbox.c branches/soc-2006-file-loggers/console/libgnt/gntbutton.c branches/soc-2006-file-loggers/console/libgnt/gntcolors.c branches/soc-2006-file-loggers/console/libgnt/gntcolors.h branches/soc-2006-file-loggers/console/libgnt/gntcombobox.c branches/soc-2006-file-loggers/console/libgnt/gntcombobox.h branches/soc-2006-file-loggers/console/libgnt/gntentry.c branches/soc-2006-file-loggers/console/libgnt/gntentry.h branches/soc-2006-file-loggers/console/libgnt/gntmain.c branches/soc-2006-file-loggers/console/libgnt/gnttree.c branches/soc-2006-file-loggers/console/libgnt/gnttree.h branches/soc-2006-file-loggers/console/libgnt/gntwidget.c branches/soc-2006-file-loggers/console/libgnt/gntwidget.h branches/soc-2006-file-loggers/console/libgnt/test/combo.c branches/soc-2006-file-loggers/doc/gtkconv-signals.dox branches/soc-2006-file-loggers/doc/log-signals.dox branches/soc-2006-file-loggers/plugins/ChangeLog.API branches/soc-2006-file-loggers/plugins/timestamp_format.c branches/soc-2006-file-loggers/src/conversation.c branches/soc-2006-file-loggers/src/gtkaccount.c branches/soc-2006-file-loggers/src/gtkconn.c branches/soc-2006-file-loggers/src/gtkconv.c branches/soc-2006-file-loggers/src/gtkconv.h branches/soc-2006-file-loggers/src/log.c branches/soc-2006-file-loggers/src/notify.c branches/soc-2006-file-loggers/src/protocols/gg/gg.c branches/soc-2006-file-loggers/src/protocols/jabber/jabber.c branches/soc-2006-file-loggers/src/protocols/jabber/jabber.h branches/soc-2006-file-loggers/src/protocols/jabber/message.c branches/soc-2006-file-loggers/src/protocols/msn/servconn.c branches/soc-2006-file-loggers/src/protocols/oscar/flap_connection.c branches/soc-2006-file-loggers/src/protocols/oscar/odc.c branches/soc-2006-file-loggers/src/protocols/oscar/oscar.h branches/soc-2006-file-loggers/src/protocols/qq/Makefile.am branches/soc-2006-file-loggers/src/protocols/qq/Makefile.mingw branches/soc-2006-file-loggers/src/protocols/qq/buddy_info.c branches/soc-2006-file-loggers/src/protocols/qq/buddy_info.h branches/soc-2006-file-loggers/src/protocols/qq/buddy_list.c branches/soc-2006-file-loggers/src/protocols/qq/buddy_status.c branches/soc-2006-file-loggers/src/protocols/qq/buddy_status.h branches/soc-2006-file-loggers/src/protocols/qq/crypt.c branches/soc-2006-file-loggers/src/protocols/qq/group_opt.c branches/soc-2006-file-loggers/src/protocols/qq/qq.c branches/soc-2006-file-loggers/src/protocols/qq/qq.h branches/soc-2006-file-loggers/src/protocols/qq/qq_proxy.c branches/soc-2006-file-loggers/src/protocols/qq/qq_proxy.h branches/soc-2006-file-loggers/src/protocols/qq/utils.c branches/soc-2006-file-loggers/src/protocols/qq/utils.h branches/soc-2006-file-loggers/src/protocols/sametime/sametime.c branches/soc-2006-file-loggers/src/protocols/simple/simple.c branches/soc-2006-file-loggers/src/signals.c branches/soc-2006-file-loggers/src/signals.h branches/soc-2006-file-loggers/src/sslconn.c branches/soc-2006-file-loggers/src/value.h branches/soc-2006-file-loggers/src/win32/win32dep.c Added Paths: ----------- branches/soc-2006-file-loggers/console/gntdebug.c branches/soc-2006-file-loggers/console/gntdebug.h branches/soc-2006-file-loggers/console/gntprefs.c branches/soc-2006-file-loggers/console/gntprefs.h branches/soc-2006-file-loggers/console/gntrequest.c branches/soc-2006-file-loggers/console/gntrequest.h branches/soc-2006-file-loggers/console/libgnt/gntcheckbox.c branches/soc-2006-file-loggers/console/libgnt/gntcheckbox.h branches/soc-2006-file-loggers/console/libgnt/gntrc.sample branches/soc-2006-file-loggers/console/libgnt/gntstyle.c branches/soc-2006-file-loggers/console/libgnt/gntstyle.h Removed Paths: ------------- branches/soc-2006-file-loggers/src/protocols/qq/TODO branches/soc-2006-file-loggers/src/protocols/qq/group_admindlg.c branches/soc-2006-file-loggers/src/protocols/qq/group_admindlg.h branches/soc-2006-file-loggers/src/protocols/qq/infodlg.c branches/soc-2006-file-loggers/src/protocols/qq/infodlg.h branches/soc-2006-file-loggers/src/protocols/qq/show.c branches/soc-2006-file-loggers/src/protocols/qq/show.h Modified: branches/soc-2006-file-loggers/COPYRIGHT =================================================================== --- branches/soc-2006-file-loggers/COPYRIGHT 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/COPYRIGHT 2006-07-29 21:38:18 UTC (rev 16598) @@ -195,6 +195,7 @@ Richard Nelson Dennis Nezic Matthew A. Nicholson +Henning Norén Szilard Novaki Novell Padraig O'Briain Modified: branches/soc-2006-file-loggers/config.h.mingw =================================================================== --- branches/soc-2006-file-loggers/config.h.mingw 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/config.h.mingw 2006-07-29 21:38:18 UTC (rev 16598) @@ -641,3 +641,5 @@ * Following are added for Win32 version of Gaim */ #define HAVE_VSNPRINTF 1 + +#define SIZEOF_TIME_T 4 Modified: branches/soc-2006-file-loggers/configure.ac =================================================================== --- branches/soc-2006-file-loggers/configure.ac 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/configure.ac 2006-07-29 21:38:18 UTC (rev 16598) @@ -60,6 +60,9 @@ dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_STRUCT_TM +AC_CHECK_SIZEOF(time_t, ,[ +#include <stdio.h> +#include <time.h>]) AC_C_BIGENDIAN Modified: branches/soc-2006-file-loggers/console/Makefile =================================================================== --- branches/soc-2006-file-loggers/console/Makefile 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/console/Makefile 2006-07-29 21:38:18 UTC (rev 16598) @@ -8,7 +8,10 @@ gntblist.c \ gntconn.c \ gntconv.c \ + gntdebug.c \ gntnotify.c \ + gntprefs.c \ + gntrequest.c \ gntui.c GG_HEADERS = \ @@ -16,7 +19,10 @@ gntblist.h \ gntconn.h \ gntconv.h \ + gntdebug.h \ gntnotify.h \ + gntprefs.h \ + gntrequest.h \ gntui.h GG_OBJECTS = \ @@ -24,7 +30,10 @@ gntblist.o \ gntconn.o \ gntconv.o \ + gntdebug.o \ gntnotify.o \ + gntprefs.o \ + gntrequest.o \ gntui.o all: gntgaim Modified: branches/soc-2006-file-loggers/console/gntaccount.c =================================================================== --- branches/soc-2006-file-loggers/console/gntaccount.c 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/console/gntaccount.c 2006-07-29 21:38:18 UTC (rev 16598) @@ -1,6 +1,7 @@ #include <gnt.h> #include <gntbox.h> #include <gntbutton.h> +#include <gntcheckbox.h> #include <gntcombobox.h> #include <gntentry.h> #include <gntlabel.h> @@ -17,6 +18,8 @@ #include "gntaccount.h" #include "gntgaim.h" +#include <string.h> + typedef struct { GntWidget *window; @@ -38,17 +41,157 @@ GntWidget *splits; GList *split_entries; + + GList *prpl_entries; + GntWidget *prpls; + + GntWidget *newmail; + GntWidget *remember; } AccountEditDialog; static void +account_add(GaimAccount *account) +{ + gnt_tree_add_choice(GNT_TREE(accounts.tree), account, + gnt_tree_create_row(GNT_TREE(accounts.tree), + gaim_account_get_username(account), + gaim_account_get_protocol_name(account)), + NULL, NULL); + gnt_tree_set_choice(GNT_TREE(accounts.tree), account, + gaim_account_get_enabled(account, GAIM_GNT_UI)); +} + +static void edit_dialog_destroy(AccountEditDialog *dialog) { + g_list_free(dialog->prpl_entries); + g_list_free(dialog->split_entries); g_free(dialog); } static void save_account_cb(AccountEditDialog *dialog) { + GaimAccount *account; + GaimPlugin *plugin; + GaimPluginProtocolInfo *prplinfo; + const char *value; + GString *username; + + /* XXX: Do some error checking first. */ + + plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); + prplinfo = GAIM_PLUGIN_PROTOCOL_INFO(plugin); + + /* Screenname && user-splits */ + value = gnt_entry_get_text(GNT_ENTRY(dialog->screenname)); + + if (value == NULL || *value == '\0') + { + gaim_notify_error(NULL, _("Error"), _("Account was not added"), + _("Screenname of an account must be non-empty.")); + return; + } + + username = g_string_new(value); + + if (prplinfo != NULL) + { + GList *iter, *entries; + for (iter = prplinfo->user_splits, entries = dialog->split_entries; + iter && entries; iter = iter->next, entries = entries->next) + { + GaimAccountUserSplit *split = iter->data; + GntWidget *entry = entries->data; + + value = gnt_entry_get_text(GNT_ENTRY(entry)); + if (value == NULL || *value == '\0') + value = gaim_account_user_split_get_default_value(split); + g_string_append_printf(username, "%c%s", + gaim_account_user_split_get_separator(split), + value); + } + } + + if (dialog->account == NULL) + { + account = gaim_account_new(username->str, gaim_plugin_get_id(plugin)); + gaim_accounts_add(account); + } + else + { + account = dialog->account; + + /* Protocol */ + gaim_account_set_protocol_id(account, gaim_plugin_get_id(plugin)); + gaim_account_set_username(account, username->str); + } + g_string_free(username, TRUE); + + /* Alias */ + value = gnt_entry_get_text(GNT_ENTRY(dialog->alias)); + if (value && *value) + gaim_account_set_alias(account, value); + + /* Remember password and password */ + gaim_account_set_remember_password(account, + gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->remember))); + value = gnt_entry_get_text(GNT_ENTRY(dialog->password)); + if (value && *value && gaim_account_get_remember_password(account)) + gaim_account_set_password(account, value); + else + gaim_account_set_password(account, NULL); + + /* Mail notification */ + /* XXX: Only if the protocol has anything to do with emails */ + gaim_account_set_check_mail(account, + gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->newmail))); + + /* Protocol options */ + if (prplinfo) + { + GList *iter, *entries; + + for (iter = prplinfo->protocol_options, entries = dialog->prpl_entries; + iter && entries; iter = iter->next, entries = entries->next) + { + GaimAccountOption *option = iter->data; + GntWidget *entry = entries->data; + GaimPrefType type = gaim_account_option_get_type(option); + const char *setting = gaim_account_option_get_setting(option); + + if (type == GAIM_PREF_STRING) + { + const char *value = gnt_entry_get_text(GNT_ENTRY(entry)); + gaim_account_set_string(account, setting, value); + } + else if (type == GAIM_PREF_INT) + { + const char *str = gnt_entry_get_text(GNT_ENTRY(entry)); + int value = 0; + if (str) + value = atoi(str); + gaim_account_set_int(account, setting, value); + } + else if (type == GAIM_PREF_BOOLEAN) + { + gboolean value = gnt_check_box_get_checked(GNT_CHECK_BOX(entry)); + gaim_account_set_bool(account, setting, value); + } + else if (type == GAIM_PREF_STRING_LIST) + { + /* TODO: */ + } + else + { + g_assert_not_reached(); + } + } + } + + /* XXX: Proxy options */ + + gnt_widget_destroy(dialog->window); } static void @@ -57,7 +200,7 @@ GntWidget *hbox; GaimPlugin *plugin; GaimPluginProtocolInfo *prplinfo; - GList *iter; + GList *iter, *entries; char *username = NULL; if (dialog->splits) @@ -99,20 +242,184 @@ g_free(buf); } - /* XXX: Add default/custom values to the splits */ + for (iter = g_list_last(prplinfo->user_splits), entries = g_list_last(dialog->split_entries); + iter && entries; iter = iter->prev, entries = entries->prev) + { + GntWidget *entry = entries->data; + GaimAccountUserSplit *split = iter->data; + const char *value = NULL; + char *s; + + if (dialog->account) + { + s = strrchr(username, gaim_account_user_split_get_separator(split)); + if (s != NULL) + { + *s = '\0'; + s++; + value = s; + } + } + if (value == NULL) + value = gaim_account_user_split_get_default_value(split); + + if (value != NULL) + gnt_entry_set_text(GNT_ENTRY(entry), value); + } + + if (username != NULL) + gnt_entry_set_text(GNT_ENTRY(dialog->screenname), username); + g_free(username); } static void +add_protocol_options(AccountEditDialog *dialog) +{ + GaimPlugin *plugin; + GaimPluginProtocolInfo *prplinfo; + GList *iter; + GntWidget *vbox, *box; + GaimAccount *account; + + if (dialog->prpls) + gnt_box_remove_all(GNT_BOX(dialog->prpls)); + else + { + dialog->prpls = vbox = gnt_vbox_new(FALSE); + gnt_box_set_pad(GNT_BOX(vbox), 0); + gnt_box_set_alignment(GNT_BOX(vbox), GNT_ALIGN_LEFT); + gnt_box_set_fill(GNT_BOX(vbox), TRUE); + } + + if (dialog->prpl_entries) + { + g_list_free(dialog->prpl_entries); + dialog->prpl_entries = NULL; + } + + vbox = dialog->prpls; + + plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); + if (!plugin) + return; + + prplinfo = GAIM_PLUGIN_PROTOCOL_INFO(plugin); + + account = dialog->account; + + for (iter = prplinfo->protocol_options; iter; iter = iter->next) + { + GaimAccountOption *option = iter->data; + GaimPrefType type = gaim_account_option_get_type(option); + + box = gnt_hbox_new(TRUE); + gnt_box_set_pad(GNT_BOX(box), 0); + gnt_box_add_widget(GNT_BOX(vbox), box); + + if (type == GAIM_PREF_BOOLEAN) + { + GntWidget *widget = gnt_check_box_new(gaim_account_option_get_text(option)); + gnt_box_add_widget(GNT_BOX(box), widget); + dialog->prpl_entries = g_list_append(dialog->prpl_entries, widget); + + if (account) + gnt_check_box_set_checked(GNT_CHECK_BOX(widget), + gaim_account_get_bool(account, + gaim_account_option_get_setting(option), + gaim_account_option_get_default_bool(option))); + else + gnt_check_box_set_checked(GNT_CHECK_BOX(widget), + gaim_account_option_get_default_bool(option)); + } + else + { + gnt_box_add_widget(GNT_BOX(box), + gnt_label_new(gaim_account_option_get_text(option))); + + if (type == GAIM_PREF_STRING_LIST) + { + /* TODO: Use a combobox */ + /* Don't forget to append the widget to prpl_entries */ + } + else + { + GntWidget *entry = gnt_entry_new(NULL); + gnt_box_add_widget(GNT_BOX(box), entry); + dialog->prpl_entries = g_list_append(dialog->prpl_entries, entry); + + if (type == GAIM_PREF_STRING) + { + const char *dv = gaim_account_option_get_default_string(option); + + if (account) + gnt_entry_set_text(GNT_ENTRY(entry), + gaim_account_get_string(account, + gaim_account_option_get_setting(option), dv)); + else + gnt_entry_set_text(GNT_ENTRY(entry), dv); + } + else if (type == GAIM_PREF_INT) + { + char str[32]; + int value = gaim_account_option_get_default_int(option); + if (account) + value = gaim_account_get_int(account, + gaim_account_option_get_setting(option), value); + snprintf(str, sizeof(str), "%d", value); + gnt_entry_set_flag(GNT_ENTRY(entry), GNT_ENTRY_FLAG_INT); + gnt_entry_set_text(GNT_ENTRY(entry), str); + } + else + { + g_assert_not_reached(); + } + } + } + } +} + +static void +update_user_options(AccountEditDialog *dialog) +{ + GaimPlugin *plugin; + GaimPluginProtocolInfo *prplinfo; + + plugin = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); + if (!plugin) + return; + + prplinfo = GAIM_PLUGIN_PROTOCOL_INFO(plugin); + + if (dialog->newmail == NULL) + dialog->newmail = gnt_check_box_new(_("New mail notifications")); + if (dialog->account) + gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->newmail), + gaim_account_get_check_mail(dialog->account)); + if (!prplinfo || !(prplinfo->options & OPT_PROTO_MAIL_CHECK)) + gnt_widget_set_visible(dialog->newmail, FALSE); + else + gnt_widget_set_visible(dialog->newmail, TRUE); + + if (dialog->remember == NULL) + dialog->remember = gnt_check_box_new(_("Remember password")); + if (dialog->account) + gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->remember), + gaim_account_get_remember_password(dialog->account)); +} + +static void prpl_changed_cb(GntWidget *combo, GaimPlugin *old, GaimPlugin *new, AccountEditDialog *dialog) { update_user_splits(dialog); + add_protocol_options(dialog); + update_user_options(dialog); /* This may not be necessary here */ gnt_box_readjust(GNT_BOX(dialog->window)); gnt_widget_draw(dialog->window); } static void -add_account(GntWidget *b, gpointer null) +edit_account(GaimAccount *account) { GntWidget *window, *hbox; GntWidget *combo, *button, *entry; @@ -122,8 +429,9 @@ dialog = g_new0(AccountEditDialog, 1); dialog->window = window = gnt_box_new(FALSE, TRUE); + dialog->account = account; gnt_box_set_toplevel(GNT_BOX(window), TRUE); - gnt_box_set_title(GNT_BOX(window), _("New Account")); + gnt_box_set_title(GNT_BOX(window), account ? _("Modify Account") : _("New Account")); gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); gnt_box_set_pad(GNT_BOX(window), 0); @@ -138,6 +446,12 @@ gnt_combo_box_add_data(GNT_COMBO_BOX(combo), iter->data, ((GaimPlugin*)iter->data)->info->name); } + if (account) + gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), + gaim_plugins_find_with_id(gaim_account_get_protocol_id(account))); + else + gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), list->data); + g_signal_connect(G_OBJECT(combo), "selection-changed", G_CALLBACK(prpl_changed_cb), dialog); gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Protocol:"))); gnt_box_add_widget(GNT_BOX(hbox), combo); @@ -157,8 +471,11 @@ gnt_box_add_widget(GNT_BOX(window), hbox); dialog->password = entry = gnt_entry_new(NULL); + gnt_entry_set_masked(GNT_ENTRY(entry), TRUE); gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Password:"))); gnt_box_add_widget(GNT_BOX(hbox), entry); + if (account) + gnt_entry_set_text(GNT_ENTRY(entry), gaim_account_get_password(account)); hbox = gnt_box_new(TRUE, FALSE); gnt_box_add_widget(GNT_BOX(window), hbox); @@ -166,9 +483,23 @@ dialog->alias = entry = gnt_entry_new(NULL); gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Alias:"))); gnt_box_add_widget(GNT_BOX(hbox), entry); + if (account) + gnt_entry_set_text(GNT_ENTRY(entry), gaim_account_get_alias(account)); + /* User options */ + update_user_options(dialog); + gnt_box_add_widget(GNT_BOX(window), dialog->remember); + gnt_box_add_widget(GNT_BOX(window), dialog->newmail); + gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE)); - + + /* The advanced box */ + add_protocol_options(dialog); + gnt_box_add_widget(GNT_BOX(window), dialog->prpls); + + /* TODO: Add proxy options */ + + /* The button box */ hbox = gnt_box_new(FALSE, FALSE); gnt_box_add_widget(GNT_BOX(window), hbox); @@ -183,9 +514,33 @@ g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(edit_dialog_destroy), dialog); gnt_widget_show(window); + gnt_box_readjust(GNT_BOX(window)); + gnt_widget_draw(window); } static void +add_account_cb(GntWidget *widget, gpointer null) +{ + edit_account(NULL); +} + +static void +modify_account_cb(GntWidget *widget, GntTree *tree) +{ + GaimAccount *account = gnt_tree_get_selection_data(tree); + if (!account) + return; + edit_account(account); +} + +static void +delete_account_cb(GntWidget *widget, GntTree *tree) +{ + /* XXX: After the request-api is complete */ + /* Note: remove the modify-dialog for the account */ +} + +static void account_toggled(GntWidget *widget, void *key, gpointer null) { GaimAccount *account = key; @@ -193,7 +548,7 @@ gaim_account_set_enabled(account, GAIM_GNT_UI, gnt_tree_get_choice(GNT_TREE(widget), key)); } -void gg_accounts_init() +void gg_accounts_show_all() { GList *iter; GntWidget *box, *button; @@ -216,14 +571,7 @@ for (iter = gaim_accounts_get_all(); iter; iter = iter->next) { GaimAccount *account = iter->data; - - gnt_tree_add_choice(GNT_TREE(accounts.tree), account, - gnt_tree_create_row(GNT_TREE(accounts.tree), - gaim_account_get_username(account), - gaim_account_get_protocol_name(account)), - NULL, NULL); - gnt_tree_set_choice(GNT_TREE(accounts.tree), account, - gaim_account_get_enabled(account, GAIM_GNT_UI)); + account_add(account); } g_signal_connect(G_OBJECT(accounts.tree), "toggled", G_CALLBACK(account_toggled), NULL); @@ -238,27 +586,65 @@ button = gnt_button_new(_("Add")); gnt_box_add_widget(GNT_BOX(box), button); - g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(add_account), NULL); + g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(add_account_cb), NULL); button = gnt_button_new(_("Modify")); gnt_box_add_widget(GNT_BOX(box), button); + g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(modify_account_cb), accounts.tree); button = gnt_button_new(_("Delete")); gnt_box_add_widget(GNT_BOX(box), button); + g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(delete_account_cb), accounts.tree); gnt_box_add_widget(GNT_BOX(accounts.window), box); gnt_widget_show(accounts.window); } +static gpointer +gg_accounts_get_handle() +{ + static int handle; + + return &handle; +} + +static void +account_added_callback(GaimAccount *account) +{ + if (accounts.window == NULL) + return; + account_add(account); + gnt_widget_draw(accounts.tree); +} + +static void +account_removed_callback(GaimAccount *account) +{ + if (accounts.window == NULL) + return; + + gnt_tree_remove(GNT_TREE(accounts.tree), account); +} + +void gg_accounts_init() +{ + gaim_signal_connect(gaim_accounts_get_handle(), "account-added", + gg_accounts_get_handle(), GAIM_CALLBACK(account_added_callback), + NULL); + gaim_signal_connect(gaim_accounts_get_handle(), "account-removed", + gg_accounts_get_handle(), GAIM_CALLBACK(account_removed_callback), + NULL); + + gg_accounts_show_all(); +} + void gg_accounts_uninit() { gnt_widget_destroy(accounts.window); } -#if 0 /* The following uiops stuff are copied from gtkaccount.c */ -/* Need to do some work on notify- and request-ui before this works */ typedef struct { GaimAccount *account; @@ -305,6 +691,31 @@ } static void +free_add_user_data(AddUserData *data) +{ + g_free(data->username); + + if (data->alias != NULL) + g_free(data->alias); + + g_free(data); +} + +static void +add_user_cb(AddUserData *data) +{ + GaimConnection *gc = gaim_account_get_connection(data->account); + + if (g_list_find(gaim_connections_get_all(), gc)) + { + gaim_blist_request_add_buddy(data->account, data->username, + NULL, data->alias); + } + + free_add_user_data(data); +} + +static void request_add(GaimAccount *account, const char *remote_user, const char *id, const char *alias, const char *msg) @@ -321,12 +732,10 @@ data->alias = (alias != NULL ? g_strdup(alias) : NULL); buffer = make_info(account, gc, remote_user, id, alias, msg); -#if 0 gaim_request_action(NULL, NULL, _("Add buddy to your list?"), buffer, GAIM_DEFAULT_ACTION_NONE, data, 2, _("Add"), G_CALLBACK(add_user_cb), _("Cancel"), G_CALLBACK(free_add_user_data)); -#endif g_free(buffer); } @@ -336,17 +745,7 @@ .status_changed = NULL, .request_add = request_add }; -#else -static GaimAccountUiOps ui_ops = -{ - .notify_added = NULL, - .status_changed = NULL, - .request_add = NULL -}; - -#endif - GaimAccountUiOps *gg_accounts_get_ui_ops() { return &ui_ops; Modified: branches/soc-2006-file-loggers/console/gntaccount.h =================================================================== --- branches/soc-2006-file-loggers/console/gntaccount.h 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/console/gntaccount.h 2006-07-29 21:38:18 UTC (rev 16598) @@ -5,3 +5,6 @@ void gg_accounts_init(); void gg_accounts_uninit(); + +void gg_accounts_show_all(); + Modified: branches/soc-2006-file-loggers/console/gntconv.c =================================================================== --- branches/soc-2006-file-loggers/console/gntconv.c 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/console/gntconv.c 2006-07-29 21:38:18 UTC (rev 16598) @@ -159,9 +159,10 @@ g_hash_table_insert(ggconvs, conv, ggc); ggc->conv = conv; + conv->ui_data = ggc; type = gaim_conversation_get_type(conv); - title = g_strdup_printf(_("%s"), gaim_conversation_get_name(conv)); + title = g_strdup_printf(_("%s"), gaim_conversation_get_title(conv)); ggc->window = gnt_box_new(FALSE, TRUE); gnt_box_set_title(GNT_BOX(ggc->window), title); gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE); @@ -199,7 +200,7 @@ gg_write_common(GaimConversation *conv, const char *who, const char *message, GaimMessageFlags flags, time_t mtime) { - GGConv *ggconv = g_hash_table_lookup(ggconvs, conv); + GGConv *ggconv = g_hash_table_lookup(ggconvs, conv); /* XXX: ggconv = conv->ui_data; should do */ char *strip; GntTextFormatFlags fl = 0; @@ -243,9 +244,9 @@ gg_write_im(GaimConversation *conv, const char *who, const char *message, GaimMessageFlags flags, time_t mtime) { + GaimAccount *account = gaim_conversation_get_account(conv); if (flags & GAIM_MESSAGE_SEND) { - GaimAccount *account = gaim_conversation_get_account(conv); who = gaim_connection_get_display_name(gaim_account_get_connection(account)); if (!who) who = gaim_account_get_alias(account); @@ -253,7 +254,13 @@ who = gaim_account_get_username(account); } else if (flags & GAIM_MESSAGE_RECV) + { + GaimBuddy *buddy; who = gaim_conversation_get_name(conv); + buddy = gaim_find_buddy(account, who); + if (buddy) + who = gaim_buddy_get_contact_alias(buddy); + } gg_write_common(conv, who, message, flags, mtime); } Copied: branches/soc-2006-file-loggers/console/gntdebug.c (from rev 16597, trunk/console/gntdebug.c) =================================================================== --- branches/soc-2006-file-loggers/console/gntdebug.c (rev 0) +++ branches/soc-2006-file-loggers/console/gntdebug.c 2006-07-29 21:38:18 UTC (rev 16598) @@ -0,0 +1,114 @@ +#include <gnt.h> +#include <gntbox.h> +#include <gnttextview.h> + +#include "gntdebug.h" +#include "gntgaim.h" + +#include <stdio.h> +#include <string.h> + +static struct +{ + GntWidget *window; + GntWidget *tview; +} debug; + +static gboolean +debug_window_kpress_cb(GntWidget *wid, const char *key, GntTextView *view) +{ + if (key[0] == 27) + { + /* XXX: This doesn't seem to always work */ + if (strcmp(key+1, GNT_KEY_DOWN) == 0) + gnt_text_view_scroll(view, 1); + else if (strcmp(key+1, GNT_KEY_UP) == 0) + gnt_text_view_scroll(view, -1); + else if (strcmp(key+1, GNT_KEY_PGDOWN) == 0) + gnt_text_view_scroll(view, wid->priv.height - 2); + else if (strcmp(key+1, GNT_KEY_PGUP) == 0) + gnt_text_view_scroll(view, -(wid->priv.height - 2)); + else + return FALSE; + return TRUE; + } + return FALSE; +} + +static void +gg_debug_print(GaimDebugLevel level, const char *category, + const char *args) +{ + if (debug.window == NULL) + fprintf(stderr, "%s: %s\n", category, args); + else + { + GntTextFormatFlags flag = GNT_TEXT_FLAG_NORMAL; + + gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), + category, GNT_TEXT_FLAG_BOLD); + gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), + ": ", GNT_TEXT_FLAG_BOLD); + + switch (level) + { + case GAIM_DEBUG_WARNING: + flag |= GNT_TEXT_FLAG_UNDERLINE; + case GAIM_DEBUG_ERROR: + case GAIM_DEBUG_FATAL: + flag |= GNT_TEXT_FLAG_BOLD; + break; + default: + break; + } + + gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), args, flag); + gnt_text_view_next_line(GNT_TEXT_VIEW(debug.tview)); + gnt_text_view_scroll(GNT_TEXT_VIEW(debug.tview), 0); + + g_signal_connect(G_OBJECT(debug.window), "key_pressed", G_CALLBACK(debug_window_kpress_cb), debug.tview); + } +} + +static GaimDebugUiOps uiops = +{ + gg_debug_print, +}; + +GaimDebugUiOps *gg_debug_get_ui_ops() +{ + return &uiops; +} + +static void +reset_debug_win(GntWidget *w, gpointer null) +{ + debug.window = debug.tview = NULL; +} + +void gg_debug_window_show() +{ + if (debug.window == NULL) + { + debug.window = gnt_vbox_new(FALSE); + gnt_box_set_toplevel(GNT_BOX(debug.window), TRUE); + gnt_box_set_title(GNT_BOX(debug.window), _("Debug Window")); + + debug.tview = gnt_text_view_new(); + gnt_box_add_widget(GNT_BOX(debug.window), debug.tview); + + g_signal_connect(G_OBJECT(debug.window), "destroy", G_CALLBACK(reset_debug_win), NULL); + } + + gnt_widget_show(debug.window); +} + +void gg_debug_init() +{ + gg_debug_window_show(); +} + +void gg_debug_uninit() +{ +} + Copied: branches/soc-2006-file-loggers/console/gntdebug.h (from rev 16597, trunk/console/gntdebug.h) =================================================================== --- branches/soc-2006-file-loggers/console/gntdebug.h (rev 0) +++ branches/soc-2006-file-loggers/console/gntdebug.h 2006-07-29 21:38:18 UTC (rev 16598) @@ -0,0 +1,8 @@ +#include "debug.h" + +GaimDebugUiOps *gg_debug_get_ui_ops(); + +void gg_debug_init(); + +void gg_debug_uninit(); + Modified: branches/soc-2006-file-loggers/console/gntgaim.c =================================================================== --- branches/soc-2006-file-loggers/console/gntgaim.c 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/console/gntgaim.c 2006-07-29 21:38:18 UTC (rev 16598) @@ -15,18 +15,25 @@ #include "util.h" #include "whiteboard.h" +#include "gntdebug.h" #include "gntgaim.h" +#include "gntprefs.h" #include "gntui.h" #define _GNU_SOURCE #include <getopt.h> -/* Anything IO-related is directly copied from gtkgaim's source tree */ +static void +debug_init() +{ + gg_debug_init(); + gaim_debug_set_ui_ops(gg_debug_get_ui_ops()); +} static GaimCoreUiOps core_ops = { - NULL, /*gaim_gtk_prefs_init,*/ - NULL, /*debug_init,*/ + gg_prefs_init, + debug_init, NULL, /*gaim_gtk_ui_init,*/ NULL, /*gaim_gtk_quit*/ }; @@ -37,6 +44,8 @@ return &core_ops; } +/* Anything IO-related is directly copied from gtkgaim's source tree */ + #define GAIM_GTK_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR) #define GAIM_GTK_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL) @@ -237,7 +246,11 @@ gaim_plugins_add_search_path(path); g_free(path); - gaim_plugins_add_search_path("/usr/local/lib/gaim"); /* XXX: */ +#ifdef LIBDIR + gaim_plugins_add_search_path(LIBDIR); +#else + gaim_plugins_add_search_path("/usr/local/lib/gaim"); /* XXX: Remove this after the restructure */ +#endif if (!gaim_core_init(GAIM_GNT_UI)) { @@ -293,6 +306,8 @@ /* XXX: Don't puke */ freopen(".error", "w", stderr); + gnt_init(); + /* Initialize the libgaim stuff */ if (!init_libgaim(argc, argv)) return 0; Modified: branches/soc-2006-file-loggers/console/gntnotify.c =================================================================== --- branches/soc-2006-file-loggers/console/gntnotify.c 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/console/gntnotify.c 2006-07-29 21:38:18 UTC (rev 16598) @@ -15,6 +15,12 @@ GntWidget *tree; } emaildialog; +static void +notify_msg_window_destroy_cb(GntWidget *window, GaimNotifyMsgType type) +{ + gaim_notify_close(type, window); +} + static void * gg_notify_message(GaimNotifyMsgType type, const char *title, const char *primary, const char *secondary) @@ -48,7 +54,10 @@ button = gnt_button_new(_("OK")); gnt_box_add_widget(GNT_BOX(window), button); - g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), window); + g_signal_connect_swapped(G_OBJECT(button), "activate", + G_CALLBACK(gnt_widget_destroy), window); + g_signal_connect(G_OBJECT(window), "destroy", + G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type)); gnt_widget_show(window); return window; @@ -57,7 +66,22 @@ /* handle is, in all/most occasions, a GntWidget * */ static void gg_close_notify(GaimNotifyType type, void *handle) { - gnt_widget_destroy(GNT_WIDGET(handle)); + GntWidget *widget = handle; + + if (!widget) + return; + + while (widget->parent) + widget = widget->parent; + + if (type == GAIM_NOTIFY_SEARCHRESULTS) + gaim_notify_searchresults_free(g_object_get_data(handle, "notify-results")); +#if 0 + /* This does not seem to be necessary */ + g_signal_handlers_disconnect_by_func(G_OBJECT(widget), + G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type)); +#endif + gnt_widget_destroy(widget); } static void *gg_notify_formatted(const char *title, const char *primary, @@ -71,7 +95,7 @@ secondary ? "\n" : "", unformat ? unformat : ""); - void *ret = gg_notify_message(GAIM_NOTIFY_MSG_INFO, title, primary, t); + void *ret = gg_notify_message(GAIM_NOTIFY_FORMATTED, title, primary, t); g_free(t); g_free(unformat); @@ -151,7 +175,7 @@ return NULL; } - ret = gg_notify_message(GAIM_NOTIFY_MSG_INFO, _("New Mail"), _("You have mail!"), message->str); + ret = gg_notify_message(GAIM_NOTIFY_EMAIL, _("New Mail"), _("You have mail!"), message->str); g_string_free(message, TRUE); return ret; } @@ -180,6 +204,112 @@ return ui_handle; } +static void +notify_button_activated(GntWidget *widget, GaimNotifySearchButton *b) +{ + GList *list = NULL; + GaimAccount *account = g_object_get_data(G_OBJECT(widget), "notify-account"); + gpointer data = g_object_get_data(G_OBJECT(widget), "notify-data"); + + list = gnt_tree_get_selection_text_list(GNT_TREE(widget)); + + b->callback(gaim_account_get_connection(account), list, data); + g_list_foreach(list, (GFunc)g_free, NULL); + g_list_free(list); +} + +static void +gg_notify_sr_new_rows(GaimConnection *gc, + GaimNotifySearchResults *results, void *data) +{ + GntTree *tree = GNT_TREE(data); + GList *o; + + /* XXX: Do I need to empty the tree here? */ + + for (o = results->rows; o; o = o->next) + { + gnt_tree_add_row_after(GNT_TREE(tree), o->data, + gnt_tree_create_row_from_list(GNT_TREE(tree), o->data), + NULL, NULL); + } +} + +static void * +gg_notify_searchresults(GaimConnection *gc, const char *title, + const char *primary, const char *secondary, + GaimNotifySearchResults *results, gpointer data) +{ + GntWidget *window, *tree, *box, *button; + GList *iter; + + window = gnt_vbox_new(FALSE); + gnt_box_set_toplevel(GNT_BOX(window), TRUE); + gnt_box_set_title(GNT_BOX(window), title); + gnt_box_set_fill(GNT_BOX(window), FALSE); + gnt_box_set_pad(GNT_BOX(window), 0); + gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); + + gnt_box_add_widget(GNT_BOX(window), + gnt_label_new_with_format(primary, GNT_TEXT_FLAG_BOLD)); + gnt_box_add_widget(GNT_BOX(window), + gnt_label_new_with_format(secondary, GNT_TEXT_FLAG_NORMAL)); + + tree = gnt_tree_new_with_columns(g_list_length(results->columns)); + gnt_tree_set_show_title(GNT_TREE(tree), TRUE); + gnt_box_add_widget(GNT_BOX(window), tree); + + box = gnt_hbox_new(TRUE); + + for (iter = results->buttons; iter; iter = iter->next) + { + GaimNotifySearchButton *b = iter->data; + const char *text; + + switch (b->type) + { + case GAIM_NOTIFY_BUTTON_LABELED: + text = b->label; + break; + case GAIM_NOTIFY_BUTTON_CONTINUE: + text = _("Continue"); + break; + case GAIM_NOTIFY_BUTTON_ADD: + text = _("Add"); + break; + case GAIM_NOTIFY_BUTTON_INFO: + text = _("Info"); + break; + case GAIM_NOTIFY_BUTTON_IM: + text = _("IM"); + break; + case GAIM_NOTIFY_BUTTON_JOIN: + text = _("Join"); + break; + case GAIM_NOTIFY_BUTTON_INVITE: + text = _("Invite"); + break; + } + + button = gnt_button_new(text); + g_object_set_data(G_OBJECT(button), "notify-account", gaim_connection_get_account(gc)); + g_object_set_data(G_OBJECT(button), "notify-data", data); + g_signal_connect_swapped(G_OBJECT(button), "activate", + G_CALLBACK(notify_button_activated), b); + + gnt_box_add_widget(GNT_BOX(box), button); + } + + gnt_box_add_widget(GNT_BOX(window), box); + + gg_notify_sr_new_rows(gc, results, tree); + + gnt_widget_show(window); + g_object_set_data(G_OBJECT(window), "notify-results", results); + + return tree; +} + static GaimNotifyUiOps ops = { .notify_message = gg_notify_message, @@ -190,8 +320,8 @@ .notify_emails = gg_notify_emails, .notify_userinfo = gg_notify_userinfo, - .notify_searchresults = NULL, /* We are going to need multi-column GntTree's for this */ - .notify_searchresults_new_rows = NULL, + .notify_searchresults = gg_notify_searchresults, + .notify_searchresults_new_rows = gg_notify_sr_new_rows, .notify_uri = NULL /* This is of low-priority to me */ }; Copied: branches/soc-2006-file-loggers/console/gntprefs.c (from rev 16597, trunk/console/gntprefs.c) =================================================================== --- branches/soc-2006-file-loggers/console/gntprefs.c (rev 0) +++ branches/soc-2006-file-loggers/console/gntprefs.c 2006-07-29 21:38:18 UTC (rev 16598) @@ -0,0 +1,14 @@ +#include <prefs.h> + +#include "gntprefs.h" +#include "gntgaim.h" + +void gg_prefs_init() +{ + gaim_prefs_add_none("/gaim"); + gaim_prefs_add_none("/gaim/gnt"); + + gaim_prefs_add_none("/gaim/gnt/plugins"); + gaim_prefs_add_string_list("/gaim/gnt/plugins/loaded", NULL); +} + Copied: branches/soc-2006-file-loggers/console/gntprefs.h (from rev 16597, trunk/console/gntprefs.h) =================================================================== --- branches/soc-2006-file-loggers/console/gntprefs.h (rev 0) +++ branches/soc-2006-file-loggers/console/gntprefs.h 2006-07-29 21:38:18 UTC (rev 16598) @@ -0,0 +1,2 @@ +void gg_prefs_init(); + Copied: branches/soc-2006-file-loggers/console/gntrequest.c (from rev 16597, trunk/console/gntrequest.c) =================================================================== --- branches/soc-2006-file-loggers/console/gntrequest.c (rev 0) +++ branches/soc-2006-file-loggers/console/gntrequest.c 2006-07-29 21:38:18 UTC (rev 16598) @@ -0,0 +1,218 @@ +#include <gnt.h> +#include <gntbox.h> +#include <gntbutton.h> +#include <gntcombobox.h> +#include <gntentry.h> +#include <gntlabel.h> + +#include "gntrequest.h" + +static GntWidget * +setup_request_window(const char *title, const char *primary, + const char *secondary) +{ + GntWidget *window; + + window = gnt_vbox_new(FALSE); + gnt_box_set_toplevel(GNT_BOX(window), TRUE); + gnt_box_set_title(GNT_BOX(window), title); + gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); + + if (primary) + gnt_box_add_widget(GNT_BOX(window), + gnt_label_new_with_format(primary, GNT_TEXT_FLAG_BOLD)); + if (secondary) + gnt_box_add_widget(GNT_BOX(window), gnt_label_new(secondary)); + + return window; +} + +static GntWidget * +setup_button_box(gpointer userdata, gpointer cb, gpointer data, ...) +{ + GntWidget *box, *button; + va_list list; + const char *text; + gpointer callback; + + box = gnt_hbox_new(TRUE); + + va_start(list, data); + + while ((text = va_arg(list, const char *))) + { + callback = va_arg(list, gpointer); + button = gnt_button_new(text); + gnt_box_add_widget(GNT_BOX(box), button); + g_object_set_data(G_OBJECT(button), "activate-callback", callback); + g_object_set_data(G_OBJECT(button), "activate-userdata", userdata); + g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(cb), data); + } + + va_end(list); + return box; +} + +static void +notify_input_cb(GntWidget *button, GntWidget *entry) +{ + GaimRequestInputCb callback = g_object_get_data(G_OBJECT(button), "activate-callback"); + gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata"); + const char *text = gnt_entry_get_text(GNT_ENTRY(entry)); + + if (callback) + callback(data, text); + + while (button->parent) + button = button->parent; + + gaim_request_close(GAIM_REQUEST_INPUT, button); +} + +static void * +gg_request_input(const char *title, const char *primary, + const char *secondary, const char *default_value, + gboolean multiline, gboolean masked, gchar *hint, + const char *ok_text, GCallback ok_cb, + const char *cancel_text, GCallback cancel_cb, + void *user_data) +{ + GntWidget *window, *box, *entry; + + window = setup_request_window(title, primary, secondary); + + entry = gnt_entry_new(default_value); + if (masked) + gnt_entry_set_masked(GNT_ENTRY(entry), TRUE); + gnt_box_add_widget(GNT_BOX(window), entry); + + box = setup_button_box(user_data, notify_input_cb, entry, + ok_text, ok_cb, cancel_text, cancel_cb, NULL); + gnt_box_add_widget(GNT_BOX(window), box); + + gnt_widget_show(window); + + return window; +} + +static void +gg_close_request(GaimRequestType type, gpointer ui_handle) +{ + GntWidget *widget = GNT_WIDGET(ui_handle); + while (widget->parent) + widget = widget->parent; + gnt_widget_destroy(widget); +} + +static void +request_choice_cb(GntWidget *button, GntComboBox *combo) +{ + GaimRequestChoiceCb callback = g_object_get_data(G_OBJECT(button), "activate-callback"); + gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata"); + int choice = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo))) - 1; + + if (callback) + callback(data, choice); + + while (button->parent) + button = button->parent; + + gaim_request_close(GAIM_REQUEST_INPUT, button); +} + +static void * +gg_request_choice(const char *title, const char *primary, + const char *secondary, unsigned int default_value, + const char *ok_text, GCallback ok_cb, + const char *cancel_text, GCallback cancel_cb, + void *user_data, va_list choices) +{ + GntWidget *window, *combo, *box; + const char *text; + int val; + + window = setup_request_window(title, primary, secondary); + + combo = gnt_combo_box_new(); + gnt_box_add_widget(GNT_BOX(window), combo); + while ((text = va_arg(choices, const char *))) + { + val = va_arg(choices, int); + gnt_combo_box_add_data(GNT_COMBO_BOX(combo), GINT_TO_POINTER(val + 1), text); + } + gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), GINT_TO_POINTER(default_value + 1)); + + box = setup_button_box(user_data, request_choice_cb, combo, + ok_text, ok_cb, cancel_text, cancel_cb, NULL); + gnt_box_add_widget(GNT_BOX(window), box); + + gnt_widget_show(window); + + return window; +} + +static void +request_action_cb(GntWidget *button, GntWidget *window) +{ + GaimRequestActionCb callback = g_object_get_data(G_OBJECT(button), "activate-callback"); + gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata"); + int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button), "activate-id")); + + callback(data, id); + + gaim_request_close(GAIM_REQUEST_ACTION, window); +} + +static void* +gg_request_action(const char *title, const char *primary, + const char *secondary, unsigned int default_value, + void *user_data, size_t actioncount, + va_list actions) +{ + GntWidget *window, *box, *button; + int i; + + window = setup_request_window(title, primary, secondary); + + box = gnt_hbox_new(TRUE); + gnt_box_add_widget(GNT_BOX(window), box); + for (i = 0; i < actioncount; i++) + { + const char *text = va_arg(actions, const char *); + GaimRequestActionCb callback = va_arg(actions, GaimRequestActionCb); + + button = gnt_button_new(text); + gnt_box_add_widget(GNT_BOX(box), button); + + g_object_set_data(G_OBJECT(button), "activate-callback", callback); + g_object_set_data(G_OBJECT(button), "activate-userdata", user_data); + g_object_set_data(G_OBJECT(button), "activate-id", GINT_TO_POINTER(i)); + g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(request_action_cb), window); + } + + gnt_widget_show(window); + + return window; +} + +static GaimRequestUiOps uiops = +{ + .request_input = gg_request_input, + .close_request = gg_close_request, + .request_choice = gg_request_choice, + .request_action = gg_request_action, +}; + +GaimRequestUiOps *gg_request_get_ui_ops() +{ + return &uiops; +} + +void gg_request_init() +{ +} + +void gg_request_uninit() +{ +} + Copied: branches/soc-2006-file-loggers/console/gntrequest.h (from rev 16597, trunk/console/gntrequest.h) =================================================================== --- branches/soc-2006-file-loggers/console/gntrequest.h (rev 0) +++ branches/soc-2006-file-loggers/console/gntrequest.h 2006-07-29 21:38:18 UTC (rev 16598) @@ -0,0 +1,8 @@ +#include "request.h" + +GaimRequestUiOps *gg_request_get_ui_ops(); + +void gg_request_init(); + +void gg_request_uninit(); + Modified: branches/soc-2006-file-loggers/console/gntui.c =================================================================== --- branches/soc-2006-file-loggers/console/gntui.c 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/console/gntui.c 2006-07-29 21:38:18 UTC (rev 16598) @@ -5,6 +5,7 @@ #include "gntconn.h" #include "gntconv.h" #include "gntnotify.h" +#include "gntrequest.h" void init_gnt_ui() { @@ -31,6 +32,9 @@ gg_notify_init(); gaim_notify_set_ui_ops(gg_notify_get_ui_ops()); + gg_request_init(); + gaim_request_set_ui_ops(gg_request_get_ui_ops()); + #ifdef STANDALONE gnt_main(); @@ -49,6 +53,9 @@ gaim_notify_set_ui_ops(NULL); gg_notify_uninit(); + gaim_request_set_ui_ops(NULL); + gg_request_uninit(); + gnt_quit(); #endif } Modified: branches/soc-2006-file-loggers/console/libgnt/Makefile.am =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/Makefile.am 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/console/libgnt/Makefile.am 2006-07-29 21:38:18 UTC (rev 16598) @@ -7,12 +7,14 @@ gntwidget.c \ gntbox.c \ gntbutton.c \ + gntcheckbox.c \ gntcolors.c \ gntcombobox.c \ gntentry.c \ gntlabel.c \ gntline.c \ gntmarshal.c \ + gntstyle.c \ gnttextview.c \ gnttree.c \ gntmain.c @@ -21,6 +23,7 @@ gntwidget.h \ gntbox.h \ gntbutton.h \ + gntcheckbox.h \ gntcolors.h \ gntcombobox.h \ gntentry.h \ @@ -28,6 +31,7 @@ gntlabel.h \ gntline.h \ gntmarshal.h \ + gntstyle.h \ gnttextview.h \ gnttree.h \ gnt.h Modified: branches/soc-2006-file-loggers/console/libgnt/gntbox.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntbox.c 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/console/libgnt/gntbox.c 2006-07-29 21:38:18 UTC (rev 16598) @@ -89,6 +89,8 @@ for (iter = box->list; iter; iter = iter->next) { + if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(iter->data), GNT_WIDGET_INVISIBLE)) + continue; gnt_widget_set_position(GNT_WIDGET(iter->data), curx, cury); gnt_widget_get_size(GNT_WIDGET(iter->data), &w, &h); if (box->vertical) @@ -217,6 +219,7 @@ static GntWidget * find_focusable_widget(GntBox *box) { + /* XXX: Make sure the widget is visible? */ if (box->focus == NULL && GNT_WIDGET(box)->parent == NULL) g_list_foreach(box->list, add_to_focus, box); @@ -229,11 +232,17 @@ static void find_next_focus(GntBox *box) { - GList *iter = g_list_find(box->focus, box->active); - if (iter && iter->next) - box->active = iter->next->data; - else if (box->focus) - box->active = box->focus->data; + gpointer last = box->active; + do + { + GList *iter = g_list_find(box->focus, box->active); + if (iter && iter->next) + box->active = iter->next->data; + else if (box->focus) + box->active = box->focus->data; + if (!GNT_WIDGET_IS_FLAG_SET(box->active, GNT_WIDGET_INVISIBLE)) + break; + } while (box->active != last); } static gboolean @@ -564,6 +573,9 @@ int height, width; int x, y; + if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_INVISIBLE)) + continue; + if (GNT_IS_BOX(w)) gnt_box_sync_children(GNT_BOX(w)); Modified: branches/soc-2006-file-loggers/console/libgnt/gntbutton.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntbutton.c 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/console/libgnt/gntbutton.c 2006-07-29 21:38:18 UTC (rev 16598) @@ -22,7 +22,7 @@ type = GNT_COLOR_NORMAL; wbkgdset(widget->window, '\0' | COLOR_PAIR(type)); - mvwprintw(widget->window, 1, 1, button->priv->text); + mvwprintw(widget->window, 1, 2, button->priv->text); DEBUG; } @@ -31,8 +31,10 @@ gnt_button_size_request(GntWidget *widget) { GntButton *button = GNT_BUTTON(widget); - widget->priv.width = g_utf8_strlen(button->priv->text, -1) + 2; - widget->priv.height = 3; + widget->priv.width = g_utf8_strlen(button->priv->text, -1) + 4; + widget->priv.height = 1; + if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_SHADOW)) + widget->priv.height += 2; } static void Copied: branches/soc-2006-file-loggers/console/libgnt/gntcheckbox.c (from rev 16597, trunk/console/libgnt/gntcheckbox.c) =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntcheckbox.c (rev 0) +++ branches/soc-2006-file-loggers/console/libgnt/gntcheckbox.c 2006-07-29 21:38:18 UTC (rev 16598) @@ -0,0 +1,153 @@ +#include "gntcheckbox.h" + +enum +{ + SIG_TOGGLED = 1, + SIGS, +}; + +static GntButtonClass *parent_class = NULL; +static guint signals[SIGS] = { 0 }; + +static void +gnt_check_box_draw(GntWidget *widget) +{ + GntCheckBox *cb = GNT_CHECK_BOX(widget); + GntColorType type; + char *text; + + if (gnt_widget_has_focus(widget)) + type = GNT_COLOR_HIGHLIGHT; + else + type = GNT_COLOR_NORMAL; + + wbkgdset(widget->window, '\0' | COLOR_PAIR(type)); + + text = g_strdup_printf("[%c]", cb->checked ? 'X' : ' '); + mvwprintw(widget->window, 0, 0, text); + g_free(text); + + wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); + mvwprintw(widget->window, 0, 4, GNT_BUTTON(cb)->priv->text); + + DEBUG; +} + +static void +gnt_check_box_size_request(GntWidget *widget) +{ +} + +static void +gnt_check_box_map(GntWidget *widget) +{ + if (widget->priv.width == 0 || widget->priv.height == 0) + gnt_widget_size_request(widget); + DEBUG; +} + +static gboolean +gnt_check_box_key_pressed(GntWidget *widget, const char *text) +{ + if (text[0] == ' ' && text[1] == '\0') + { + GNT_CHECK_BOX(widget)->checked = !GNT_CHECK_BOX(widget)->checked; + g_signal_emit(widget, signals[SIG_TOGGLED], 0); + gnt_widget_draw(widget); + return TRUE; + } + + return FALSE; +} + +static void +gnt_check_box_destroy(GntWidget *widget) +{ +} + +static void +gnt_check_box_class_init(GntCheckBoxClass *klass) +{ + GntWidgetClass *wclass = GNT_WIDGET_CLASS(klass); + + parent_class = GNT_BUTTON_CLASS(klass); + /*parent_class->destroy = gnt_check_box_destroy;*/ + wclass->draw = gnt_check_box_draw; + /*parent_class->map = gnt_check_box_map;*/ + /*parent_class->size_request = gnt_check_box_size_request;*/ + wclass->key_pressed = gnt_check_box_key_pressed; + + signals[SIG_TOGGLED] = + g_signal_new("toggled", + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(GntCheckBoxClass, toggled), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + DEBUG; +} + +static void +gnt_check_box_init(GTypeInstance *instance, gpointer class) +{ + GNT_WIDGET_SET_FLAGS(GNT_WIDGET(instance), GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW); + DEBUG; +} + +/****************************************************************************** + * GntCheckBox API + *****************************************************************************/ +GType +gnt_check_box_get_gtype(void) +{ + static GType type = 0; + + if(type == 0) + { + static const GTypeInfo info = { + sizeof(GntCheckBoxClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc)gnt_check_box_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(GntCheckBox), + 0, /* n_preallocs */ + gnt_check_box_init, /* instance_init */ + }; + + type = g_type_register_static(GNT_TYPE_BUTTON, + "GntCheckBox", + &info, 0); + } + + return type; +} + +GntWidget *gnt_check_box_new(const char *text) +{ + GntWidget *widget = g_object_new(GNT_TYPE_CHECK_BOX, NULL); + + GNT_BUTTON(widget)->priv->text = g_strdup(text); + gnt_widget_set_take_focus(widget, TRUE); + + return widget; +} + +void gnt_check_box_set_checked(GntCheckBox *box, gboolean set) +{ + if (set != box->checked) + { + box->checked = set; + g_signal_emit(box, signals[SIG_TOGGLED], 0); + } +} + +gboolean gnt_check_box_get_checked(GntCheckBox *box) +{ + return box->checked; +} + + + Copied: branches/soc-2006-file-loggers/console/libgnt/gntcheckbox.h (from rev 16597, trunk/console/libgnt/gntcheckbox.h) =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntcheckbox.h (rev 0) +++ branches/soc-2006-file-loggers/console/libgnt/gntcheckbox.h 2006-07-29 21:38:18 UTC (rev 16598) @@ -0,0 +1,54 @@ +#ifndef GNT_CHECK_BOX_H +#define GNT_CHECK_BOX_H + +#include "gntbutton.h" +#include "gnt.h" +#include "gntcolors.h" +#include "gntkeys.h" + +#define GNT_TYPE_CHECK_BOX (gnt_check_box_get_gtype()) +#define GNT_CHECK_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_CHECK_BOX, GntCheckBox)) +#define GNT_CHECK_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_CHECK_BOX, GntCheckBoxClass)) +#define GNT_IS_CHECK_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_CHECK_BOX)) +#define GNT_IS_CHECK_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_CHECK_BOX)) +#define GNT_CHECK_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_CHECK_BOX, GntCheckBoxClass)) + +#define GNT_CHECK_BOX_FLAGS(obj) (GNT_CHECK_BOX(obj)->priv.flags) +#define GNT_CHECK_BOX_SET_FLAGS(obj, flags) (GNT_CHECK_BOX_FLAGS(obj) |= flags) +#define GNT_CHECK_BOX_UNSET_FLAGS(obj, flags) (GNT_CHECK_BOX_FLAGS(obj) &= ~(flags)) + +typedef struct _GnCheckBox GntCheckBox; +typedef struct _GnCheckBoxPriv GntCheckBoxPriv; +typedef struct _GnCheckBoxClass GntCheckBoxClass; + +struct _GnCheckBox +{ + GntButton parent; + gboolean checked; +}; + +struct _GnCheckBoxClass +{ + GntButtonClass parent; + + void (*toggled)(void); + + void (*gnt_reserved1)(void); + void (*gnt_reserved2)(void); + void (*gnt_reserved3)(void); + void (*gnt_reserved4)(void); +}; + +G_BEGIN_DECLS + +GType gnt_check_box_get_gtype(void); + +GntWidget *gnt_check_box_new(const char *text); + +void gnt_check_box_set_checked(GntCheckBox *box, gboolean set); + +gboolean gnt_check_box_get_checked(GntCheckBox *box); + +G_END_DECLS + +#endif /* GNT_CHECK_BOX_H */ Modified: branches/soc-2006-file-loggers/console/libgnt/gntcolors.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntcolors.c 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/console/libgnt/gntcolors.c 2006-07-29 21:38:18 UTC (rev 16598) @@ -1,6 +1,11 @@ #include <ncursesw/ncurses.h> #include "gntcolors.h" +#include <glib.h> + +#include <stdlib.h> +#include <string.h> + static struct { short r, g, b; @@ -75,3 +80,125 @@ restore_colors(); } +static int +get_color(char *key) +{ + int color; + + key = g_strstrip(key); + + if (strcmp(key, "black") == 0) + color = GNT_COLOR_BLACK; + else if (strcmp(key, "red") == 0) + color = GNT_COLOR_RED; + else if (strcmp(key, "green") == 0) + color = GNT_COLOR_GREEN; + else if (strcmp(key, "blue") == 0) + color = GNT_COLOR_BLUE; + else if (strcmp(key, "white") == 0) + color = GNT_COLOR_WHITE; + else if (strcmp(key, "gray") == 0) + color = GNT_COLOR_GRAY; + else if (strcmp(key, "darkgray") == 0) + color = GNT_COLOR_DARK_GRAY; + else + color = -1; + return color; +} + +void gnt_colors_parse(GKeyFile *kfile) +{ + GError *error = NULL; + gsize nkeys; + char **keys = g_key_file_get_keys(kfile, "colors", &nkeys, &error); + + if (error) + { + /* XXX: some error happened. */ + g_error_free(error); + } + else + { + while (nkeys--) + { + gsize len; + char *key = keys[nkeys]; + char **list = g_key_file_get_string_list(kfile, "colors", key, &len, NULL); + if (len == 3) + { + int r = atoi(list[0]); + int g = atoi(list[1]); + int b = atoi(list[2]); + int color = -1; + + g_ascii_strdown(key, -1); + color = get_color(key); + if (color == -1) + continue; + + init_color(color, r, g, b); + } + g_strfreev(list); + } + + g_strfreev(keys); + } + + gnt_color_pairs_parse(kfile); +} + +void gnt_color_pairs_parse(GKeyFile *kfile) +{ + GError *error = NULL; + gsize nkeys; + char **keys = g_key_file_get_keys(kfile, "colorpairs", &nkeys, &error); + + if (error) + { + /* XXX: some error happened. */ + g_error_free(error); + return; + } + + while (nkeys--) + { + gsize len; + char *key = keys[nkeys]; + char **list = g_key_file_get_string_list(kfile, "colorpairs", key, &len, NULL); + if (len == 2) + { + GntColorType type = 0; + int fg = get_color(g_ascii_strdown(list[0], -1)); + int bg = get_color(g_ascii_strdown(list[1], -1)); + if (fg == -1 || bg == -1) + continue; + + g_ascii_strdown(key, -1); + + if (strcmp(key, "normal") == 0) + type = GNT_COLOR_NORMAL; + else if (strcmp(key, "highlight") == 0) + type = GNT_COLOR_HIGHLIGHT; + else if (strcmp(key, "highlightd") == 0) + type = GNT_COLOR_HIGHLIGHT_D; + else if (strcmp(key, "shadow") == 0) + type = GNT_COLOR_SHADOW; + else if (strcmp(key, "title") == 0) + type = GNT_COLOR_TITLE; + else if (strcmp(key, "titled") == 0) + type = GNT_COLOR_TITLE_D; + else if (strcmp(key, "text") == 0) + type = GNT_COLOR_TEXT_NORMAL; + else if (strcmp(key, "disabled") == 0) + type = GNT_COLOR_DISABLED; + else + continue; + + init_pair(type, fg, bg); + } + g_strfreev(list); + } + + g_strfreev(keys); +} + Modified: branches/soc-2006-file-loggers/console/libgnt/gntcolors.h =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntcolors.h 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/console/libgnt/gntcolors.h 2006-07-29 21:38:18 UTC (rev 16598) @@ -1,6 +1,8 @@ #ifndef GNT_COLORS_H #define GNT_COLORS_H +#include <glib.h> + typedef enum { GNT_COLOR_NORMAL = 1, @@ -34,4 +36,8 @@ void gnt_uninit_colors(); +void gnt_colors_parse(GKeyFile *kfile); + +void gnt_color_pairs_parse(GKeyFile *kfile); + #endif Modified: branches/soc-2006-file-loggers/console/libgnt/gntcombobox.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntcombobox.c 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/console/libgnt/gntcombobox.c 2006-07-29 21:38:18 UTC (rev 16598) @@ -20,10 +20,14 @@ { if (box->selected != key) { + /* XXX: make sure the key actually does exist */ gpointer old = box->selected; box->selected = key; g_signal_emit(box, signals[SIG_SELECTION_CHANGED], 0, old, key); - gnt_widget_draw(GNT_WIDGET(box)); + if (GNT_WIDGET(box)->window) + gnt_widget_draw(GNT_WIDGET(box)); + if (box->dropdown) + gnt_tree_set_selected(GNT_TREE(box->dropdown), key); } } @@ -246,3 +250,8 @@ return box->selected; } +void gnt_combo_box_set_selected(GntComboBox *box, gpointer key) +{ + set_selection(box, key); +} + Modified: branches/soc-2006-file-loggers/console/libgnt/gntcombobox.h =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntcombobox.h 2006-07-29 20:26:50 UTC (rev 16597) +++ branches/soc-2006-file-loggers/console/libgnt/gntcombobox.h 2006-07-29 21:38:18 UTC (rev 16598) @@ -50,6 +50,8 @@ gpointer gnt_combo_box_get... [truncated message content] |