uiinfo problem
- From: Ricardo Cabral <bfe00991 mail telepac pt>
- To: gnome-devel-list gnome org
- Subject: uiinfo problem
- Date: Thu, 01 Mar 2001 19:42:28 +0000
hello all
i am writing because of a little problem i am getting with assigning
some data to pass to a callback in a checkbox menuitem that uses uiinfo
structures.
i have a gtktext box and i want to be able/unable to edit it according
to the checkbox status
the declaration of that menu is something like this:
GtkWidget *note_text; /* this is the widget im using as a gtk text box.
it is created later in the code file */
static GnomeUIInfo file1_menu_uiinfo[] =
{
GNOMEUIINFO_MENU_NEW_ITEM (N_("_New Note"), NULL,
on_new_note_activate, NULL),
{
GNOME_APP_UI_ITEM, N_("_Delete this note"),
NULL,
on_delete_this_note_activate, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
{
GNOME_APP_UI_TOGGLEITEM, N_("Note is editable"),
NULL,
on_note_is_editable_activate, NULL, NULL, // this is the problem
line
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
GNOMEUIINFO_END
};
this works this way, but if i add note_text as a data pointer to the
callback, whether casting it or not to gpointer, like this:
on_note_is_editable_activate, note_text, NULL,
or like this:
on_note_is_editable_activate, (gpointer)note_text, NULL,
i get this
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../intl -I/usr/include
-DNEED_GNOMESUPPORT_H -I/usr/lib/gnome-libs/include
-I/usr/lib/glib/include -I/usr/X11R6/include -I/usr/X11R6/include
-I/usr/lib/glib/include -g -O2 -Wall -Wunused -c interface.c
interface.c:92: initializer element is not constant
interface.c:92: (near initialization for
`file1_menu_uiinfo[2].user_data')
make: *** [interface.o] Error 1
any ideas on how can i fix this? (i send with this email a copy of the
problem file, hope it helps)
thanks in advance!
Ricardo
--
."-. cumprimentos (regards),
/X | _o.----. _ Ricardo Cabral - NightDog
/\_ \/ / __ \_// ) "A internet e' oxigenio"
\__)-/_/\_____)____/ "Eu respiro Internet..."
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <gnome.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
extern NOTES note[MAXNOTES];
GtkWidget*
create_about (void)
{
const gchar *authors[] = {
"Ricardo Cabral (NightDog)",
NULL
};
GtkWidget *about;
about = gnome_about_new ("Remember-it", VERSION,
_("This program is GPL"),
authors,
_("http://\nThis program is for people who need \"reminders\" for doing things like me."),
"remember/gremembe.gif");
gtk_object_set_data (GTK_OBJECT (about), "about", about);
gtk_window_set_modal (GTK_WINDOW (about), TRUE);
return about;
}
GtkWidget*
create_messagebox1 (void)
{
GtkWidget *messagebox1;
GtkWidget *dialog_vbox1;
GtkWidget *button3;
GtkWidget *dialog_action_area1;
messagebox1 = gnome_message_box_new (_("Gremember will now create .gremember file where it's going to save it's data."),
GNOME_MESSAGE_BOX_INFO, NULL);
gtk_object_set_data (GTK_OBJECT (messagebox1), "messagebox1", messagebox1);
gtk_window_set_title (GTK_WINDOW (messagebox1), _("Information"));
gtk_window_set_position (GTK_WINDOW (messagebox1), GTK_WIN_POS_CENTER);
gtk_window_set_policy (GTK_WINDOW (messagebox1), TRUE, TRUE, TRUE);
dialog_vbox1 = GNOME_DIALOG (messagebox1)->vbox;
gtk_object_set_data (GTK_OBJECT (messagebox1), "dialog_vbox1", dialog_vbox1);
gtk_widget_show (dialog_vbox1);
gnome_dialog_append_button (GNOME_DIALOG (messagebox1), GNOME_STOCK_BUTTON_OK);
button3 = g_list_last (GNOME_DIALOG (messagebox1)->buttons)->data;
gtk_widget_ref (button3);
gtk_object_set_data_full (GTK_OBJECT (messagebox1), "button3", button3,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (button3);
GTK_WIDGET_SET_FLAGS (button3, GTK_CAN_DEFAULT);
dialog_action_area1 = GNOME_DIALOG (messagebox1)->action_area;
gtk_widget_ref (dialog_action_area1);
gtk_object_set_data_full (GTK_OBJECT (messagebox1), "dialog_action_area1", dialog_action_area1,
(GtkDestroyNotify) gtk_widget_unref);
return messagebox1;
}
GtkWidget *note_text;
static GnomeUIInfo file1_menu_uiinfo[] =
{
GNOMEUIINFO_MENU_NEW_ITEM (N_("_New Note"), NULL, on_new_note_activate,NULL),
{
GNOME_APP_UI_ITEM, N_("_Delete this note"),
NULL,
on_delete_this_note_activate, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
{
GNOME_APP_UI_TOGGLEITEM, N_("Note is editable"),
NULL,
on_note_is_editable_activate, (gpointer)note_text, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
GNOMEUIINFO_END
};
static GnomeUIInfo priority1_menu_uiinfo[] =
{
{
GNOME_APP_UI_ITEM, N_("High"),
NULL,
on_high_activate, NULL, NULL,
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BOOK_RED,
0, 0, NULL
},
{
GNOME_APP_UI_ITEM, N_("Medium"),
NULL,
on_medium_activate, NULL, NULL,
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BOOK_YELLOW,
0, 0, NULL
},
{
GNOME_APP_UI_ITEM, N_("Low"),
NULL,
on_low_activate, NULL, NULL,
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BOOK_GREEN,
0, 0, NULL
},
GNOMEUIINFO_END
};
static GnomeUIInfo help1_menu_uiinfo[] =
{
GNOMEUIINFO_MENU_ABOUT_ITEM (on_about_activate, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo menubar1_uiinfo[] =
{
GNOMEUIINFO_MENU_FILE_TREE (file1_menu_uiinfo),
{
GNOME_APP_UI_SUBTREE, N_("Priority"),
NULL,
priority1_menu_uiinfo, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
GNOMEUIINFO_MENU_HELP_TREE (help1_menu_uiinfo),
GNOMEUIINFO_END
};
GtkWidget*
create_mainwindow (int editable, int notenumber)
{
GtkWidget *mainwindow;
GtkWidget *vbox1;
GtkWidget *menubar1;
GtkWidget *scrolledwindow1;
mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_object_set_data (GTK_OBJECT (mainwindow), "mainwindow", mainwindow);
gtk_window_set_title (GTK_WINDOW (mainwindow), _("Remember-it"));
gtk_window_set_policy (GTK_WINDOW (mainwindow), FALSE, FALSE, FALSE);
vbox1 = gtk_vbox_new (FALSE, 0);
gtk_widget_ref (vbox1);
gtk_object_set_data_full (GTK_OBJECT (mainwindow), "vbox1", vbox1,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (vbox1);
gtk_container_add (GTK_CONTAINER (mainwindow), vbox1);
menubar1 = gtk_menu_bar_new ();
gtk_widget_ref (menubar1);
gtk_object_set_data_full (GTK_OBJECT (mainwindow), "menubar1", menubar1,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (menubar1);
gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0);
gnome_app_fill_menu (GTK_MENU_SHELL (menubar1), menubar1_uiinfo,
NULL, FALSE, 0);
gtk_widget_ref (menubar1_uiinfo[0].widget);
gtk_object_set_data_full (GTK_OBJECT (mainwindow), "file1",
menubar1_uiinfo[0].widget,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_ref (file1_menu_uiinfo[0].widget);
gtk_object_set_data_full (GTK_OBJECT (mainwindow), "new_note",
file1_menu_uiinfo[0].widget,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_ref (file1_menu_uiinfo[1].widget);
gtk_object_set_data_full (GTK_OBJECT (mainwindow), "delete_this_note",
file1_menu_uiinfo[1].widget,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_ref (file1_menu_uiinfo[2].widget);
gtk_object_set_data_full (GTK_OBJECT (mainwindow), "note_is_editable",
file1_menu_uiinfo[2].widget,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_ref (menubar1_uiinfo[1].widget);
gtk_object_set_data_full (GTK_OBJECT (mainwindow), "priority1",
menubar1_uiinfo[1].widget,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_ref (priority1_menu_uiinfo[0].widget);
gtk_object_set_data_full (GTK_OBJECT (mainwindow), "high",
priority1_menu_uiinfo[0].widget,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_ref (priority1_menu_uiinfo[1].widget);
gtk_object_set_data_full (GTK_OBJECT (mainwindow), "medium",
priority1_menu_uiinfo[1].widget,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_ref (priority1_menu_uiinfo[2].widget);
gtk_object_set_data_full (GTK_OBJECT (mainwindow), "low",
priority1_menu_uiinfo[2].widget,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_ref (menubar1_uiinfo[2].widget);
gtk_object_set_data_full (GTK_OBJECT (mainwindow), "help1",
menubar1_uiinfo[2].widget,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_ref (help1_menu_uiinfo[0].widget);
gtk_object_set_data_full (GTK_OBJECT (mainwindow), "about",
help1_menu_uiinfo[0].widget,
(GtkDestroyNotify) gtk_widget_unref);
scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_ref (scrolledwindow1);
gtk_object_set_data_full (GTK_OBJECT (mainwindow), "scrolledwindow1", scrolledwindow1,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (scrolledwindow1);
gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow1, TRUE, TRUE, 0);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
note_text = gtk_text_new (NULL, NULL);
gtk_widget_ref (note_text);
gtk_object_set_data_full (GTK_OBJECT (mainwindow), "note_text", note_text,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (note_text);
if (editable == TRUE) {
gtk_container_add (GTK_CONTAINER (scrolledwindow1), note_text);
gtk_text_set_editable (GTK_TEXT (note_text), TRUE);
gtk_text_insert (GTK_TEXT (note_text), NULL, NULL, NULL,
_("Type your note here so you won't forget it"), 42);
}
if (editable == FALSE) {
gtk_container_add (GTK_CONTAINER (scrolledwindow1), note_text);
gtk_text_set_editable (GTK_TEXT (note_text), TRUE);
gtk_text_insert (GTK_TEXT (note_text), NULL, NULL, NULL,
note[notenumber].buffer,
strlen(note[notenumber].buffer));
gtk_text_set_editable (GTK_TEXT (note_text), FALSE);
}
return mainwindow;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]