Re: Disabling menu And Modal dialog boxes!
- From: Iago Rubio <iago rubio hispalinux es>
- To: gtk-app-devel-list gnome org
- Subject: Re: Disabling menu And Modal dialog boxes!
- Date: Mon, 28 Mar 2005 11:43:39 +0200
On Mon, 2005-03-28 at 12:30 +0530, APR Trainees wrote:
hi again,
Thanx for the help...
as u mentioned here id tried using this earlier too.Irwin had
suggested set_sensitive also.
The problem is when i try to use these it says that the 1st argument
if from an incompatible pointer type.
now the function is:-
gtk_widget_set_sensitive(*GTKWIDGET ,FALSE)
so if i pass the name of the menu or the verb associated wth the
context menu to this function it gives an error!
You should pass a widget pointer to this.
i'm pasting my code here so that u could get a better idea!
as u said about using a structure or data etc for referencing,i cudnt
quite implement it!
the code:-
I was reading the code to check for the callbacks of the Bonobo
component but I didn't found them.
I also tryied to find the menu dialog creation invocation and also was
unable to found it. Well, I'm doing it quite quickly because I'm a bit
busy so may be I'm missing something.
Can you change the dialog creation signature to something like this ?
GtkWidget* create_dialog (PanelApplet* applet, int type, char * message)
Then you can - on dialog construction - use the functions:
BonoboUIComponent*
panel_applet_get_popup_component (PanelApplet *applet);
void
bonobo_ui_component_freeze (BonoboUIComponent *component,
CORBA_Environment *opt_ev);
And on destruction:
void
bonobo_ui_component_thaw (BonoboUIComponent *component,
CORBA_Environment *opt_ev);
I suppose it should fix your problem.
#include <panel-applet.h>
#include <gtk/gtklabel.h>
#include <gnome.h>
#include <bonobo.h>
GtkWidget* create_dialog (int type, char * message);
static const BonoboUIVerb myexample_menu_verbs [];
static const char Context_menu_un_xml [] =
"<popup name=\"button3\">\n"
" <menuitem name=\"mnuGet\" "
" verb=\"pepGet\" "
" _label=\"_Get Status\"\n"
" pixtype=' "
" pixname=' />\n"
" <menuitem name=\"mnuStatus\" "
" verb=\"pepStatus\" "
" _label=\"_Unknown\"\n"
" pixtype=' "
" sensitive=False "
" pixname=' />\n"
" <menuitem name=\"mnuAbout\" "
" verb=\"pepAbout\" "
" _label=\"_About\"\n"
" pixtype=' "
" pixname=' />\n"
"</popup>\n";
Now in another function i try to use:
gtk_widget_set_sensitive("pepStatus",FALSE);
This won't work.
//Function called to make dialog and set it modal
//modal not yet working!
GtkWidget* create_dialog (int type, char * message)
{
GtkWidget *dialog;
GtkWidget *dialog_vbox;
GtkWidget *hbox;
GtkWidget *dialog_action_area;
GtkWidget *okbutton;
GtkWidget *image;
GtkWidget *label1;
GtkWidget *label2;
GtkWidget *label3;
char about_data[256];
int retVal;
dialog = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (dialog), _("About"));
gtk_window_set_modal (GTK_WINDOW (dialog), 1);
//gtk_window_set_modal(GTK_WINDOW (dialog),TRUE);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
dialog_vbox = GTK_DIALOG (dialog)->vbox;
gtk_widget_show (dialog_vbox);
gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
hbox = gtk_hbox_new (TRUE, 0);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (dialog_vbox), hbox, TRUE, TRUE, 0);
image = gtk_image_new_from_file ("icon.ico");
gtk_widget_show (image);
gtk_box_pack_start (GTK_BOX (hbox), image, TRUE, TRUE, 0);
sprintf(about_data,"about");
label1 = gtk_label_new (_(about_data));
gtk_widget_show (label1);
gtk_box_pack_start (GTK_BOX (dialog_vbox), label1, FALSE, FALSE, 0);
gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT);
dialog_action_area = GTK_DIALOG (dialog)->action_area;
gtk_widget_show (dialog_action_area);
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area),
GTK_BUTTONBOX_SPREAD);
okbutton = gtk_button_new_from_stock ("gtk-ok");
gtk_widget_show (okbutton);
gtk_dialog_add_action_widget (GTK_DIALOG (dialog), okbutton, GTK_RESPONSE_OK);
GTK_WIDGET_SET_FLAGS (okbutton, GTK_CAN_DEFAULT);
g_signal_connect_data ((gpointer) okbutton, "clicked",
G_CALLBACK (gtk_widget_destroy),
GTK_OBJECT (dialog),
NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
g_object_set_data (G_OBJECT(dialog), "dialog", dialog);
g_object_set_data (G_OBJECT(dialog), "dialog_vbox", dialog_vbox);
g_object_set_data (G_OBJECT(dialog), "hbox", hbox);
g_object_set_data (G_OBJECT(dialog), "image", image);
g_object_set_data (G_OBJECT(dialog), "label1", label1);
g_object_set_data (G_OBJECT(dialog), "dialog_action_area", dialog_action_area);
g_object_set_data (G_OBJECT(dialog), "okbutton", okbutton);
return dialog;
}
static const BonoboUIVerb myexample_menu_verbs [] =
{
BONOBO_UI_VERB ("pepGet", get_request),
BONOBO_UI_VERB ("pepAbout", display_about),
BONOBO_UI_VERB ("pepStatus", set_request),
BONOBO_UI_VERB_END
};
static gboolean
myexample_applet_fill (PanelApplet *applet,
const gchar *iid,
gpointer data)
{
GtkWidget *event_box;
GtkWidget *image;
if (strcmp (iid, "OAFIID:ExampleApplet") != 0)
return FALSE;
image = gtk_image_new_from_file("icon.ico");
//("/usr/share/pixmaps/InmarsatIcon.png");
event_box = gtk_event_box_new();
gtk_container_add (GTK_CONTAINER (event_box), image);
gtk_container_add (GTK_CONTAINER (applet), event_box);
gtk_widget_show_all (GTK_WIDGET (applet));
panel_applet_setup_menu (PANEL_APPLET (applet),
Context_menu_un_xml,
myexample_menu_verbs,
NULL);
return TRUE;
}
PANEL_APPLET_BONOBO_FACTORY ("OAFIID:ExampleApplet_Factory",
PANEL_TYPE_APPLET,
"The Hello World Applet",
"0",
myexample_applet_fill,
NULL);
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
--
Iago Rubio
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]