如何添加项洋泾浜菜单 [英] How do I add item to Pidgin menu

查看:128
本文介绍了如何添加项洋泾浜菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要随心所欲项目到洋泾浜菜单。让它的好友→显示→组的。我希望它是checkbutton(如好友→显示→空组的)自定义功能相关联。我怎样才能做到这一点?

I want to add arbitrary item to Pidgin menu. Let it be Buddies → Show → Groups. I want it to be checkbutton (like Buddies → Show → Empty Groups) with custom function associated. How can I do this?

  • In Pidgin 2.10.9
  • In Pidgin 3.0.0 (development branch)

推荐答案

下面的例子是洋泾浜版本2.10.9。我相信有3.0.0(当前开发分支)没有很多改变,因此将适用有太多以最小的修改。

首先,下载洋泾浜的来源。在Ubuntu中,这是通过简单地运行完成

First of all, download Pidgin sources. In Ubuntu this is done simply by running

apt-get source pidgin

这将取libpurple,Pidgin和雀来源。然后进入洋泾浜-2.10.9 /洋泾浜/ gtkblist.c 并找到行

static GtkItemFactoryEntry blist_menu[] =

有你会看到文字的Gtk菜单。添加以下行:

There you will see Gtk menu in text. Add the following line:

{ N_("/Buddies/Show/_Groups"), NULL, pidgin_blist_show_groups_cb, 1, "<CheckItem>", NULL },

{ N_("/Buddies/Show/_Empty Groups"), NULL, pidgin_blist_show_empty_groups_cb, 1, "<CheckItem>", NULL },

您可以看到添加的行加入后,它只是模拟。第三数组成员负责更新菜单项的状态的功能。

You can see that the line added is just the analog of after which it was added. The 3rd array member is the function responsible for updating menu item status.

接下来,添加您刚才指定的功能, pidgin_blist_show_groups_cb 。你可以做到这一点找到 pidgin_blist_show_empty_groups_cb 并复制它的内容。

Next, add the function you just specified, pidgin_blist_show_groups_cb. You can do it finding the pidgin_blist_show_empty_groups_cb and copying it's contents.

static void pidgin_blist_show_groups_cb(gpointer data, guint action, GtkWidget *item)
{
    pidgin_set_cursor(gtkblist->window, GDK_WATCH);

    purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/blist/show_groups",
            gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)));

    pidgin_clear_cursor(gtkblist->window);
}

此外,您还需要设置启动项状态。查找功能

Also, you need to set item status on startup. Find the function

static void pidgin_blist_show(PurpleBuddyList *list)

和添加

gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show/Groups"))),
                                                      purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_groups"));

gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show/Empty Groups"))),
                                                   purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_empty_groups"));

在加preference / blist / show_groups以及添加回调它的我如何添加自定义preference到洋泾浜?。要测试你的变化,编译和安装洋泾浜语:

The adding preference "/blist/show_groups" as well as adding callback to it is explained in How do I add custom preference into Pidgin?. To test your changes, compile and install pidgin:

sudo apt-get build-dep pidgin
cd pidgin-2.10.9/
fakeroot debian/rules binary
sudo dpkg -i ../pidgin_2.10.9-0ubuntu3.deb

这篇关于如何添加项洋泾浜菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆