=== modified file 'src/launcher/main.c' --- src/launcher/main.c 2010-08-03 15:12:16 +0000 +++ src/launcher/main.c 2010-09-14 20:07:10 +0000 @@ -31,6 +31,9 @@ #include #include #include +#include + +#define COMMAND_ADD_FAVORITE 1 struct prefs _nl_prefs = {NULL}; int EVENT_ICON_INFO_ENTER = 0; @@ -95,6 +98,47 @@ win_quit_show(win); } +static void +_add_favorite(const char *favorite) +{ + gchar *uid = NULL; + + if (!favorite) return; + + INF("Add Favorite: %s\n", favorite); + + if ((g_str_has_prefix(favorite, "file://")) || + (g_str_has_prefix(favorite, "http://")) || + (g_str_has_prefix(favorite, "https://"))) + { + LauncherFavorites *favs; + + favs = launcher_favorites_get_default(); + if (g_str_has_suffix(favorite, ".desktop")) + { + gchar *uri; + + uri = g_filename_from_uri(favorite, NULL, NULL); + if (uri) + { + uid = g_strdup_printf("app-%d", (gint)time(NULL)); + launcher_favorites_set_string(favs, uid, "type", "application"); + launcher_favorites_set_string(favs, uid, "desktop_file", uri); + launcher_favorites_add_favorite(favs, uid); + g_free(uri); + } + } + else + { + uid = g_strdup_printf("uri-%d", (gint)time(NULL)); + launcher_favorites_set_string(favs, uid, "type", "uri"); + launcher_favorites_set_string(favs, uid, "uri", favorite); + launcher_favorites_set_string(favs, uid, "name", favorite); + launcher_favorites_add_favorite(favs, uid); + } + } +} + static void _showing_desktop_changed(WnckScreen *screen, Evas_Object *win) { @@ -381,6 +425,7 @@ ECORE_GETOPT_CALLBACK_ARGS ('g', "geometry", "window geometry to use.", "X:Y:W:H", ecore_getopt_callback_geometry_parse, NULL), + ECORE_GETOPT_STORE_STR('a', "add-favorite", "add location to favorites"), ECORE_GETOPT_STORE_INT('d', "debug", "debug level (see -q and -v)"), ECORE_GETOPT_COUNT('q', "quiet", "print out less information"), ECORE_GETOPT_COUNT('v', "verbose", "print out more information"), @@ -401,9 +446,11 @@ Eina_Bool quit_option = 0; int debug_level = EINA_LOG_LEVEL_WARN; Eina_Rectangle geometry = {-1, -1, -1, -1}; + char *add_favorite = NULL; char *theme = NULL, realtheme[PATH_MAX]; Ecore_Getopt_Value values[] = { ECORE_GETOPT_VALUE_PTR_CAST(geometry), + ECORE_GETOPT_VALUE_STR(add_favorite), ECORE_GETOPT_VALUE_INT(debug_level), ECORE_GETOPT_VALUE_INT(debug_level), ECORE_GETOPT_VALUE_INT(debug_level), @@ -479,15 +526,23 @@ goto shutdown_sound; } - /* Make sure we're the only NLE */ - unique = unique_app_new_with_commands ("net.launchpad.launch-lite-proj", NULL, NULL, NULL); - if (unique_app_is_running (unique)) - { - ERR("already running.\n"); - /* Show other instance before we go */ - wnck_screen_toggle_showing_desktop (wnck_screen_get_default(), TRUE); - goto shutdown_gstuff; - } + /* Make sure we're the only NLE */ + unique = unique_app_new_with_commands ("net.launchpad.launch-lite-proj", NULL, NULL, NULL); + if (unique_app_is_running (unique)) + { + if (add_favorite) _add_favorite(add_favorite); + + ERR("already running.\n"); + + /* Show other instance before we go */ + wnck_screen_toggle_showing_desktop (wnck_screen_get_default(), TRUE); + + goto shutdown_gstuff; + } + else + { + if (add_favorite) _add_favorite(add_favorite); + } win = win_add(); if (!win)