Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 269291 Details for
Bug 400131
[PATCH] intlclock: fill in more information automatically
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Fill in more info automatically from user input
intlclock-fill-in.patch (text/plain), 5.49 KB, created by
Bill Nottingham
on 2007-11-26 21:12:33 UTC
(
hide
)
Description:
Fill in more info automatically from user input
Filename:
MIME Type:
Creator:
Bill Nottingham
Created:
2007-11-26 21:12:33 UTC
Size:
5.49 KB
patch
obsolete
>diff -ru intlclock-1.0/src/intlclock-ui.c intlclock-1.0/src/intlclock-ui.c >--- intlclock-1.0/src/intlclock-ui.c 2007-10-29 12:07:57.000000000 -0400 >+++ intlclock-1.0/src/intlclock-ui.c 2007-11-26 16:04:47.000000000 -0500 >@@ -2911,48 +2911,6 @@ > gtk_window_present (GTK_WINDOW (window)); > } > >-static gdouble >-distance (gdouble lat1, gdouble lon1, >- gdouble lat2, gdouble lon2) >-{ >- gdouble radius = 6372.795; >- >- return acos (cos (lat1) * cos (lat2) * cos (lon1 - lon2) + sin (lat1) * sin (lat2)) * radius; >-} >- >-static gchar * >-find_timezone (IntlClockUI *this, >- const char *name, >- gfloat lat, >- gfloat lon) >-{ >- IntlClockUIPrivate *priv = PRIVATE (INTLCLOCK_UI (this)); >- IntlClockZoneTable *zonetab = intlclock_get_zonetable (priv->clock); >- GList *zones, *l; >- double dist, d; >- gfloat zlat, zlon; >- IntlClockZoneInfo *best; >- >- dist = 1e6; >- best = NULL; >- zones = intlclock_zonetable_get_zones (zonetab); >- for (l = zones; l; l = l->next) { >- IntlClockZoneInfo *info = l->data; >- intlclock_zoneinfo_get_coords (info, &zlat, &zlon); >- >- d = distance (lat, lon, zlat*M_PI/180.0, zlon*M_PI/180.0); >- >- if (d < dist) { >- best = info; >- dist = d; >- } >- } >- >- intlclock_zoneinfo_get_coords (best, &zlat, &zlon); >- >- return g_strdup (intlclock_zoneinfo_get_name (best)); >-} >- > static void > update_timezone (IntlClockUI *this, > const char *name, >@@ -2960,6 +2918,7 @@ > gfloat lon) > { > IntlClockUIPrivate *priv = PRIVATE (INTLCLOCK_UI (this)); >+ IntlClockZoneTable *zones = intlclock_get_zonetable (priv->clock); > GtkWidget *zone_combo = glade_xml_get_widget (priv->glade_xml, "edit-location-timezone-combo"); > GtkTreeModel *model; > gchar *timezone; >@@ -2969,7 +2928,7 @@ > prefs.temperature_unit = priv->temperature_unit; > prefs.speed_unit = priv->speed_unit; > >- timezone = find_timezone (this, name, lat, lon); >+ timezone = intlclock_zonetable_find_timezone (zones, lat, lon); > loc = intlclock_location_new (name, timezone, lat*180.0/M_PI, lon*180.0/M_PI, NULL, &prefs); > > g_signal_handler_block (zone_combo, priv->zone_combo_changed); >@@ -3100,11 +3059,6 @@ > > IntlClockZoneInfo *info = intlclock_zonetable_get_l10n_zone (zones, timezone_l10n); > >- if (!info) { >- intlclock_edit_hide (edit_window, this); >- return; >- } >- > const gchar *name = gtk_entry_get_text (GTK_ENTRY (name_entry)); > gfloat lat = 0; > gfloat lon = 0; >@@ -3119,6 +3073,16 @@ > if (gtk_combo_box_get_active (GTK_COMBO_BOX (lon_combo)) != 0) { > lon = -lon; > } >+ >+ if (!info && lat != 0 && lon != 0) { >+ gchar *tz = intlclock_zonetable_find_timezone(zones, lat * M_PI/180.0, lon * M_PI/180.0); >+ if (tz) >+ info = intlclock_zonetable_get_zone (zones, tz); >+ if (!info) { >+ intlclock_edit_hide (edit_window, this); >+ return; >+ } >+ } > > if (loc) { > intlclock_location_set_timezone (loc, intlclock_zoneinfo_get_name (info)); >@@ -3131,6 +3095,14 @@ > > prefs.temperature_unit = priv->temperature_unit; > prefs.speed_unit = priv->speed_unit; >+ >+ if (weather_code == NULL) { >+ GtkTreeModel *model; >+ >+ fill_location_tree(this); >+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->location_tree)); >+ weather_code = find_weather_code (model, name, lat * M_PI/180.0, lon * M_PI/180.0); >+ } > > loc = intlclock_location_new (name, intlclock_zoneinfo_get_name (info), lat, lon, weather_code, &prefs); > >diff -ru intlclock-1.0/src/intlclock-zonetable.c intlclock-1.0/src/intlclock-zonetable.c >--- intlclock-1.0/src/intlclock-zonetable.c 2007-10-28 23:06:21.000000000 -0400 >+++ intlclock-1.0/src/intlclock-zonetable.c 2007-11-26 15:51:11.000000000 -0500 >@@ -5,6 +5,7 @@ > #endif > > #include <glib.h> >+#include <math.h> > #include <stdio.h> > #include <string.h> > >@@ -402,6 +403,46 @@ > g_io_channel_unref (channel); > } > >+ >+static gdouble >+distance (gdouble lat1, gdouble lon1, >+ gdouble lat2, gdouble lon2) >+{ >+ gdouble radius = 6372.795; >+ >+ return acos (cos (lat1) * cos (lat2) * cos (lon1 - lon2) + sin (lat1) * sin (lat2)) * radius; >+} >+ >+gchar * >+intlclock_zonetable_find_timezone (IntlClockZoneTable *this, >+ gfloat lat, >+ gfloat lon) >+{ >+ GList *zones, *l; >+ double dist, d; >+ gfloat zlat, zlon; >+ IntlClockZoneInfo *best; >+ >+ dist = 1e6; >+ best = NULL; >+ zones = intlclock_zonetable_get_zones (this); >+ for (l = zones; l; l = l->next) { >+ IntlClockZoneInfo *info = l->data; >+ intlclock_zoneinfo_get_coords (info, &zlat, &zlon); >+ >+ d = distance (lat, lon, zlat*M_PI/180.0, zlon*M_PI/180.0); >+ >+ if (d < dist) { >+ best = info; >+ dist = d; >+ } >+ } >+ >+ intlclock_zoneinfo_get_coords (best, &zlat, &zlon); >+ >+ return g_strdup (intlclock_zoneinfo_get_name (best)); >+} >+ > IntlClockZoneInfo * > intlclock_zonetable_get_zone (IntlClockZoneTable *this, gchar *name) > { >diff -ru intlclock-1.0/src/intlclock-zonetable.h intlclock-1.0/src/intlclock-zonetable.h >--- intlclock-1.0/src/intlclock-zonetable.h 2007-10-06 10:39:57.000000000 -0400 >+++ intlclock-1.0/src/intlclock-zonetable.h 2007-11-26 15:49:17.000000000 -0500 >@@ -32,6 +32,7 @@ > IntlClockZoneInfo *intlclock_zonetable_get_zone (IntlClockZoneTable *this, gchar *name); > IntlClockZoneInfo *intlclock_zonetable_get_l10n_zone (IntlClockZoneTable *this, gchar *l10n_name); > GList *intlclock_zonetable_get_zones (IntlClockZoneTable *this); >+gchar *intlclock_zonetable_find_timezone (IntlClockZoneTable *this, gfloat lat, gfloat lon); > > IntlClockCountry *intlclock_zonetable_get_country (IntlClockZoneTable *this, gchar *code); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 400131
: 269291