Mercurial > pidgin.yaz
changeset 19124:7e0379a41a44
propagate from branch 'im.pidgin.pidgin' (head 89468df5d1cdb033902c9f7e41cfdf3a348d97bc)
to branch 'im.pidgin.soc.2007.finchfeat' (head aa0595d32b99d229dafb41c7c83e1d1944175f99)
author | Eric Polino <aluink@pidgin.im> |
---|---|
date | Fri, 29 Jun 2007 20:05:17 +0000 |
parents | 700b642631bc (current diff) 576edd9c4f72 (diff) |
children | 915ef65d68e3 |
files | finch/libgnt/gntwidget.c pidgin/sounds/Makefile.am pidgin/sounds/Makefile.mingw pidgin/sounds/alert.wav pidgin/sounds/login.wav pidgin/sounds/logout.wav pidgin/sounds/receive.wav pidgin/sounds/send.wav |
diffstat | 38 files changed, 1268 insertions(+), 96 deletions(-) [+] |
line wrap: on
line diff
--- a/COPYRIGHT Fri Jun 29 19:36:31 2007 +0000 +++ b/COPYRIGHT Fri Jun 29 20:05:17 2007 +0000 @@ -274,6 +274,7 @@ Joao Luís Marques Pinto Aleksander Piotrowski Julien Pivotto +Eric Polino <aluink@gmail.com> Ari Pollak Robey Pointer Eric Polino
--- a/Makefile.am Fri Jun 29 19:36:31 2007 +0000 +++ b/Makefile.am Fri Jun 29 20:05:17 2007 +0000 @@ -42,7 +42,7 @@ GNT_DIR=finch endif -SUBDIRS = libpurple doc $(GNT_DIR) $(GTK_DIR) m4macros po +SUBDIRS = libpurple doc $(GNT_DIR) $(GTK_DIR) m4macros po share docs: Doxyfile if HAVE_DOXYGEN
--- a/configure.ac Fri Jun 29 19:36:31 2007 +0000 +++ b/configure.ac Fri Jun 29 20:05:17 2007 +0000 @@ -2114,7 +2114,6 @@ pidgin/plugins/perl/Makefile pidgin/plugins/perl/common/Makefile.PL pidgin/plugins/ticker/Makefile - pidgin/sounds/Makefile libpurple/example/Makefile libpurple/gconf/Makefile libpurple/purple.pc @@ -2147,6 +2146,8 @@ libpurple/protocols/zephyr/Makefile libpurple/tests/Makefile libpurple/version.h + share/Makefile + share/sounds/Makefile finch/Makefile finch/libgnt/Makefile finch/libgnt/gnt.pc
--- a/finch/Makefile.am Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/Makefile.am Fri Jun 29 20:05:17 2007 +0000 @@ -25,6 +25,7 @@ gntpounce.c \ gntprefs.c \ gntrequest.c \ + gntsound.c \ gntstatus.c \ gntui.c @@ -42,6 +43,7 @@ gntpounce.h \ gntprefs.h \ gntrequest.h \ + gntsound.h \ gntstatus.h \ gntui.h @@ -58,6 +60,7 @@ $(GLIB_LIBS) \ $(LIBXML_LIBS) \ $(GNT_LIBS) \ + $(GSTREAMER_LIBS) \ ./libgnt/libgnt.la \ $(top_builddir)/libpurple/libpurple.la @@ -75,4 +78,5 @@ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) \ $(LIBXML_CFLAGS) \ + $(GSTREAMER_CFLAGS) \ $(GNT_CFLAGS)
--- a/finch/finch.h Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/finch.h Fri Jun 29 20:05:17 2007 +0000 @@ -27,3 +27,4 @@ #define FINCH_UI "gnt-purple" +#define FINCH_PREFS_ROOT "/finch"
--- a/finch/gntconv.h Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/gntconv.h Fri Jun 29 20:05:17 2007 +0000 @@ -30,6 +30,9 @@ #include "conversation.h" +/* Grabs the conv out of a PurpleConverstation */ +#define FINCH_CONV(conv) ((FinchConv *)(conv)->ui_data) + /*************************************************************************** * @name GNT Conversations API ***************************************************************************/
--- a/finch/gntdebug.c Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/gntdebug.c Fri Jun 29 20:05:17 2007 +0000 @@ -301,7 +301,7 @@ REGISTER_G_LOG_HANDLER("GThread"); g_set_print_handler(print_stderr); /* Redirect the debug messages to stderr */ - g_set_printerr_handler(suppress_error_messages); +// g_set_printerr_handler(suppress_error_messages); purple_prefs_add_none(PREF_ROOT); purple_prefs_add_string(PREF_ROOT "/filter", "");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/finch/gntsound.c Fri Jun 29 20:05:17 2007 +0000 @@ -0,0 +1,748 @@ +/** +* @file gntsound.c GNT Sound API +* @ingroup finch +* +* finch +* +* Finch is the legal property of its developers, whose names are too numerous +* to list here. Please refer to the COPYRIGHT file distributed with this +* source distribution. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* 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 "finch.h" + +#ifdef _WIN32 +#include <windows.h> +#include <mmsystem.h> +#endif + +#ifdef USE_GSTREAMER +#include <gst/gst.h> +#endif /* USE_GSTREAMER */ + +#include "debug.h" +#include "notify.h" +#include "prefs.h" +#include "sound.h" +#include "util.h" + +#include "gntbox.h" +#include "gntwindow.h" +#include "gntcombobox.h" +#include "gntlabel.h" +#include "gntconv.h" +#include "gntsound.h" +#include "gntwidget.h" +#include "gntentry.h" +#include "gntcheckbox.h" +#include "gntline.h" + +struct finch_sound_event { + char *label; + char *pref; + char *def; +}; + +typedef struct { + GntWidget *method; + GntWidget *command; + GntWidget *conv_focus; + GntWidget *while_status; + GntWidget *volume; + GntWidget *window; +} SoundPrefDialog; + +static struct { + const gchar *method; + const gchar *command; + gboolean conv_focus; + gint while_status; + gint volume; + GntTree *events; + SoundPrefDialog *dialog; +} sound_pref_data; + +#define PLAY_SOUND_TIMEOUT 15000 + +static guint mute_login_sounds_timeout = 0; +static gboolean mute_login_sounds = FALSE; + +#ifdef USE_GSTREAMER +static gboolean gst_init_failed; +#endif /* USE_GSTREAMER */ + +static struct finch_sound_event sounds[PURPLE_NUM_SOUNDS] = { + {N_("Buddy logs in"), "login", "login.wav"}, + {N_("Buddy logs out"), "logout", "logout.wav"}, + {N_("Message received"), "im_recv", "receive.wav"}, + {N_("Message received begins conversation"), "first_im_recv", "receive.wav"}, + {N_("Message sent"), "send_im", "send.wav"}, + {N_("Person enters chat"), "join_chat", "login.wav"}, + {N_("Person leaves chat"), "left_chat", "logout.wav"}, + {N_("You talk in chat"), "send_chat_msg", "send.wav"}, + {N_("Others talk in chat"), "chat_msg_recv", "receive.wav"}, + /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ + {NULL, "pounce_default", "alert.wav"}, + {N_("Someone says your screen name in chat"), "nick_said", "alert.wav"} +}; + +static gboolean +unmute_login_sounds_cb(gpointer data) +{ + mute_login_sounds = FALSE; + mute_login_sounds_timeout = 0; + return FALSE; +} + +static gboolean +chat_nick_matches_name(PurpleConversation *conv, const char *aname) +{ + PurpleConvChat *chat = NULL; + char *nick = NULL; + char *name = NULL; + gboolean ret = FALSE; + chat = purple_conversation_get_chat_data(conv); + + if (chat==NULL) + return ret; + + nick = g_strdup(purple_normalize(conv->account, chat->nick)); + name = g_strdup(purple_normalize(conv->account, aname)); + + if (g_utf8_collate(nick, name) == 0) + ret = TRUE; + + g_free(nick); + g_free(name); + + return ret; +} + +/* + * play a sound event for a conversation, honoring make_sound flag + * of conversation and checking for focus if conv_focus pref is set + */ +static void +play_conv_event(PurpleConversation *conv, PurpleSoundEventID event) +{ + /* If we should not play the sound for some reason, then exit early */ + if (conv != NULL) + { + FinchConv *gntconv; + gboolean has_focus; + + gntconv = FINCH_CONV(conv); + + has_focus = purple_conversation_has_focus(conv); + + if (has_focus && !purple_prefs_get_bool(FINCH_PREFS_ROOT "/sound/conv_focus")) + { + return; + } + } + + purple_sound_play_event(event, conv ? purple_conversation_get_account(conv) : NULL); +} + +static void +buddy_state_cb(PurpleBuddy *buddy, PurpleSoundEventID event) +{ + purple_sound_play_event(event, purple_buddy_get_account(buddy)); +} + +static void +im_msg_received_cb(PurpleAccount *account, char *sender, + char *message, PurpleConversation *conv, + PurpleMessageFlags flags, PurpleSoundEventID event) +{ + if (flags & PURPLE_MESSAGE_DELAYED) + return; + + if (conv==NULL){ + purple_sound_play_event(PURPLE_SOUND_FIRST_RECEIVE, account); + } + else{ + play_conv_event(conv, event); + } +} + +static void +im_msg_sent_cb(PurpleAccount *account, const char *receiver, + const char *message, PurpleSoundEventID event) +{ + PurpleConversation *conv = purple_find_conversation_with_account( + PURPLE_CONV_TYPE_ANY, receiver, account); + play_conv_event(conv, event); +} + +static void +chat_buddy_join_cb(PurpleConversation *conv, const char *name, + PurpleConvChatBuddyFlags flags, gboolean new_arrival, + PurpleSoundEventID event) +{ + if (new_arrival && !chat_nick_matches_name(conv, name)) + play_conv_event(conv, event); +} + +static void +chat_buddy_left_cb(PurpleConversation *conv, const char *name, + const char *reason, PurpleSoundEventID event) +{ + if (!chat_nick_matches_name(conv, name)) + play_conv_event(conv, event); +} + +static void +chat_msg_sent_cb(PurpleAccount *account, const char *message, + int id, PurpleSoundEventID event) +{ + PurpleConnection *conn = purple_account_get_connection(account); + PurpleConversation *conv = NULL; + + if (conn!=NULL) + conv = purple_find_chat(conn,id); + + play_conv_event(conv, event); +} + +static void +chat_msg_received_cb(PurpleAccount *account, char *sender, + char *message, PurpleConversation *conv, + PurpleMessageFlags flags, PurpleSoundEventID event) +{ + PurpleConvChat *chat; + + if (flags & PURPLE_MESSAGE_DELAYED) + return; + + chat = purple_conversation_get_chat_data(conv); + g_return_if_fail(chat != NULL); + + if (purple_conv_chat_is_user_ignored(chat, sender)) + return; + + if (chat_nick_matches_name(conv, sender)) + return; + + if (flags & PURPLE_MESSAGE_NICK || purple_utf8_has_word(message, chat->nick)) + play_conv_event(conv, PURPLE_SOUND_CHAT_NICK); + else + play_conv_event(conv, event); +} + +/* + * We mute sounds for the 10 seconds after you log in so that + * you don't get flooded with sounds when the blist shows all + * your buddies logging in. + */ +static void +account_signon_cb(PurpleConnection *gc, gpointer data) +{ + if (mute_login_sounds_timeout != 0) + g_source_remove(mute_login_sounds_timeout); + mute_login_sounds = TRUE; + mute_login_sounds_timeout = purple_timeout_add(10000, unmute_login_sounds_cb, NULL); +} + +const char * +finch_sound_get_event_option(PurpleSoundEventID event) +{ + if(event >= PURPLE_NUM_SOUNDS) + return 0; + + return sounds[event].pref; +} + +const char * +finch_sound_get_event_label(PurpleSoundEventID event) +{ + if(event >= PURPLE_NUM_SOUNDS) + return NULL; + + return sounds[event].label; +} + +void * +finch_sound_get_handle() +{ + static int handle; + + return &handle; +} + +static void +finch_sound_init(void) +{ + void *gnt_sound_handle = finch_sound_get_handle(); + void *blist_handle = purple_blist_get_handle(); + void *conv_handle = purple_conversations_get_handle(); +#ifdef USE_GSTREAMER + GError *error = NULL; +#endif + + purple_signal_connect(purple_connections_get_handle(), "signed-on", + gnt_sound_handle, PURPLE_CALLBACK(account_signon_cb), + NULL); + + purple_prefs_add_none(FINCH_PREFS_ROOT "/sound"); + purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/enabled"); + purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/file"); + purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/login", TRUE); + purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/login", ""); + purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/logout", TRUE); + purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/logout", ""); + purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/im_recv", TRUE); + purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/im_recv", ""); + purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/first_im_recv", FALSE); + purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/first_im_recv", ""); + purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/send_im", TRUE); + purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/send_im", ""); + purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/join_chat", FALSE); + purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/join_chat", ""); + purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/left_chat", FALSE); + purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/left_chat", ""); + purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/send_chat_msg", FALSE); + purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/send_chat_msg", ""); + purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/chat_msg_recv", FALSE); + purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/chat_msg_recv", ""); + purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/nick_said", FALSE); + purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/nick_said", ""); + purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/pounce_default", TRUE); + purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/pounce_default", ""); + purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/conv_focus", TRUE); + purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/mute", FALSE); + purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/command", ""); + purple_prefs_add_string(FINCH_PREFS_ROOT "/sound/method", "automatic"); + purple_prefs_add_int(FINCH_PREFS_ROOT "/sound/volume", 50); + +#ifdef USE_GSTREAMER + purple_debug_info("sound", "Initializing sound output drivers.\n"); + if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) { + purple_notify_error(NULL, _("GStreamer Failure"), + _("GStreamer failed to initialize."), + error ? error->message : ""); + if (error) { + g_error_free(error); + error = NULL; + } + } +#endif /* USE_GSTREAMER */ + + purple_signal_connect(blist_handle, "buddy-signed-on", + gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb), + GINT_TO_POINTER(PURPLE_SOUND_BUDDY_ARRIVE)); + purple_signal_connect(blist_handle, "buddy-signed-off", + gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb), + GINT_TO_POINTER(PURPLE_SOUND_BUDDY_LEAVE)); + purple_signal_connect(conv_handle, "received-im-msg", + gnt_sound_handle, PURPLE_CALLBACK(im_msg_received_cb), + GINT_TO_POINTER(PURPLE_SOUND_RECEIVE)); + purple_signal_connect(conv_handle, "sent-im-msg", + gnt_sound_handle, PURPLE_CALLBACK(im_msg_sent_cb), + GINT_TO_POINTER(PURPLE_SOUND_SEND)); + purple_signal_connect(conv_handle, "chat-buddy-joined", + gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_join_cb), + GINT_TO_POINTER(PURPLE_SOUND_CHAT_JOIN)); + purple_signal_connect(conv_handle, "chat-buddy-left", + gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_left_cb), + GINT_TO_POINTER(PURPLE_SOUND_CHAT_LEAVE)); + purple_signal_connect(conv_handle, "sent-chat-msg", + gnt_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb), + GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY)); + purple_signal_connect(conv_handle, "received-chat-msg", + gnt_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb), + GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY)); +} + +static void +finch_sound_uninit(void) +{ +#ifdef USE_GSTREAMER + if (!gst_init_failed) + gst_deinit(); +#endif + + purple_signals_disconnect_by_handle(finch_sound_get_handle()); +} + +#ifdef USE_GSTREAMER +static gboolean +bus_call (GstBus *bus, GstMessage *msg, gpointer data) +{ + GstElement *play = data; + GError *err = NULL; + + switch (GST_MESSAGE_TYPE (msg)) { + case GST_MESSAGE_EOS: + gst_element_set_state(play, GST_STATE_NULL); + gst_object_unref(GST_OBJECT(play)); + break; + case GST_MESSAGE_ERROR: + gst_message_parse_error(msg, &err, NULL); + purple_debug_error("gstreamer", err->message); + g_error_free(err); + break; + case GST_MESSAGE_WARNING: + gst_message_parse_warning(msg, &err, NULL); + purple_debug_warning("gstreamer", err->message); + g_error_free(err); + break; + default: + break; + } + return TRUE; +} +#endif + +static void +finch_sound_play_file(const char *filename) +{ + const char *method; +#ifdef USE_GSTREAMER + float volume; + char *uri; + GstElement *sink = NULL; + GstElement *play = NULL; + GstBus *bus = NULL; +#endif + if (purple_prefs_get_bool(FINCH_PREFS_ROOT "/sound/mute")) + return; + + method = purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/method"); + + if (!strcmp(method, "none")) { + return; + } else if (!strcmp(method, "beep")) { + beep(); + return; + } + + if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { + purple_debug_error("gntsound", "sound file (%s) does not exist.\n", filename); + return; + } + +#ifndef _WIN32 + if (!strcmp(method, "custom")) { + const char *sound_cmd; + char *command; + char *esc_filename; + GError *error = NULL; + + sound_cmd = purple_prefs_get_path(FINCH_PREFS_ROOT "/sound/command"); + + if (!sound_cmd || *sound_cmd == '\0') { + purple_debug_error("gntsound", + "'Command' sound method has been chosen, " + "but no command has been set."); + return; + } + + esc_filename = g_shell_quote(filename); + + if(strstr(sound_cmd, "%s")) + command = purple_strreplace(sound_cmd, "%s", esc_filename); + else + command = g_strdup_printf("%s %s", sound_cmd, esc_filename); + + if(!g_spawn_command_line_async(command, &error)) { + purple_debug_error("gntsound", "sound command could not be launched: %s\n", error->message); + g_error_free(error); + } + + g_free(esc_filename); + g_free(command); + return; + } +#ifdef USE_GSTREAMER + if (gst_init_failed) /* Perhaps do beep instead? */ + return; + volume = (float)(CLAMP(purple_prefs_get_int(FINCH_PREFS_ROOT "/sound/volume"),0,100)) / 50; + if (!strcmp(method, "automatic")) { + if (purple_running_gnome()) { + sink = gst_element_factory_make("gconfaudiosink", "sink"); + } + if (!sink) + sink = gst_element_factory_make("autoaudiosink", "sink"); + if (!sink) { + purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); + return; + } + } else if (!strcmp(method, "esd")) { + sink = gst_element_factory_make("esdsink", "sink"); + if (!sink) { + purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); + return; + } + } else if (!strcmp(method, "alsa")) { + sink = gst_element_factory_make("alsasink", "sink"); + if (!sink) { + purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); + return; + } + } else { + purple_debug_error("sound", "Unknown sound method '%s'\n", method); + return; + } + + play = gst_element_factory_make("playbin", "play"); + + if (play == NULL) { + return; + } + + uri = g_strdup_printf("file://%s", filename); + + g_object_set(G_OBJECT(play), "uri", uri, + "volume", volume, + "audio-sink", sink, NULL); + + bus = gst_pipeline_get_bus(GST_PIPELINE(play)); + gst_bus_add_watch(bus, bus_call, play); + + gst_element_set_state(play, GST_STATE_PLAYING); + + gst_object_unref(bus); + g_free(uri); + +#else /* USE_GSTREAMER */ + beep(); + return; +#endif /* USE_GSTREAMER */ +#else /* _WIN32 */ + purple_debug_info("sound", "Playing %s\n", filename); + + if (G_WIN32_HAVE_WIDECHAR_API ()) { + wchar_t *wc_filename = g_utf8_to_utf16(filename, + -1, NULL, NULL, NULL); + if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) + purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); + g_free(wc_filename); + } else { + char *l_filename = g_locale_from_utf8(filename, + -1, NULL, NULL, NULL); + if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME)) + purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); + g_free(l_filename); + } +#endif /* _WIN32 */ +} + +static void +finch_sound_play_event(PurpleSoundEventID event) +{ + char *enable_pref; + char *file_pref; + if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds) + return; + + if (event >= PURPLE_NUM_SOUNDS) { + purple_debug_error("sound", "got request for unknown sound: %d\n", event); + return; + } + + enable_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/enabled/%s", + sounds[event].pref); + file_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/file/%s", sounds[event].pref); + + /* check NULL for sounds that don't have an option, ie buddy pounce */ + if (purple_prefs_get_bool(enable_pref)) { + char *filename = g_strdup(purple_prefs_get_path(file_pref)); + if(!filename || !strlen(filename)) { + g_free(filename); + /* XXX Consider creating a constant for "sounds/purple" to be shared with Pidgin */ + filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL); + } + + purple_sound_play_file(filename, NULL); + g_free(filename); + } + + g_free(enable_pref); + g_free(file_pref); +} + +static void init_pref_data() +{ + GntTree *events = NULL; + + if(sound_pref_data.method){ + return; + } + + /* TODO Setup the events tree */ + + sound_pref_data.method = purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/method"); + sound_pref_data.command = purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/command"); + sound_pref_data.conv_focus = purple_prefs_get_bool(FINCH_PREFS_ROOT "/sound/conv_focus"); + sound_pref_data.while_status = purple_prefs_get_int(FINCH_PREFS_ROOT "/purple/sound/while_status"); + sound_pref_data.volume = CLAMP(purple_prefs_get_int(FINCH_PREFS_ROOT "/sound/volume"),0,100); + sound_pref_data.events = events; + + return; +} + +static gboolean +save_cb(GntBindable *data, gpointer *win) +{ + gnt_widget_destroy(GNT_WIDGET(win)); + return TRUE; +} + +static gboolean +cancel_cb(GntBindable *data, gpointer win) +{ + gnt_widget_destroy(GNT_WIDGET(win)); + return TRUE; +} + +static void release_pref_window(GntBindable *data, gpointer null) { + g_free(sound_pref_data.dialog); + sound_pref_data.dialog = NULL; +} + +void +finch_sounds_show_all(void) +{ + GntWidget *box; + GntWidget *cmbox; + GntWidget *entry; + GntWidget *chkbox; + GntWidget *button; + GntWidget *label; + GntWidget *win; + gchar *buf; + + if(sound_pref_data.dialog){ + gnt_window_present(sound_pref_data.dialog->window); + return; + } + + init_pref_data(); + + sound_pref_data.dialog = g_new0(SoundPrefDialog,1); + + sound_pref_data.dialog->window = win = gnt_window_box_new(FALSE,TRUE); + gnt_box_set_pad(GNT_BOX(win),0); + gnt_box_set_fill(GNT_BOX(win),FALSE); + gnt_box_set_toplevel(GNT_BOX(win), TRUE); + gnt_box_set_title(GNT_BOX(win),_("Sound Preferences")); + gnt_box_set_fill(GNT_BOX(win),TRUE); + gnt_box_set_alignment(GNT_BOX(win),GNT_ALIGN_MID); + gnt_widget_set_name(win, "sounds"); + + sound_pref_data.dialog->method = cmbox = gnt_combo_box_new(); + gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"automatic",_("Automatic")); + gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"alsa","ALSA"); + gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"esd","ESD"); + gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"beep",_("Console Beep")); + gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"custom",_("Command")); + gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"nosound",_("No Sound")); + gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),sound_pref_data.method); + + label = gnt_label_new_with_format(_("Sound Method"),GNT_TEXT_FLAG_BOLD); + gnt_box_add_widget(GNT_BOX(win),label); + box = gnt_hbox_new(TRUE); + gnt_box_set_fill(GNT_BOX(box),FALSE); + gnt_box_set_pad(GNT_BOX(box),0); + gnt_box_add_widget(GNT_BOX(box),gnt_label_new(_("Method: "))); + gnt_box_add_widget(GNT_BOX(box),cmbox); + gnt_box_add_widget(GNT_BOX(win),box); + + box = gnt_hbox_new(TRUE); + gnt_box_set_pad(GNT_BOX(box),0); + gnt_box_set_fill(GNT_BOX(box),FALSE); + gnt_box_add_widget(GNT_BOX(box),gnt_label_new(_("Sound Command\n(%s for filename)"))); + sound_pref_data.dialog->command = entry = gnt_entry_new(sound_pref_data.command); + gnt_box_add_widget(GNT_BOX(box),entry); + gnt_box_add_widget(GNT_BOX(win),box); + + gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE)); + + gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Sound Options"),GNT_TEXT_FLAG_BOLD)); + sound_pref_data.dialog->conv_focus = chkbox = gnt_check_box_new("Sounds when conversation has focus"); + gnt_check_box_set_checked(GNT_CHECK_BOX(chkbox),sound_pref_data.conv_focus); + gnt_box_add_widget(GNT_BOX(win),chkbox); + + box = gnt_hbox_new(TRUE); + gnt_box_set_pad(GNT_BOX(box),0); + gnt_box_set_fill(GNT_BOX(box),FALSE); + gnt_box_add_widget(GNT_BOX(box),gnt_label_new("Enable Sounds:")); + sound_pref_data.dialog->while_status = cmbox = gnt_combo_box_new(); + gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"always","Always"); + gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"available","Only when available"); + gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"away","Only when not available"); + switch(sound_pref_data.while_status){ + case 1:gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),"available");break; + case 2:gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),"away");break; + default:gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),"always");break; + } + gnt_box_add_widget(GNT_BOX(box),cmbox); + gnt_box_add_widget(GNT_BOX(win),box); + + box = gnt_hbox_new(TRUE); + gnt_box_set_pad(GNT_BOX(box),0); + gnt_box_set_fill(GNT_BOX(box),FALSE); + gnt_box_add_widget(GNT_BOX(box),gnt_label_new("Volume(0-100):")); + + buf = g_strdup_printf("%d",sound_pref_data.volume); + sound_pref_data.dialog->volume = entry = gnt_entry_new(buf); + g_free(buf); + gnt_widget_set_name(entry,"volume"); + gnt_box_add_widget(GNT_BOX(box),entry); + gnt_box_add_widget(GNT_BOX(win),box); + + gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE)); + + gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Sound Events"),GNT_TEXT_FLAG_BOLD)); + /* Put events tree here */ + + box = gnt_hbox_new(TRUE); + gnt_box_set_pad(GNT_BOX(box),0); + gnt_box_set_fill(GNT_BOX(box),TRUE); + button = gnt_button_new("Save"); + g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(save_cb),NULL); + gnt_box_add_widget(GNT_BOX(box),button); + button = gnt_button_new("Cancel"); + g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(cancel_cb),NULL); + gnt_box_add_widget(GNT_BOX(box),button); + gnt_box_add_widget(GNT_BOX(win),box); + + + g_signal_connect(G_OBJECT(win),"destroy",G_CALLBACK(release_pref_window),NULL); + + gnt_widget_show(win); + +} + +static PurpleSoundUiOps sound_ui_ops = +{ + finch_sound_init, + finch_sound_uninit, + finch_sound_play_file, + finch_sound_play_event, + NULL, + NULL, + NULL, + NULL +}; + +PurpleSoundUiOps * +finch_sound_get_ui_ops(void) +{ + return &sound_ui_ops; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/finch/gntsound.h Fri Jun 29 20:05:17 2007 +0000 @@ -0,0 +1,72 @@ +/** + * @file gntsound.h GNT Sound API + * @ingroup finch + * + * finch + * + * Finch is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _GNT_SOUND_H +#define _GNT_SOUND_H + +#include "sound.h" + +/**********************************************************************/ +/** @name GNT Sound API */ +/**********************************************************************/ +/*@{*/ + +/** +* Get the prefs option for an event. +* +* @param event The event. +* @return The option. +*/ +const char *finch_sound_get_event_option(PurpleSoundEventID event); + +/** +* Get the label for an event. +* +* @param event The event. +* @return The label. +*/ +const char *finch_sound_get_event_label(PurpleSoundEventID event); + +/** +* Gets GNT sound UI ops. +* +* @return The UI operations structure. +*/ +PurpleSoundUiOps *finch_sound_get_ui_ops(void); + +/** + * Show the sound settings dialog. + */ +void finch_sounds_show_all(void); + +/** +* Get the handle for the GNT sound system. +* +* @return The handle to the sound system +*/ +void *finch_sound_get_handle(void); + +/*@}*/ + +#endif
--- a/finch/gntui.c Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/gntui.c Fri Jun 29 20:05:17 2007 +0000 @@ -35,6 +35,7 @@ #include "gntprefs.h" #include "gntrequest.h" #include "gntstatus.h" +#include "gntsound.h" #include <prefs.h> @@ -58,6 +59,9 @@ finch_blist_init(); purple_blist_set_ui_ops(finch_blist_get_ui_ops()); + /* Initialize sound */ + purple_sound_set_ui_ops(finch_sound_get_ui_ops()); + /* Now the conversations */ finch_conversation_init(); purple_conversations_set_ui_ops(finch_conv_get_ui_ops()); @@ -80,6 +84,7 @@ gnt_register_action(_("Debug Window"), finch_debug_window_show); gnt_register_action(_("File Transfers"), finch_xfer_dialog_show); gnt_register_action(_("Plugins"), finch_plugins_show_all); + gnt_register_action(_("Sounds"), finch_sounds_show_all); gnt_register_action(_("Preferences"), finch_prefs_show_all); gnt_register_action(_("Statuses"), finch_savedstatus_show_all);
--- a/finch/libgnt/gnt.h Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/libgnt/gnt.h Fri Jun 29 20:05:17 2007 +0000 @@ -148,4 +148,3 @@ * @param string */ void gnt_set_clipboard_string(gchar *string); -
--- a/finch/libgnt/gntbindable.c Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/libgnt/gntbindable.c Fri Jun 29 20:05:17 2007 +0000 @@ -20,13 +20,201 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <string.h> + #include "gntbindable.h" #include "gntstyle.h" #include "gnt.h" #include "gntutils.h" +#include "gnttextview.h" +#include "gnttree.h" +#include "gntbox.h" +#include "gntbutton.h" +#include "gntwindow.h" +#include "gntlabel.h" static GObjectClass *parent_class = NULL; +static struct +{ + char * okeys; /* Old keystrokes */ + char * keys; /* New Keystrokes being bound to the action */ + GntBindableClass * klass; /* Class of the object that's getting keys rebound */ + char * name; /* The name of the action */ + GList * params; /* The list of paramaters */ + +} rebind_info = {NULL,NULL,NULL,NULL,NULL}; + +static void +gnt_bindable_free_rebind_info() +{ + g_free(rebind_info.name); + g_free(rebind_info.keys); + g_free(rebind_info.okeys); +} + +static gboolean +gnt_bindable_rebinding_cancel(GntBindable *bindable, gpointer data) +{ + gnt_bindable_free_rebind_info(); + gnt_widget_destroy(GNT_WIDGET(data)); + return TRUE; +} + +static gboolean +gnt_bindable_rebinding_rebind(GntBindable *bindable, gpointer data) +{ + + if(rebind_info.keys) { + gnt_bindable_register_binding(rebind_info.klass, + NULL, + rebind_info.okeys, + rebind_info.params); + gnt_bindable_register_binding(rebind_info.klass, + rebind_info.name, + rebind_info.keys, + rebind_info.params); + } + gnt_bindable_free_rebind_info(); + + gnt_widget_destroy(GNT_WIDGET(data)); + + return TRUE; +} + +static gboolean +gnt_bindable_rebinding_grab_key(GntBindable *bindable, const char *text, gpointer *data) +{ + + GntTextView *textview= GNT_TEXT_VIEW(data); + char *new_text; + const char *tmp; + + if(text && *text){ + + if(!strcmp(text, GNT_KEY_CTRL_I) || !strcmp(text, GNT_KEY_ENTER)){ + return FALSE; + } + + tmp = gnt_key_lookup(text); + new_text = g_strdup_printf("KEY: \"%s\"",tmp); + gnt_text_view_clear(textview); + gnt_text_view_append_text_with_flags(textview,new_text,GNT_TEXT_FLAG_NORMAL); + g_free(new_text); + + g_free(rebind_info.keys); + rebind_info.keys = g_strdup(text); + + + return TRUE; + } + return FALSE; +} +static void +gnt_bindable_rebinding_activate(GntBindable *data, gpointer bindable) +{ + + GntTree * tree = GNT_TREE(data); + + GntWidget *vbox = gnt_box_new(FALSE,TRUE); + + GntWidget *label; + const char * widget_name = g_type_name(G_OBJECT_TYPE(bindable)); + char * keys; + + GntWidget *key_textview; + + GntWidget *bind_button, *cancel_button; + GntWidget *button_box; + + GntWidget *win = gnt_window_new(); + GList * current_row_data,*itr; + char * tmp; + + rebind_info.klass = GNT_BINDABLE_GET_CLASS(bindable); + + current_row_data = gnt_tree_get_selection_text_list(tree); + rebind_info.name = g_strdup(g_list_nth_data(current_row_data,1)); + + keys = gnt_tree_get_selection_data(tree); + rebind_info.okeys = g_strdup(gnt_key_translate(keys)); + + rebind_info.params = NULL; + + itr = current_row_data; + while(itr){ + g_free(itr->data); + itr = itr->next; + } + g_list_free(current_row_data); + + gnt_box_set_alignment(GNT_BOX(vbox), GNT_ALIGN_MID); + + gnt_box_set_title(GNT_BOX(win),"Key Capture"); + + tmp = g_strdup_printf("Type the new bindings for %s in a %s.",rebind_info.name,widget_name); + label = gnt_label_new(tmp); + g_free(tmp); + gnt_box_add_widget(GNT_BOX(vbox),label); + + tmp = g_strdup_printf("KEY: \"%s\"",keys); + key_textview = gnt_text_view_new(); + gnt_widget_set_size(key_textview,key_textview->priv.x,2); + gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(key_textview),tmp,GNT_TEXT_FLAG_NORMAL); + g_free(tmp); + gnt_widget_set_name(key_textview,"keystroke"); + gnt_box_add_widget(GNT_BOX(vbox),key_textview); + + g_signal_connect(G_OBJECT(win), "key_pressed", G_CALLBACK(gnt_bindable_rebinding_grab_key),key_textview); + + button_box = gnt_box_new(FALSE,FALSE); + + bind_button = gnt_button_new("BIND"); + gnt_widget_set_name(bind_button,"bind"); + gnt_box_add_widget(GNT_BOX(button_box), bind_button); + + cancel_button = gnt_button_new("Cancel"); + gnt_widget_set_name(cancel_button,"cancel"); + gnt_box_add_widget(GNT_BOX(button_box),cancel_button); + + g_signal_connect(G_OBJECT(bind_button), "activate", G_CALLBACK(gnt_bindable_rebinding_rebind),win); + g_signal_connect(G_OBJECT(cancel_button), "activate", G_CALLBACK(gnt_bindable_rebinding_cancel),win); + + + gnt_box_add_widget(GNT_BOX(vbox),button_box); + + gnt_box_add_widget(GNT_BOX(win),vbox); + gnt_widget_show(win); + +} + +typedef struct { + GHashTable *hash; + GntTree *tree; +} BindingView; + +static void +add_binding(gpointer key, gpointer value, gpointer data) +{ + BindingView *bv = data; + GntBindableActionParam *act = value; + const char *name = g_hash_table_lookup(bv->hash, act->action); + if (name && *name) { + const char *k = gnt_key_lookup(key); + if (!k) + k = key; + gnt_tree_add_row_after(bv->tree, (gpointer)k, + gnt_tree_create_row(bv->tree, k, name), NULL, NULL); + } +} + +static void +add_action(gpointer key, gpointer value, gpointer data) +{ + BindingView *bv = data; + g_hash_table_insert(bv->hash, value, key); +} + static void gnt_bindable_class_init(GntBindableClass *klass) { @@ -251,4 +439,56 @@ g_free(param); } +GntBindable * gnt_bindable_bindings_view(GntBindable *bind) +{ + GntBindable *tree = GNT_BINDABLE(gnt_tree_new_with_columns(2)); + GntBindableClass *klass = GNT_BINDABLE_CLASS(GNT_BINDABLE_GET_CLASS(bind)); + GHashTable *hash = g_hash_table_new(g_direct_hash, g_direct_equal); + BindingView bv = {hash, GNT_TREE(tree)}; + gnt_tree_set_compare_func(bv.tree, (GCompareFunc)g_utf8_collate); + g_hash_table_foreach(klass->actions, add_action, &bv); + g_hash_table_foreach(klass->bindings, add_binding, &bv); + if (GNT_TREE(tree)->list == NULL) { + gnt_widget_destroy(GNT_WIDGET(tree)); + tree = NULL; + } else + gnt_tree_adjust_columns(bv.tree); + g_hash_table_destroy(hash); + + return tree; +} + +static void +reset_binding_window(GntBindableClass *window, gpointer k) +{ + GntBindableClass *klass = GNT_BINDABLE_CLASS(k); + klass->help_window = NULL; +} + +gboolean +gnt_bindable_build_help_window(GntBindable *bindable) +{ + + GntWidget *tree; + GntBindableClass *klass = GNT_BINDABLE_GET_CLASS(bindable); + char *title; + + tree = GNT_WIDGET(gnt_bindable_bindings_view(bindable)); + + klass->help_window = GNT_BINDABLE(gnt_window_new()); + title = g_strdup_printf("Bindings for %s", g_type_name(G_OBJECT_TYPE(bindable))); + gnt_box_set_title(GNT_BOX(klass->help_window), title); + if (tree) { + g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(gnt_bindable_rebinding_activate), bindable); + gnt_box_add_widget(GNT_BOX(klass->help_window), tree); + } else + gnt_box_add_widget(GNT_BOX(klass->help_window), gnt_label_new("This widget has no customizable bindings.")); + + g_signal_connect(G_OBJECT(klass->help_window), "destroy", G_CALLBACK(reset_binding_window), klass); + gnt_widget_show(GNT_WIDGET(klass->help_window)); + g_free(title); + + return TRUE; +} +
--- a/finch/libgnt/gntbindable.h Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/libgnt/gntbindable.h Fri Jun 29 20:05:17 2007 +0000 @@ -57,7 +57,8 @@ GHashTable *actions; /* name -> Action */ GHashTable *bindings; /* key -> ActionParam */ - void (*gnt_reserved1)(void); + GntBindable * help_window; + void (*gnt_reserved2)(void); void (*gnt_reserved3)(void); void (*gnt_reserved4)(void); @@ -150,6 +151,31 @@ */ gboolean gnt_bindable_perform_action_named(GntBindable *bindable, const char *name, ...); +/** +* Returns a GntTree populated with "key" -> "binding" for the widget. +*/ +/** +* +* @param widget +* +* @return +*/ +GntBindable * gnt_bindable_bindings_view(GntBindable *bind); + +/** + * + * Builds a window that list the key bindings for a GntBindable object. From this window a user can select a listing to rebind a new key for the given action. + * + */ +/** + * + * @param bindable + * + * @return + */ + +gboolean gnt_bindable_build_help_window(GntBindable *bindable); + G_END_DECLS #endif /* GNT_BINDABLE_H */
--- a/finch/libgnt/gntbox.c Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/libgnt/gntbox.c Fri Jun 29 20:05:17 2007 +0000 @@ -315,10 +315,6 @@ { find_next_focus(box); } - else if (strcmp(text, GNT_KEY_BACK_TAB) == 0) - { - find_prev_focus(box); - } } else if (text[0] == '\t') {
--- a/finch/libgnt/gntcombobox.h Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/libgnt/gntcombobox.h Fri Jun 29 20:05:17 2007 +0000 @@ -69,7 +69,8 @@ G_BEGIN_DECLS /** - * + * + * Get the GType for GntComboBox * * @return */ @@ -77,44 +78,55 @@ /** * + * Create a new GntComboBox * - * @return + * @return A new GntComboBox */ GntWidget * gnt_combo_box_new(void); /** * - * @param box - * @param key - * @param text + * Add an entry + * + * @param box The GntComboBox + * @param key The data + * @param text The text to display */ void gnt_combo_box_add_data(GntComboBox *box, gpointer key, const char *text); /** + * + * Remove an entry * - * @param box - * @param key + * @param box The GntComboBox + * @param key The data to be removed */ void gnt_combo_box_remove(GntComboBox *box, gpointer key); /** * - * @param box + * Remove all entries + * + * @param box The GntComboBox */ void gnt_combo_box_remove_all(GntComboBox *box); /** * - * @param box + * Get the data that is currently selected * - * @return + * @param box The GntComboBox + * + * @return The data of the currently selected entry */ gpointer gnt_combo_box_get_selected_data(GntComboBox *box); /** * - * @param box - * @param key + * Set the current selection to a specific entry + * + * @param box The GntComboBox + * @param key The data to be set to */ void gnt_combo_box_set_selected(GntComboBox *box, gpointer key);
--- a/finch/libgnt/gntkeys.c Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/libgnt/gntkeys.c Fri Jun 29 20:05:17 2007 +0000 @@ -72,7 +72,6 @@ INSERT_KEY("pagedown", GNT_KEY_PGDOWN); INSERT_KEY("insert", GNT_KEY_INS); INSERT_KEY("delete", GNT_KEY_DEL); - INSERT_KEY("back_tab", GNT_KEY_BACK_TAB); INSERT_KEY("left", GNT_KEY_LEFT); INSERT_KEY("right", GNT_KEY_RIGHT); @@ -206,8 +205,8 @@ node->flags |= IS_END; return; } - while (*path && node->next[(unsigned char)*path]) { - node = node->next[(unsigned char)*path]; + while (*path && node->next[*path]) { + node = node->next[*path]; node->ref++; path++; } @@ -215,7 +214,7 @@ return; n = g_new0(struct _node, 1); n->ref = 1; - node->next[(unsigned char)*path++] = n; + node->next[*path++] = n; add_path(n, path); } @@ -230,13 +229,13 @@ if (!*path) return; - next = node->next[(unsigned char)*path]; + next = node->next[*path]; if (!next) return; del_path(next, path + 1); next->ref--; if (next->ref == 0) { - node->next[(unsigned char)*path] = NULL; + node->next[*path] = NULL; g_free(next); } } @@ -252,12 +251,12 @@ struct _node *n = &root; root.flags &= ~IS_END; - while (*path && n->next[(unsigned char)*path] && !(n->flags & IS_END)) { + while (*path && n->next[*path] && !(n->flags & IS_END)) { if (!g_ascii_isspace(*path) && !g_ascii_iscntrl(*path) && !g_ascii_isgraph(*path)) return 0; - n = n->next[(unsigned char)*path++]; + n = n->next[*path++]; depth++; }
--- a/finch/libgnt/gntmain.c Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/libgnt/gntmain.c Fri Jun 29 20:05:17 2007 +0000 @@ -246,6 +246,12 @@ if (HOLDING_ESCAPE) keys[0] = '\033'; k = keys; + if(*k < 0){ /* Alt not sending ESC* */ + *(k + 1) = 128 - *k; + *k = 27; + *(k + 2) = 0; + rd++; + } while (rd) { char back; int p;
--- a/finch/libgnt/gntmenu.c Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/libgnt/gntmenu.c Fri Jun 29 20:05:17 2007 +0000 @@ -242,10 +242,7 @@ static void gnt_menu_hide(GntWidget *widget) { - GntMenu *sub, *menu = GNT_MENU(widget); - - while ((sub = menu->submenu)) - gnt_widget_hide(GNT_WIDGET(sub)); + GntMenu *menu = GNT_MENU(widget); if (menu->parentmenu) menu->parentmenu->submenu = NULL; }
--- a/finch/libgnt/gntstyle.c Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/libgnt/gntstyle.c Fri Jun 29 20:05:17 2007 +0000 @@ -22,6 +22,7 @@ #include "gntstyle.h" #include "gntcolors.h" + #include "gntws.h" #include <glib.h>
--- a/finch/libgnt/gntutils.h Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/libgnt/gntutils.h Fri Jun 29 20:05:17 2007 +0000 @@ -40,6 +40,7 @@ */ void gnt_util_get_text_bound(const char *text, int *width, int *height); +/* excluding *end */ /** * Get the onscreen width of a string, or a substring. *
--- a/finch/libgnt/gntwm.c Fri Jun 29 19:36:31 2007 +0000 +++ b/finch/libgnt/gntwm.c Fri Jun 29 20:05:17 2007 +0000 @@ -34,7 +34,9 @@ #include <string.h> #include <time.h> +#include "gntbutton.h" #include "gntwm.h" +#include "gntentry.h" #include "gntstyle.h" #include "gntmarshal.h" #include "gnt.h" @@ -83,6 +85,7 @@ static time_t last_active_time; static gboolean idle_update; static GList *act = NULL; /* list of WS with unseen activitiy */ +static gboolean ignore_keys = FALSE; static GList * g_list_bring_to_front(GList *list, gpointer data) @@ -494,35 +497,6 @@ return TRUE; } -static gboolean -help_for_widget(GntBindable *bindable, GList *null) -{ - GntWM *wm = GNT_WM(bindable); - GntWidget *widget, *tree, *win, *active; - char *title; - - if (!wm->cws->ordered) - return TRUE; - - widget = wm->cws->ordered->data; - if (!GNT_IS_BOX(widget)) - return TRUE; - active = GNT_BOX(widget)->active; - - tree = gnt_widget_bindings_view(active); - win = gnt_window_new(); - title = g_strdup_printf("Bindings for %s", g_type_name(G_OBJECT_TYPE(active))); - gnt_box_set_title(GNT_BOX(win), title); - if (tree) - gnt_box_add_widget(GNT_BOX(win), tree); - else - gnt_box_add_widget(GNT_BOX(win), gnt_label_new("This widget has no customizable bindings.")); - - gnt_widget_show(win); - - return TRUE; -} - static void destroy__list(GntWidget *widget, GntWM *wm) { @@ -1136,6 +1110,71 @@ return TRUE; } +static gboolean +ignore_keys_start(GntBindable *bindable, GList *n) +{ + GntWM *wm = GNT_WM(bindable); + + if(!wm->menu && !wm->_list.window && wm->mode == GNT_KP_MODE_NORMAL){ + ignore_keys = TRUE; + return TRUE; + } + return FALSE; +} + +static gboolean +ignore_keys_end(GntBindable *bindable, GList *n) +{ + return ignore_keys ? !(ignore_keys = FALSE) : FALSE; +} + +static gboolean +help_for_bindable(GntWM *wm, GntBindable *bindable) +{ + gboolean ret = TRUE; + GntBindableClass *klass = GNT_BINDABLE_GET_CLASS(bindable); + + if (klass->help_window) { + gnt_wm_raise_window(wm, GNT_WIDGET(klass->help_window)); + } else { + ret = gnt_bindable_build_help_window(bindable); + } + return ret; + +} + +static gboolean +help_for_wm(GntBindable *bindable, GList *null) +{ + return help_for_bindable(GNT_WM(bindable),bindable); +} + +static gboolean +help_for_window(GntBindable *bindable, GList *null) +{ + GntWM *wm = GNT_WM(bindable); + GntWidget *widget = wm->cws->ordered->data; + + return help_for_bindable(wm,GNT_BINDABLE(widget)); +} + +static gboolean +help_for_widget(GntBindable *bindable, GList *null) +{ + GntWM *wm = GNT_WM(bindable); + GntWidget *widget; + + if (!wm->cws->ordered) + return TRUE; + + widget = wm->cws->ordered->data; + if (!GNT_IS_BOX(widget)) + return TRUE; + + return help_for_bindable(wm, GNT_BINDABLE(GNT_BOX(widget)->active)); + +} + static void gnt_wm_class_init(GntWMClass *klass) { @@ -1284,6 +1323,16 @@ "\033" "s", NULL); gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "toggle-clipboard", toggle_clipboard, "\033" "C", NULL); + gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "help-for-wm", help_for_wm, + "\033" "\\", NULL); + gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "help-for-window", help_for_window, + "\033" "|", NULL); + gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "toggle-clipboard", toggle_clipboard, + "\033" "C", NULL); + gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "ignore-keys-start", ignore_keys_start, + GNT_KEY_CTRL_G, NULL); + gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "ignore-keys-end", ignore_keys_end, + "\033" GNT_KEY_CTRL_G, NULL); gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); @@ -1684,6 +1733,14 @@ keys = gnt_bindable_remap_keys(GNT_BINDABLE(wm), keys); idle_update = TRUE; + if(ignore_keys){ + if(keys && !strcmp(keys, "\033" GNT_KEY_CTRL_G)){ + if(gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)){ + return TRUE; + } + } + return wm->cws->ordered ? gnt_widget_key_pressed(GNT_WIDGET(wm->cws->ordered->data), keys) : FALSE; + } if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) { return TRUE;
--- a/pidgin/Makefile.am Fri Jun 29 19:36:31 2007 +0000 +++ b/pidgin/Makefile.am Fri Jun 29 20:05:17 2007 +0000 @@ -65,7 +65,7 @@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = pidgin.pc -SUBDIRS = pixmaps plugins sounds +SUBDIRS = pixmaps plugins bin_PROGRAMS = pidgin
--- a/pidgin/gtksound.c Fri Jun 29 19:36:31 2007 +0000 +++ b/pidgin/gtksound.c Fri Jun 29 20:05:17 2007 +0000 @@ -543,7 +543,8 @@ char *filename = g_strdup(purple_prefs_get_path(file_pref)); if(!filename || !strlen(filename)) { g_free(filename); - filename = g_build_filename(DATADIR, "sounds", "pidgin", sounds[event].def, NULL); + /* XXX Consider creating a constant for "sounds/purple" to be shared with Finch */ + filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL); } purple_sound_play_file(filename, NULL);
--- a/pidgin/sounds/Makefile.am Fri Jun 29 19:36:31 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -soundsdir = $(datadir)/sounds/pidgin -sounds_DATA = \ - alert.wav \ - login.wav \ - logout.wav \ - receive.wav \ - send.wav - -EXTRA_DIST = \ - Makefile.mingw \ - $(sounds_DATA) -
--- a/pidgin/sounds/Makefile.mingw Fri Jun 29 19:36:31 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -# -# Makefile.mingw -# -# Description: Makefile for win32 (mingw) version of Pidgin sounds -# - -PIDGIN_TREE_TOP := ../.. -include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak - -datadir := $(PIDGIN_INSTALL_DIR) -include ./Makefile.am - -.PHONY: install - -install: - if test '$(sounds_DATA)'; then \ - mkdir -p $(soundsdir); \ - cp $(sounds_DATA) $(soundsdir); \ - fi; -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/Makefile.am Fri Jun 29 20:05:17 2007 +0000 @@ -0,0 +1,2 @@ + +SUBDIRS = sounds
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/sounds/Makefile.am Fri Jun 29 20:05:17 2007 +0000 @@ -0,0 +1,12 @@ +soundsdir = $(datadir)/sounds/purple +sounds_DATA = \ + alert.wav \ + login.wav \ + logout.wav \ + receive.wav \ + send.wav + +EXTRA_DIST = \ + Makefile.mingw \ + $(sounds_DATA) +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/sounds/Makefile.mingw Fri Jun 29 20:05:17 2007 +0000 @@ -0,0 +1,20 @@ +# +# Makefile.mingw +# +# Description: Makefile for win32 (mingw) version of Pidgin sounds +# + +PIDGIN_TREE_TOP := ../.. +include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak + +datadir := $(PIDGIN_INSTALL_DIR) +include ./Makefile.am + +.PHONY: install + +install: + if test '$(sounds_DATA)'; then \ + mkdir -p $(soundsdir); \ + cp $(sounds_DATA) $(soundsdir); \ + fi; +