app: handle calendars colours better
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=745487
This commit is contained in:
@@ -132,7 +132,8 @@ process_sources (GcalApplication *application)
|
||||
|
||||
gint arr_length, i = 0;
|
||||
GQuark color_id;
|
||||
const gchar* color_str;
|
||||
GdkRGBA color;
|
||||
gchar* color_str;
|
||||
|
||||
gchar **new_css_snippets;
|
||||
gchar *new_css_data;
|
||||
@@ -148,10 +149,13 @@ process_sources (GcalApplication *application)
|
||||
{
|
||||
source = l->data;
|
||||
|
||||
color_str = get_color_name_from_source (source);
|
||||
get_color_name_from_source (source, &color);
|
||||
color_str = gdk_rgba_to_string (&color);
|
||||
color_id = g_quark_from_string (color_str);
|
||||
|
||||
new_css_snippets[i] = g_strdup_printf (CSS_TEMPLATE, color_id, color_str);
|
||||
|
||||
g_free (color_str);
|
||||
}
|
||||
|
||||
g_list_free (sources);
|
||||
|
||||
@@ -135,7 +135,7 @@ fill_sources_menu (GcalEditDialog *dialog)
|
||||
source = E_SOURCE (aux->data);
|
||||
|
||||
/* retrieve color */
|
||||
gdk_rgba_parse (&color, get_color_name_from_source (source));
|
||||
get_color_name_from_source (source, &color);
|
||||
pix = gcal_get_pixbuf_from_color (&color, 16);;
|
||||
|
||||
/* menu item */
|
||||
@@ -195,7 +195,7 @@ on_calendar_selected (GtkWidget *menu_item,
|
||||
GdkPixbuf *pix;
|
||||
|
||||
/* retrieve color */
|
||||
gdk_rgba_parse (&color, get_color_name_from_source (source));
|
||||
get_color_name_from_source (source, &color);
|
||||
|
||||
pix = gcal_get_pixbuf_from_color (&color, 16);
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->source_image), pix);
|
||||
@@ -821,7 +821,7 @@ gcal_edit_dialog_set_event_data (GcalEditDialog *dialog,
|
||||
gtk_entry_set_text (GTK_ENTRY (priv->summary_entry), e_summary.value);
|
||||
|
||||
/* dialog titlebar's title & subtitle */
|
||||
gdk_rgba_parse (&color, get_color_name_from_source (data->source));
|
||||
get_color_name_from_source (data->source, &color);
|
||||
|
||||
pix = gcal_get_pixbuf_from_color (&color, 16);
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->source_image), pix);
|
||||
|
||||
@@ -680,7 +680,7 @@ gcal_event_widget_new_from_data (GcalEventData *data)
|
||||
|
||||
GQuark color_id;
|
||||
GdkRGBA color;
|
||||
gchar *custom_css_class;
|
||||
gchar *color_str, *custom_css_class;
|
||||
|
||||
ECalComponentDateTime dt;
|
||||
icaltimetype *date;
|
||||
@@ -715,13 +715,15 @@ gcal_event_widget_new_from_data (GcalEventData *data)
|
||||
gcal_event_widget_set_summary (event, (gchar*) e_summary.value);
|
||||
|
||||
/* color */
|
||||
gdk_rgba_parse (&color, get_color_name_from_source (priv->source));
|
||||
get_color_name_from_source (priv->source, &color);
|
||||
gcal_event_widget_set_color (event, &color);
|
||||
|
||||
color_id = g_quark_from_string (get_color_name_from_source (priv->source));
|
||||
color_str = gdk_rgba_to_string (&color);
|
||||
color_id = g_quark_from_string (color_str);
|
||||
custom_css_class = g_strdup_printf ("color-%d", color_id);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (widget), custom_css_class);
|
||||
g_free (custom_css_class);
|
||||
g_free (color_str);
|
||||
|
||||
/* start date */
|
||||
e_cal_component_get_dtstart (priv->component, &dt);
|
||||
|
||||
@@ -880,7 +880,6 @@ gcal_manager_get_sources (GcalManager *manager)
|
||||
if (!unit->enabled)
|
||||
continue;
|
||||
aux = g_list_append (aux, key);
|
||||
|
||||
}
|
||||
return aux;
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ make_row_for_event_data (GcalSearchView *view,
|
||||
priv = gcal_search_view_get_instance_private (view);
|
||||
|
||||
/* get event color */
|
||||
gdk_rgba_parse (&color, get_color_name_from_source (data->source));
|
||||
get_color_name_from_source (data->source, &color);
|
||||
pixbuf = gcal_get_pixbuf_from_color (&color, 16);
|
||||
|
||||
/* make an image of the color */
|
||||
|
||||
@@ -237,7 +237,7 @@ get_result_metas_cb (GcalShellSearchProvider *search_provider,
|
||||
e_cal_component_get_summary (data->event_component, &summary);
|
||||
g_variant_builder_add (&builder, "{sv}", "name", g_variant_new_string (summary.value));
|
||||
|
||||
gdk_rgba_parse (&color, get_color_name_from_source (data->source));
|
||||
get_color_name_from_source (data->source, &color);
|
||||
gicon = get_circle_pixbuf_from_color (&color, 128);
|
||||
icon_variant = g_icon_serialize (G_ICON (gicon));
|
||||
g_variant_builder_add (&builder, "{sv}", "icon", icon_variant);
|
||||
|
||||
+6
-3
@@ -161,11 +161,14 @@ get_circle_pixbuf_from_color (GdkRGBA *color,
|
||||
return pix;
|
||||
}
|
||||
|
||||
const gchar*
|
||||
get_color_name_from_source (ESource *source)
|
||||
void
|
||||
get_color_name_from_source (ESource *source, GdkRGBA *out_color)
|
||||
{
|
||||
ESourceSelectable *extension = E_SOURCE_SELECTABLE (e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR));
|
||||
return e_source_selectable_get_color (extension);
|
||||
|
||||
/* FIXME: We should handle calendars colours better */
|
||||
if (!gdk_rgba_parse (out_color, e_source_selectable_get_color (extension)))
|
||||
gdk_rgba_parse (out_color, "#becedd"); /* calendar default colour */
|
||||
}
|
||||
|
||||
gint
|
||||
|
||||
+2
-1
@@ -63,7 +63,8 @@ GdkPixbuf* gcal_get_pixbuf_from_color (GdkRGBA
|
||||
GdkPixbuf* get_circle_pixbuf_from_color (GdkRGBA *color,
|
||||
gint size);
|
||||
|
||||
const gchar* get_color_name_from_source (ESource *source);
|
||||
void get_color_name_from_source (ESource *source,
|
||||
GdkRGBA *out_color);
|
||||
|
||||
gint gcal_compare_event_widget_by_date (gconstpointer a,
|
||||
gconstpointer b);
|
||||
|
||||
+1
-1
@@ -745,7 +745,7 @@ add_source (GcalManager *manager,
|
||||
|
||||
/* retrieve the source's color & build item name */
|
||||
item_name = g_strdup_printf ("%s", e_source_get_uid (source));
|
||||
gdk_rgba_parse (&color, get_color_name_from_source (source));
|
||||
get_color_name_from_source (source, &color);
|
||||
pix = gcal_get_pixbuf_from_color (&color, 16);
|
||||
|
||||
/* create the menu item */
|
||||
|
||||
Reference in New Issue
Block a user