comparison src/gtknotify.c @ 7136:2b99c950b817

[gaim-migrate @ 7703] death to old crufty code, and browser.c committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Fri, 03 Oct 2003 23:19:21 +0000
parents acd2a66e59ed
children 414c701ef1ff
comparison
equal deleted inserted replaced
7135:eba5f7be0bc8 7136:2b99c950b817
375 } 375 }
376 else 376 else
377 gtk_widget_destroy(GTK_WIDGET(ui_handle)); 377 gtk_widget_destroy(GTK_WIDGET(ui_handle));
378 } 378 }
379 379
380 static void *
381 gaim_gtk_notify_uri(const char *uri)
382 {
383 #ifndef _WIN32
384 char *command = NULL;
385 GError *error = NULL;
386 const char *web_browser;
387
388 web_browser = gaim_prefs_get_string("/gaim/gtk/browsers/browser");
389
390 if (!strcmp(web_browser, "netscape")) {
391 command = g_strdup_printf("netscape \"%s\"", uri);
392 } else if (!strcmp(web_browser, "opera")) {
393 if (gaim_prefs_get_bool("/gaim/gtk/browsers/new_window"))
394 command = g_strdup_printf("opera -newwindow \"%s\"", uri);
395 else
396 command = g_strdup_printf("opera \"%s\"", uri);
397 } else if (!strcmp(web_browser, "kfmclient")) {
398 command = g_strdup_printf("kfmclient openURL \"%s\"", uri);
399 } else if (!strcmp(web_browser, "galeon")) {
400 if (gaim_prefs_get_bool("/gaim/gtk/browsers/new_window"))
401 command = g_strdup_printf("galeon -w \"%s\"", uri);
402 else
403 command = g_strdup_printf("galeon \"%s\"", uri);
404 } else if (!strcmp(web_browser, "mozilla")) {
405 command = g_strdup_printf("mozilla \"%s\"", uri);
406 } else if (!strcmp(web_browser, "custom")) {
407 const char *web_command;
408
409 web_command = gaim_prefs_get_string("/gaim/gtk/browsers/command");
410
411 if (web_command == NULL || *web_command == '\0') {
412 gaim_notify_error(NULL, NULL, _("Unable to open URL"),
413 _("The 'Manual' browser command has been "
414 "chosen, but no command has been set."));
415 return NULL;
416 }
417
418 if (strstr(web_command, "%s"))
419 command = gaim_strreplace(web_command, "%s", uri);
420 else {
421 /*
422 * There is no "%s" in the browser command. Assume the user
423 * wanted the URL tacked on to the end of the command.
424 */
425 command = g_strdup_printf("%s %s", web_command, uri);
426 }
427 }
428
429 if (!gaim_program_is_valid(command)) {
430 gchar *tmp = g_strdup_printf(_("The browser \"%s\" is invalid."),
431 command);
432 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp);
433 g_free(tmp);
434
435 } else if (!g_spawn_command_line_async(command, &error)) {
436 char *tmp = g_strdup_printf(
437 _("Error launching \"command\": %s"),
438 error->message);
439
440 gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp);
441
442 g_free(tmp);
443 g_error_free(error);
444 }
445
446 g_free(command);
447
448 #else
449 ShellExecute(NULL, NULL, uri, NULL, ".\\", 0);
450 #endif
451
452 return NULL;
453 }
454
380 static GaimNotifyUiOps ops = 455 static GaimNotifyUiOps ops =
381 { 456 {
382 gaim_gtk_notify_message, 457 gaim_gtk_notify_message,
383 gaim_gtk_notify_email, 458 gaim_gtk_notify_email,
384 gaim_gtk_notify_emails, 459 gaim_gtk_notify_emails,