/[gluid]/menu.c
ViewVC logotype

Annotation of /menu.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8 - (hide annotations)
Fri Sep 25 21:04:28 2009 UTC (11 years, 8 months ago) by ben
File MIME type: text/plain
File size: 2377 byte(s)
use images in menu items
1 ben 1 /*
2     * menu.c Copyright © 2009 by Benoît Rouits <brouits@free.fr>
3     * Published under the terms of the GNU General Public License v2 (GPLv2).
4     *
5     * This program is free software; you can redistribute it and/or
6     * modify it under the terms of the GNU General Public License
7     * as published by the Free Software Foundation; either version 2
8     * of the License, or (at your option) any later version.
9     *
10     * This program is distributed in the hope that it will be useful,
11     * but WITHOUT ANY WARRANTY; without even the implied warranty of
12     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13     * GNU General Public License for more details.
14     *
15     * You should have received a copy of the GNU General Public License
16     * along with this program; if not, write to the Free Software
17     * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18     * Boston, MA 02110-1301, USA.
19     *
20     * see the COPYING file included in the jackie package or
21     * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt for the full licence
22     *
23     */
24    
25     #include <glib.h>
26     #include <gtk/gtk.h>
27    
28     GtkMenu* menu_new(void)
29     {
30     GtkWidget* menu;
31    
32     menu = gtk_menu_new ();
33    
34     return GTK_MENU(menu);
35     }
36    
37     /* append an item to the menu, and connect its callback on "activate" event */
38     GtkMenuItem* menu_append_item(GtkMenu* menu, gchar* label, GCallback callback, gpointer cb_data)
39     {
40     GtkWidget* item;
41    
42     item = gtk_menu_item_new_with_label (label);
43     gtk_menu_shell_append ((GtkMenuShell*) (menu), item);
44     if (callback)
45     g_signal_connect (G_OBJECT(item), "activate", G_CALLBACK(callback), cb_data);
46     gtk_widget_show (item);
47    
48     return GTK_MENU_ITEM(item);
49     }
50    
51     /* show the menu */
52     void menu_show(GtkMenu* menu, guint button, guint activate_time)
53     {
54     gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button, activate_time);
55     return;
56     }
57    
58     /* hide the menu */
59     void menu_hide(GtkMenu* menu)
60     {
61     gtk_menu_popdown(GTK_MENU(menu));
62     return;
63     }
64 ben 8
65     /* append a stock imageitem to the menu, and connect its callback on "activate" event */
66     GtkMenuItem* menu_append_image_item(GtkMenu* menu, const gchar* stock_id, GCallback callback, gpointer cb_data)
67     {
68     GtkWidget* item;
69    
70     item = gtk_image_menu_item_new_from_stock(stock_id, NULL);
71     gtk_menu_shell_append ((GtkMenuShell*) (menu), item);
72     if (callback)
73     g_signal_connect (G_OBJECT(item), "activate", G_CALLBACK(callback), cb_data);
74     gtk_widget_show (item);
75    
76     return GTK_MENU_ITEM(item);
77     }
78    

  ViewVC Help
Powered by ViewVC 1.1.26