pidgin.vv: 8a5e7d72: Add a basic menu to the media window.

maiku at soc.pidgin.im maiku at soc.pidgin.im
Thu Feb 5 03:55:31 EST 2009


-----------------------------------------------------------------
Revision: 8a5e7d720be0e54f922433c20634edb0ed1387e2
Ancestor: aa0c8867256450c37f9b97135601a39544821ac8
Author: maiku at soc.pidgin.im
Date: 2009-02-05T08:22:27
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/8a5e7d720be0e54f922433c20634edb0ed1387e2

Modified files:
        pidgin/gtkmedia.c

ChangeLog: 

Add a basic menu to the media window.

-------------- next part --------------
============================================================
--- pidgin/gtkmedia.c	ad8bbdc4fc206a5332fa1de867f09a0b882be959
+++ pidgin/gtkmedia.c	20e2dd157d7e3e7a43d7a2f48dd6e0f5e8cc7083
@@ -33,6 +33,7 @@
 #include "request.h"
 
 #include "gtkmedia.h"
+#include "gtkutils.h"
 
 #ifdef USE_VV
 
@@ -57,6 +58,7 @@ struct _PidginMediaPrivate
 	GstElement *send_level;
 	GstElement *recv_level;
 
+	GtkWidget *menubar;
 	GtkWidget *statusbar;
 
 	GtkWidget *calling;
@@ -221,6 +223,55 @@ static void
 }
 
 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 @@ pidgin_media_init (PidginMedia *media)
 			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));


More information about the Commits mailing list