X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain.c;h=55d0ad94cc99ef79be4d88adb7fd283e60a44ae4;hb=bdae122854ed2d93abf51d7ef4acfd72cd77f209;hp=9c0384d575306e00a833ae09b468370e269a14fd;hpb=42017a7e834a0ddc97a37f24affc58c3c1b63a3a;p=aweather diff --git a/src/main.c b/src/main.c index 9c0384d..55d0ad9 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2010 Andy Spencer + * Copyright (C) 2009-2011 Andy Spencer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,6 +47,12 @@ static void log_func(const gchar *log_domain, GLogLevelFlags log_level, } } +static void xdg_open(GtkLinkButton *button, const gchar *link, gpointer user_data) +{ + gchar *argv[] = {"xdg-open", (gchar*)link, NULL}; + g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL); +} + static void on_log_level_changed(GtkSpinButton *spinner, AWeatherGui *self) { g_message("main: log_level_changed"); @@ -58,9 +64,9 @@ static void set_location_time(AWeatherGui *gui, char *site, char *time) /* Set time * Do this before setting setting location * so that it doesn't refresh twice */ - struct tm tm = {}; - strptime(time, "%Y-%m-%d %H:%M", &tm); - time_t sec = mktime(&tm); + int year, mon, day, hour, min; + sscanf(time, "%d-%d-%d %d:%d", &year, &mon, &day, &hour, &min); + time_t sec = mktime(&(struct tm){0, year-1900, mon-1, day, hour, min}); if (sec > 0) grits_viewer_set_time(gui->viewer, sec); g_debug("date = [%s] == %lu\n", time, sec); @@ -122,6 +128,9 @@ int main(int argc, char *argv[]) return -1; } + /* Use external handler for link buttons */ + gtk_link_button_set_uri_hook(xdg_open, NULL, NULL); + /* Setup debug level for aweather_gui_new */ g_log_set_handler(NULL, G_LOG_LEVEL_MASK, log_func, NULL); log_levels = int2log(opt_debug >= 0 ? opt_debug : debug); @@ -159,6 +168,7 @@ int main(int argc, char *argv[]) grits_viewer_set_offline(gui->viewer, offline); set_toggle_action(gui, "update", autoupdate); set_toggle_action(gui, "fullscreen", fullscreen); + g_free(prefs_site); /* Done with init, show gui */ gtk_widget_show_all(GTK_WIDGET(gui));