Mercurial > pidgin
changeset 26092:cc96a5ec4782
Add a basic menu to the media window.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Thu, 05 Feb 2009 08:22:27 +0000 |
parents | 58071d9f10b1 |
children | 1830d339f9b9 08a3749993fe |
files | pidgin/gtkmedia.c |
diffstat | 1 files changed, 55 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkmedia.c Thu Feb 05 03:08:52 2009 +0000 +++ b/pidgin/gtkmedia.c Thu Feb 05 08:22:27 2009 +0000 @@ -33,6 +33,7 @@ #include "request.h" #include "gtkmedia.h" +#include "gtkutils.h" #ifdef USE_VV @@ -57,6 +58,7 @@ GstElement *send_level; GstElement *recv_level; + GtkWidget *menubar; GtkWidget *statusbar; GtkWidget *calling; @@ -221,6 +223,55 @@ } static void +menu_hangup(gpointer data, guint action, GtkWidget *item) +{ + PidginMedia *gtkmedia = PIDGIN_MEDIA(data); + purple_media_hangup(gtkmedia->priv->media); +} + +static GtkItemFactoryEntry menu_items[] = { + { N_("/_Media"), NULL, NULL, 0, "<Branch>", NULL }, + { N_("/Media/_Hangup"), NULL, menu_hangup, 0, "<Item>", NULL }, +}; + +static gint menu_item_count = sizeof(menu_items) / sizeof(menu_items[0]); + +static const char * +item_factory_translate_func (const char *path, gpointer func_data) +{ + return _(path); +} + +static GtkWidget * +setup_menubar(PidginMedia *window) +{ + GtkItemFactory *item_factory; + GtkAccelGroup *accel_group; + GtkWidget *menu; + + accel_group = gtk_accel_group_new (); + gtk_window_add_accel_group(GTK_WINDOW(window), accel_group); + g_object_unref(accel_group); + + item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, + "<main>", accel_group); + + gtk_item_factory_set_translate_func(item_factory, + (GtkTranslateFunc)item_factory_translate_func, + NULL, NULL); + + gtk_item_factory_create_items(item_factory, menu_item_count, + menu_items, window); + g_signal_connect(G_OBJECT(accel_group), "accel-changed", + G_CALLBACK(pidgin_save_accels_cb), NULL); + + menu = gtk_item_factory_get_widget(item_factory, "<main>"); + + gtk_widget_show(menu); + return menu; +} + +static void pidgin_media_init (PidginMedia *media) { GtkWidget *vbox, *hbox; @@ -238,6 +289,10 @@ 0, _("Connecting...")); gtk_widget_show(media->priv->statusbar); + media->priv->menubar = setup_menubar(media); + gtk_box_pack_start(GTK_BOX(vbox), media->priv->menubar, + FALSE, TRUE, 0); + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_widget_show(GTK_WIDGET(hbox));