event-widget: render locked state of the calendar
This commit is contained in:
+57
-2
@@ -33,6 +33,9 @@ typedef struct
|
|||||||
gboolean all_day;
|
gboolean all_day;
|
||||||
gboolean has_reminders;
|
gboolean has_reminders;
|
||||||
|
|
||||||
|
/* internal data */
|
||||||
|
gboolean read_only;
|
||||||
|
|
||||||
/* weak ESource reference */
|
/* weak ESource reference */
|
||||||
ESource *source;
|
ESource *source;
|
||||||
/* ECalComponent data */
|
/* ECalComponent data */
|
||||||
@@ -559,6 +562,7 @@ gcal_event_widget_draw (GtkWidget *widget,
|
|||||||
gint x,y;
|
gint x,y;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint left_gap;
|
gint left_gap;
|
||||||
|
gint right_gap;
|
||||||
gint icon_size = 0;
|
gint icon_size = 0;
|
||||||
|
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
@@ -598,7 +602,21 @@ gcal_event_widget_draw (GtkWidget *widget,
|
|||||||
pango_extents_to_pixels (&logical_rect, NULL);
|
pango_extents_to_pixels (&logical_rect, NULL);
|
||||||
icon_size = logical_rect.height;
|
icon_size = logical_rect.height;
|
||||||
left_gap = icon_size + padding.left;
|
left_gap = icon_size + padding.left;
|
||||||
pango_layout_set_width (layout, (width - (padding.left + padding.right + left_gap) ) * PANGO_SCALE);
|
pango_layout_set_width (layout, (width - (left_gap + padding.left + padding.right) ) * PANGO_SCALE);
|
||||||
|
}
|
||||||
|
|
||||||
|
right_gap = 0;
|
||||||
|
if (priv->read_only)
|
||||||
|
{
|
||||||
|
if (icon_size == 0)
|
||||||
|
{
|
||||||
|
pango_layout_get_extents (layout, NULL, &logical_rect);
|
||||||
|
pango_extents_to_pixels (&logical_rect, NULL);
|
||||||
|
icon_size = logical_rect.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
right_gap = icon_size + padding.right;
|
||||||
|
pango_layout_set_width (layout, (width - (left_gap + padding.left + padding.right + right_gap) ) * PANGO_SCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_render_layout (context, cr,
|
gtk_render_layout (context, cr,
|
||||||
@@ -606,7 +624,7 @@ gcal_event_widget_draw (GtkWidget *widget,
|
|||||||
y + padding.top,
|
y + padding.top,
|
||||||
layout);
|
layout);
|
||||||
|
|
||||||
/* render icon */
|
/* render reminder icon */
|
||||||
if (priv->has_reminders)
|
if (priv->has_reminders)
|
||||||
{
|
{
|
||||||
GtkIconTheme *icon_theme;
|
GtkIconTheme *icon_theme;
|
||||||
@@ -632,6 +650,32 @@ gcal_event_widget_draw (GtkWidget *widget,
|
|||||||
cairo_paint (cr);
|
cairo_paint (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* render locked icon */
|
||||||
|
if (priv->read_only)
|
||||||
|
{
|
||||||
|
GtkIconTheme *icon_theme;
|
||||||
|
GtkIconInfo *icon_info;
|
||||||
|
GdkPixbuf *pixbuf;
|
||||||
|
gboolean was_symbolic;
|
||||||
|
|
||||||
|
icon_theme = gtk_icon_theme_get_default ();
|
||||||
|
icon_info = gtk_icon_theme_lookup_icon (icon_theme,
|
||||||
|
"changes-prevent-symbolic",
|
||||||
|
icon_size,
|
||||||
|
0);
|
||||||
|
pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info,
|
||||||
|
context,
|
||||||
|
&was_symbolic,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gdk_cairo_set_source_pixbuf (cr,
|
||||||
|
pixbuf,
|
||||||
|
width - right_gap,
|
||||||
|
y + padding.top);
|
||||||
|
g_object_unref (pixbuf);
|
||||||
|
cairo_paint (cr);
|
||||||
|
}
|
||||||
|
|
||||||
pango_font_description_free (font_desc);
|
pango_font_description_free (font_desc);
|
||||||
g_object_unref (layout);
|
g_object_unref (layout);
|
||||||
|
|
||||||
@@ -793,6 +837,17 @@ gcal_event_widget_peek_uuid (GcalEventWidget *event)
|
|||||||
return priv->uuid;
|
return priv->uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gcal_new_event_widget_set_read_only (GcalEventWidget *event,
|
||||||
|
gboolean read_only)
|
||||||
|
{
|
||||||
|
GcalEventWidgetPrivate *priv;
|
||||||
|
|
||||||
|
priv = gcal_event_widget_get_instance_private (event);
|
||||||
|
|
||||||
|
priv->read_only = read_only;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gcal_event_widget_set_date:
|
* gcal_event_widget_set_date:
|
||||||
* @event: a #GcalEventWidget
|
* @event: a #GcalEventWidget
|
||||||
|
|||||||
@@ -63,6 +63,9 @@ GtkWidget* gcal_event_widget_new_with_summary_and_color (const gchar *
|
|||||||
|
|
||||||
const gchar* gcal_event_widget_peek_uuid (GcalEventWidget *event);
|
const gchar* gcal_event_widget_peek_uuid (GcalEventWidget *event);
|
||||||
|
|
||||||
|
void gcal_new_event_widget_set_read_only (GcalEventWidget *event,
|
||||||
|
gboolean read_only);
|
||||||
|
|
||||||
void gcal_event_widget_set_date (GcalEventWidget *event,
|
void gcal_event_widget_set_date (GcalEventWidget *event,
|
||||||
const icaltimetype *date);
|
const icaltimetype *date);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user