LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-28-2012, 06:23 AM   #1
nime
LQ Newbie
 
Registered: Jan 2011
Location: Croatia
Distribution: Ubuntu 9.1
Posts: 28

Rep: Reputation: 1
Gtk custom dialog


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.
 
  


Reply

Tags
gtk



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
adding custom dialog to wxWidgets GordonAkst Linux - Software 0 09-16-2010 06:57 PM
GTK Dialog Box Button Order Woodsman Slackware 4 01-17-2009 11:49 PM
'dialog' app for GTK+2.0 General Programming 6 04-23-2006 01:10 PM
Dialog modal+GTK santhosh.linux Programming 1 02-20-2006 11:47 AM
gtk+ dialog, data check before close danxl Programming 1 10-11-2003 11:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration