weather: Display service attributions in AboutDialog.
Note that this injects strings we can't translate.
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
a188c68653
commit
2cbdba9a95
+64
-22
@@ -456,15 +456,54 @@ gcal_application_launch_search (GSimpleAction *search,
|
|||||||
gcal_window_set_search_mode (GCAL_WINDOW (self->window), TRUE);
|
gcal_window_set_search_mode (GCAL_WINDOW (self->window), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_about_response (GtkAboutDialog *about,
|
||||||
|
int response_id,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
|
||||||
|
g_return_if_fail (user_data == NULL);
|
||||||
|
|
||||||
|
if (response_id == GTK_RESPONSE_CANCEL)
|
||||||
|
gtk_widget_destroy (GTK_WIDGET (about));
|
||||||
|
}
|
||||||
|
|
||||||
|
static gchar*
|
||||||
|
build_about_copyright (GcalApplication *self)
|
||||||
|
{
|
||||||
|
GString *builder ; /* owned */
|
||||||
|
const gchar *attribution; /* unowned */
|
||||||
|
g_autoptr (GDateTime) dt = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GCAL_IS_APPLICATION (self), NULL);
|
||||||
|
|
||||||
|
builder = g_string_new ("<span size=\"small\">");
|
||||||
|
dt = g_date_time_new_now_local ();
|
||||||
|
|
||||||
|
/* Build string: */
|
||||||
|
g_string_append_printf (builder,
|
||||||
|
_("Copyright \xC2\xA9 2012\xE2\x80\x93%d " "The Calendar authors"),
|
||||||
|
g_date_time_get_year (dt));
|
||||||
|
|
||||||
|
attribution = gcal_weather_service_get_attribution (self->weather_service);
|
||||||
|
if (attribution != NULL)
|
||||||
|
{
|
||||||
|
g_string_append_c (builder, '\n');
|
||||||
|
g_string_append (builder, attribution);
|
||||||
|
}
|
||||||
|
g_string_append (builder, "</span>");
|
||||||
|
|
||||||
|
return g_string_free (builder, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gcal_application_show_about (GSimpleAction *simple,
|
gcal_application_show_about (GSimpleAction *simple,
|
||||||
GVariant *parameter,
|
GVariant *parameter,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GcalApplication *self;
|
GcalApplication *self; /* unowned */
|
||||||
char *copyright;
|
GtkWidget *dialog; /* owned */
|
||||||
GDateTime *dt;
|
|
||||||
int created_year = 2012;
|
|
||||||
const gchar *authors[] = {
|
const gchar *authors[] = {
|
||||||
"Erick Pérez Castellanos <erickpc@gnome.org>",
|
"Erick Pérez Castellanos <erickpc@gnome.org>",
|
||||||
"Georges Basile Stavracas Neto <georges.stavracas@gmail.com>",
|
"Georges Basile Stavracas Neto <georges.stavracas@gmail.com>",
|
||||||
@@ -479,26 +518,15 @@ gcal_application_show_about (GSimpleAction *simple,
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
self = GCAL_APPLICATION (user_data);
|
self = GCAL_APPLICATION (user_data);
|
||||||
dt = g_date_time_new_now_local ();
|
|
||||||
|
|
||||||
if (g_date_time_get_year (dt) == created_year)
|
dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
|
||||||
{
|
"transient-for", GTK_WINDOW (self->window),
|
||||||
copyright = g_strdup_printf (_("Copyright \xC2\xA9 %d "
|
"modal", TRUE,
|
||||||
"The Calendar authors"),
|
"destroy-with-parent", TRUE,
|
||||||
created_year);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
copyright = g_strdup_printf (_("Copyright \xC2\xA9 %d\xE2\x80\x93%d "
|
|
||||||
"The Calendar authors"),
|
|
||||||
created_year, g_date_time_get_year (dt));
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_show_about_dialog (GTK_WINDOW (self->window),
|
|
||||||
"program-name", _("Calendar"),
|
"program-name", _("Calendar"),
|
||||||
"version", VERSION,
|
"version", VERSION,
|
||||||
"copyright", copyright,
|
|
||||||
"license-type", GTK_LICENSE_GPL_3_0,
|
"license-type", GTK_LICENSE_GPL_3_0,
|
||||||
"authors", authors,
|
"authors", authors,
|
||||||
"artists", artists,
|
"artists", artists,
|
||||||
@@ -506,8 +534,22 @@ gcal_application_show_about (GSimpleAction *simple,
|
|||||||
"translator-credits", _("translator-credits"),
|
"translator-credits", _("translator-credits"),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_clear_pointer (©right, g_free);
|
/* Poke AboutDialog internals to display links in
|
||||||
g_clear_pointer (&dt, g_date_time_unref);
|
* attributions. This workaround is also used by
|
||||||
|
* gnome-weather.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
g_autofree gchar *copyright;
|
||||||
|
GObject *cpyright_lbl; /* unowned */
|
||||||
|
|
||||||
|
copyright = build_about_copyright (self);
|
||||||
|
cpyright_lbl = gtk_widget_get_template_child (GTK_WIDGET (dialog), GTK_TYPE_ABOUT_DIALOG, "copyright_label");
|
||||||
|
gtk_label_set_markup (GTK_LABEL (cpyright_lbl), copyright);
|
||||||
|
gtk_widget_show (GTK_WIDGET (cpyright_lbl));
|
||||||
|
}
|
||||||
|
|
||||||
|
g_signal_connect (dialog, "response", G_CALLBACK (on_about_response), NULL);
|
||||||
|
gtk_widget_show (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -847,10 +847,6 @@ gcal_weather_service_update_location (GcalWeatherService *self,
|
|||||||
(location == NULL)? "<null>" : gweather_location_get_name (location));
|
(location == NULL)? "<null>" : gweather_location_get_name (location));
|
||||||
|
|
||||||
self->gweather_info = gweather_info_new (location, GWEATHER_FORECAST_ZONE | GWEATHER_FORECAST_LIST);
|
self->gweather_info = gweather_info_new (location, GWEATHER_FORECAST_ZONE | GWEATHER_FORECAST_LIST);
|
||||||
/* TODO: display weather attributions somewhere:
|
|
||||||
* gweather_info_get_attribution (self->gweather_info);
|
|
||||||
* Do no roll-out a release without resolving this one before!
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* NOTE: We do not get detailed infos for GWEATHER_PROVIDER_ALL.
|
/* NOTE: We do not get detailed infos for GWEATHER_PROVIDER_ALL.
|
||||||
* This combination works fine, though. We should open a bug / investigate
|
* This combination works fine, though. We should open a bug / investigate
|
||||||
@@ -1440,3 +1436,23 @@ gcal_weather_service_get_weather_infos (GcalWeatherService *self)
|
|||||||
|
|
||||||
return self->weather_infos;
|
return self->weather_infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gcal_weather_service_get_attribution:
|
||||||
|
*
|
||||||
|
* Returns weather service attribution.
|
||||||
|
*
|
||||||
|
* Returns: (nullable) (transfer none): Text to display.
|
||||||
|
*/
|
||||||
|
const gchar*
|
||||||
|
gcal_weather_service_get_attribution (GcalWeatherService *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GCAL_IS_WEATHER_SERVICE (self), NULL);
|
||||||
|
|
||||||
|
if (self->gweather_info != NULL)
|
||||||
|
return gweather_info_get_attribution (self->gweather_info);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ guint gcal_weather_service_get_check_interval (GcalWeatherService
|
|||||||
|
|
||||||
GSList* gcal_weather_service_get_weather_infos (GcalWeatherService *self);
|
GSList* gcal_weather_service_get_weather_infos (GcalWeatherService *self);
|
||||||
|
|
||||||
|
const gchar* gcal_weather_service_get_attribution (GcalWeatherService *self);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user