[gnome-calendar/calendar-management] source-manager-dialog: initial attempt to make it look like the proposed mockups
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/calendar-management] source-manager-dialog: initial attempt to make it look like the proposed mockups
- Date: Tue, 3 Feb 2015 02:46:16 +0000 (UTC)
commit aab43be6d3b0c12d1dbb42e84c456a020943782b
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Feb 3 00:44:57 2015 -0200
source-manager-dialog: initial attempt to make it look like the proposed mockups
A lot of code was removed & modified.
data/theme/gtk-styles.css | 5 +
data/ui/menus.ui | 10 +-
data/ui/source-manager-dialog.ui | 374 ++++++++++++++------------------------
src/gcal-source-manager-dialog.c | 115 ++++++++++--
4 files changed, 239 insertions(+), 265 deletions(-)
---
diff --git a/data/theme/gtk-styles.css b/data/theme/gtk-styles.css
index 43674a3..2a66f0c 100644
--- a/data/theme/gtk-styles.css
+++ b/data/theme/gtk-styles.css
@@ -217,3 +217,8 @@ GcalEventWidget.color-light:backdrop {
background-color: @theme_base_color;
}
+.sources-frame {
+ border-left: 0px;
+ border-right: 0px;
+ border-top: 0px;
+}
diff --git a/data/ui/menus.ui b/data/ui/menus.ui
index 384cd1e..494142c 100644
--- a/data/ui/menus.ui
+++ b/data/ui/menus.ui
@@ -46,16 +46,12 @@
<menu id="sourcesmenu">
<section>
<item>
- <attribute name="label" translatable="yes">From file</attribute>
+ <attribute name="label" translatable="yes">From file…</attribute>
<attribute name="action">sources.file</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">Local</attribute>
- <attribute name="action">sources.local</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Web</attribute>
- <attribute name="action">sources.web</attribute>
+ <attribute name="label" translatable="yes">URL…</attribute>
+ <attribute name="action">sources.url</attribute>
</item>
</section>
</menu>
diff --git a/data/ui/source-manager-dialog.ui b/data/ui/source-manager-dialog.ui
index 7c56853..fdae9a7 100644
--- a/data/ui/source-manager-dialog.ui
+++ b/data/ui/source-manager-dialog.ui
@@ -3,20 +3,23 @@
<interface>
<requires lib="gtk+" version="3.14"/>
<template class="GcalSourceManagerDialog" parent="GtkDialog">
- <property name="width_request">600</property>
+ <property name="width_request">450</property>
<property name="height_request">450</property>
<property name="can_focus">False</property>
- <property name="border_width">6</property>
+ <property name="resizable">False</property>
<property name="modal">True</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="use_header_bar">0</property>
<property name="type_hint">dialog</property>
+ <property name="destroy_with_parent">True</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
+ <property name="border-width">0</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
- <property name="layout_style">end</property>
<child>
<placeholder/>
</child>
@@ -31,253 +34,60 @@
</packing>
</child>
<child>
- <object class="GtkStack" id="main_stack">
+ <object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="transition_type">crossfade</property>
+ <property name="row_spacing">12</property>
+ <property name="column_spacing">12</property>
<child>
- <object class="GtkGrid" id="main_grid">
+ <object class="GtkScrolledWindow" id="scrolledwindow">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="column_spacing">12</property>
+ <property name="shadow_type">etched-in</property>
<child>
- <object class="GtkBox" id="box1">
+ <object class="GtkViewport" id="viewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="vexpand">True</property>
- <property name="orientation">vertical</property>
<child>
- <object class="GtkScrolledWindow" id="scrolled_window">
- <property name="width_request">240</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="vexpand">True</property>
- <property name="shadow_type">etched-in</property>
- <child>
- <object class="GtkViewport" id="viewport">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkListBox" id="sources_listbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <signal name="row-selected" handler="row_selected_cb"
object="GcalSourceManagerDialog" swapped="no" />
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolbar" id="toolbar">
+ <object class="GtkListBox" id="sources_listbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <child>
- <object class="GtkToolItem" id="button_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkBox" id="box2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkMenuButton" id="add_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <child>
- <object class="GtkImage" id="add_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">list-add-symbolic</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="remove_button">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <child>
- <object class="GtkImage" id="remove_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">list-remove-symbolic</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <style>
- <class name="linked"/>
- </style>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <style>
- <class name="inline-toolbar"/>
- </style>
+ <property name="selection_mode">none</property>
+ <property name="activate_on_single_click">False</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkStack" id="edit_stack">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="transition_type">crossfade</property>
- <child>
- <object class="GtkGrid" id="select_source_page">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="row_spacing">18</property>
- <child>
- <object class="GtkLabel" id="select_source_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Select a calendar or create a new
one</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkImage" id="select_source_image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="pixel_size">32</property>
- <property name="icon_name">x-office-calendar-symbolic</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="name">grid</property>
- <property name="title" translatable="yes">grid</property>
- </packing>
- </child>
- <child>
- <object class="GtkGrid" id="edit_grid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="margin_top">19</property>
- <property name="margin_bottom">18</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="orientation">vertical</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkLabel" id="color_label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Color</property>
- <property name="xalign">1</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkColorButton" id="edit_color_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="edit_default_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Default calendar</property>
- <property name="xalign">1</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkSwitch" id="default_source_switch">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="name">edit_page</property>
- <property name="title" translatable="yes">Edit</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
</child>
+ <style>
+ <class name="sources-frame"/>
+ </style>
</object>
<packing>
- <property name="name">management</property>
- <property name="title" translatable="yes">Management</property>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="bottom_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_bottom">6</property>
+ <property name="hexpand">True</property>
+ <property name="label" translatable="yes">Calendars from your Online Accounts appear
here.</property>
+ <property name="justify">center</property>
+ <property name="ellipsize">end</property>
+ <property name="yalign">1</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
</packing>
</child>
</object>
@@ -296,22 +106,110 @@
<property name="title">Calendars</property>
<property name="show_close_button">True</property>
<child>
- <object class="GtkButton" id="back_button">
- <property name="can_focus">False</property>
+ <object class="GtkMenuButton" id="add_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
- <object class="GtkImage" id="back_image">
+ <object class="GtkBox" id="add_source_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon_name">go-previous-symbolic</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="add_source_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Add</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="add_source_arrow_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">pan-down-symbolic</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
</child>
</object>
</child>
- <child>
- <object class="GtkButton" id="create_button">
- <property name="label" translatable="yes">Create</property>
+ </object>
+ </child>
+ </template>
+ <object class="GtkDialog" id="url_dialog">
+ <property name="can_focus">False</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="type_hint">dialog</property>
+ <property name="modal">True</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox2">
+ <property name="can_focus">False</property>
+ <property name="margin_start">18</property>
+ <property name="margin_end">18</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">12</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">0</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area2">
<property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="url_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="titlebar">
+ <object class="GtkHeaderBar" id="url_headerbar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="title">Insert URL</property>
+ <property name="has_subtitle">False</property>
+ <child>
+ <object class="GtkButton" id="cancel_button">
+ <property name="label" translatable="yes">Cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="add_url_button">
+ <property name="label" translatable="yes">Add</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
<property name="receives_default">True</property>
<style>
<class name="suggested-action"/>
@@ -324,5 +222,5 @@
</child>
</object>
</child>
- </template>
+ </object>
</interface>
diff --git a/src/gcal-source-manager-dialog.c b/src/gcal-source-manager-dialog.c
index 27b110d..3ec94b0 100644
--- a/src/gcal-source-manager-dialog.c
+++ b/src/gcal-source-manager-dialog.c
@@ -19,15 +19,12 @@
#include "gcal-source-manager-dialog.h"
#include "gcal-manager.h"
+#include "gcal-utils.h"
struct _GcalSourceManagerDialogPrivate
{
GtkWidget *add_button;
- GtkWidget *default_source_switch;
- GtkWidget *edit_color_button;
- GtkWidget *edit_stack;
GtkWidget *headerbar;
- GtkWidget *remove_button;
GtkWidget *sources_listbox;
/*
@@ -46,6 +43,12 @@ enum {
PROP_MANAGER
};
+enum {
+ SOURCE_GOA,
+ SOURCE_OWNCLOUD,
+ SOURCE_OTHER
+};
+
/* callbacks */
static void display_header_func (GtkListBoxRow *row,
GtkListBoxRow *before,
@@ -60,6 +63,10 @@ static void source_added_cb (GcalManager
gboolean enabled,
gpointer user_data);
+static gint sort_func_cb (GtkListBoxRow *current,
+ GtkListBoxRow *before,
+ gpointer user_data);
+
static void source_removed_cb (GcalManager *manager,
ESource *source,
gpointer user_data);
@@ -121,8 +128,6 @@ row_selected_cb (GtkListBox *listbox,
GcalSourceManagerDialogPrivate *priv;
priv = gcal_source_manager_dialog_get_instance_private (GCAL_SOURCE_MANAGER_DIALOG (user_data));
- gtk_widget_set_sensitive (priv->remove_button, row != NULL);
-
if (row != NULL)
{
ESource *source;
@@ -132,17 +137,8 @@ row_selected_cb (GtkListBox *listbox,
source = g_hash_table_lookup (priv->row_to_source, row);
extension = E_SOURCE_SELECTABLE (e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR));
- gtk_stack_set_visible_child_name (GTK_STACK (priv->edit_stack), "edit_page");
-
- /* default source switch */
- gtk_switch_set_active (GTK_SWITCH (priv->default_source_switch),
- source == gcal_manager_get_default_source (priv->manager));
- gtk_widget_set_sensitive (priv->default_source_switch,
- source != gcal_manager_get_default_source (priv->manager));
-
/* source color */
gdk_rgba_parse (&color, e_source_selectable_get_color (E_SOURCE_SELECTABLE (extension)));
- gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (priv->edit_color_button), &color);
}
}
@@ -150,6 +146,7 @@ row_selected_cb (GtkListBox *listbox,
* source_added_cb:
*
* Callback for when an #ESource is added
+ *
* to the #GcalManager.
*
* Returns:
@@ -172,6 +169,69 @@ source_added_cb (GcalManager *manager,
gtk_container_add (GTK_CONTAINER (priv->sources_listbox), row);
}
+
+/**
+ * sort_func_cb:
+ * @current: the current #GtkListBoxRow
+ * @before: the previous #GtkListBoxRow, or #NULL
+ * @user_data: user-passed data
+ *
+ * Sort the listbox with the following criterea:
+ * 1. GOA accounts
+ * 2. ownCloud accounts
+ * 3. the others
+ *
+ * Note that if they have the same source,
+ * they'll be sorted by their names.
+ *
+ * Returns: 1 if @current is after @before, 0 if
+ * they are equal, -1 otherwise
+ */
+static gint
+sort_func_cb (GtkListBoxRow *current,
+ GtkListBoxRow *before,
+ gpointer user_data)
+{
+ GcalSourceManagerDialogPrivate *priv;
+ ESource *current_source, *prev_source;
+ gint current_ext, prev_ext;
+
+ priv = gcal_source_manager_dialog_get_instance_private (GCAL_SOURCE_MANAGER_DIALOG (user_data));
+
+ current_source = g_hash_table_lookup (priv->row_to_source, current);
+ prev_source = g_hash_table_lookup (priv->row_to_source, before);
+
+ /* TODO: improve code to select the extension source */
+
+ /* online accounts */
+ if (e_source_has_extension (current_source, E_SOURCE_EXTENSION_GOA))
+ {
+ current_ext = SOURCE_GOA;
+ goto previous_row;
+ }
+ else
+ {
+ current_ext = SOURCE_OTHER;
+ }
+
+previous_row:
+
+ /* online accounts */
+ if (e_source_has_extension (prev_source, E_SOURCE_EXTENSION_GOA))
+ {
+ prev_ext = SOURCE_GOA;
+ }
+ else
+ {
+ prev_ext = SOURCE_OTHER;
+ }
+
+ if (current_ext != prev_ext)
+ return (current_ext > prev_ext ? 1 : -1);
+ else
+ return g_strcmp0 (e_source_get_display_name (current_source), e_source_get_display_name (prev_source));
+}
+
/**
* source_removed_cb:
*
@@ -211,11 +271,29 @@ make_row_for_source (GcalSourceManagerDialog *dialog,
GtkWidget *grid;
GtkWidget *label;
+ ESourceSelectable *extension;
+ GtkWidget *color_icon;
+ GdkPixbuf *pix;
+ GdkRGBA color;
+
priv = gcal_source_manager_dialog_get_instance_private (dialog);
+ extension = E_SOURCE_SELECTABLE (e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR));
/* grid */
grid = gtk_grid_new ();
- g_object_set (grid, "column-spacing", 12, "border-width", 6, NULL);
+ g_object_set (grid,
+ "column-spacing", 12,
+ "margin-start", 18,
+ "margin-end", 18,
+ "margin-top", 12,
+ "margin-bottom", 12,
+ NULL);
+
+ /* color */
+ gdk_rgba_parse (&color, e_source_selectable_get_color (extension));
+ pix = gcal_get_pixbuf_from_color (&color, 16);
+ color_icon = gtk_image_new_from_pixbuf (pix);
+ gtk_container_add (GTK_CONTAINER (grid), color_icon);
/* label */
label = gtk_label_new (e_source_get_display_name (source));
@@ -319,11 +397,7 @@ gcal_source_manager_dialog_class_init (GcalSourceManagerDialogClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/source-manager-dialog.ui");
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceManagerDialog, add_button);
- gtk_widget_class_bind_template_child_private (widget_class, GcalSourceManagerDialog,
default_source_switch);
- gtk_widget_class_bind_template_child_private (widget_class, GcalSourceManagerDialog, edit_color_button);
- gtk_widget_class_bind_template_child_private (widget_class, GcalSourceManagerDialog, edit_stack);
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceManagerDialog, headerbar);
- gtk_widget_class_bind_template_child_private (widget_class, GcalSourceManagerDialog, remove_button);
gtk_widget_class_bind_template_child_private (widget_class, GcalSourceManagerDialog, sources_listbox);
gtk_widget_class_bind_template_callback (widget_class, row_selected_cb);
@@ -355,6 +429,7 @@ gcal_source_manager_dialog_constructed (GObject *object)
/* add separators to the listbox */
gtk_list_box_set_header_func (GTK_LIST_BOX (priv->sources_listbox), display_header_func, NULL, NULL);
+ gtk_list_box_set_sort_func (GTK_LIST_BOX (priv->sources_listbox), sort_func_cb, object, NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]