[Glade-users] Timing out a dialog
Tristan Van Berkom
tvb at gnome.org
Fri Mar 6 17:37:36 EST 2009
On Fri, Mar 6, 2009 at 8:27 AM, His Majesty <balakkvj at gmail.com> wrote:
> Hi Tristan,
> I am not sure how to implement your solution.
This should be the sequence you need:
- Create and configure dialog
- source_id = g_timeout_add (2 seconds, new dialog); <--- right here
- run dialog
- if (source_id > 0) source_id = (g_source_remove (source_id), 0);
<--- and cancel it here, reset the timeout id also...
and the timeout:
- quit dialog
- source_id = 0; <-- reset source timeout id
- return FALSE; <-- ensure timeout is cancelled
Cheers,
-Tristan
> I have a function that takes in an argument for use as the message in
> the dialog.
> Here is the function
> ========================================
> void mainWindow::on_command_show_action(Glib::ustring object)
> {
> Glib::ustring message= object;
> Gtk::MessageDialog dialog(*this, message);
> Glib::ustring comment= "Action performed.";
> dialog.set_secondary_text(comment);
> int result = dialog.run();
> }
> ========================================
>
> This function is called when a button is pressed using
> initiateCommand->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this,
> &mainWindow::on_command_take_action),"!S5101 Fired"));
>
> I have tried using g_timeout_add in main, but there I cannot use
> dialog as my user data.
> If I put this at the dialog, it does not like MessageDialog,
> typecasting mismatch errors (Says cannot cast MessageDialog as void*).
>
> I have also tried g_signal_emit_by_name + timer, but strangely it is
> not doing the job at all. I still have to click the dialog.
>
> Any hints as to where I call the g_timeout_add?
>
> Thanks ever so much!
>
> Regards,
> B
>
> 2009/3/5 Tristan Van Berkom <tvb at gnome.org>:
>> When you launch the dialog initially then use g_timeout_add()
>> to register a timeout callback, give it the dialog as user data
>> (and hold on to the return value of g_timeout_add()...), then
>> quit the dialog/reset the source_id from the callback ... and/or
>> when gtk_dialog_run() returns:
>>
>> if (source_id > 0) source_id = (g_source_remove (source_id), 0);
>>
>> Cheers,
>> -Tristan
>>
>> On Thu, Mar 5, 2009 at 11:00 AM, His Majesty <balakkvj at gmail.com> wrote:
>>> Hello people,
>>> For sometime now, I have been trying to timeout a
>>> dialog. To illustrate,
>>> imagine you have a button A and when it is clicked, it responds "A clicked".
>>> Now, what I am trying to do is close the dialog window without any
>>> further click after a pre-determined period, say 2 seconds.
>>>
>>> Any ideas how to go about it?
>>>
>>> PS: I am using debian-2.6.26-1 i686 with glade-3
>>>
>>> Thanks in advance for any ideas.
>>>
>>> B
>>> _______________________________________________
>>> Glade-users maillist - Glade-users at lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/glade-users
>>>
>>
> _______________________________________________
> Glade-users maillist - Glade-users at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/glade-users
>
More information about the Glade-users
mailing list