From 77bfb99eac375387bb5c851998e7006d4c440f0f Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 31 Jul 2008 11:29:15 +0000 Subject: ** Fixes bug #545568 2008-07-31 Matthew Barnes ** Fixes bug #545568 * e-plugin.c (ep_load): Make sure system plugins are enabled on startup. * plugins/addressbook-file/org-gnome-addressbook-file.eplug.xml: * plugins/caldav/org-gnome-caldav.eplug.xml: * plugins/calendar-file/org-gnome-calendar-file.eplug.xml: * plugins/calendar-http/org-gnome-calendar-http.eplug.xml: * plugins/calendar-weather/org-gnome-calendar-weather.eplug.xml: * plugins/exchange-operations/org-gnome-exchange-operations.eplug.xml: * plugins/google-account-setup/org-gnome-evolution-google.eplug.xml: * plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug.xml: * plugins/hula-account-setup/org-gnome-hula-account-setup.eplug.xml: Add "system_plugin=true" so it's not shown in the Plugin Manager. These plugins are not designed to be disabled by the user. svn path=/trunk/; revision=35871 --- plugins/calendar-weather/ChangeLog | 8 ++++++++ plugins/calendar-weather/org-gnome-calendar-weather.eplug.xml | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'plugins/calendar-weather') diff --git a/plugins/calendar-weather/ChangeLog b/plugins/calendar-weather/ChangeLog index 78f2dc28d7..13f1f22a89 100644 --- a/plugins/calendar-weather/ChangeLog +++ b/plugins/calendar-weather/ChangeLog @@ -1,3 +1,11 @@ +2008-07-31 Matthew Barnes + + ** Fixes part of bug #545568 + + * org-gnome-calendar-weather.eplug.xml: + Add "system_plugin=true" so it's not shown in the Plugin Manager. + This plugin is not designed to be disabled by the user. + 2008-03-31 Suman Manjunath ** Fix for bug #346555 diff --git a/plugins/calendar-weather/org-gnome-calendar-weather.eplug.xml b/plugins/calendar-weather/org-gnome-calendar-weather.eplug.xml index 442fd83074..e6767d128a 100644 --- a/plugins/calendar-weather/org-gnome-calendar-weather.eplug.xml +++ b/plugins/calendar-weather/org-gnome-calendar-weather.eplug.xml @@ -4,7 +4,8 @@ type="shlib" location="@PLUGINDIR@/liborg-gnome-calendar-weather@SOEXT@" id="org.gnome.evolution.calendar.weather" - _name="Weather Calendars"> + _name="Weather Calendars" + system_plugin="true"> <_description>Provides core functionality for weather calendars. -- cgit v1.2.3 From 792772dc246fe7d2119f946a2ea95a70256fb147 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 3 Dec 2008 12:28:57 +0000 Subject: ** Part of fix for bug #352287 2008-12-03 Milan Crha ** Part of fix for bug #352287 * calendar/gui/e-day-view-top-item.c: (e_day_view_top_item_draw_long_event): Draw top icons in full detail/color depth (for weather, for example). * plugins/calendar-weather/Makefile.am: Compile and link with libgweather. * plugins/calendar-weather/calendar-weather.c: (e_plugin_lib_enable), (selection_changed), (find_location_func), (find_location), (treeview_clicked), (create_source_selector), (build_location_path), (location_clicked), (e_calendar_weather_location): Use libgweather for weather calendar. Note: Requires eds revision at least 9793. svn path=/trunk/; revision=36827 --- plugins/calendar-weather/ChangeLog | 11 ++ plugins/calendar-weather/Makefile.am | 11 +- plugins/calendar-weather/calendar-weather.c | 175 +++++++++++----------------- 3 files changed, 87 insertions(+), 110 deletions(-) (limited to 'plugins/calendar-weather') diff --git a/plugins/calendar-weather/ChangeLog b/plugins/calendar-weather/ChangeLog index 13f1f22a89..2d70b465a0 100644 --- a/plugins/calendar-weather/ChangeLog +++ b/plugins/calendar-weather/ChangeLog @@ -1,3 +1,14 @@ +2008-12-03 Milan Crha + + ** Part of fix for bug #352287 + + * Makefile.am: Compile and link with libgweather. + * calendar-weather.c: (e_plugin_lib_enable), (selection_changed), + (find_location_func), (find_location), (treeview_clicked), + (create_source_selector), (build_location_path), + (location_clicked), (e_calendar_weather_location): + Use libgweather for weather calendar. + 2008-07-31 Matthew Barnes ** Fixes part of bug #545568 diff --git a/plugins/calendar-weather/Makefile.am b/plugins/calendar-weather/Makefile.am index 8f57db1dcc..b5a811118c 100644 --- a/plugins/calendar-weather/Makefile.am +++ b/plugins/calendar-weather/Makefile.am @@ -1,5 +1,7 @@ eds_datadir = `pkg-config --variable=privdatadir evolution-data-server-1.2` weatherdatadir = $(datadir)/evolution/$(BASE_VERSION)/weather +LIBGWEATHER_CFLAGS = `pkg-config --cflags gweather` +LIBGWEATHER_LIBS = `pkg-config --libs gweather` INCLUDES = \ -I$(top_srcdir) \ @@ -7,7 +9,8 @@ INCLUDES = \ $(EVOLUTION_CALENDAR_CFLAGS) \ $(SOURCE_SEL_CFLAGS) \ -DWEATHER_DATADIR=\""$(weatherdatadir)"\" \ - -DWEATHER_EDS_DATADIR=\""$(eds_datadir)/weather"\" + -DWEATHER_EDS_DATADIR=\""$(eds_datadir)/weather"\" \ + $(LIBGWEATHER_CFLAGS) @EVO_PLUGIN_RULE@ @@ -24,12 +27,12 @@ plugin_DATA = org-gnome-calendar-weather.eplug plugin_LTLIBRARIES = liborg-gnome-calendar-weather.la liborg_gnome_calendar_weather_la_SOURCES = calendar-weather.c -liborg_gnome_calendar_weather_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED) -liborg_gnome_calendar_weather_la_LIBADD = \ +liborg_gnome_calendar_weather_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED) $(LIBGWEATHER_LIBS) +liborg_gnome_calendar_weather_la_LIBADD = \ $(top_builddir)/calendar/gui/libevolution-calendar.la \ $(EVOLUTION_CALENDAR_LIBS) -EXTRA_DIST = \ +EXTRA_DIST = \ org-gnome-calendar-weather.eplug.xml \ $(weatherdata_DATA) diff --git a/plugins/calendar-weather/calendar-weather.c b/plugins/calendar-weather/calendar-weather.c index 68cac54258..a6dce31326 100644 --- a/plugins/calendar-weather/calendar-weather.c +++ b/plugins/calendar-weather/calendar-weather.c @@ -21,6 +21,7 @@ #include #include +#include "e-util/e-icon-factory.h" #include #include #include @@ -32,6 +33,11 @@ #include #include +#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE +#include +#include +#undef GWEATHER_I_KNOW_THIS_IS_UNSTABLE + GtkWidget *e_calendar_weather_location (EPlugin *epl, EConfigHookItemFactoryData *data); GtkWidget *e_calendar_weather_refresh (EPlugin *epl, EConfigHookItemFactoryData *data); GtkWidget *e_calendar_weather_units (EPlugin *epl, EConfigHookItemFactoryData *data); @@ -39,8 +45,6 @@ gboolean e_calendar_weather_check (EPlugin *epl, EConfigHookPageCheckData *dat void e_calendar_weather_migrate (EPlugin *epl, ECalEventTargetComponent *data); int e_plugin_lib_enable (EPluginLib *epl, int enable); -static GtkTreeStore *store = NULL; - #define WEATHER_BASE_URI "weather://" int @@ -48,22 +52,44 @@ e_plugin_lib_enable (EPluginLib *epl, int enable) { GList *l; gboolean found = FALSE; + const char *tmp; + + static struct { + const char *description; + const char *icon_name; + } categories[] = { + { N_("Weather: Fog"), "weather-fog" }, + { N_("Weather: Cloudy"), "weather-few-clouds" }, + { N_("Weather: Cloudy Night"), "weather-few-clouds-night" }, + { N_("Weather: Overcast"), "weather-overcast" }, + { N_("Weather: Showers"), "weather-showers" }, + { N_("Weather: Snow"), "weather-snow" }, + { N_("Weather: Sunny"), "weather-clear" }, + { N_("Weather: Clear Night"), "weather-clear-night" }, + { N_("Weather: Thunderstorms"), "weather-storm" }, + { NULL, NULL } + }; + + tmp = _(categories [0].description); /* Add the categories icons if we don't have them. */ for (l = e_categories_get_list (); l; l = g_list_next (l)) { - if (!strcmp ((const char *)l->data, _("Weather: Cloudy"))) { + if (!strcmp ((const char *)l->data, tmp)) { found = TRUE; break; } } + if (!found) { - e_categories_add (_("Weather: Cloudy"), NULL, WEATHER_DATADIR "/category_weather_cloudy_16.png", FALSE); - e_categories_add (_("Weather: Fog"), NULL, WEATHER_DATADIR "/category_weather_fog_16.png", FALSE); - e_categories_add (_("Weather: Partly Cloudy"), NULL, WEATHER_DATADIR "/category_weather_partly_cloudy_16.png", FALSE); - e_categories_add (_("Weather: Rain"), NULL, WEATHER_DATADIR "/category_weather_rain_16.png", FALSE); - e_categories_add (_("Weather: Snow"), NULL, WEATHER_DATADIR "/category_weather_snow_16.png", FALSE); - e_categories_add (_("Weather: Sunny"), NULL, WEATHER_DATADIR "/category_weather_sun_16.png", FALSE); - e_categories_add (_("Weather: Thunderstorms"), NULL, WEATHER_DATADIR "/category_weather_tstorm_16.png", FALSE); + int i; + + for (i = 0; categories[i].description; i++) { + char *filename; + + filename = e_icon_factory_get_icon_filename (categories[i].icon_name, E_ICON_SIZE_MENU); + e_categories_add (_(categories[i].description), NULL, filename, FALSE); + g_free (filename); + } } return 0; @@ -109,69 +135,6 @@ e_calendar_weather_migrate (EPlugin *epl, ECalEventTargetComponent *data) e_source_list_sync (source_list, NULL); } -static void -parse_subtree (GtkTreeIter *parent, xmlNode *node) -{ - GtkTreeIter iter; - xmlNode *child; - - if (node->type == XML_ELEMENT_NODE) { - gtk_tree_store_append (store, &iter, parent); - if (strcmp ((const char *)node->name, "location") == 0) { - xmlAttr *attr; - - child = node->children; - g_assert (child->type == XML_TEXT_NODE); - gtk_tree_store_set (store, &iter, 0, child->content, -1); - - for (attr = node->properties; attr; attr = attr->next) { - if (strcmp ((const char *)attr->name, "code") == 0) - gtk_tree_store_set (store, &iter, 1, attr->children->content, -1); - else if (strcmp ((const char *)attr->name, "url") == 0) - gtk_tree_store_set (store, &iter, 2, attr->children->content, -1); - else if (strcmp ((const char *)attr->name, "type") == 0) - gtk_tree_store_set (store, &iter, 3, attr->children->content, -1); - } - } else { - xmlAttr *attr; - - for (child = node->children; child; child = child->next) - parse_subtree (&iter, child); - - for (attr = node->properties; attr; attr = attr->next) - if (strcmp ((const char *)attr->name, "name") == 0) - gtk_tree_store_set (store, &iter, 0, attr->children->content, -1); - } - } -} - -static void -load_locations (void) -{ - xmlDoc *doc; - xmlNode *root, *child; - - LIBXML_TEST_VERSION - - doc = xmlParseFile (WEATHER_EDS_DATADIR "/Locations.xml"); - if (doc == NULL) { - g_warning ("failed to read locations file"); - return; - } - - if (store == NULL) - store = gtk_tree_store_new (4, - G_TYPE_STRING, /* name */ - G_TYPE_STRING, /* code */ - G_TYPE_STRING, /* URL */ - G_TYPE_STRING); /* type */ - - root = xmlDocGetRootElement (doc); - for (child = root->children; child; child = child->next) - parse_subtree (NULL, child); - xmlFreeDoc (doc); -} - static void selection_changed (GtkTreeSelection *selection, GtkDialog *dialog) { @@ -179,18 +142,9 @@ selection_changed (GtkTreeSelection *selection, GtkDialog *dialog) GtkTreeIter iter; if (gtk_tree_selection_get_selected (selection, &model, &iter)) { - gchar *code = NULL; - gtk_tree_model_get (model, &iter, 1, &code, -1); - if (code != NULL) { - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE); - } else { - GtkTreeView *view = gtk_tree_selection_get_tree_view (selection); - GtkTreePath *path; - path = gtk_tree_model_get_path (model, &iter); - gtk_tree_view_expand_row (view, path, FALSE); - gtk_tree_path_free (path); - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE); - } + WeatherLocation *loc = NULL; + gtk_tree_model_get (model, &iter, GWEATHER_XML_COL_POINTER, &loc, -1); + gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, loc != NULL); } else { gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE); } @@ -198,6 +152,7 @@ selection_changed (GtkTreeSelection *selection, GtkDialog *dialog) static struct { + gboolean is_old; gchar **ids; GtkTreeIter *result; } find_data; @@ -205,13 +160,13 @@ static struct static gboolean find_location_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *node, gpointer data) { - gchar *type, *code, *name; - gtk_tree_model_get (model, node, 0, &name, 1, &code, 3, &type, -1); - if (name == NULL || code == NULL || type == NULL) + WeatherLocation *wl = NULL; + + gtk_tree_model_get (model, node, GWEATHER_XML_COL_POINTER, &wl, -1); + if (!wl || !wl->name || !wl->code) return FALSE; - if ((!strcmp (type, find_data.ids[0])) && - (!strcmp (code, find_data.ids[1])) && - (!strcmp (name, find_data.ids[2]))) { + if (((!strcmp (wl->code, find_data.ids[0])) || (find_data.is_old && !strcmp (wl->code + 1, find_data.ids[0]))) && + (!strcmp (wl->name, find_data.ids[1]))) { find_data.result = gtk_tree_iter_copy (node); return TRUE; } @@ -219,12 +174,18 @@ find_location_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *node, g } static GtkTreeIter * -find_location (gchar *relative_url) +find_location (GtkTreeModel *model, gchar *relative_url) { - /* type/code/name */ + /* old URL uses type/code/name, but new uses only code/name */ + if (strncmp (relative_url, "ccf/", 4) == 0) { + relative_url = relative_url + 4; + find_data.is_old = TRUE; + } else + find_data.is_old = FALSE; + find_data.ids = g_strsplit (relative_url, "/", -1); find_data.result = NULL; - gtk_tree_model_foreach (GTK_TREE_MODEL (store), (GtkTreeModelForeachFunc) find_location_func, NULL); + gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) find_location_func, NULL); g_strfreev (find_data.ids); return find_data.result; @@ -239,9 +200,9 @@ treeview_clicked (GtkTreeView *treeview, GdkEventButton *event, GtkDialog *dialo GtkTreeIter iter; if (gtk_tree_selection_get_selected (selection, &model, &iter)) { - gchar *code = NULL; - gtk_tree_model_get (model, &iter, 1, &code, -1); - if (code != NULL) { + WeatherLocation *wl = NULL; + gtk_tree_model_get (model, &iter, GWEATHER_XML_COL_POINTER, &wl, -1); + if (wl != NULL && wl->code != NULL && wl->name != NULL) { gtk_dialog_response (dialog, GTK_RESPONSE_OK); return TRUE; } @@ -250,6 +211,8 @@ treeview_clicked (GtkTreeView *treeview, GdkEventButton *event, GtkDialog *dialo return FALSE; } +static GtkTreeModel *store = NULL; + static GtkDialog * create_source_selector (ESource *source) { @@ -274,7 +237,7 @@ create_source_selector (ESource *source) scrolledwindow = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_widget_show (scrolledwindow); - treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); + treeview = gtk_tree_view_new_with_model (store); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE); gtk_widget_show (treeview); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolledwindow), treeview); @@ -286,7 +249,7 @@ create_source_selector (ESource *source) uri_text = e_source_get_uri (source); uri = e_uri_new (uri_text); if (uri->path && strlen (uri->path)) { - GtkTreeIter *iter = find_location (uri_text + 10); + GtkTreeIter *iter = find_location (store, uri_text + 10); GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), iter); gtk_tree_view_expand_to_path (GTK_TREE_VIEW (treeview), path); gtk_tree_selection_select_path (selection, path); @@ -317,11 +280,11 @@ build_location_path (GtkTreeIter *iter) GtkTreeIter parent; gchar *path, *temp1, *temp2; - gtk_tree_model_get (GTK_TREE_MODEL (store), iter, 0, &temp1, -1); + gtk_tree_model_get (GTK_TREE_MODEL (store), iter, GWEATHER_XML_COL_LOC, &temp1, -1); path = g_strdup (temp1); while (gtk_tree_model_iter_parent (GTK_TREE_MODEL (store), &parent, iter)) { - gtk_tree_model_get (GTK_TREE_MODEL (store), &parent, 0, &temp1, -1); + gtk_tree_model_get (GTK_TREE_MODEL (store), &parent, GWEATHER_XML_COL_LOC, &temp1, -1); temp2 = g_strdup_printf ("%s : %s", temp1, path); g_free (path); path = temp2; @@ -347,17 +310,17 @@ location_clicked (GtkButton *button, ESource *source) GtkTreeModel *model; GtkTreeIter iter; GtkWidget *label; - gchar *type, *code, *name; + WeatherLocation *wl = NULL; gchar *path, *uri; gtk_tree_selection_get_selected (selection, &model, &iter); - gtk_tree_model_get (model, &iter, 0, &name, 1, &code, 3, &type, -1); + gtk_tree_model_get (model, &iter, GWEATHER_XML_COL_POINTER, &wl, -1); path = build_location_path (&iter); label = gtk_bin_get_child (GTK_BIN (button)); gtk_label_set_text (GTK_LABEL (label), path); - uri = g_strdup_printf ("%s/%s/%s", type, code, name); + uri = g_strdup_printf ("%s/%s", wl->code, wl->name); /* FIXME - url_encode (&uri); */ e_source_set_relative_uri (source, uri); g_free (uri); @@ -387,7 +350,7 @@ e_calendar_weather_location (EPlugin *epl, EConfigHookItemFactoryData *data) static GtkWidget *hidden; if (store == NULL) - load_locations (); + store = gweather_xml_load_locations (); if (!hidden) hidden = gtk_label_new (""); @@ -416,7 +379,7 @@ e_calendar_weather_location (EPlugin *epl, EConfigHookItemFactoryData *data) gtk_widget_show (button); if (uri->path && strlen (uri->path)) { - GtkTreeIter *iter = find_location (uri_text + 10); + GtkTreeIter *iter = find_location (store, uri_text + 10); gchar *location = build_location_path (iter); text = gtk_label_new (location); g_free (location); -- cgit v1.2.3 From 415b951b22cd467afadf1866c53ef5c1caa5eacb Mon Sep 17 00:00:00 2001 From: Suman Manjunath Date: Wed, 10 Dec 2008 03:38:51 +0000 Subject: Make the libgweather dependency optional, build the weather calendar setup plugin by default and provide an option to disable it. svn path=/trunk/; revision=36860 --- plugins/calendar-weather/ChangeLog | 5 +++++ plugins/calendar-weather/Makefile.am | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'plugins/calendar-weather') diff --git a/plugins/calendar-weather/ChangeLog b/plugins/calendar-weather/ChangeLog index 2d70b465a0..a34f5df01b 100644 --- a/plugins/calendar-weather/ChangeLog +++ b/plugins/calendar-weather/ChangeLog @@ -1,3 +1,8 @@ +2008-12-10 Suman Manjunath + + * Makefile.am: Don't try to specify LIBGWEATHER_(CFLAGS|LIBS), they + will be provided by configure.in. + 2008-12-03 Milan Crha ** Part of fix for bug #352287 diff --git a/plugins/calendar-weather/Makefile.am b/plugins/calendar-weather/Makefile.am index b5a811118c..2e2be150e3 100644 --- a/plugins/calendar-weather/Makefile.am +++ b/plugins/calendar-weather/Makefile.am @@ -1,7 +1,5 @@ eds_datadir = `pkg-config --variable=privdatadir evolution-data-server-1.2` weatherdatadir = $(datadir)/evolution/$(BASE_VERSION)/weather -LIBGWEATHER_CFLAGS = `pkg-config --cflags gweather` -LIBGWEATHER_LIBS = `pkg-config --libs gweather` INCLUDES = \ -I$(top_srcdir) \ -- cgit v1.2.3 From 8a072ffc7c0ddcde472877a51ace0bb14f86fb0a Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 24 Apr 2009 11:45:21 +0200 Subject: GN-bug #572348 - Removed deprecated Gtk+ symbols Some still left, because those gone in kill-bonobo branch. --- plugins/calendar-weather/ChangeLog | 6 ++ plugins/calendar-weather/calendar-weather.c | 102 ++++++++++++---------------- 2 files changed, 49 insertions(+), 59 deletions(-) (limited to 'plugins/calendar-weather') diff --git a/plugins/calendar-weather/ChangeLog b/plugins/calendar-weather/ChangeLog index a34f5df01b..8aa7f8990c 100644 --- a/plugins/calendar-weather/ChangeLog +++ b/plugins/calendar-weather/ChangeLog @@ -1,3 +1,9 @@ +2009-04-24 Milan Crha + + ** Fix for bug #572348 + + * calendar-weather.c: Remove deprecated Gtk+ symbols. + 2008-12-10 Suman Manjunath * Makefile.am: Don't try to specify LIBGWEATHER_(CFLAGS|LIBS), they diff --git a/plugins/calendar-weather/calendar-weather.c b/plugins/calendar-weather/calendar-weather.c index a6dce31326..f61d90c4d0 100644 --- a/plugins/calendar-weather/calendar-weather.c +++ b/plugins/calendar-weather/calendar-weather.c @@ -397,7 +397,7 @@ e_calendar_weather_location (EPlugin *epl, EConfigHookItemFactoryData *data) } static void -set_refresh_time (ESource *source, GtkWidget *spin, GtkWidget *option) +set_refresh_time (ESource *source, GtkWidget *spin, GtkWidget *combobox) { int time; int item_num = 0; @@ -417,15 +417,15 @@ set_refresh_time (ESource *source, GtkWidget *spin, GtkWidget *option) item_num = 1; time /= 60; } - gtk_option_menu_set_history (GTK_OPTION_MENU (option), item_num); + gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), item_num); gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time); } static char * -get_refresh_minutes (GtkWidget *spin, GtkWidget *option) +get_refresh_minutes (GtkWidget *spin, GtkWidget *combobox) { int setting = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin)); - switch (gtk_option_menu_get_history (GTK_OPTION_MENU (option))) { + switch (gtk_combo_box_get_active (GTK_COMBO_BOX (combobox))) { case 0: /* minutes */ break; @@ -452,24 +452,24 @@ static void spin_changed (GtkSpinButton *spin, ECalConfigTargetSource *t) { char *refresh_str; - GtkWidget *option; + GtkWidget *combobox; - option = g_object_get_data (G_OBJECT (spin), "option"); + combobox = g_object_get_data (G_OBJECT (spin), "combobox"); - refresh_str = get_refresh_minutes ((GtkWidget *) spin, option); + refresh_str = get_refresh_minutes ((GtkWidget *) spin, combobox); e_source_set_property (t->source, "refresh", refresh_str); g_free (refresh_str); } static void -option_changed (GtkOptionMenu *option, ECalConfigTargetSource *t) +combobox_changed (GtkComboBox *combobox, ECalConfigTargetSource *t) { char *refresh_str; GtkWidget *spin; - spin = g_object_get_data (G_OBJECT (option), "spin"); + spin = g_object_get_data (G_OBJECT (combobox), "spin"); - refresh_str = get_refresh_minutes (spin, (GtkWidget *) option); + refresh_str = get_refresh_minutes (spin, (GtkWidget *) combobox); e_source_set_property (t->source, "refresh", refresh_str); g_free (refresh_str); } @@ -478,9 +478,8 @@ GtkWidget * e_calendar_weather_refresh (EPlugin *epl, EConfigHookItemFactoryData *data) { static GtkWidget *label; - GtkWidget *option, *spin, *menu, *hbox, *parent; - GtkWidget *times[4]; - int row, i; + GtkWidget *spin, *combobox, *hbox, *parent; + int row; ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target; ESource *source = t->source; EUri *uri; @@ -519,25 +518,18 @@ e_calendar_weather_refresh (EPlugin *epl, EConfigHookItemFactoryData *data) gtk_widget_show (spin); gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, TRUE, 0); - option = gtk_option_menu_new (); - gtk_widget_show (option); - times[0] = gtk_menu_item_new_with_label (_("minutes")); - times[1] = gtk_menu_item_new_with_label (_("hours")); - times[2] = gtk_menu_item_new_with_label (_("days")); - times[3] = gtk_menu_item_new_with_label (_("weeks")); - menu = gtk_menu_new (); - gtk_widget_show (menu); - for (i = 0; i < 4; i++) { - gtk_widget_show (times[i]); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), times[i]); - } - gtk_option_menu_set_menu (GTK_OPTION_MENU (option), menu); - set_refresh_time (source, spin, option); - gtk_box_pack_start (GTK_BOX (hbox), option, FALSE, TRUE, 0); - - g_object_set_data (G_OBJECT (option), "spin", spin); - g_signal_connect (G_OBJECT (option), "changed", G_CALLBACK (option_changed), t); - g_object_set_data (G_OBJECT (spin), "option", option); + combobox = gtk_combo_box_new_text (); + gtk_widget_show (combobox); + gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("minutes")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("hours")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("days")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("weeks")); + set_refresh_time (source, spin, combobox); + gtk_box_pack_start (GTK_BOX (hbox), combobox, FALSE, TRUE, 0); + + g_object_set_data (G_OBJECT (combobox), "spin", spin); + g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (combobox_changed), t); + g_object_set_data (G_OBJECT (spin), "combobox", combobox); g_signal_connect (G_OBJECT (spin), "value-changed", G_CALLBACK (spin_changed), t); gtk_table_attach (GTK_TABLE (parent), hbox, 1, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 0, 0); @@ -546,34 +538,34 @@ e_calendar_weather_refresh (EPlugin *epl, EConfigHookItemFactoryData *data) } static void -set_units (ESource *source, GtkWidget *option) +set_units (ESource *source, GtkWidget *combobox) { const char *format = e_source_get_property (source, "units"); if (format == NULL) { format = e_source_get_property (source, "temperature"); if (format == NULL) { e_source_set_property (source, "units", "metric"); - gtk_option_menu_set_history (GTK_OPTION_MENU (option), 0); + gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0); } else if (strcmp ((const char *)format, "fahrenheit") == 0) { /* old format, convert */ e_source_set_property (source, "units", "imperial"); - gtk_option_menu_set_history (GTK_OPTION_MENU (option), 1); + gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 1); } else { e_source_set_property (source, "units", "metric"); - gtk_option_menu_set_history (GTK_OPTION_MENU (option), 0); + gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0); } } else { if (strcmp ((const char *)format, "metric") == 0) - gtk_option_menu_set_history (GTK_OPTION_MENU (option), 0); + gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0); else - gtk_option_menu_set_history (GTK_OPTION_MENU (option), 1); + gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 1); } } static void -units_changed (GtkOptionMenu *option, ECalConfigTargetSource *t) +units_changed (GtkComboBox *combobox, ECalConfigTargetSource *t) { - int choice = gtk_option_menu_get_history (GTK_OPTION_MENU (option)); + int choice = gtk_combo_box_get_active (GTK_COMBO_BOX (combobox)); if (choice == 0) e_source_set_property (t->source, "units", "metric"); else @@ -584,9 +576,8 @@ GtkWidget * e_calendar_weather_units (EPlugin *epl, EConfigHookItemFactoryData *data) { static GtkWidget *label; - GtkWidget *option, *menu, *parent; - GtkWidget *formats[2]; - int row, i; + GtkWidget *combobox, *parent; + int row; ECalConfigTargetSource *t = (ECalConfigTargetSource *) data->target; ESource *source = t->source; EUri *uri; @@ -617,23 +608,16 @@ e_calendar_weather_units (EPlugin *epl, EConfigHookItemFactoryData *data) gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row+1, GTK_FILL, 0, 0, 0); - option = gtk_option_menu_new (); - gtk_widget_show (option); - formats[0] = gtk_menu_item_new_with_label (_("Metric (Celsius, cm, etc)")); - formats[1] = gtk_menu_item_new_with_label (_("Imperial (Fahrenheit, inches, etc)")); - menu = gtk_menu_new (); - gtk_widget_show (menu); - for (i = 0; i < 2; i++) { - gtk_widget_show (formats[i]); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), formats[i]); - } - gtk_option_menu_set_menu (GTK_OPTION_MENU (option), menu); - set_units (source, option); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), option); - g_signal_connect (G_OBJECT (option), "changed", G_CALLBACK (units_changed), t); - gtk_table_attach (GTK_TABLE (parent), option, 1, 2, row, row+1, GTK_FILL, 0, 0, 0); + combobox = gtk_combo_box_new_text (); + gtk_widget_show (combobox); + gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Metric (Celsius, cm, etc)")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("Imperial (Fahrenheit, inches, etc)")); + set_units (source, combobox); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), combobox); + g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (units_changed), t); + gtk_table_attach (GTK_TABLE (parent), combobox, 1, 2, row, row+1, GTK_FILL, 0, 0, 0); - return option; + return combobox; } gboolean -- cgit v1.2.3