From a5dcdcc924630b566c12484367122cb6725b7701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erick=20P=C3=A9rez=20Castellanos?= Date: Sat, 26 May 2012 13:46:49 -0400 Subject: [PATCH] Started EventView coding. --- data/gtk-styles.css | 12 +++ po/POTFILES.in | 1 + src/Makefile.am | 2 + src/gcal-event-view.c | 203 ++++++++++++++++++++++++++++++++++++++++++ src/gcal-event-view.h | 58 ++++++++++++ src/gcal-manager.c | 2 +- src/gcal-window.c | 42 ++++++++- 7 files changed, 317 insertions(+), 3 deletions(-) create mode 100644 src/gcal-event-view.c create mode 100644 src/gcal-event-view.h diff --git a/data/gtk-styles.css b/data/gtk-styles.css index 21c8532f..b039aae5 100644 --- a/data/gtk-styles.css +++ b/data/gtk-styles.css @@ -38,6 +38,18 @@ background-color: #555753; } +.event-view .frame { + border-style: solid; + border-color: @borders; + border-width: 0.5px; + border-radius: 3px; +} + +/* TODO: not working */ +.event-view .view { + box-shadow: 40 40 black; +} + .event { padding-top: 2px; padding-bottom: 2px; diff --git a/po/POTFILES.in b/po/POTFILES.in index 7f010899..107624d0 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -4,6 +4,7 @@ src/main.c src/gcal-application.c src/gcal-main-toolbar.c src/gcal-month-view.c +src/gcal-event-view.c data/gnome-calendar.desktop.in.in data/org.gnome.calendar.gschema.xml.in diff --git a/src/Makefile.am b/src/Makefile.am index 04df3682..a06e837f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -31,6 +31,8 @@ gnome_calendar_SOURCES = \ gcal-month-view.h \ gcal-event-widget.c \ gcal-event-widget.h \ + gcal-event-view.c \ + gcal-event-view.h \ gcal-manager.c \ gcal-manager.h \ gcal-utils.c \ diff --git a/src/gcal-event-view.c b/src/gcal-event-view.c new file mode 100644 index 00000000..6420ce9b --- /dev/null +++ b/src/gcal-event-view.c @@ -0,0 +1,203 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */ +/* + * gcal-event-view.c + * Copyright (C) 2012 Erick Pérez Castellanos + * + * gnome-calendar is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gnome-calendar is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "gcal-event-view.h" + +#include + +struct _GcalEventViewPrivate +{ + gboolean edit_mode; + + GtkWidget *e_what; + GtkWidget *e_host; + + GtkWidget *e_since; + GtkWidget *e_until; + GtkWidget *c_all_day; + + GtkWidget *e_where; + + GtkWidget *cb_cal; + + GtkWidget *t_desc; + + GtkWidget *attending_yes; + GtkWidget *attending_maybe; + GtkWidget *attending_no; + + GcalManager *manager; +}; + +static void gcal_event_view_constructed (GObject *object); + +static void gcal_event_view_set_combo_box (GcalEventView *view); + +G_DEFINE_TYPE(GcalEventView, gcal_event_view, GTK_TYPE_GRID) + +static void +gcal_event_view_class_init(GcalEventViewClass *klass) +{ + GObjectClass *object_class; + + object_class = G_OBJECT_CLASS (klass); + object_class->constructed = gcal_event_view_constructed; + + g_type_class_add_private((gpointer)klass, sizeof(GcalEventViewPrivate)); +} + +static void gcal_event_view_init(GcalEventView *self) +{ + GtkStyleContext *context; + + self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self, + GCAL_TYPE_EVENT_VIEW, + GcalEventViewPrivate); + + context = gtk_widget_get_style_context (GTK_WIDGET (self)); + gtk_style_context_add_class (context, "event-view"); +} + +static void +gcal_event_view_constructed (GObject *object) +{ + GcalEventViewPrivate *priv; + GtkWidget *what; + GtkWidget *host; + GtkWidget *when; + GtkWidget *to; + GtkWidget *calendar; + GtkWidget *where; + GtkWidget *desc; + GtkWidget *desc_frame; + GtkWidget *attending; + GtkWidget *attending_box; + + priv = GCAL_EVENT_VIEW (object)->priv; + if (G_OBJECT_CLASS (gcal_event_view_parent_class)->constructed != NULL) + G_OBJECT_CLASS (gcal_event_view_parent_class)->constructed (object); + + priv->e_what = gtk_entry_new (); + priv->e_host = gtk_entry_new (); + + priv->e_since = gtk_entry_new (); + priv->e_until = gtk_entry_new (); + priv->c_all_day = gtk_check_button_new_with_label (_("All day")); + + priv->e_where = gtk_entry_new (); + + priv->cb_cal = gtk_combo_box_new (); + gtk_widget_set_halign (priv->cb_cal, GTK_ALIGN_START); + + priv->t_desc = gtk_text_view_new (); + + priv->attending_yes = gtk_toggle_button_new_with_label (_("Yes")); + priv->attending_maybe = gtk_toggle_button_new_with_label (_("Maybe")); + priv->attending_no = gtk_toggle_button_new_with_label (_("No")); + + attending_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); + gtk_box_set_spacing (GTK_BOX (attending_box), 2); + gtk_button_box_set_layout (GTK_BUTTON_BOX (attending_box), GTK_BUTTONBOX_SPREAD); + gtk_widget_set_halign (attending_box, GTK_ALIGN_START); + gtk_container_add (GTK_CONTAINER (attending_box), priv->attending_yes); + gtk_container_add (GTK_CONTAINER (attending_box), priv->attending_maybe); + gtk_container_add (GTK_CONTAINER (attending_box), priv->attending_no); + + what = gtk_label_new (_("What")); + gtk_widget_set_halign (what, GTK_ALIGN_END); + gtk_grid_attach (GTK_GRID (object), what, 0, 0, 1, 1); + gtk_grid_attach (GTK_GRID (object), priv->e_what, 1, 0, 3, 1); + + host = gtk_label_new (_("Host")); + gtk_widget_set_halign (host, GTK_ALIGN_END); + gtk_grid_attach (GTK_GRID (object), host, 4, 0, 1, 1); + gtk_grid_attach (GTK_GRID (object), priv->e_host, 5, 0, 1, 1); + + when = gtk_label_new (_("When")); + gtk_widget_set_halign (when, GTK_ALIGN_END); + gtk_grid_attach (GTK_GRID (object), when, 0, 1, 1, 1); + gtk_grid_attach (GTK_GRID (object), priv->e_since, 1, 1, 1, 1); + to = gtk_label_new (_("to")); + gtk_grid_attach (GTK_GRID (object), to, 2, 1, 1, 1); + gtk_grid_attach (GTK_GRID (object), priv->e_until, 3, 1, 1, 1); + gtk_grid_attach (GTK_GRID (object), priv->c_all_day, 1, 2, 1, 1); + + where = gtk_label_new (_("Where")); + gtk_widget_set_halign (where, GTK_ALIGN_END); + gtk_grid_attach (GTK_GRID (object), where, 0, 3, 1, 1); + gtk_grid_attach (GTK_GRID (object), priv->e_where, 1, 3, 3, 1); + + calendar = gtk_label_new (_("Calendar")); + gtk_widget_set_halign (calendar, GTK_ALIGN_END); + gtk_grid_attach (GTK_GRID (object), calendar, 0, 4, 1, 1); + gtk_grid_attach (GTK_GRID (object), priv->cb_cal, 1, 4, 3, 1); + + desc = gtk_label_new (_("Description")); + gtk_widget_set_halign (desc, GTK_ALIGN_END); + gtk_widget_set_valign (desc, GTK_ALIGN_START); + gtk_grid_attach (GTK_GRID (object), desc, 0, 5, 1, 1); + desc_frame = gtk_frame_new (NULL); + gtk_container_add (GTK_CONTAINER (desc_frame), priv->t_desc); + gtk_widget_set_size_request (desc_frame, -1, 200); + gtk_grid_attach (GTK_GRID (object), desc_frame, 1, 5, 3, 1); + + attending = gtk_label_new (_("Attending")); + gtk_widget_set_halign (attending, GTK_ALIGN_END); + gtk_grid_attach (GTK_GRID (object), attending, 0, 6, 1, 1); + gtk_grid_attach (GTK_GRID (object), attending_box, 1, 6, 3, 1); + + gtk_grid_set_row_spacing (GTK_GRID (object), 10); + gtk_grid_set_column_spacing (GTK_GRID (object), 6); + gtk_widget_show_all (GTK_WIDGET (object)); +} + +static void +gcal_event_view_set_combo_box (GcalEventView *view) +{ + GcalEventViewPrivate *priv; + GtkCellRenderer *renderer; + + priv = view->priv; + + gtk_combo_box_set_model ( + GTK_COMBO_BOX (priv->cb_cal), + GTK_TREE_MODEL (gcal_manager_get_sources_model (priv->manager))); + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->cb_cal), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->cb_cal), + renderer, + "text", + 1, + NULL); + gtk_combo_box_set_active (GTK_COMBO_BOX (priv->cb_cal), 0); +} + +GtkWidget* +gcal_event_view_new_with_manager (GcalManager *manager) +{ + GtkWidget *view; + GcalEventViewPrivate *priv; + + view = g_object_new (GCAL_TYPE_EVENT_VIEW, NULL); + priv = GCAL_EVENT_VIEW (view)->priv; + priv->manager = manager; + gcal_event_view_set_combo_box (GCAL_EVENT_VIEW (view)); + + return view; +} diff --git a/src/gcal-event-view.h b/src/gcal-event-view.h new file mode 100644 index 00000000..f65ee91c --- /dev/null +++ b/src/gcal-event-view.h @@ -0,0 +1,58 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */ +/* + * gcal-event-view.h + * Copyright (C) 2012 Erick Pérez Castellanos + * + * gnome-calendar is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gnome-calendar is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef __GCAL_EVENT_VIEW_H__ +#define __GCAL_EVENT_VIEW_H__ + +#include "gcal-manager.h" + +#include + +G_BEGIN_DECLS + +#define GCAL_TYPE_EVENT_VIEW (gcal_event_view_get_type ()) +#define GCAL_EVENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GCAL_TYPE_EVENT_VIEW, GcalEventView)) +#define GCAL_EVENT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GCAL_TYPE_EVENT_VIEW, GcalEventViewClass)) +#define GCAL_IS_EVENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GCAL_TYPE_EVENT_VIEW)) +#define GCAL_IS_EVENT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GCAL_TYPE_EVENT_VIEW)) +#define GCAL_EVENT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GCAL_TYPE_EVENT_VIEW, GcalEventViewClass)) + +typedef struct _GcalEventView GcalEventView; +typedef struct _GcalEventViewClass GcalEventViewClass; +typedef struct _GcalEventViewPrivate GcalEventViewPrivate; + +struct _GcalEventView +{ + GtkGrid parent; + + GcalEventViewPrivate *priv; +}; + +struct _GcalEventViewClass +{ + GtkGridClass parent_class; +}; + +GType gcal_event_view_get_type (void); + +GtkWidget* gcal_event_view_new_with_manager (GcalManager *manager); + +G_END_DECLS + +#endif /* __GCAL_EVENT_VIEW_H__ */ diff --git a/src/gcal-manager.c b/src/gcal-manager.c index ff4d0ceb..9b7dcc79 100644 --- a/src/gcal-manager.c +++ b/src/gcal-manager.c @@ -30,7 +30,7 @@ enum { - COLUMN_UID, //corresponding source uid + COLUMN_UID = 0, //corresponding source uid COLUMN_NAME, COLUMN_ACTIVE, COLUMN_COLOR, diff --git a/src/gcal-window.c b/src/gcal-window.c index 07a655fb..e0d12490 100644 --- a/src/gcal-window.c +++ b/src/gcal-window.c @@ -24,6 +24,7 @@ #include "gcal-month-view.h" #include "gcal-view.h" #include "gcal-event-widget.h" +#include "gcal-event-view.h" #include "gcal-utils.h" #include @@ -311,11 +312,23 @@ _gcal_window_view_changed (GcalMainToolbar *main_toolbar, gpointer user_data) { GcalWindowPrivate *priv; + gint activated_page; priv = GCAL_WINDOW (user_data)->priv; priv->active_view = view_type; - g_debug ("GcalViewTypeEnum in GcalWindow %d", priv->active_view); + if ((activated_page = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), + priv->views[view_type])) + != -1) + { + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), + activated_page); + } + else + { + //TODO create view + g_debug ("GcalViewTypeEnum in GcalWindow %d", priv->active_view); + } } static void @@ -348,7 +361,32 @@ static void _gcal_window_add_event (GcalMainToolbar *main_toolbar, gpointer user_data) { - g_debug ("Catched signal add-event"); + GcalWindowPrivate *priv; + + priv = GCAL_WINDOW (user_data)->priv; + if (priv->add_view == NULL) + { + priv->add_view = gcal_event_view_new_with_manager ( + _gcal_window_get_manager (GCAL_WINDOW (user_data))); + gtk_widget_set_hexpand (priv->add_view, TRUE); + gtk_widget_set_vexpand (priv->add_view, TRUE); + gtk_widget_set_margin_top (priv->add_view, 10); + gtk_widget_set_margin_left (priv->add_view, 20); + gtk_widget_set_margin_right (priv->add_view, 20); + + gtk_widget_show (priv->add_view); + gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), + priv->add_view, + NULL); + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), -1); + } + else + { + //TODO: Reload/clean/reinitialize status + gtk_notebook_set_current_page ( + GTK_NOTEBOOK (priv->notebook), + gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), priv->add_view)); + } } static void