X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Fmain.c;h=55d0ad94cc99ef79be4d88adb7fd283e60a44ae4;hb=c652b9b627de78f667008991e8f4c2e7b6e454b5;hp=89eeda7b9f552e093ac8aecaf5840a6b7b4f34d3;hpb=d1e3f70aff8abe0dd288f5debbec86e38e20571c;p=aweather diff --git a/src/main.c b/src/main.c index 89eeda7..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);