From 8be56d700309fad3966356249f024ed94ff36f8b Mon Sep 17 00:00:00 2001 From: TingPing Date: Wed, 12 Jun 2013 10:41:52 -0400 Subject: Don't open libcanberra connection for every event Closes #645 --- src/common/text.c | 19 +++++++++++++------ src/fe-gtk/fe-gtk.c | 18 +++++++++++++----- 2 files changed, 26 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/common/text.c b/src/common/text.c index 3d1c9280..f0a1dfb1 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -58,6 +58,9 @@ struct pevt_stage1 struct pevt_stage1 *next; }; +#ifdef USE_LIBCANBERRA +static ca_context *ca_con; +#endif static void mkdir_p (char *filename); static char *log_create_filename (char *channame); @@ -2209,9 +2212,6 @@ sound_play (const char *file, gboolean quiet) char *wavfile; #ifndef WIN32 char *cmd; -#ifdef USE_LIBCANBERRA - ca_context *con; -#endif #endif /* the pevents GUI editor triggers this after removing a soundfile */ @@ -2240,9 +2240,16 @@ sound_play (const char *file, gboolean quiet) PlaySound (wavfile, NULL, SND_NODEFAULT|SND_FILENAME|SND_ASYNC); #else #ifdef USE_LIBCANBERRA - ca_context_create (&con); - /* TODO: Volume setting? */ - if (ca_context_play (con, 0, CA_PROP_MEDIA_FILENAME, wavfile, NULL) != 0) + if (ca_con == NULL) + { + ca_context_create (&ca_con); + ca_context_change_props (ca_con, + CA_PROP_APPLICATION_ID, "hexchat", + CA_PROP_APPLICATION_NAME, "HexChat", + CA_PROP_APPLICATION_ICON_NAME, "hexchat", NULL); + } + + if (ca_context_play (ca_con, 0, CA_PROP_MEDIA_FILENAME, wavfile, NULL) != 0) #endif { cmd = g_find_program_in_path ("play"); diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index d737b744..e017b9b9 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -62,6 +62,9 @@ GdkPixmap *channelwin_pix; +#ifdef USE_LIBCANBERRA +static ca_context *ca_con; +#endif #ifdef USE_XLIB @@ -674,11 +677,16 @@ fe_beep (session *sess) } #else #ifdef USE_LIBCANBERRA - ca_context *con; - ca_context_create (&con); - if (ca_context_play (con, 0, - CA_PROP_APPLICATION_NAME, DISPLAY_NAME, - CA_PROP_EVENT_ID, "message-new-instant", NULL) != 0) + if (ca_con == NULL) + { + ca_context_create (&ca_con); + ca_context_change_props (ca_con, + CA_PROP_APPLICATION_ID, "hexchat", + CA_PROP_APPLICATION_NAME, DISPLAY_NAME, + CA_PROP_APPLICATION_ICON_NAME, "hexchat", NULL); + } + + if (ca_context_play (ca_con, 0, CA_PROP_EVENT_ID, "message-new-instant", NULL) != 0) #endif gdk_beep (); #endif -- cgit 1.4.1 From cb1b1c6e1cd04805f4c6804c40aac79fe76dc4b4 Mon Sep 17 00:00:00 2001 From: TingPing Date: Thu, 13 Jun 2013 15:55:38 -0300 Subject: Tweak autojoin wording --- src/fe-gtk/menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index 3bd50b1a..cd94aa60 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -1049,11 +1049,11 @@ menu_addfavoritemenu (server *serv, GtkWidget *menu, char *channel) if (joinlist_is_in_list (serv, channel)) { - menu_toggle_item (_("_Autojoin"), menu, menu_delfav_cb, serv, TRUE); + menu_toggle_item (_("_Autojoin Channel"), menu, menu_delfav_cb, serv, TRUE); } else { - menu_toggle_item (_("_Autojoin"), menu, menu_addfav_cb, serv, FALSE); + menu_toggle_item (_("_Autojoin Channel"), menu, menu_addfav_cb, serv, FALSE); } } -- cgit 1.4.1 From 9b958ed3932ddfbfb139d6bbe6c40c7638535dd6 Mon Sep 17 00:00:00 2001 From: TingPing Date: Thu, 13 Jun 2013 18:38:59 -0300 Subject: Use snprintf --- src/common/plugin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/plugin.c b/src/common/plugin.c index 61d5cb40..8a704e5f 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -1826,7 +1826,7 @@ hexchat_pluginpref_set_int (hexchat_plugin *pl, const char *var, int value) { char buffer[12]; - sprintf (buffer, "%d", value); + snprintf (buffer, sizeof (buffer), "%d", value); return hexchat_pluginpref_set_str_real (pl, var, buffer, 1); } -- cgit 1.4.1 From 7ef8d0d4438c8780dfe6db53add4bdc23118732a Mon Sep 17 00:00:00 2001 From: TingPing Date: Thu, 13 Jun 2013 20:53:55 -0400 Subject: More autojoin wording tweaks --- src/fe-gtk/chanlist.c | 2 +- src/fe-gtk/maingui.c | 2 +- src/fe-gtk/menu.c | 15 +++++++++++---- src/fe-gtk/menu.h | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/fe-gtk/chanlist.c b/src/fe-gtk/chanlist.c index 00c55b5f..0f0307b7 100644 --- a/src/fe-gtk/chanlist.c +++ b/src/fe-gtk/chanlist.c @@ -629,7 +629,7 @@ chanlist_button_cb (GtkTreeView *tree, GdkEventButton *event, server *serv) chanlist_copytopic, serv); chan = chanlist_get_selected (serv, FALSE); - menu_addfavoritemenu (serv, menu, chan); + menu_addfavoritemenu (serv, menu, chan, FALSE); g_free (chan); gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, 0, event->time); diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index 473b6c11..100642e1 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -1617,7 +1617,7 @@ mg_create_tabmenu (session *sess, GdkEventButton *event, chan *ch) menu_quick_item (0, 0, menu, XCMENU_SHADED, 0, 0); if (sess->type == SESS_CHANNEL) - menu_addfavoritemenu (sess->server, menu, sess->channel); + menu_addfavoritemenu (sess->server, menu, sess->channel, TRUE); else if (sess->type == SESS_SERVER) menu_addconnectmenu (sess->server, menu); } diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index cd94aa60..1948348a 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -1016,7 +1016,7 @@ menu_chanmenu (struct session *sess, GdkEventButton * event, char *chan) str_copy); } - menu_addfavoritemenu (sess->server, menu, str_copy); + menu_addfavoritemenu (sess->server, menu, str_copy, FALSE); menu_add_plugin_items (menu, "\x5$CHAN", str_copy); menu_popup (menu, event, NULL); @@ -1035,8 +1035,10 @@ menu_addfav_cb (GtkWidget *item, server *serv) } void -menu_addfavoritemenu (server *serv, GtkWidget *menu, char *channel) +menu_addfavoritemenu (server *serv, GtkWidget *menu, char *channel, gboolean istree) { + char *str; + if (!serv->network) return; @@ -1046,14 +1048,19 @@ menu_addfavoritemenu (server *serv, GtkWidget *menu, char *channel) free (str_copy); str_copy = strdup (channel); } + + if (istree) + str = _("_Autojoin"); + else + str = _("Autojoin Channel"); if (joinlist_is_in_list (serv, channel)) { - menu_toggle_item (_("_Autojoin Channel"), menu, menu_delfav_cb, serv, TRUE); + menu_toggle_item (str, menu, menu_delfav_cb, serv, TRUE); } else { - menu_toggle_item (_("_Autojoin Channel"), menu, menu_addfav_cb, serv, FALSE); + menu_toggle_item (str, menu, menu_addfav_cb, serv, FALSE); } } diff --git a/src/fe-gtk/menu.h b/src/fe-gtk/menu.h index 9cc92e9e..3dd96261 100644 --- a/src/fe-gtk/menu.h +++ b/src/fe-gtk/menu.h @@ -23,7 +23,7 @@ GtkWidget *menu_create_main (void *accel_group, int bar, int away, int toplevel, GtkWidget **menu_widgets); void menu_urlmenu (GdkEventButton * event, char *url); void menu_chanmenu (session *sess, GdkEventButton * event, char *chan); -void menu_addfavoritemenu (server *serv, GtkWidget *menu, char *channel); +void menu_addfavoritemenu (server *serv, GtkWidget *menu, char *channel, gboolean istree); void menu_addconnectmenu (server *serv, GtkWidget *menu); void menu_nickmenu (session *sess, GdkEventButton * event, char *nick, int num_sel); void menu_middlemenu (session *sess, GdkEventButton *event); -- cgit 1.4.1