GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Aug 31, 2014 12:16 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Dialog window
PostPosted: Sat Jan 28, 2012 11:59 pm 
Offline
Familiar Face

Joined: Fri Dec 09, 2011 6:25 pm
Posts: 12
How can I create a dialog like this
http://imageshack.us/photo/my-images/818/schermata012455956alle0.png/
instead of this http://imageshack.us/photo/my-images/545/schermata012455956alle0.png/?

the second dialog is done like this
Code:
GtkWidget *dialog;
   dialog = gtk_message_dialog_new (GTK_WINDOW (window),
                 GTK_DIALOG_MODAL,
            GTK_MESSAGE_WARNING,
            GTK_BUTTONS_CLOSE,
            "Scegliere un punto di partenza e uno di arrivo differenti!");
   gtk_window_set_title (GTK_WINDOW (dialog), "Errore selezione");
    // Destroy the dialog when the user responds to it (e.g. clicks a button)
    g_signal_connect_swapped (dialog, "response",
       G_CALLBACK (gtk_widget_destroy), dialog);

   gtk_dialog_run (GTK_DIALOG (dialog));

I want a minimize botton on the top left of the dialog, not a close (X) botton.
Thank you


Top
 Profile  
 
 Post subject: Re: Dialog window
PostPosted: Sun Jan 29, 2012 5:17 am 
Offline
GTK+ Guru

Joined: Sun Apr 06, 2008 6:43 pm
Posts: 286
Location: Fortress of solitude
Try with gtk_window_set_resizable

_________________
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.


Top
 Profile  
 
 Post subject: Re: Dialog window
PostPosted: Sun Jan 29, 2012 5:39 pm 
Offline
Familiar Face

Joined: Fri Dec 09, 2011 6:25 pm
Posts: 12
no, that's not what i want. I have two combo boxes. When I select the same thing from the 2 boxes or when I don't select nothing from 1 of the 2 combo boxes, the error_dialog must say "Choose 2 different things from the combo boxes". Then, if I click close I return to the main window where i can choose other different things from the combo boxes.
I need a "not removable" window, resizable is not what i need..


Top
 Profile  
 
 Post subject: Re: Dialog window
PostPosted: Sun Jan 29, 2012 9:44 pm 
Offline
GTK+ Geek

Joined: Sat Sep 03, 2011 6:36 pm
Posts: 94
To me that seems just like a normal resized window with a vbox, a label and an aligned button.Nothing more to be exact.


Top
 Profile  
 
 Post subject: Re: Dialog window
PostPosted: Sun Jan 29, 2012 9:59 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
Hang on that seems to contradict what you said earlier. I thought you wanted a window with a minimise button (as opposed to a destroy button), now you say that you want a window that can't be removed.
Firstly don't remove the destroy button. You may think it does the same thing as your ok button but programs can break at different points and when things go wrong its nice to have a number of options available to kill a process. The destroy button is a lot more fool-proof than your close button so keep it there.
As to non-removable you have the GTK_DIALOG_MODAL flag set so the dialog will be the rest of the application is frozen until the dialog is destroyed so you don't have to worry about that (it's also a good idea to set GTK_DIALOG_DESTROY_WITH_PARENT). It will be modal anyway as you're using gtk_dialog_run.
you'd also do better to dispense with the signal callback and call gtk_widget_destroy after gtk_dialog_run (which doesn't complete until a response is given). You only need a signal callback if its to be non-modal.
As to the minimise etc. buttons they can be set with gtk_window_set_type_hint. This must be done before you display it though. The dialog construct already calls this but hopefully if used just after you can override it. This function still doesn't give you full control over the way the window will be displayed as that will depend on what window manager is used by your system; you can only offer it hints as t how it is meant to function. Still I don't see the point. The message dialogs are displayed that way for a reason and being able to minimise something that is freezing the running of an application can only really be counter-productive.


Top
 Profile  
 
 Post subject: Re: Dialog window
PostPosted: Tue Jan 31, 2012 2:25 pm 
Offline
Familiar Face

Joined: Fri Dec 09, 2011 6:25 pm
Posts: 12
Thank you Paul, but now I try to explain better..
Every window in Linux has on the top and at the left 3 buttons.
X (close) v (Minimize) and ^ (maximize)
I want to put minimize and maximize in my dialog and gtk_set_resizable doesn't work.
(I'm on Ubuntu 10.04)


Top
 Profile  
 
 Post subject: Re: Dialog window
PostPosted: Tue Jan 31, 2012 9:27 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
It's not true that every window has three buttons. Some have three as you say, some have 1 as is the case of message dialogs (as far as I know) and some can even have four (e.g. minimise, maximise, destroy, resize). As I indicated in my previous post, this is controlled by the window manager, not by GTK. GTK has, however, control over describing what kind of a window it is to the window manager. This is done through the aforementioned function gtk_window_set_type_hint() you can experiment around with them but will probably find the _NORMAL type hint will give you the closest behaviour to what you want.

But honestly, why would you want a modal dialog to act unlike a modal dialog. There's a very good reason why these windows don't have minimise and maximise buttons; putting in these features doesn't add to your program but detract from it.
Let's say it gets minimised and the user doesn't notice this or forgets it (or there might be multiple users). The user is left with an unresponsive program with no clue as to why. Unless they discover that minimised window, they will swear and curse at the programmer and then kill the program loosing whatever work they have done. As for maximising there's not enough text in your dialog to warrant that.
Seriously leave it be.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group