From ad87be3194b4f625135726e0ef967bc7a9da6ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erick=20P=C3=A9rez=20Castellanos?= Date: Thu, 26 Apr 2012 01:32:37 -0400 Subject: [PATCH] Second commit. Adding actions. --- .gitignore | 69 ++++++++++++++++++++++++ Makefile.am | 17 +++--- configure.ac | 86 +++++++++++++++++++++++------- doc/Assumptions | 9 ++++ doc/Flows | 30 +++++++++++ doc/Internals | 118 +++++++++++++++++++++++++++++++++++++++++ doc/Makefile.am | 4 ++ src/Makefile.am | 7 +-- src/gcal-application.c | 109 +++++++++++++++++++++++++++++-------- src/gcal-application.h | 7 +-- 10 files changed, 401 insertions(+), 55 deletions(-) create mode 100644 doc/Assumptions create mode 100644 doc/Flows create mode 100644 doc/Internals create mode 100644 doc/Makefile.am diff --git a/.gitignore b/.gitignore index ae70eb6d..1041986c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,71 @@ +*.la +*.lo +*.o +.deps +.libs +ABOUT-NLS +ChangeLog +INSTALL +Makefile +Makefile.in +aclocal.m4 +autom4te.cache +config.h +config.h.in +config.log +config.status +config +configure +data/gnome-documents-search-provider.ini +data/gnome-documents.desktop +data/gnome-documents.desktop.in +data/org.gnome.Documents.GDataMiner.service +data/org.gnome.documents.gschema.valid +data/org.gnome.documents.gschema.xml +intltool-extract.in +intltool-merge.in +intltool-update.in +libtool +m4/ +omf.make +po/*.gmo +po/*.header +po/*.sed +po/*.sin +po/.intltool-merge-cache +po/Makefile.in.in +po/Makevars.template +po/POTFILES +po/Rules-quot +po/stamp-it +src/*.gir +src/*.typelib +src/Makefile +src/Makefile.in +src/gd-tracker-gdata-miner +src/gnome-documents +src/gnome-documents-debug +src/gnome-documents-search-provider +src/path.js +src/org.gnome.Documents.SearchProvider.service +stamp-h1 +xmldocs.make +*~ +*.patch +*.sw? +.emacs.desktop* +/data/gnome-calendar.desktop +/data/gnome-calendar.desktop.in +/data/org.gnome.calendar.gschema.valid +/data/org.gnome.calendar.gschema.xml +/src/gnome-calendar +gnome-calendar.anjuta .anjuta* gnome_calendar.anjuta +/config.guess +/config.sub +/depcomp +/install-sh +/ltmain.sh +/missing +/mkinstalldirs diff --git a/Makefile.am b/Makefile.am index cd12846b..ec352131 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,14 +1,10 @@ -## Process this file with automake to produce Makefile.in -## Created by Anjuta +ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} -SUBDIRS = src po +SUBDIRS = src po doc gnome_calendardocdir = ${prefix}/doc/gnome_calendar gnome_calendardoc_DATA = \ README\ - COPYING\ - AUTHORS\ - ChangeLog\ INSTALL\ NEWS @@ -17,8 +13,13 @@ INTLTOOL_FILES = intltool-extract.in \ intltool-merge.in \ intltool-update.in -EXTRA_DIST = $(gnome_calendardoc_DATA) \ - $(INTLTOOL_FILES) +EXTRA_DIST = \ + $(gnome_calendardoc_DATA) \ + $(INTLTOOL_FILES) \ + THANKS \ + TODO \ + autogen.sh + DISTCLEANFILES = intltool-extract \ intltool-merge \ diff --git a/configure.ac b/configure.ac index 11ef4ccc..fd5955ff 100644 --- a/configure.ac +++ b/configure.ac @@ -1,17 +1,23 @@ -AC_INIT(gnome_calendar, 0.0.1) +dnl -*- mode: m4 -*- +AC_PREREQ(2.63) +AC_INIT([gnome-calendar],[0.0.2],[],[gnome-calendar]) -AC_CONFIG_HEADERS([config.h]) +AM_CONFIG_HEADER(config/config.h) +AC_CONFIG_SRCDIR([src/main.c]) +AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_AUX_DIR([config]) -AM_INIT_AUTOMAKE([1.11]) +m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) -AM_SILENT_RULES([yes]) - -AC_PROG_CC +# require automake 1.11 +AM_INIT_AUTOMAKE([1.11 dist-xz no-dist-gzip tar-ustar foreign]) +AM_MAINTAINER_MODE([enable]) dnl *************************************************************************** dnl Internationalization dnl *************************************************************************** IT_PROG_INTLTOOL([0.35.0]) +PKG_PROG_PKG_CONFIG([0.22]) GETTEXT_PACKAGE=gnome_calendar AC_SUBST(GETTEXT_PACKAGE) @@ -19,20 +25,62 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [GETTEXT package name]) AM_GLIB_GNU_GETTEXT +## don't rerun to this point if we abort +AC_CACHE_SAVE + +AC_PROG_CC +AM_PROG_CC_C_O +AC_PROG_CXX +AC_ISC_POSIX +AC_HEADER_STDC + +# no stupid static libraries +AM_DISABLE_STATIC +# enable libtool +AC_PROG_LIBTOOL +# avoid libtool for LTCOMPILE, use it only to link + +## don't rerun to this point if we abort +AC_CACHE_SAVE + LT_INIT -PKG_CHECK_MODULES(GNOME_CALENDAR, - [gio-2.0 - glib-2.0 - gtk+-3.0 >= 3.4 - clutter-1.0 - clutter-gtk-1.0 - libedataserver-1.2 - libedataserverui-3.0 - libecal-1.2]) +GLIB_GSETTINGS -AC_OUTPUT([ - Makefile - src/Makefile - po/Makefile.in +GLIB_MIN_VERSION=2.30.0 +GTK_MIN_VERSION=3.4.0 +CLUTTER_MIN_VERSION=1.10 +CLUTTER_GTK_MIN_VERSION=1.2 +ECAL_REQUIRED=3.1.5 +EDATASERVER_REQUIRED=3.1.5 +EDATASERVERUI_REQUIRED=3.1.5 + +PKG_CHECK_MODULES(CALENDAR, + glib-2.0 >= $GLIB_MIN_VERSION + gtk+-3.0 >= $GTK_MIN_VERSION + clutter-1.0 >= CLUTTER_MIN_VERSION + clutter-gtk-1.0 >= CLUTTER_GTK_MIN_VERSION + libecal-1.2 >= $ECAL_REQUIRED + libedataserver-1.2 >= EDATASERVER_REQUIRED + libedataserverui-3.0 >= EDATASERVERUI_REQUIRED) + +AC_CONFIG_FILES([ + Makefile + src/Makefile + po/Makefile.in + doc/Makefile ]) + +AC_OUTPUT + +dnl ========================================================================== +echo " + + gnome-calendar $VERSION + ================== + + prefix: ${prefix} + compiler: ${CC} + + Now type 'make' to build $PACKAGE +" diff --git a/doc/Assumptions b/doc/Assumptions new file mode 100644 index 00000000..ab164b3b --- /dev/null +++ b/doc/Assumptions @@ -0,0 +1,9 @@ +Some words about how do we work so far: + +1. We load calendar sources from Online Accounts. + (So we'll need a view for adding sources, since I refuse + to read some gconf key from evolution to load some others. + Maybe that's will be the way eventually, but well) + +2. Using sexp for getting objects between two dates: + (occur-in-time-range? (make-time "20001116T230000Z") (make-time "20001217T230000Z") "America/New_York") diff --git a/doc/Flows b/doc/Flows new file mode 100644 index 00000000..a929b421 --- /dev/null +++ b/doc/Flows @@ -0,0 +1,30 @@ +These are some of the flows followed inside the application. + +Adding calendar (gcal_store_add_source) + Sources are added defined by an URI, at least for now. I think there's + been done on improving this, but for now, there and URI defining every + source we're adding. + + - Check if the URI already existed + (here will have to take into account relative and absolute URIs) + - If it isn't new end processing. + - Create the ECalClient, add it to the list. + - Open the ECalClient (e_client_open) + - Retrieve capabilities ? (ask IRC, what's this) //FIXME this wil be later implemented, when needed + - Get Object list based on the existing query + - Create ECalClientView using the existing query. + - Hook to ECalClientView signals + +Setting a view in the main window (MainWindow.set_view) + This will work for setting a new view (the app hasn't instanced a view + of that type yet), or for updating an old view with a new time lapse + + - Update GSettings key for keeping active-view-type + - Create/Update the view with the active date from MainWindow._date + - Retrieve new time range from view. + - Update time range in MainWindow._store (a GcalStore) + - Hook up to signals emitted from GcalStore to read new events + from updated time range + - Hook up to signals emitted from GcalStore to get events + updates lively + - Update MainWindow._view_type diff --git a/doc/Internals b/doc/Internals new file mode 100644 index 00000000..2e3152db --- /dev/null +++ b/doc/Internals @@ -0,0 +1,118 @@ +Rough description of some internals of Gnome Calendar Application + + ++ mainToolbar object: + + Has 3 states: + 1. Overview + 2. View Event + 3. Edit Event (this one could act as New Event View, or even as New anything view) + + ++ Global + + Has dconf-key attribute + For keeping the last view and last day selected + + Has GcalStore object + For managingn source and events, and everything else + + Has a SourceManager object + + ++ SourceManager + + It's the javascript counter part of GcalStore objects. It will handle adding + sources to GcalStore. + + ++ GcalStore + + Has a list of GcalSToreUnit, + Containing: + Esource, ECalClient,ECalClientView + + Has a list of ESourceGroup + + Has GDate *initial_date, *final_date + For defining a range to get events from + Could have an active query representing the range (s-exp) + + Has a list of Events in the active range (a list of ECalComponent) + + Emit signals for: + - objects-added (wrapping ECalClientView) + - objects-removed (wrapping ECalClientView) + - events-retrieved (for time range changing) + + ++ GcalSource + + Has a base_uri + Has a relative uri + Has a color + + ++ GcalApplication + + Has command-line option + For opening on the day specified + + ++ GcalView + + Has NavigationPane + Has GDate: selected_date attribute + + Has child classes + 1. GcalDayView + ... + + ++ GcalEvent + + Has one source + + ++ GcalMainWindow + + Design + + +- GtkClutter.Embed::ClutterBox(BoxLayout) ----------------------------------+ + | | + | +- _bodyContainer::ClutterBox(BoxLayout) -----------------------------+ | + | | | | + | | +- _mainToolbar ------------------------------------------------+ | | + | | | | | | + | | +---------------------------------------------------------------+ | | + | | +- _contentsContainer::ClutterBox(BinLayout) -------------------+ | | + | | | | | | + | | | +- _sourcesView ------------------------------------------+ | | | + | | | | | | | | + | | | +---------------------------------------------------------+ | | | + | | | | | | + | | | +- _notebookActor ----------------------------------------+ | | | + | | | | | | | | + | | | | | | | | + | | | | | | | | + | | | +---------------------------------------------------------+ | | | + | | +---------------------------------------------------------------+ | | + | | | | + | +---------------------------------------------------------------------+ | + +----------------------------------------------------------------------------+ + + Has an active_view attribute + For keeping the type view is actually showing + + Has views + 1. GcalDayView + 2. GcalWeekView + 3. GcalMonthView + ... + + Has GDate attribute + For keeping actual date + + Has set_view/update_view method + For updating the view content by talking to GcalStore + about events an dates of the view diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 00000000..41139727 --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST= \ + Assumptions \ + Flows \ + Internals diff --git a/src/Makefile.am b/src/Makefile.am index 7bf65c14..a419fb14 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,13 +2,13 @@ AM_CPPFLAGS = \ -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \ -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \ -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \ - $(GNOME_CALENDAR_CFLAGS) + $(CALENDAR_CFLAGS) AM_CFLAGS =\ -Wall\ -g -bin_PROGRAMS = gnome_calendar +bin_PROGRAMS = gnome-calendar gnome_calendar_SOURCES = \ main.c \ @@ -18,6 +18,7 @@ gnome_calendar_SOURCES = \ gnome_calendar_LDFLAGS = \ -Wl,--export-dynamic -gnome_calendar_LDADD = $(GNOME_CALENDAR_LIBS) +gnome_calendar_LDADD = \ + $(CALENDAR_LIBS) diff --git a/src/gcal-application.c b/src/gcal-application.c index 72150119..ab9b4720 100644 --- a/src/gcal-application.c +++ b/src/gcal-application.c @@ -20,42 +20,51 @@ #include - -G_DEFINE_TYPE (GcalApplication, gnome_calendar, GTK_TYPE_APPLICATION); - - - -static void -gcal_application_new_window (GApplication *app, - GFile *file) +struct _GcalApplicationPrivate { - GtkWidget *window; + GtkWidget *window; +}; - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (window), _("Calendar")); - - - gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (app)); - gtk_widget_show_all (GTK_WIDGET (window)); -} +static void gcal_application_startup (GApplication *app); + +static void _gcal_application_set_app_menu (GApplication *app); +static void _gcal_application_show_about (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data); +static void _gcal_application_quit (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data); + +G_DEFINE_TYPE (GcalApplication, gcal_application, GTK_TYPE_APPLICATION); -/* GApplication implementation */ static void gcal_application_activate (GApplication *application) { - gcal_application_new_window (application, NULL); + GcalApplication *app = GCAL_APPLICATION (application); + + if (app->priv->window != NULL) + gtk_window_present (GTK_WINDOW (app->priv->window)); + else + { + app->priv->window = gtk_application_window_new (GTK_APPLICATION (app)); + gtk_window_set_title (GTK_WINDOW (app->priv->window), _("Calendar")); + + gtk_widget_show_all (GTK_WIDGET (app->priv->window)); + } } static void -gcal_application_init (GcalApplication *object) +gcal_application_init (GcalApplication *self) { + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + GCAL_TYPE_APPLICATION, + GcalApplicationPrivate); } static void gcal_application_finalize (GObject *object) { - G_OBJECT_CLASS (gcal_application_parent_class)->finalize (object); } @@ -63,9 +72,64 @@ static void gcal_application_class_init (GcalApplicationClass *klass) { G_APPLICATION_CLASS (klass)->activate = gcal_application_activate; - G_APPLICATION_CLASS (klass)->open = gcal_application_open; + G_APPLICATION_CLASS (klass)->startup = gcal_application_startup; G_OBJECT_CLASS (klass)->finalize = gcal_application_finalize; + + g_type_class_add_private ((gpointer) klass, sizeof(GcalApplicationPrivate)); +} + +static void +gcal_application_startup (GApplication *app) +{ + G_APPLICATION_CLASS (gcal_application_parent_class)->startup (app); + + _gcal_application_set_app_menu (app); +} + +static void +_gcal_application_set_app_menu (GApplication *app) +{ + GMenu *app_menu = g_menu_new (); + + GSimpleAction *about = g_simple_action_new ("about", NULL); + g_signal_connect (about, + "activate", + G_CALLBACK (_gcal_application_show_about), + app); + g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (about)); + g_menu_append (app_menu, _("About"), "app.about"); + + GSimpleAction *quit = g_simple_action_new ("quit", NULL); + g_signal_connect (quit, + "activate", + G_CALLBACK (_gcal_application_quit), + app); + g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (quit)); + g_menu_append (app_menu, _("Quit"), "app.quit"); + + gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL (app_menu)); +} + +static void +_gcal_application_show_about (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) +{ + GcalApplication *app = GCAL_APPLICATION (user_data); + + gtk_show_about_dialog (GTK_WINDOW (app->priv->window), + "program-name", "Calendar", + NULL); +} + +static void _gcal_application_quit (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) +{ + GApplication *app = G_APPLICATION (user_data); + + g_application_quit (app); } GcalApplication * @@ -73,8 +137,9 @@ gcal_application_new (void) { g_type_init (); + g_set_application_name ("Calendar"); + return g_object_new (gcal_application_get_type (), "application-id", "org.gnome.Calendar", - "flags", G_APPLICATION_HANDLES_COMMAND_LINE, NULL); } diff --git a/src/gcal-application.h b/src/gcal-application.h index 9f3b64b3..d9b20dd8 100644 --- a/src/gcal-application.h +++ b/src/gcal-application.h @@ -31,9 +31,9 @@ G_BEGIN_DECLS #define GCAL_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCAL_TYPE_APPLICATION)) #define GCAL_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCAL_TYPE_APPLICATION, GcalApplicationClass)) -typedef struct _GcalApplicationClass GcalApplicationClass; -typedef struct _GcalApplication GcalApplication; - +typedef struct _GcalApplicationClass GcalApplicationClass; +typedef struct _GcalApplication GcalApplication; +typedef struct _GcalApplicationPrivate GcalApplicationPrivate; struct _GcalApplicationClass { @@ -44,6 +44,7 @@ struct _GcalApplication { GtkApplication parent_instance; + GcalApplicationPrivate *priv; }; GType gcal_application_get_type (void) G_GNUC_CONST;