pidgin: d198e35f: Use GtkUIManager for gtk media stuff, si...
qulogic at pidgin.im
qulogic at pidgin.im
Mon Jul 26 02:01:19 EDT 2010
----------------------------------------------------------------------
Revision: d198e35f28e8800ec2979cfb22965fbe0a31e10d
Parent: f325010b914ef4f3e5862018f5674e74fa7b1549
Author: qulogic at pidgin.im
Date: 07/26/10 00:21:47
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/d198e35f28e8800ec2979cfb22965fbe0a31e10d
Changelog:
Use GtkUIManager for gtk media stuff, since it's internal.
applied changes from 7f3cdd61a34080056b8024a0297d01ed559bef25
through c9211cd8bf87478800560441c7eb893f1e3995e0
applied partial changes from 231d9237a777f9d01fa2ff9c26a575a0ac8db31c
through d0c6c98ad725a3a64114bd1d5c1da1220d738c93
Changes against parent f325010b914ef4f3e5862018f5674e74fa7b1549
patched pidgin/gtkmedia.c
-------------- next part --------------
============================================================
--- pidgin/gtkmedia.c 0a6382426c4778907761c3f0653f65d0c922fb1e
+++ pidgin/gtkmedia.c 79989baf8a8d3a89d38134832f96986d2453a66b
@@ -84,7 +84,7 @@ struct _PidginMediaPrivate
gchar *screenname;
gulong level_handler_id;
- GtkItemFactory *item_factory;
+ GtkUIManager *ui;
GtkWidget *menubar;
GtkWidget *statusbar;
@@ -260,50 +260,60 @@ static void
#endif
static void
-menu_hangup(gpointer data, guint action, GtkWidget *item)
+menu_hangup(GtkAction *action, gpointer data)
{
PidginMedia *gtkmedia = PIDGIN_MEDIA(data);
purple_media_stream_info(gtkmedia->priv->media,
PURPLE_MEDIA_INFO_HANGUP, NULL, NULL, TRUE);
}
-static GtkItemFactoryEntry menu_items[] = {
- { N_("/_Media"), NULL, NULL, 0, "<Branch>", NULL },
- { N_("/Media/_Hangup"), NULL, menu_hangup, 0, "<Item>", NULL },
+static const GtkActionEntry menu_entries[] = {
+ { "MediaMenu", NULL, N_("_Media"), NULL, NULL, NULL },
+ { "Hangup", NULL, N_("_Hangup"), NULL, NULL, G_CALLBACK(menu_hangup) },
};
-static gint menu_item_count = sizeof(menu_items) / sizeof(menu_items[0]);
+static const char *media_menu =
+"<ui>"
+ "<menubar name='Media'>"
+ "<menu action='MediaMenu'>"
+ "<menuitem action='Hangup'/>"
+ "</menu>"
+ "</menubar>"
+"</ui>";
-static const char *
-item_factory_translate_func (const char *path, gpointer func_data)
-{
- return _(path);
-}
-
static GtkWidget *
setup_menubar(PidginMedia *window)
{
+ GtkActionGroup *action_group;
+ GError *error;
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);
+ action_group = gtk_action_group_new("MediaActions");
+ gtk_action_group_add_actions(action_group,
+ menu_entries,
+ G_N_ELEMENTS(menu_entries),
+ GTK_WINDOW(window));
+#ifdef ENABLE_NLS
+ gtk_action_group_set_translation_domain(action_group,
+ PACKAGE);
+#endif
- window->priv->item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR,
- "<main>", accel_group);
+ window->priv->ui = gtk_ui_manager_new();
+ gtk_ui_manager_insert_action_group(window->priv->ui, action_group, 0);
- gtk_item_factory_set_translate_func(window->priv->item_factory,
- (GtkTranslateFunc)item_factory_translate_func,
- NULL, NULL);
+ accel_group = gtk_ui_manager_get_accel_group(window->priv->ui);
+ gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
- gtk_item_factory_create_items(window->priv->item_factory,
- menu_item_count, menu_items, window);
- g_signal_connect(G_OBJECT(accel_group), "accel-changed",
- G_CALLBACK(pidgin_save_accels_cb), NULL);
+ error = NULL;
+ if (!gtk_ui_manager_add_ui_from_string(window->priv->ui, media_menu, -1, &error))
+ {
+ g_message("building menus failed: %s", error->message);
+ g_error_free(error);
+ exit(EXIT_FAILURE);
+ }
- menu = gtk_item_factory_get_widget(
- window->priv->item_factory, "<main>");
+ menu = gtk_ui_manager_get_widget(window->priv->ui, "/Media");
gtk_widget_show(menu);
return menu;
@@ -384,9 +394,9 @@ pidgin_media_dispose(GObject *media)
gtkmedia->priv->media = NULL;
}
- if (gtkmedia->priv->item_factory) {
- g_object_unref(gtkmedia->priv->item_factory);
- gtkmedia->priv->item_factory = NULL;
+ if (gtkmedia->priv->ui) {
+ g_object_unref(gtkmedia->priv->ui);
+ gtkmedia->priv->ui = NULL;
}
G_OBJECT_CLASS(parent_class)->dispose(media);
More information about the Commits
mailing list