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 Feb 14, 2016 10:08 am

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: problem with non modal dialog GTK 2+
PostPosted: Fri Dec 06, 2013 12:08 pm 
Familiar Face

Joined: Fri Oct 26, 2012 10:49 am
Posts: 46
I have a problem with a non modal dialog.
I want to copy some files wit a system command, and before it begins I want to show a non modal dialog that shows "wait...."

Then copy function works and when it is done, it closes the non modal dialog.
Thats what I wanted. But if I use the follwing code, it doesn't work:
The code shows the non modal dialog without text and picture, then its packs the archiv (system(commandStr) and the first it shows the non modal dialog with text and icon.
What is wrong?
Is not it enough to show the modal dialog with gtk_widget_show_all();?
If I would show a modal dialog after this command , the non modal dialog would be shown with text and icon.

Thanks a lot in advance for your help


     ts_msg_non_modal(parentWindow,message, GTK_MESSAGE_INFO); 
     rs_start_rs_pack_archiv(currFolder, newFileName);

void ts_msg_non_modal(GtkWindow *parent, char *meldung, GtkMessageType messageType)
   GtkWidget *vbox;
   ts_local.info_dialog = gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT, messageType, GTK_BUTTONS_NONE, "%s", meldung);
   vbox = gtk_dialog_get_content_area (GTK_DIALOG(ts_local.info_dialog));
   gtk_box_pack_start(GTK_CONTAINER(vbox), global.images.Hourglass, FALSE, TRUE, 0 );

   g_signal_connect_swapped(ts_local.info_dialog, "response", G_CALLBACK (cb_on_close_non_modal), ts_local.info_dialog);


static int rs_start_rs_pack_archiv(char *currFolder, char *newFileName)
   char commandStr[1024];
   char copyPath[1024];
sprintf(commandStr, "cd %s; tar cvzf %s  *  > %s",  copyPath, completeFilename, ARCHIVE_BACKUP_LOG);
     error = system(commandStr);

 Post subject: Re: problem with non modal dialog GTK 2+
PostPosted: Thu Dec 12, 2013 9:03 am 
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 971
Location: UK

Your code has a few problems. With regards to the redrawing of the window, what happens is GTK queues drawing events so that drawing is only done when control is returned back to the main loop.

What you are doing in your code is :-
- requesting the drawing of the widgets (which are put in a cue).
- Run your external application which only returns when completed.
- Destroy your widgets.
- Return control back to the main loop where the redraws are done.

Your other problem is the use of fixed size buffers in the function rs_start_rs_pack_archiv() when using the function sprintf(). This can lead to buffer overflows.

It would be better to use the GLib functions to spawn new application. See - This way you get better error handling and your application and the new task can run together so not blocking your GUI. It is also possible to monitor the running of your spawned task so that you can then close your "wait" window.


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: Yahoo [Bot] and 2 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group