strange problem with radiomenuitem
- From: Alexander Nagel <feuerschwanz76 web de>
- To: gtk-app-devel-list gnome org
- Subject: strange problem with radiomenuitem
- Date: Thu, 27 Oct 2005 13:31:56 +0200
Hi all,
i created some radiomenuitem with this.
string tmp;
for (int i = 0; i<10;i++)
{
ostringstream outStream;
outStream << i;
tmp = "Gruppe " +outStream.str();
Widgets_MainWindow.menugroupitems[i] = gtk_radio_menu_item_new_with_label
(Widgets_MainWindow.GroupList, tmp.c_str());
gtk_menu_shell_append (GTK_MENU_SHELL (Widgets_MainWindow.menugroups),
Widgets_MainWindow.menugroupitems[i]);
Widgets_MainWindow.GroupList = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM
(Widgets_MainWindow.menugroupitems[i]));
gtk_widget_add_accelerator (Widgets_MainWindow.menugroupitems[i], "activate",
Widgets_MainWindow.accel_group, gdk_keyval_from_name (outStream.str().c_str()), GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE);
gtk_widget_show (Widgets_MainWindow.menugroupitems[i]);
g_signal_connect ((gpointer) Widgets_MainWindow.menugroupitems [i], "activate", G_CALLBACK
(on_menugroup_items_activate), (gpointer) i);
}
(don't laugh about the stream thing. If someone could give me a hint to
make that better would be great.)
and this is the callback:
void on_menugroup_items_activate (GtkObject *object, gpointer user_data)
{
cout << "Gruppe " << (int) user_data << endl;
}
So the callback just print the number of the chosen group.
And this work.
But....
1. During compilation i get a warning about
'cast to pointer from integer of different size'
for the g_signal_connect line. How can i avoid this?
2. It is normal that the callback is called twice?
For example if group 3 is marked and i change to 5 i get
Gruppe 3
Gruppe 5
then marking group 9
Gruppe 5
Gruppe 9
Is that normal?
3. When i choose group 1 the callback always produces
Gruppe 1
Gruppe 0
regardless from the previous group.
Why?
any ideas would be much appreciated..
regards
Alex
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]