r3273 - in trunk/src/target/OM-2007.2/applications/openmoko-today2: . src
chris at sita.openmoko.org
chris at sita.openmoko.org
Thu Oct 25 19:00:15 CEST 2007
Author: chris
Date: 2007-10-25 19:00:13 +0200 (Thu, 25 Oct 2007)
New Revision: 3273
Removed:
trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-summary.c
trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-summary.h
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-today2/ChangeLog
trunk/src/target/OM-2007.2/applications/openmoko-today2/src/Makefile.am
trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-main.c
trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-journal.c
trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today.h
Log:
* src/Makefile.am:
* src/today-main.c: (today_dial_button_clicked_cb),
(bg_child_expose_cb), (set_time_idle), (today_create_home_page),
(location_notify), (main):
* src/today-pim-journal.c: (today_pim_journal_update_messages),
(header_clicked_cb), (missed_calls_button_press_cb),
(unread_messages_button_press_cb), (tasks_button_press_cb),
(dates_button_press_cb), (store_opened_cb),
(today_pim_journal_box_new):
* src/today-pim-summary.c:
* src/today-pim-summary.h:
* src/today.h:
Visual overhaul to the home screen
Modified: trunk/src/target/OM-2007.2/applications/openmoko-today2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-today2/ChangeLog 2007-10-25 16:57:18 UTC (rev 3272)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/ChangeLog 2007-10-25 17:00:13 UTC (rev 3273)
@@ -1,3 +1,19 @@
+2007-10-25 Chris Lord <chris at openedhand.com>
+
+ * src/Makefile.am:
+ * src/today-main.c: (today_dial_button_clicked_cb),
+ (bg_child_expose_cb), (set_time_idle), (today_create_home_page),
+ (location_notify), (main):
+ * src/today-pim-journal.c: (today_pim_journal_update_messages),
+ (header_clicked_cb), (missed_calls_button_press_cb),
+ (unread_messages_button_press_cb), (tasks_button_press_cb),
+ (dates_button_press_cb), (store_opened_cb),
+ (today_pim_journal_box_new):
+ * src/today-pim-summary.c:
+ * src/today-pim-summary.h:
+ * src/today.h:
+ Visual overhaul to the home screen
+
2007-10-23 Chris Lord <chris at openedhand.com>
* src/today-main.c: (digital_clock_notify), (main):
Modified: trunk/src/target/OM-2007.2/applications/openmoko-today2/src/Makefile.am
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-today2/src/Makefile.am 2007-10-25 16:57:18 UTC (rev 3272)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/src/Makefile.am 2007-10-25 17:00:13 UTC (rev 3273)
@@ -13,8 +13,6 @@
openmoko_today_SOURCES = \
today-main.c \
today.h \
- today-pim-summary.c \
- today-pim-summary.h \
today-utils.c \
today-utils.h \
today-events-store.h \
Modified: trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-main.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-main.c 2007-10-25 16:57:18 UTC (rev 3272)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-main.c 2007-10-25 17:00:13 UTC (rev 3273)
@@ -14,7 +14,6 @@
#include <libjana-gtk/jana-gtk.h>
#include "today.h"
#include "today-utils.h"
-#include "today-pim-summary.h"
#include "today-pim-journal.h"
#include "today-launcher.h"
#include "today-task-manager.h"
@@ -40,7 +39,7 @@
today_dial_button_clicked_cb (GtkToolButton *button, TodayData *data)
{
launcher_start (data->window, today_get_launcher ((const gchar *[])
- {"openmoko-dialer", NULL }, TRUE, TRUE));
+ {"openmoko-dialer", "-s", NULL }, TRUE, FALSE));
}
static void
@@ -74,6 +73,50 @@
return FALSE;
}
+static gboolean
+bg_child_expose_cb (GtkWidget *widget, GdkEventExpose *event, TodayData *data)
+{
+ cairo_t *cr;
+/* GtkWidget *parent;
+ gint x = 0, y = 0;
+
+ if (!data->wallpaper) return FALSE;
+
+ parent = widget;
+ do {
+ if (!GTK_WIDGET_NO_WINDOW (parent)) {
+ x += parent->allocation.x;
+ y += parent->allocation.y;
+ }
+ parent = gtk_widget_get_parent (parent);
+ } while (parent && (parent != data->bg_ebox));
+ if (!parent) return FALSE;
+
+ gdk_draw_drawable (widget->window, widget->style->black_gc,
+ data->wallpaper, x, y,
+ 0, 0, -1, -1);*/
+
+ /* Draw a semi-transparent rounded rectangle */
+ cr = gdk_cairo_create (widget->window);
+ cairo_translate (cr, widget->allocation.x, widget->allocation.y);
+ cairo_new_path (cr);
+ cairo_move_to (cr, 12, 6);
+ cairo_rel_line_to (cr, widget->allocation.width - 24, 0);
+ cairo_rel_curve_to (cr, 6, 0, 6, 6, 6, 6);
+ cairo_rel_line_to (cr, 0, widget->allocation.height - 24);
+ cairo_rel_curve_to (cr, 0, 6, -6, 6, -6, 6);
+ cairo_rel_line_to (cr, -(widget->allocation.width - 24), 0);
+ cairo_rel_curve_to (cr, -6, 0, -6, -6, -6, -6);
+ cairo_rel_line_to (cr, 0, -(widget->allocation.height - 24));
+ cairo_rel_curve_to (cr, 0, -6, 6, -6, 6, -6);
+ cairo_close_path (cr);
+ cairo_set_source_rgba (cr, 1, 1, 1, 0.5);
+ cairo_fill (cr);
+ cairo_destroy (cr);
+
+ return FALSE;
+}
+
static void
bg_size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation,
TodayData *data)
@@ -93,10 +136,23 @@
set_time_idle (TodayData *data)
{
JanaTime *time;
+ gchar *date_str;
time = jana_ecal_utils_time_now (data->location);
jana_gtk_clock_set_time (JANA_GTK_CLOCK (data->clock), time);
+ date_str = jana_utils_strftime (time, "%A, %d. %B %Y");
+ gtk_button_set_label (GTK_BUTTON (data->date_button), date_str);
+ g_free (date_str);
+ /* Update query every half-hour */
+ if (data->dates_view && ((jana_time_get_minutes (time) % 30) == 0)) {
+ JanaTime *end = jana_time_duplicate (time);
+ jana_time_set_day (end, jana_time_get_day (end) + 1);
+ jana_time_set_isdate (end, TRUE);
+ jana_store_view_set_range (data->dates_view, time, end);
+ g_object_unref (end);
+ }
+
#if GLIB_CHECK_VERSION(2,14,0)
g_timeout_add_seconds (60 - jana_time_get_seconds (time),
(GSourceFunc)set_time_idle, data);
@@ -113,7 +169,7 @@
static GtkWidget *
today_create_home_page (TodayData *data)
{
- GtkWidget *main_vbox, *vbox, *align, *viewport, *scroll;
+ GtkWidget *main_vbox, *vbox, *align;
/* Add home page */
main_vbox = gtk_vbox_new (FALSE, 0);
@@ -160,41 +216,31 @@
G_CALLBACK (bg_expose_cb), data);
g_signal_connect (data->bg_ebox, "size-allocate",
G_CALLBACK (bg_size_allocate_cb), data);
+ gtk_box_pack_start (GTK_BOX (main_vbox), data->bg_ebox, TRUE, TRUE, 0);
+ gtk_widget_show (data->bg_ebox);
/* Get location and create clock widget */
data->location = jana_ecal_utils_guess_location ();
data->clock = jana_gtk_clock_new ();
jana_gtk_clock_set_draw_shadow (JANA_GTK_CLOCK (data->clock), TRUE);
+ gtk_widget_show (data->clock);
- /* Create viewport for clock/journal/PIM summary widgets */
- viewport = gtk_viewport_new (NULL, NULL);
- scroll = moko_finger_scroll_new ();
- gtk_container_add (GTK_CONTAINER (scroll), viewport);
- gtk_box_pack_start (GTK_BOX (main_vbox), scroll, TRUE, TRUE, 0);
- gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport),
- GTK_SHADOW_NONE);
- gtk_widget_show_all (scroll);
-
/* Pack widgets */
- vbox = gtk_vbox_new (FALSE, 6);
-
- gtk_box_pack_start (GTK_BOX (vbox), data->clock, TRUE, TRUE, 0);
- gtk_widget_show_all (data->clock);
-
+ align = gtk_alignment_new (0.5, 0, 1, 0);
data->message_box = today_pim_journal_box_new (data);
- gtk_box_pack_start (GTK_BOX (vbox), data->message_box, FALSE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (align), data->message_box);
+ gtk_widget_set_app_paintable (align, TRUE);
+ g_signal_connect (align, "expose-event",
+ G_CALLBACK (bg_child_expose_cb), data);
gtk_widget_show (data->message_box);
+ gtk_widget_show (align);
- data->summary_box = today_pim_summary_box_new (data);
- gtk_box_pack_start (GTK_BOX (vbox), data->summary_box, FALSE, TRUE, 6);
- gtk_widget_show (data->summary_box);
-
- align = gtk_alignment_new (0.5, 0.5, 1, 1);
+ vbox = gtk_vbox_new (FALSE, 6);
gtk_alignment_set_padding (GTK_ALIGNMENT (align), 6, 6, 6, 6);
- gtk_container_add (GTK_CONTAINER (viewport), data->bg_ebox);
- gtk_container_add (GTK_CONTAINER (data->bg_ebox), align);
- gtk_container_add (GTK_CONTAINER (align), vbox);
- gtk_widget_show_all (data->bg_ebox);
+ gtk_box_pack_start (GTK_BOX (vbox), data->clock, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (data->bg_ebox), vbox);
+ gtk_widget_show (vbox);
/* Set the time on the clock */
set_time_idle (data);
@@ -272,6 +318,22 @@
gconf_value_get_bool (value));
}
+static void
+location_notify (GConfClient *client, guint cnxn_id,
+ GConfEntry *entry, TodayData *data)
+{
+ GConfValue *value;
+
+ value = gconf_entry_get_value (entry);
+ if (value) {
+ const gchar *location = gconf_value_get_string (value);
+ if (location) {
+ g_free (data->location);
+ data->location = g_strdup (location);
+ }
+ }
+}
+
int
main (int argc, char **argv)
{
@@ -300,7 +362,7 @@
/* Create widgets */
data.window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title (GTK_WINDOW (data.window), _("Today"));
+ gtk_window_set_title (GTK_WINDOW (data.window), _("Home"));
/* Notebook */
data.notebook = gtk_notebook_new ();
@@ -330,7 +392,7 @@
g_signal_connect (G_OBJECT (data.window), "delete-event",
G_CALLBACK (gtk_main_quit), NULL);
-#if 0
+#if 1
/* Force theme settings */
g_object_set (gtk_settings_get_default (),
"gtk-theme-name", "openmoko-standard-2", /* Moko */
@@ -358,6 +420,12 @@
/* Listen to wallpaper setting */
gconf_client_add_dir (gconf_client_get_default (),
+ JANA_ECAL_LOCATION_KEY_DIR, GCONF_CLIENT_PRELOAD_NONE, NULL);
+ gconf_client_notify_add (gconf_client_get_default (),
+ JANA_ECAL_LOCATION_KEY,
+ (GConfClientNotifyFunc)location_notify,
+ &data, NULL, NULL);
+ gconf_client_add_dir (gconf_client_get_default (),
GCONF_POKY_INTERFACE_PREFIX, GCONF_CLIENT_PRELOAD_NONE, NULL);
gconf_client_notify_add (gconf_client_get_default (),
GCONF_POKY_INTERFACE_PREFIX GCONF_POKY_WALLPAPER,
Modified: trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-journal.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-journal.c 2007-10-25 16:57:18 UTC (rev 3272)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-journal.c 2007-10-25 17:00:13 UTC (rev 3273)
@@ -2,40 +2,94 @@
#include <glib/gi18n.h>
#include <moko-stock.h>
#include <libtaku/launcher-util.h>
+#include <libjana/jana.h>
+#include <libjana-ecal/jana-ecal.h>
+#include <libjana-gtk/jana-gtk.h>
+#include "today-tasks-store.h"
#include "today-utils.h"
#include "today-pim-journal.h"
-enum {
- COLUMN_ICON,
- COLUMN_TEXT,
- COLUMN_LAST
-};
-
static void
today_pim_journal_update_messages (TodayData *data)
{
- gchar *message;
+ gchar *message = NULL;
+ gint n_tasks = 0;
- if (data->n_unread_messages > 0)
- message = g_strdup_printf (_("%d new messages"),
+ /* Missed calls */
+ if (data->n_missed_calls > 0) {
+ message = g_strdup_printf (_("%d missed call(s)"),
+ data->n_missed_calls);
+ }
+
+ if (message) {
+ gtk_label_set_text (GTK_LABEL (
+ data->missed_calls_label), message);
+ gtk_widget_show (data->missed_calls_box);
+ g_free (message);
+ message = NULL;
+ } else
+ gtk_widget_hide (data->missed_calls_box);
+
+ /* Unread messages */
+ if (data->n_unread_messages > 0) {
+ message = g_strdup_printf (_("%d new message(s)"),
data->n_unread_messages);
- else
- message = g_strdup_printf (_("No new messages"));
+ }
- gtk_list_store_set (GTK_LIST_STORE (data->journal_model),
- &data->unread_messages, COLUMN_TEXT,
- message, -1);
- g_free (message);
+ if (message) {
+ gtk_label_set_text (GTK_LABEL (
+ data->unread_messages_label), message);
+ gtk_widget_show (data->unread_messages_box);
+ g_free (message);
+ } else {
+ gtk_widget_hide (data->unread_messages_box);
+ }
+
+ /* Upcoming events */
+ if (data->dates_model &&
+ gtk_tree_model_iter_n_children (data->dates_model, NULL) > 0) {
+ GtkTreeIter iter;
+ JanaTime *start;
+ gchar *summary;
+
+ /* Set the label from the first event in the model */
+ gtk_tree_model_get_iter_first (data->dates_model, &iter);
+ gtk_tree_model_get (data->dates_model, &iter,
+ JANA_GTK_EVENT_STORE_COL_SUMMARY, &summary,
+ JANA_GTK_EVENT_STORE_COL_START, &start, -1);
+
+ message = g_strdup_printf ("(%02d:%02d) %s",
+ jana_time_get_hours (start),
+ jana_time_get_minutes (start),
+ summary);
+ gtk_label_set_text (GTK_LABEL (data->dates_label), message);
+ gtk_widget_show (data->dates_box);
- if (data->n_missed_calls > 0)
- message = g_strdup_printf (_("%d missed calls"),
- data->n_missed_calls);
- else
- message = g_strdup_printf (_("No missed calls"));
- gtk_list_store_set (GTK_LIST_STORE (data->journal_model),
- &data->missed_calls, COLUMN_TEXT,
- message, -1);
- g_free (message);
+ g_free (summary);
+ g_free (message);
+ g_object_unref (start);
+ } else
+ gtk_widget_hide (data->dates_box);
+
+ /* Uncompleted tasks */
+ if (gtk_tree_model_iter_n_children (data->tasks_store, NULL) > 0) {
+ GtkTreeIter iter;
+
+ gtk_tree_model_get_iter_first (data->tasks_store, &iter);
+ do {
+ gboolean complete;
+ gtk_tree_model_get (data->tasks_store, &iter,
+ COLUMN_DONE, &complete, -1);
+ if (!complete) n_tasks++;
+ } while (gtk_tree_model_iter_next (data->tasks_store, &iter));
+ }
+ if (n_tasks > 0) {
+ message = g_strdup_printf (_("%d incomplete task(s)"), n_tasks);
+ gtk_label_set_text (GTK_LABEL (data->tasks_label), message);
+ g_free (message);
+ gtk_widget_show (data->tasks_box);
+ } else
+ gtk_widget_hide (data->tasks_box);
}
static void
@@ -83,97 +137,235 @@
}
static void
-today_pim_journal_header_clicked_cb (GtkTreeViewColumn *column, TodayData *data)
+header_clicked_cb (GtkWidget *button, TodayData *data)
{
- /* TODO: Maybe just launch dialer normally here? */
- launcher_start (data->window, today_get_launcher ((const gchar *[])
- { "openmoko-dialer", "-m", NULL }, TRUE, TRUE));
+ launcher_start (data->window, today_get_launcher (
+ (const gchar *[]){ "openmoko-worldclock", NULL, NULL },
+ TRUE, TRUE));
}
-static void
+/*static void
today_pim_journal_selection_changed_cb (GtkTreeSelection *selection,
TodayData *data)
{
- if (gtk_tree_selection_count_selected_rows (selection)) {
+ if ((data->n_missed_calls > 0) &&
+ gtk_tree_selection_count_selected_rows (selection)) {
gtk_tree_selection_unselect_all (selection);
launcher_start (data->window, today_get_launcher (
(const gchar *[]){ "openmoko-dialer", "-m", NULL },
- TRUE, TRUE));
+ TRUE, FALSE));
}
+}*/
+
+static gboolean
+missed_calls_button_press_cb (GtkWidget *widget, GdkEventButton *event,
+ TodayData *data)
+{
+ launcher_start (data->window, today_get_launcher (
+ (const gchar *[]){ "openmoko-dialer", "-m", NULL },
+ TRUE, FALSE));
+
+ return FALSE;
}
-GtkWidget *
-today_pim_journal_box_new (TodayData *data)
+static gboolean
+unread_messages_button_press_cb (GtkWidget *widget, GdkEventButton *event,
+ TodayData *data)
{
- GtkWidget *treeview;
- GtkCellRenderer *text_renderer, *pixbuf_renderer;
- GtkTreeViewColumn *column;
+ /*launcher_start (data->window, today_get_launcher (
+ (const gchar *[]){ "openmoko-dialer", "-m", NULL },
+ TRUE, FALSE));*/
+ g_debug ("TODO: Launch messages app");
+
+ return FALSE;
+}
+
+static gboolean
+tasks_button_press_cb (GtkWidget *widget, GdkEventButton *event,
+ TodayData *data)
+{
+ launcher_start (data->window, today_get_launcher (
+ (const gchar *[]){ "tasks", NULL, NULL },
+ TRUE, FALSE));
+
+ return FALSE;
+}
+
+static gboolean
+dates_button_press_cb (GtkWidget *widget, GdkEventButton *event,
+ TodayData *data)
+{
+ launcher_start (data->window, today_get_launcher (
+ (const gchar *[]){ "openmoko-dates", NULL, NULL },
+ TRUE, FALSE));
+
+ return FALSE;
+}
+
+static void
+store_opened_cb (JanaStore *store, TodayData *data)
+{
+ JanaTime *start, *end;
- data->journal_model = gtk_list_store_new (COLUMN_LAST,
- G_TYPE_STRING, G_TYPE_STRING);
+ start = jana_ecal_utils_time_now (data->location);
+ end = jana_time_duplicate (start);
+ jana_time_set_day (end, jana_time_get_day (end) + 1);
+ jana_time_set_isdate (end, TRUE);
- gtk_list_store_insert_with_values (data->journal_model,
- &data->missed_calls,
- 0, COLUMN_ICON, MOKO_STOCK_CALL_MISSED,
- COLUMN_TEXT, _("No missed calls"), -1);
+ data->dates_view = jana_store_get_view (store);
+ jana_store_view_set_range (data->dates_view, start, end);
+
+ data->dates_model = GTK_TREE_MODEL (
+ jana_gtk_event_store_new_full (data->dates_view,
+ jana_time_get_offset (start)));
+
+ g_object_unref (start);
+ g_object_unref (end);
+
+ g_signal_connect_swapped (data->dates_model, "row-inserted",
+ G_CALLBACK (today_pim_journal_update_messages), data);
+ g_signal_connect_swapped (data->dates_model, "row-changed",
+ G_CALLBACK (today_pim_journal_update_messages), data);
+ g_signal_connect_swapped (data->dates_model, "row-deleted",
+ G_CALLBACK (today_pim_journal_update_messages), data);
+
+ jana_store_view_start (data->dates_view);
+}
- gtk_list_store_insert_with_values (data->journal_model,
- &data->unread_messages,
- 1, COLUMN_ICON, "openmoko-messages",
- COLUMN_TEXT, _("No new messages"), -1);
+GtkWidget *
+today_pim_journal_box_new (TodayData *data)
+{
+ JanaStore *store;
+ MokoJournal *journal;
+ GtkWidget *vbox, *hbox, *image;
- treeview = gtk_tree_view_new_with_model (
- GTK_TREE_MODEL (data->journal_model));
- gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), FALSE);
+ data->date_button = gtk_button_new_with_label ("");
- text_renderer = gtk_cell_renderer_text_new ();
- pixbuf_renderer = gtk_cell_renderer_pixbuf_new ();
+ /* Missed calls box */
+ data->missed_calls_box = gtk_event_box_new ();
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (
+ data->missed_calls_box), FALSE);
+ hbox = gtk_hbox_new (FALSE, 6);
+ image = gtk_image_new_from_stock (
+ MOKO_STOCK_CALL_MISSED, GTK_ICON_SIZE_LARGE_TOOLBAR);
+ data->missed_calls_label = gtk_label_new ("");
+ gtk_misc_set_alignment (GTK_MISC (data->missed_calls_label), 0, 0.5);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
+ gtk_box_pack_end (GTK_BOX (hbox),
+ data->missed_calls_label, TRUE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (data->missed_calls_box), hbox);
+ gtk_widget_add_events (data->missed_calls_box, GDK_BUTTON_PRESS_MASK);
+ g_signal_connect (data->missed_calls_box, "button-press-event",
+ G_CALLBACK (missed_calls_button_press_cb), data);
- column = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (column, "OpenMoko");
+ /* Unread messages box */
+ data->unread_messages_box = gtk_event_box_new ();
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (
+ data->unread_messages_box), FALSE);
+ hbox = gtk_hbox_new (FALSE, 6);
+ image = gtk_image_new_from_icon_name (
+ "openmoko-messages", GTK_ICON_SIZE_LARGE_TOOLBAR);
+ data->unread_messages_label = gtk_label_new ("");
+ gtk_misc_set_alignment (GTK_MISC (data->unread_messages_label), 0, 0.5);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
+ gtk_box_pack_end (GTK_BOX (hbox),
+ data->unread_messages_label, TRUE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (data->unread_messages_box), hbox);
+ gtk_widget_add_events (data->unread_messages_box,
+ GDK_BUTTON_PRESS_MASK);
+ g_signal_connect (data->missed_calls_box, "button-press-event",
+ G_CALLBACK (unread_messages_button_press_cb), data);
- gtk_tree_view_column_pack_start (column,
- pixbuf_renderer, FALSE);
- gtk_tree_view_column_pack_end (column,
- text_renderer, TRUE);
+ /* Events box */
+ data->dates_box = gtk_event_box_new ();
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (
+ data->dates_box), FALSE);
+ hbox = gtk_hbox_new (FALSE, 6);
+ image = gtk_image_new_from_icon_name (
+ "dates", GTK_ICON_SIZE_LARGE_TOOLBAR);
+ data->dates_label = gtk_label_new ("");
+ gtk_misc_set_alignment (GTK_MISC (data->dates_label), 0, 0.5);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
+ gtk_box_pack_end (GTK_BOX (hbox),
+ data->dates_label, TRUE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (data->dates_box), hbox);
+ gtk_widget_add_events (data->dates_box,
+ GDK_BUTTON_PRESS_MASK);
+ g_signal_connect (data->dates_box, "button-press-event",
+ G_CALLBACK (dates_button_press_cb), data);
- gtk_tree_view_column_add_attribute (column, pixbuf_renderer,
- "icon-name", COLUMN_ICON);
- gtk_tree_view_column_add_attribute (column, text_renderer,
- "text", COLUMN_TEXT);
+ /* Tasks box */
+ data->tasks_box = gtk_event_box_new ();
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (
+ data->tasks_box), FALSE);
+ hbox = gtk_hbox_new (FALSE, 6);
+ image = gtk_image_new_from_icon_name (
+ "tasks", GTK_ICON_SIZE_LARGE_TOOLBAR);
+ data->tasks_label = gtk_label_new ("");
+ gtk_misc_set_alignment (GTK_MISC (data->tasks_label), 0, 0.5);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
+ gtk_box_pack_end (GTK_BOX (hbox),
+ data->tasks_label, TRUE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (data->tasks_box), hbox);
+ gtk_widget_add_events (data->tasks_box,
+ GDK_BUTTON_PRESS_MASK);
+ g_signal_connect (data->tasks_box, "button-press-event",
+ G_CALLBACK (tasks_button_press_cb), data);
- gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
-
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), TRUE);
- gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (treeview), TRUE);
+ g_signal_connect (data->date_button, "clicked",
+ G_CALLBACK (header_clicked_cb), data);
- g_signal_connect (G_OBJECT (column), "clicked",
- G_CALLBACK (today_pim_journal_header_clicked_cb), data);
- g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)),
- "changed", G_CALLBACK (today_pim_journal_selection_changed_cb),
- data);
+ /* Pack widgets */
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (vbox), data->date_button, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox),
+ data->missed_calls_box, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox),
+ data->unread_messages_box, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox),
+ data->dates_box, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox),
+ data->tasks_box, FALSE, TRUE, 0);
+ gtk_widget_show_all (vbox);
/* Open up journal and connect to signals to find out about missed
* calls and new messages.
- * TODO: Revise this when libmokojournal has support for 'new' missed
- * calls and changes.
*/
data->n_missed_calls = 0;
data->n_unread_messages = 0;
- data->journal = moko_journal_open_default ();
+ data->dates_view = NULL;
+ data->dates_model = NULL;
+ journal = moko_journal_open_default ();
- if (data->journal)
- {
- g_signal_connect (G_OBJECT (data->journal), "entry_added",
- G_CALLBACK (today_pim_journal_entry_added_cb), data);
- g_signal_connect (G_OBJECT (data->journal), "entry_removed",
- G_CALLBACK (today_pim_journal_entry_removed_cb), data);
- moko_journal_load_from_storage (data->journal);
- }
- else
- {
- g_warning ("Could not load journal");
+ if (journal) {
+ g_signal_connect (G_OBJECT (journal), "entry_added",
+ G_CALLBACK (today_pim_journal_entry_added_cb), data);
+ g_signal_connect (G_OBJECT (journal), "entry_removed",
+ G_CALLBACK (today_pim_journal_entry_removed_cb), data);
+ } else {
+ g_warning ("Could not load journal");
}
+
+ /* Open up calendar store */
+ store = jana_ecal_store_new (JANA_COMPONENT_EVENT);
+ g_signal_connect (store, "opened",
+ G_CALLBACK (store_opened_cb), data);
+ jana_store_open (store);
+
+ /* Create tasks store */
+ data->tasks_store = GTK_TREE_MODEL (today_tasks_store_new ());
+ g_signal_connect_swapped (data->tasks_store, "row-inserted",
+ G_CALLBACK (today_pim_journal_update_messages), data);
+ g_signal_connect_swapped (data->tasks_store, "row-changed",
+ G_CALLBACK (today_pim_journal_update_messages), data);
+ g_signal_connect_swapped (data->tasks_store, "row-deleted",
+ G_CALLBACK (today_pim_journal_update_messages), data);
- return treeview;
+ /* Start up journal */
+ if (journal) moko_journal_load_from_storage (journal);
+
+ /* Update labels */
+ today_pim_journal_update_messages (data);
+
+ return vbox;
}
Deleted: trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-summary.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-summary.c 2007-10-25 16:57:18 UTC (rev 3272)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-summary.c 2007-10-25 17:00:13 UTC (rev 3273)
@@ -1,212 +0,0 @@
-
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-#include <libkoto/koto-task.h>
-#include <libkoto/koto-task-view.h>
-#include <libtaku/launcher-util.h>
-#include "today-utils.h"
-#include "today-pim-summary.h"
-#include "today-events-store.h"
-#include "today-tasks-store.h"
-#include "today.h"
-
-/**
- * today_update_date ()
- *
- * Update the specified GtkTreeViewColumn with the current date
- */
-static gboolean
-today_pim_summary_update_date (GtkTreeViewColumn *column)
-{
- time_t t;
- struct tm *tmp;
- gchar date_str[64];
-
- time (&t);
- if (!(tmp = localtime (&t))) return TRUE;
-
- strftime (date_str, sizeof (date_str), "%A, %d. %B %Y", tmp);
- gtk_tree_view_column_set_title (column, date_str);
-
- return TRUE;
-}
-
-static gboolean
-today_pim_summary_visible_cb (GtkTreeModel *model, GtkTreeIter *iter,
- gpointer user_data)
-{
- KotoTask *task;
- gboolean done;
-
- gtk_tree_model_get (model, iter, COLUMN_TASK, &task,
- COLUMN_DONE, &done, -1);
-
- if (!done) return TRUE;
-
- if (icaltime_compare (icalcomponent_get_dtstamp (task->comp),
- icaltime_today ()) >= 0) return TRUE;
-
- return FALSE;
-}
-
-static void
-today_pim_summary_show_notice (TodayData *data)
-{
- /* Add notice */
- data->notice_visible = TRUE;
- gtk_list_store_insert_with_values (
- GTK_LIST_STORE (data->events_model),
- &data->notice, 0,
- TODAY_EVENTS_STORE_COL_COMP, NULL,
- TODAY_EVENTS_STORE_COL_UID, NULL,
- TODAY_EVENTS_STORE_COL_SUMMARY,
- _("No pending events or tasks"),
- -1);
-}
-
-static void
-today_pim_summary_row_inserted_cb (GtkTreeModel *tree_model,
- GtkTreePath *path, GtkTreeIter *iter,
- gpointer user_data)
-{
- TodayData *data = (TodayData *)user_data;
- data->rows ++;
- if ((data->notice_visible) && (data->rows == 2)) {
- /* Remove notice */
- data->notice_visible = FALSE;
- gtk_list_store_remove (GTK_LIST_STORE (data->events_model),
- &data->notice);
- }
-}
-
-static void
-today_pim_summary_row_deleted_cb (GtkTreeModel *tree_model,
- GtkTreePath *path, gpointer user_data)
-{
- TodayData *data = (TodayData *)user_data;
- data->rows --;
- if ((data->rows < 1) && (!data->notice_visible)) {
- today_pim_summary_show_notice (data);
- }
-}
-
-static void
-today_pim_summary_cell_data_cb (GtkTreeViewColumn *tree_column,
- GtkCellRenderer *cell, GtkTreeModel *tree_model,
- GtkTreeIter *iter, gpointer user_data)
-{
- gboolean done;
- gchar *summary;
-
- gtk_tree_model_get (tree_model, iter, COLUMN_DONE, &done,
- COLUMN_SUMMARY, &summary, -1);
-
- g_object_set (G_OBJECT (cell), "text", summary,
- "strikethrough", done, NULL);
-}
-
-static void
-today_pim_summary_header_clicked_cb (GtkTreeViewColumn *column, TodayData *data)
-{
- g_debug ("TODO: App to set time/date");
-}
-
-static void
-today_pim_summary_events_selection_changed_cb (GtkTreeSelection *selection,
- TodayData *data)
-{
- if (gtk_tree_selection_count_selected_rows (selection)) {
- gtk_tree_selection_unselect_all (selection);
- launcher_start (data->window, today_get_launcher (
- (const gchar *[]){ "openmoko-dates", NULL },
- TRUE, TRUE));
- }
-}
-
-static void
-today_pim_summary_tasks_selection_changed_cb (GtkTreeSelection *selection,
- TodayData *data)
-{
- if (gtk_tree_selection_count_selected_rows (selection)) {
- gtk_tree_selection_unselect_all (selection);
- launcher_start (data->window, today_get_launcher (
- (const gchar *[]){ "tasks", NULL },
- TRUE, TRUE));
- }
-}
-
-GtkWidget *
-today_pim_summary_box_new (TodayData *data)
-{
- GtkTreeModel *tasks_model;
- GtkWidget *vbox, *events_tree, *tasks_tree;
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
-
- data->rows = 0;
- data->events_model = GTK_TREE_MODEL (today_events_store_new ());
- tasks_model = GTK_TREE_MODEL (today_tasks_store_new ());
- data->tasks_model = gtk_tree_model_filter_new (tasks_model, NULL);
- events_tree = gtk_tree_view_new_with_model (data->events_model);
- tasks_tree = gtk_tree_view_new_with_model (data->tasks_model);
- gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (events_tree), FALSE);
- gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tasks_tree), FALSE);
- gtk_widget_show (events_tree);
- gtk_widget_show (tasks_tree);
-
- gtk_tree_model_filter_set_visible_func (
- GTK_TREE_MODEL_FILTER (data->tasks_model),
- today_pim_summary_visible_cb, NULL, NULL);
-
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer),
- "ellipsize", PANGO_ELLIPSIZE_END, NULL);
- column = gtk_tree_view_column_new_with_attributes ("Tasks",
- renderer, "text", COLUMN_SUMMARY, NULL);
- gtk_tree_view_insert_column (GTK_TREE_VIEW (tasks_tree),
- column, 0);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tasks_tree),
- FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer,
- today_pim_summary_cell_data_cb,
- GTK_TREE_VIEW (tasks_tree), NULL);
-
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer),
- "ellipsize", PANGO_ELLIPSIZE_END, NULL);
- column = gtk_tree_view_column_new_with_attributes ("Events",
- renderer, "text", TODAY_EVENTS_STORE_COL_SUMMARY, NULL);
- gtk_tree_view_insert_column (GTK_TREE_VIEW (events_tree), column, 0);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (events_tree), TRUE);
- gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (events_tree), TRUE);
-
- today_pim_summary_update_date (column);
- g_timeout_add (60 * 1000, (GSourceFunc)
- today_pim_summary_update_date, column);
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), events_tree, FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), tasks_tree, FALSE, TRUE, 0);
-
- g_signal_connect (G_OBJECT (data->events_model), "row-inserted",
- G_CALLBACK (today_pim_summary_row_inserted_cb), data);
- g_signal_connect (G_OBJECT (tasks_model), "row-inserted",
- G_CALLBACK (today_pim_summary_row_inserted_cb), data);
- g_signal_connect (G_OBJECT (data->events_model), "row-deleted",
- G_CALLBACK (today_pim_summary_row_deleted_cb), data);
- g_signal_connect (G_OBJECT (tasks_model), "row-deleted",
- G_CALLBACK (today_pim_summary_row_deleted_cb), data);
-
- g_signal_connect (G_OBJECT (column), "clicked",
- G_CALLBACK (today_pim_summary_header_clicked_cb), data);
- g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (
- GTK_TREE_VIEW (events_tree))), "changed", G_CALLBACK (
- today_pim_summary_events_selection_changed_cb), data);
- g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (
- GTK_TREE_VIEW (tasks_tree))), "changed", G_CALLBACK (
- today_pim_summary_tasks_selection_changed_cb), data);
-
- today_pim_summary_show_notice (data);
-
- return vbox;
-}
Deleted: trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-summary.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-summary.h 2007-10-25 16:57:18 UTC (rev 3272)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-summary.h 2007-10-25 17:00:13 UTC (rev 3273)
@@ -1,10 +0,0 @@
-
-#ifndef TODAY_PIM_SUMMARY_H
-#define TODAY_PIM_SUMMARY_H
-
-#include <gtk/gtk.h>
-#include "today.h"
-
-GtkWidget *today_pim_summary_box_new (TodayData *data);
-
-#endif
Modified: trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today.h 2007-10-25 16:57:18 UTC (rev 3272)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today.h 2007-10-25 17:00:13 UTC (rev 3273)
@@ -5,6 +5,7 @@
#include <gtk/gtk.h>
#include <libtaku/taku-launcher-tile.h>
#include <moko-journal.h>
+#include <libjana/jana.h>
#define GCONF_POKY_INTERFACE_PREFIX "/desktop/poky/interface"
#define GCONF_POKY_WALLPAPER "/wallpaper"
@@ -26,18 +27,20 @@
GdkPixmap *wallpaper;
gchar *location;
- GtkTreeModel *events_model;
- GtkTreeModel *tasks_model;
- GtkTreeIter notice;
- gboolean notice_visible;
- int rows;
-
- MokoJournal *journal;
- GtkListStore *journal_model;
- GtkTreeIter missed_calls;
+ GtkWidget *date_button;
+ GtkWidget *missed_calls_box;
+ GtkWidget *missed_calls_label;
gint n_missed_calls;
- GtkTreeIter unread_messages;
+ GtkWidget *unread_messages_box;
+ GtkWidget *unread_messages_label;
gint n_unread_messages;
+ JanaStoreView *dates_view;
+ GtkTreeModel *dates_model;
+ GtkWidget *dates_box;
+ GtkWidget *dates_label;
+ GtkTreeModel *tasks_store;
+ GtkWidget *tasks_box;
+ GtkWidget *tasks_label;
/* App launcher */
GList *categories;
More information about the commitlog
mailing list