Example #1
0
void open_url(GtkWindow *parent, const gchar * url)
{
#ifdef WINDOWS
  ShellExecute(NULL, NULL, (char *) url, NULL, ".\\", 0);
#else /* WINDOWS */
  const gchar *browsers[] = {
    "xdg-open", "gnome-open", "kfmclient openURL",
    "sensible-browser", "firefox", "epiphany",
    "iceweasel", "seamonkey", "galeon", "mozilla",
    "opera", "konqueror", "netscape", "links -g",
    "chromium-browser", "chromium", "chrome",
    "safari", "camino", "omniweb", "icab",
    NULL
  };
  gint i=0;
  
  const gchar *browser = g_getenv("BROWSER");
  if (browser == NULL || browser[0] == '\0') {
    /* $BROWSER not set -> use first entry */
    browser = browsers[i++];
  }
  do {
    if (spawn_command_line_async(browser, url)) {
      return;
    }

    browser = browsers[i++];
  } while(browser);
  
  a_dialog_error_msg ( parent, _("Could not launch web browser.") );
#endif /* WINDOWS */
}
Example #2
0
void open_url(GtkWindow *parent, const gchar * url)
{
#ifdef WINDOWS
  ShellExecute(NULL, NULL, (char *) url, NULL, ".\\", 0);
#else
  gboolean use_browser = FALSE;
  if ( a_settings_get_boolean ( "use_env_browser", &use_browser ) ) {
    const gchar *browser = g_getenv("BROWSER");
    if (browser == NULL || browser[0] == '\0') {
      browser = "firefox";
    }
    if (spawn_command_line_async(browser, url)) {
      return;
    }
    else
      g_warning("Failed to run: %s on %s", browser, url);
  }
  else {
    GError *error = NULL;
    gtk_show_uri ( gtk_widget_get_screen (GTK_WIDGET(parent)), url, GDK_CURRENT_TIME, &error );
    if ( error ) {
      a_dialog_error_msg_extra ( parent, _("Could not launch web browser. %s"), error->message );
      g_error_free ( error );
    }
  }
#endif
}
Example #3
0
void new_email(GtkWindow *parent, const gchar * address)
{
  gchar *uri = g_strdup_printf("mailto:%s", address);
#ifdef WINDOWS
  ShellExecute(NULL, NULL, (char *) uri, NULL, ".\\", 0);
#else /* WINDOWS */
  if (!spawn_command_line_async("xdg-email", uri))
    a_dialog_error_msg ( parent, _("Could not create new email.") );
#endif /* WINDOWS */
  g_free(uri);
  uri = NULL;
}