2
* Copyright 2012 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3, as published
6
* by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License along
14
* with this program. If not, see <http://www.gnu.org/licenses/>.
17
* Lars Uebernickel <lars.uebernickel@canonical.com>
20
#include "gmenuutils.h"
21
#include "dbus-data.h"
23
/* g_menu_find_section:
25
* @section: the section to be found in @menu
27
* @Returns the index of the first menu item that is linked to #section, or -1
28
* if there's no such item.
31
g_menu_find_section (GMenu *menu,
34
GMenuModel *model = G_MENU_MODEL (menu);
38
g_return_val_if_fail (G_IS_MENU_MODEL (section), -1);
40
n_items = g_menu_model_get_n_items (model);
41
for (i = 0; i < n_items; i++)
46
link = g_menu_model_get_item_link (model, i, G_MENU_LINK_SECTION);
47
found = section == link;
49
g_object_unref (link);
60
g_menu_append_with_icon (GMenu *menu,
63
const gchar *detailed_action)
67
iconstr = g_icon_to_string (icon);
68
g_menu_append_with_icon_name (menu, label, iconstr, detailed_action);
74
g_menu_append_with_icon_name (GMenu *menu,
76
const gchar *icon_name,
77
const gchar *detailed_action)
81
item = g_menu_item_new (label, detailed_action);
82
g_menu_item_set_attribute (item, "icon", "s", icon_name);
84
g_menu_append_item (menu, item);
86
g_object_unref (item);