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 4:15 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 
Offline
Familiar Face

Joined: Fri Oct 26, 2012 10:49 am
Posts: 36
Hello!
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

MBoerner


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


Code:
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);
   gtk_widget_show_all(ts_local.info_dialog);

}


Code:
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);
     ....
       ts_msg_non_modal_destroy(ts_get_current_non_modal_dialog());
}   


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

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

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 - https://developer.gnome.org/glib/stable/glib-Spawning-Processes.html. 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.

_________________
E.


Top
 Profile  
 
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: No registered users 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