Regarding application exit when click on button which open url on browser

I am working on printing panel which is in Gnome control panel .I want to open a url after clicking on a class.
Ui file contain like below. where webinterface is Ui part upon click on this url should open in browser.

This is how I call funtion upon click on ui
This is funciton which will call upon click
Ui will look like below

In above image all 4 parts are on different file I just merger all screen shot

After click on web interface button application exited with out giving any error.

Please Help me to figure out mistake. Thanks in advance.

I am new in gtk developement working on some improvement in printing panel with Till Kampeter ( Open printing). My work upon completion will release with all linux distro. if anyone free for helping or guid me when I am stuck with gtk things please comment you contact ,

Thanks in advance

Hi,

gtk_uri_launcher_launch is asyncronous, the actual processing will be done in the background. So if you immediately quit the application, then the launch request will not be handled.

You can keep the application alive by calling g_application_hold from the click callback, then call g_application_release from the launcher result callback to allow the application to shutdown once the launch is finished.

1 Like

Hello!
First of all Thanks for reply.
I do not want close application after click on URL .Just It must open on browser.
I would be very helpful if you give me any instance of code where gtk_uri_launcher_launch used or how exactly I have to do.
Thanks

Ah ok, sorry for the confusion.

There are some examples in the gtk code itself: gtk/gtkaboutdialog.c · main · GNOME / gtk · GitLab

I see you don’t pass a Window in your code… Looks like gtk won’t use the portals interfaces in that case, could it be the issue?

Thanks you so much . It works for me . below is updated function
static void
on_click_web_interface (PpPrinterEntry *self)
{
GtkUriLauncher *launcher;
launcher = gtk_uri_launcher_new (self->web_interface);
gtk_uri_launcher_launch (launcher, NULL, NULL, NULL, NULL);
g_object_unref (launcher);

return;

}

1 Like