Hello,
I am trying to make usage of Gtk more modular for using one dialog with more projects.
So, I have separate code file and separate glade file for my dialog.
Dialog is called as function from main file where dialog is not referenced, but function is.
Code:
my_func(GTK_WIDGET(my_window), some_int);
First, experimental example of dialog:
Code:
int my_func(GtkWidget *caller, int some_int)
{
GtkWidget *dialog;
dialog = gtk_dialog_new_with_buttons ("my Dialog",
GTK_WINDOW(caller),
GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK,
GTK_RESPONSE_OK,
"_my Button",
GTK_RESPONSE_CANCEL,
NULL);
//
int x, y;
gdk_window_get_origin(GDK_WINDOW(GTK_WIDGET(caller)->window), &x, &y);
gtk_window_move(GTK_WINDOW(dialog), x+8, y);
//
int dlgresponse;
dlgresponse = gtk_dialog_run(GTK_DIALOG(dialog));
This works nice and is modal to caller window, exact
as have to be.
Question is, how can I use my own custom dialog created with glade.
I try many ways but none is modal even I use this:
Code:
...code with gtkbuilder for read my glade file, reference widgets and connecting signals...
gtk_window_set_modal(GTK_WINDOW(GTK_DIALOG(dialog)), TRUE);
gtk_window_set_transient_for(GTK_WINDOW(GTK_DIALOG(dialog)), GTK_WINDOW(GTK_WIDGET(caller)));
Caller variable is here for referencing main window.
For positioning works OK but for modality NOT. Program works but I can select and run all widgets from main window while dialog is showed althrough dialog stays on top.
Shortly, dialog is not modal though I want to be.
Any help will be welcome.