1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
/*
* File: selection.c
*
* Copyright 2004 Sebastian Geerken <s.geerken@ping.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
/*
* See comments at the beginning of "gtk_ext_menu.c".
*/
#include "gtk_ext_menu_item.h"
#include <gtk/gtksignal.h>
#include <gtk/gtkaccellabel.h>
static void Gtk_ext_menu_item_class_init (GtkExtMenuItemClass *klass);
static void Gtk_ext_menu_item_init (GtkExtMenuItem *item);
static gint std_activate_signal;
static gint activate_signals[3];
/*
* Standard Gtk+ function.
*/
GtkType a_Gtk_ext_menu_item_get_type (void)
{
static GtkType type = 0;
if (!type) {
GtkTypeInfo info = {
"GtkExtMenuItem",
sizeof (GtkExtMenuItem),
sizeof (GtkExtMenuItemClass),
(GtkClassInitFunc) Gtk_ext_menu_item_class_init,
(GtkObjectInitFunc) Gtk_ext_menu_item_init,
(GtkArgSetFunc) NULL,
(GtkArgGetFunc) NULL,
(GtkClassInitFunc)NULL
};
type = gtk_type_unique (gtk_menu_item_get_type (), &info);
}
return type;
}
/*
* Standard Gtk+ function.
*/
static void Gtk_ext_menu_item_class_init (GtkExtMenuItemClass *klass)
{
GtkObjectClass *object_class;
object_class = (GtkObjectClass*) klass;
activate_signals[0] =
gtk_signal_new ("activate1",
GTK_RUN_FIRST | GTK_RUN_ACTION,
object_class->type,
GTK_SIGNAL_OFFSET (GtkExtMenuItemClass, activate1),
gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
activate_signals[1] =
gtk_signal_new ("activate2",
GTK_RUN_FIRST | GTK_RUN_ACTION,
object_class->type,
GTK_SIGNAL_OFFSET (GtkExtMenuItemClass, activate2),
gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
activate_signals[2] =
gtk_signal_new ("activate3",
GTK_RUN_FIRST | GTK_RUN_ACTION,
object_class->type,
GTK_SIGNAL_OFFSET (GtkExtMenuItemClass, activate3),
gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (object_class, activate_signals, 3);
klass->activate1 = NULL;
klass->activate2 = NULL;
klass->activate3 = NULL;
std_activate_signal =
GTK_WIDGET_CLASS(gtk_type_class (gtk_menu_item_get_type ()))
->activate_signal;
}
/*
* Standard Gtk+ function.
*/
static void Gtk_ext_menu_item_init (GtkExtMenuItem *item)
{
}
/*
* Create a new, empty GtkExtMenuItem.
*/
GtkWidget *a_Gtk_ext_menu_item_new (void)
{
return gtk_type_new (a_Gtk_ext_menu_item_get_type ());
}
/*
* Create a GtkExtMenuItem with a label as child.
*/
GtkWidget *a_Gtk_ext_menu_item_new_with_label (const gchar *label)
{
GtkWidget *menu_item;
GtkWidget *accel_label;
menu_item = a_Gtk_ext_menu_item_new ();
accel_label = gtk_accel_label_new (label);
gtk_misc_set_alignment (GTK_MISC (accel_label), 0.0, 0.5);
gtk_container_add (GTK_CONTAINER (menu_item), accel_label);
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (accel_label), menu_item);
gtk_widget_show (accel_label);
return menu_item;
}
/*
* This method is called by GtkExtMenu, before handling a button release event.
* See comments there.
*/
void p_Gtk_ext_menu_item_prepare_button_release (GtkExtMenuItem *item,
GdkEventButton *event)
{
if (event->button >= 1 && event->button <= 3)
GTK_WIDGET_CLASS(GTK_OBJECT(item)->klass)->activate_signal =
activate_signals[event->button - 1];
}
/*
* This method is called by GtkExtMenu, after handling a button release event.
* See comments there.
*/
void p_Gtk_ext_menu_item_finish_button_release (GtkExtMenuItem *item,
GdkEventButton *event)
{
GTK_WIDGET_CLASS(GTK_OBJECT(item)->klass)->activate_signal =
std_activate_signal;
}
|