X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Faweather-gui.c;h=558f43f12444f2138b87784ea7e4c1927afbb1ce;hb=3f4b3144007c6213f0733b41ee279aa180a74e67;hp=93fad72c03214e05f7192c06d2984ac0d56f9090;hpb=41cb797b1ae28e992a73bc2c12ba0c05cbb16f72;p=aweather diff --git a/src/aweather-gui.c b/src/aweather-gui.c index 93fad72..558f43f 100644 --- a/src/aweather-gui.c +++ b/src/aweather-gui.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 @@ -355,7 +355,7 @@ static void site_setup(AWeatherGui *self) gtk_tree_store_append(store, &state, NULL); gtk_tree_store_set (store, &state, 0, cities[i].code, 1, cities[i].name, -1); - } else { + } else if (cities[i].type == LOCATION_CITY) { gtk_tree_store_append(store, &city, &state); gtk_tree_store_set (store, &city, 0, cities[i].code, 1, cities[i].name, -1); @@ -387,6 +387,7 @@ static void prefs_setup(AWeatherGui *self) GtkTreeIter iter; if (gtk_tree_model_find_string(model, &iter, NULL, 0, is)) gtk_combo_box_set_active_iter(GTK_COMBO_BOX(isw), &iter); + g_free(is); } /* Load Plugins */ @@ -402,13 +403,6 @@ static void prefs_setup(AWeatherGui *self) gtk_tree_view_append_column(tview, col2); g_signal_connect(rend2, "toggled", G_CALLBACK(on_plugin_toggled), self); gtk_tree_view_set_model(GTK_TREE_VIEW(tview), GTK_TREE_MODEL(self->gtk_plugins)); - - /* Setup auto update enable */ - gboolean auto_update = grits_prefs_get_boolean(self->prefs, "aweather/update_enab", NULL); - GObject *action = aweather_gui_get_object(self, "update"); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), auto_update); - g_signal_connect_swapped(self->viewer, "refresh", G_CALLBACK(set_update_timeout), self); - set_update_timeout(self); } static void time_setup(AWeatherGui *self) @@ -441,6 +435,27 @@ static void time_setup(AWeatherGui *self) G_CALLBACK(update_time_widget), self); } +static void icons_setup(AWeatherGui *self) +{ + gchar *icons[] = { + ICONDIR "/hicolor/16x16/apps/aweather.png", + ICONDIR "/hicolor/22x22/apps/aweather.png", + ICONDIR "/hicolor/24x24/apps/aweather.png", + ICONDIR "/hicolor/32x32/apps/aweather.png", + ICONDIR "/hicolor/48x48/apps/aweather.png", + ICONDIR "/hicolor/scalable/apps/aweather.svg", + }; + GList *list = NULL; + for (int i = 0; i < G_N_ELEMENTS(icons); i++) { + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(icons[i], NULL); + if (!pixbuf) + g_warning("AWeatherGui: icons_setup - %s failed", icons[i]); + list = g_list_prepend(list, pixbuf); + } + gtk_window_set_default_icon_list(list); + g_list_free(list); +} + /*********** * Methods * @@ -510,7 +525,6 @@ void aweather_gui_load_plugins(AWeatherGui *self) { g_debug("AWeatherGui: load_plugins"); GtkTreeIter iter; - self->gtk_plugins = GTK_LIST_STORE(aweather_gui_get_object(self, "plugins")); for (GList *cur = grits_plugins_available(self->plugins); cur; cur = cur->next) { gchar *name = cur->data; GError *error = NULL; @@ -541,6 +555,7 @@ static void aweather_gui_parser_finished(GtkBuildable *_self, GtkBuilder *builde self->prefs = grits_prefs_new(config, defaults); self->plugins = grits_plugins_new(PLUGINSDIR, self->prefs); self->viewer = GRITS_VIEWER(aweather_gui_get_widget(self, "main_viewer")); + self->gtk_plugins = GTK_LIST_STORE(aweather_gui_get_object(self, "plugins")); grits_viewer_setup(self->viewer, self->plugins, self->prefs); g_free(config); g_free(defaults); @@ -549,6 +564,7 @@ static void aweather_gui_parser_finished(GtkBuildable *_self, GtkBuilder *builde site_setup(self); time_setup(self); prefs_setup(self); + icons_setup(self); /* Connect signals */ gtk_builder_connect_signals(self->builder, self); @@ -557,6 +573,8 @@ static void aweather_gui_parser_finished(GtkBuildable *_self, GtkBuilder *builde g_signal_connect_swapped(self->viewer, "offline", G_CALLBACK(gtk_toggle_action_set_active), aweather_gui_get_object(self, "offline")); + g_signal_connect_swapped(self->viewer, "refresh", + G_CALLBACK(set_update_timeout), self); g_signal_connect_swapped(self->viewer, "realize", G_CALLBACK(aweather_gui_load_plugins), self); }