X-Git-Url: http://pileus.org/git/?p=aweather;a=blobdiff_plain;f=src%2Faweather-gui.c;h=6d8e4239fadca1f331f3eeeb0b9bfebf0fef0594;hp=499be3d3b0f491df1906040a77698514d32624de;hb=5d02e9824afbc67d431e3d3e59797425f91cddcd;hpb=3bd2e381b8fb0dc48be6143029ee3341d059f314 diff --git a/src/aweather-gui.c b/src/aweather-gui.c index 499be3d..6d8e423 100644 --- a/src/aweather-gui.c +++ b/src/aweather-gui.c @@ -441,6 +441,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 * @@ -506,6 +527,23 @@ void aweather_gui_deattach_plugin(AWeatherGui *self, const gchar *name) grits_plugins_disable(self->plugins, name); gtk_widget_queue_draw(GTK_WIDGET(self->viewer)); } +void aweather_gui_load_plugins(AWeatherGui *self) +{ + g_debug("AWeatherGui: load_plugins"); + GtkTreeIter iter; + for (GList *cur = grits_plugins_available(self->plugins); cur; cur = cur->next) { + gchar *name = cur->data; + GError *error = NULL; + gboolean enabled = grits_prefs_get_boolean_v(self->prefs, "plugins", cur->data, &error); + if (error && error->code == G_KEY_FILE_ERROR_GROUP_NOT_FOUND) + enabled = TRUE; + gtk_list_store_append(self->gtk_plugins, &iter); + gtk_list_store_set(self->gtk_plugins, &iter, 0, name, 1, enabled, -1); + if (enabled) + aweather_gui_attach_plugin(self, name); + } +} + /**************** @@ -523,29 +561,16 @@ 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); - /* 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; - gboolean enabled = grits_prefs_get_boolean_v(self->prefs, "plugins", cur->data, &error); - if (error && error->code == G_KEY_FILE_ERROR_GROUP_NOT_FOUND) - enabled = TRUE; - gtk_list_store_append(self->gtk_plugins, &iter); - gtk_list_store_set(self->gtk_plugins, &iter, 0, name, 1, enabled, -1); - if (enabled) - aweather_gui_attach_plugin(self, name); - } - /* Misc, helpers */ site_setup(self); time_setup(self); prefs_setup(self); + icons_setup(self); /* Connect signals */ gtk_builder_connect_signals(self->builder, self); @@ -554,6 +579,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, "realize", + G_CALLBACK(aweather_gui_load_plugins), self); } static void aweather_gui_buildable_init(GtkBuildableIface *iface) {