Esempio n. 1
0
/**
 * gweather_timezone_get_by_tzid:
 * @tzid: A timezone identifier, like "America/New_York" or "Europe/London"
 *
 * Get the #GWeatherTimezone for @tzid.
 *
 * Returns: (transfer none): A #GWeatherTimezone. This object
 * belongs to GWeather, do not unref it.
 *
 * Since: 3.12
 */
GWeatherTimezone *
gweather_timezone_get_by_tzid (const char *tzid)
{
    GWeatherLocation *world;

    world = gweather_location_get_world ();

    return g_hash_table_lookup (world->timezone_cache, tzid);
}
Esempio n. 2
0
static GWeatherLocation*
get_default_location (GWeatherApplet *gw_applet)
{
    const gchar *station_code;
    GVariant *default_loc;

    default_loc = g_settings_get_value (gw_applet->lib_settings, "default-location");
    g_variant_get (default_loc, "(&s&sm(dd))", NULL, &station_code, NULL, NULL, NULL);

	return gweather_location_find_by_station_code (gweather_location_get_world (), station_code);
}
static GtkTreeModel *
gweather_timezone_model_new (GWeatherLocation *top)
{
    GtkTreeStore *store;
    GtkTreeModel *model;
    GtkTreeIter iter;
    char *unknown;
    GWeatherTimezone *utc;

    store = gtk_tree_store_new (2, G_TYPE_STRING, GWEATHER_TYPE_TIMEZONE);
    model = GTK_TREE_MODEL (store);

    unknown = g_markup_printf_escaped ("<i>%s</i>", C_("timezone", "Unknown"));

    gtk_tree_store_append (store, &iter, NULL);
    gtk_tree_store_set (store, &iter,
			GWEATHER_TIMEZONE_MENU_NAME, unknown,
			GWEATHER_TIMEZONE_MENU_ZONE, NULL,
			-1);

    utc = gweather_timezone_get_utc ();
    if (utc) {
        insert_location (store, utc, NULL, NULL);
        gweather_timezone_unref (utc);
    }

    gtk_tree_store_append (store, &iter, NULL);

    g_free (unknown);

    if (!top)
	top = gweather_location_get_world ();

    insert_locations (store, top);

    return model;
}