mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-23 06:08:07 +00:00
Fix clickable link in chatroom on Windows and MacOS
This commit is contained in:
parent
c578229f92
commit
ee44a22e62
2 changed files with 20 additions and 18 deletions
|
|
@ -411,12 +411,7 @@ static gboolean link_event_handler(GtkTextTag *tag, GObject *text_view,GdkEvent
|
|||
gtk_text_iter_forward_to_tag_toggle(&uri_end, tag);
|
||||
uri = gtk_text_iter_get_slice(&uri_begin, &uri_end);
|
||||
if(((GdkEventButton *)event)->button == 1) {
|
||||
GError *error = NULL;
|
||||
gtk_show_uri(NULL, uri, gdk_event_get_time(event), &error);
|
||||
if(error) {
|
||||
g_warning("Could not open %s from chat: %s", uri, error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
linphone_gtk_open_browser(uri);
|
||||
} else if(((GdkEventButton *)event)->button == 3) {
|
||||
GtkMenu *menu = GTK_MENU(g_object_get_data(text_view, "link_ctx_menu"));
|
||||
g_object_set_data_full(G_OBJECT(menu), "uri", g_strdup(uri), g_free);
|
||||
|
|
|
|||
31
gtk/main.c
31
gtk/main.c
|
|
@ -1466,19 +1466,26 @@ static void linphone_gtk_registration_state_changed(LinphoneCore *lc, LinphonePr
|
|||
update_registration_status(cfg,rs);
|
||||
}
|
||||
|
||||
void linphone_gtk_open_browser(const char *url){
|
||||
/*in gtk 2.16, gtk_show_uri does not work...*/
|
||||
#ifndef WIN32
|
||||
#if GTK_CHECK_VERSION(2,18,3)
|
||||
gtk_show_uri(NULL,url,GDK_CURRENT_TIME,NULL);
|
||||
#else
|
||||
char cl[255];
|
||||
snprintf(cl,sizeof(cl),"/usr/bin/x-www-browser %s",url);
|
||||
g_spawn_command_line_async(cl,NULL);
|
||||
#endif
|
||||
#else /*WIN32*/
|
||||
ShellExecute(0,"open",url,NULL,NULL,1);
|
||||
void linphone_gtk_open_browser(const char *uri) {
|
||||
const char *cmd_name = NULL;
|
||||
char cmd_line[256];
|
||||
GError *error = NULL;
|
||||
|
||||
#ifdef __APPLE__
|
||||
cmd_name = "/usr/bin/open";
|
||||
#elseif defined(WIN32)
|
||||
cmd_name = "open";
|
||||
#endif
|
||||
if(cmd_name) {
|
||||
g_snprintf(cmd_line, sizeof(cmd_line), "%s %s", cmd_name, uri);
|
||||
g_spawn_command_line_async(cmd_line, &error);
|
||||
} else {
|
||||
gtk_show_uri(NULL, uri, GDK_CURRENT_TIME, &error);
|
||||
}
|
||||
if(error) {
|
||||
g_warning("Could not open %s: %s", uri, error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
}
|
||||
|
||||
void linphone_gtk_link_to_website(GtkWidget *item){
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue