[gnome-calendar] year-view: add no events label to popover mode
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] year-view: add no events label to popover mode
- Date: Tue, 27 Jan 2015 18:07:00 +0000 (UTC)
commit 7b6037e707e549ad333db688c795339732ef953e
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Tue Jan 27 11:31:05 2015 -0500
year-view: add no events label to popover mode
data/theme/gtk-styles.css | 15 ++++++++++-----
data/ui/year-view.ui | 37 ++-----------------------------------
src/gcal-year-view.c | 32 +++++++++++++-------------------
3 files changed, 25 insertions(+), 59 deletions(-)
---
diff --git a/data/theme/gtk-styles.css b/data/theme/gtk-styles.css
index 5f2554b..dd08bfa 100644
--- a/data/theme/gtk-styles.css
+++ b/data/theme/gtk-styles.css
@@ -132,11 +132,11 @@ GtkBox.sidebar {
border-style: solid;
}
-GtkBox.sidebar:dir(ltr) {
+GcalYearView GtkBox.sidebar:dir(ltr) {
border-left-width: 1px;
}
-GtkBox.sidebar:dir(rtl) {
+GcalYearView GtkBox.sidebar:dir(rtl) {
border-right-width: 1px;
}
@@ -154,12 +154,17 @@ GtkPopover.popover-sidebar {
background-color: @theme_bg_color;
}
-GtkScrolledWindow.popover-sidebar {
+GtkPopover.popover-sidebar GtkScrolledWindow {
border-bottom-width: 0;
}
-GtkButton.popover-sidebar {
- border-radius: 0;
+GtkPopover.popover-sidebar GtkButton {
+ border-top-left-radius: 0;
+ border-top-right-radius: 0;
+}
+
+GtkPopover.popover-sidebar GtkBox {
+ border-width: 1px 1px 0 1px;
}
GcalEventWidget {
diff --git a/data/ui/year-view.ui b/data/ui/year-view.ui
index 6497027..582c784 100644
--- a/data/ui/year-view.ui
+++ b/data/ui/year-view.ui
@@ -17,6 +17,7 @@
</object>
<packing>
<property name="position">0</property>
+ <property name="pack_type">start</property>
</packing>
</child>
<child>
@@ -108,45 +109,11 @@
</template>
<object class="GtkPopover" id="popover">
<property name="relative_to">navigator</property>
+ <property name="border_width">6</property>
<style>
<class name="popover-sidebar" />
</style>
<signal name="closed" handler="popover_closed_cb" object="GcalYearView" swapped="yes" />
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="width_request">200</property>
- <property name="orientation">vertical</property>
- <property name="margin">6</property>
- <child>
- <object class="GtkScrolledWindow" id="popover_sidebar">
- <property name="visible">True</property>
- <property name="shadow_type">out</property>
- <property name="vexpand">True</property>
- <style>
- <class name="popover-sidebar" />
- </style>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton">
- <property name="visible">True</property>
- <property name="valign">end</property>
- <property name="label" translatable="yes">Add new event…</property>
- <style>
- <class name="popover-sidebar" />
- </style>
- <signal name="clicked" handler="add_event_clicked_cb" object="GcalYearView" swapped="yes" />
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
</object>
</interface>
diff --git a/src/gcal-year-view.c b/src/gcal-year-view.c
index 3400922..059581d 100644
--- a/src/gcal-year-view.c
+++ b/src/gcal-year-view.c
@@ -53,7 +53,6 @@ struct _GcalYearViewPrivate
GtkWidget *navigator_sidebar;
GtkWidget *popover; /* Popover for popover_mode */
- GtkWidget *popover_sidebar;
/* manager singleton */
GcalManager *manager;
@@ -905,6 +904,9 @@ add_event_clicked_cb (GcalYearView *year_view,
GcalYearViewPrivate *priv = year_view->priv;
icaltimetype *start_date, *end_date = NULL;
+ if (priv->popover_mode)
+ gtk_widget_hide (priv->popover);
+
if (priv->start_selected_date->day == 0)
{
start_date = gcal_dup_icaltime (priv->current_date);
@@ -1036,35 +1038,28 @@ gcal_year_view_size_allocate (GtkWidget *widget,
gtk_style_context_restore (context);
priv->popover_mode = (alloc->width < NAVIGATOR_CELL_WIDTH * 4 + padding_left * 8 +
SIDEBAR_PREFERRED_WIDTH);
- if (gtk_widget_get_visible (priv->sidebar) == priv->popover_mode)
- gtk_widget_set_visible (priv->sidebar, !priv->popover_mode);
-
if (priv->popover_mode && !gtk_widget_is_ancestor (priv->events_sidebar, priv->popover))
{
- GtkWidget *parent = gtk_widget_get_parent (priv->events_sidebar);
- g_object_ref (priv->events_sidebar);
+ g_object_ref (priv->sidebar);
- gtk_container_remove (GTK_CONTAINER (parent), priv->events_sidebar);
- gtk_container_add (GTK_CONTAINER (priv->popover_sidebar), priv->events_sidebar);
+ gtk_container_remove (GTK_CONTAINER (widget), priv->sidebar);
+ gtk_container_add (GTK_CONTAINER (priv->popover), priv->sidebar);
- gtk_widget_show_all (priv->events_sidebar);
- g_object_unref (priv->events_sidebar);
- gtk_widget_destroy (parent);
+ g_object_unref (priv->sidebar);
+ gtk_widget_show_all (priv->sidebar);
popover_closed_cb (GCAL_YEAR_VIEW (widget), GTK_POPOVER (priv->popover));
}
else if (!priv->popover_mode && gtk_widget_is_ancestor (priv->events_sidebar, priv->popover))
{
- GtkWidget *parent = gtk_widget_get_parent (priv->events_sidebar);
- g_object_ref (priv->events_sidebar);
+ g_object_ref (priv->sidebar);
- gtk_container_remove (GTK_CONTAINER (parent), priv->events_sidebar);
- gtk_container_add (GTK_CONTAINER (priv->navigator_sidebar), priv->events_sidebar);
+ gtk_container_remove (GTK_CONTAINER (priv->popover), priv->sidebar);
+ gtk_box_pack_end (GTK_BOX (widget), priv->sidebar, FALSE, TRUE, 0);
- gtk_widget_show_all (priv->events_sidebar);
- g_object_unref (priv->events_sidebar);
- gtk_widget_destroy (parent);
+ g_object_unref (priv->sidebar);
+ gtk_widget_show (priv->sidebar);
g_signal_handlers_block_by_func (priv->popover, popover_closed_cb, widget);
gtk_widget_hide (priv->popover);
g_signal_handlers_unblock_by_func (priv->popover, popover_closed_cb, widget);
@@ -1212,7 +1207,6 @@ gcal_year_view_class_init (GcalYearViewClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GcalYearView, navigator_sidebar);
gtk_widget_class_bind_template_child_private (widget_class, GcalYearView, no_events_title);
gtk_widget_class_bind_template_child_private (widget_class, GcalYearView, popover);
- gtk_widget_class_bind_template_child_private (widget_class, GcalYearView, popover_sidebar);
gtk_widget_class_bind_template_callback (widget_class, draw_navigator);
gtk_widget_class_bind_template_callback (widget_class, navigator_button_press_cb);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]