emview_gui_menu.c from EmStar at Krugle
Show emview_gui_menu.c syntax highlighted
/*
*
* Copyright (c) 2003 The Regents of the University of California. All
* rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Neither the name of the University nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "emview_i.h"
/*
* Various menu helper functions
*/
/* Toggles a variable value */
static
gint emview_toggle_cb(void *user_data)
{
int *frob = (int *) user_data;
*frob = !(*frob);
return TRUE;
}
GtkWidget *emview_sub_menu(GtkWidget *super_menu, char *label)
{
GtkWidget *menu;
GtkWidget *item;
elog(LOG_DEBUG(10), "Appending new sub-menu '%s'", label);
item = gtk_menu_item_new_with_label(label);
gtk_menu_append(GTK_MENU(super_menu), item);
gtk_widget_show(item);
menu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
return menu;
}
GtkWidget *emview_toplevel_menu(char *label, GtkWidget **item_ret)
{
GtkWidget *menu;
GtkWidget *item;
elog(LOG_DEBUG(10), "Appending toplevel Menu '%s'", label);
item = gtk_menu_item_new_with_label(label);
gtk_menu_bar_append(GTK_MENU_BAR(_core.gui.menu_bar), item);
gtk_widget_show(item);
menu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
if (item_ret) *item_ret = item;
return menu;
}
GtkWidget *emview_menu_item(GtkWidget *menu, GtkWidget *menuitem,
GtkFunction callback, void *data)
{
gtk_menu_append(GTK_MENU(menu), menuitem);
if (callback)
gtk_signal_connect_object (GTK_OBJECT (menuitem), "activate",
GTK_SIGNAL_FUNC(callback), data);
gtk_widget_show(menuitem);
return menuitem;
}
GtkWidget *emview_check_menu_item(GtkWidget *menu, char *label, int *var)
{
GtkWidget *item = emview_menu_item(menu, gtk_check_menu_item_new_with_label(label),
emview_toggle_cb, (void *)var);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), *var);
return item;
}
See more files for this project here