r2622 - in trunk/src/target/OM-2007.2/applications/openmoko-today2: . libtaku src
chris at sita.openmoko.org
chris at sita.openmoko.org
Fri Aug 3 16:08:50 CEST 2007
Author: chris
Date: 2007-08-03 16:08:48 +0200 (Fri, 03 Aug 2007)
New Revision: 2622
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-today2/ChangeLog
trunk/src/target/OM-2007.2/applications/openmoko-today2/libtaku/launcher-util.c
trunk/src/target/OM-2007.2/applications/openmoko-today2/libtaku/launcher-util.h
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-pim-summary.c
trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-utils.c
trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-utils.h
Log:
Launch the appropriate apps when clicking the summaries on the home page
Modified: trunk/src/target/OM-2007.2/applications/openmoko-today2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-today2/ChangeLog 2007-08-03 13:43:10 UTC (rev 2621)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/ChangeLog 2007-08-03 14:08:48 UTC (rev 2622)
@@ -1,5 +1,28 @@
2007-08-03 Chris Lord,,, <chris at openedhand.com>
+ * libtaku/launcher-util.c: (launcher_start):
+ * libtaku/launcher-util.h:
+ Make the LauncherData const, it isn't changed
+
+ * src/today-main.c: (today_dial_button_clicked_cb),
+ (today_contacts_button_clicked_cb),
+ (today_messages_button_clicked_cb),
+ (today_dates_button_clicked_cb), (main):
+ * src/today-pim-journal.c: (today_pim_journal_header_clicked_cb),
+ (today_pim_journal_selection_changed_cb),
+ (today_pim_journal_box_new):
+ * src/today-pim-summary.c: (today_pim_summary_header_clicked_cb),
+ (today_pim_summary_events_selection_changed_cb),
+ (today_pim_summary_tasks_selection_changed_cb),
+ (today_pim_summary_box_new):
+ Launch the appropriate apps when clicking the summaries on the home page
+
+ * src/today-utils.c: (today_get_launcher):
+ * src/today-utils.h:
+ Make a global LauncherData filling convenience function
+
+2007-08-03 Chris Lord,,, <chris at openedhand.com>
+
* libtaku/taku-launcher-tile.c: (taku_launcher_tile_finalize),
(reset_state), (taku_launcher_tile_clicked),
(taku_launcher_tile_for_desktop_file),
Modified: trunk/src/target/OM-2007.2/applications/openmoko-today2/libtaku/launcher-util.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-today2/libtaku/launcher-util.c 2007-08-03 13:43:10 UTC (rev 2621)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/libtaku/launcher-util.c 2007-08-03 14:08:48 UTC (rev 2622)
@@ -289,7 +289,7 @@
/* TODO: optionally link to GtkUnique and directly handle that? */
void
-launcher_start (GtkWidget *widget, LauncherData *data)
+launcher_start (GtkWidget *widget, const LauncherData *data)
{
GError *error = NULL;
#ifdef USE_LIBSN
Modified: trunk/src/target/OM-2007.2/applications/openmoko-today2/libtaku/launcher-util.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-today2/libtaku/launcher-util.h 2007-08-03 13:43:10 UTC (rev 2621)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/libtaku/launcher-util.h 2007-08-03 14:08:48 UTC (rev 2622)
@@ -16,6 +16,9 @@
* Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#ifndef HAVE_LAUNCHER_UTIL_H
+#define HAVE_LAUNCHER_UTIL_H
+
#include <glib.h>
#include <gtk/gtkicontheme.h>
#include <gtk/gtkwidget.h>
@@ -36,8 +39,10 @@
LauncherData *launcher_parse_desktop_file (const char *filename, GError **error);
-void launcher_start (GtkWidget *widget, LauncherData *data);
+void launcher_start (GtkWidget *widget, const LauncherData *data);
char * launcher_get_icon (GtkIconTheme *icon_theme, LauncherData *data, int size);
void launcher_destroy (LauncherData *data);
+
+#endif
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-08-03 13:43:10 UTC (rev 2621)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-main.c 2007-08-03 14:08:48 UTC (rev 2622)
@@ -32,47 +32,32 @@
"tab-expand", TRUE, NULL);
}
-/* TODO: Make this less nasty */
-static LauncherData launcher_data;
static void
-today_fill_launcher (const gchar *exec, gboolean use_sn, gboolean single)
-{
- if (launcher_data.argv) g_free (launcher_data.argv);
- launcher_data.argv = exec_to_argv (exec);
- launcher_data.name = (gchar *)exec;
- launcher_data.description = "";
- launcher_data.icon = NULL;
- launcher_data.categories = (char *[]){ "" };
- launcher_data.use_sn = use_sn;
- launcher_data.single_instance = single;
-}
-
-static void
today_dial_button_clicked_cb (GtkToolButton *button, TodayData *data)
{
- today_fill_launcher ("openmoko-dialer", TRUE, TRUE);
- launcher_start (data->window, &launcher_data);
+ launcher_start (data->window, today_get_launcher (
+ "openmoko-dialer -s", TRUE, TRUE));
}
static void
today_contacts_button_clicked_cb (GtkToolButton *button, TodayData *data)
{
- today_fill_launcher ("openmoko-contacts", TRUE, TRUE);
- launcher_start (data->window, &launcher_data);
+ launcher_start (data->window, today_get_launcher (
+ "openmoko-contacts", TRUE, TRUE));
}
static void
today_messages_button_clicked_cb (GtkToolButton *button, TodayData *data)
{
- today_fill_launcher ("openmoko-messages", TRUE, TRUE);
- launcher_start (data->window, &launcher_data);
+ launcher_start (data->window, today_get_launcher (
+ "openmoko-messages", TRUE, TRUE));
}
static void
today_dates_button_clicked_cb (GtkToolButton *button, TodayData *data)
{
- today_fill_launcher ("dates", TRUE, TRUE);
- launcher_start (data->window, &launcher_data);
+ launcher_start (data->window, today_get_launcher (
+ "dates", TRUE, TRUE));
}
static GtkWidget *
@@ -220,8 +205,6 @@
}
#endif
- launcher_data.argv = NULL;
-
/* Show and start */
gtk_widget_show (data.window);
gtk_main ();
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-08-03 13:43:10 UTC (rev 2621)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-journal.c 2007-08-03 14:08:48 UTC (rev 2622)
@@ -1,7 +1,9 @@
-#include "today-pim-journal.h"
#include <glib/gi18n.h>
#include <moko-stock.h>
+#include <libtaku/launcher-util.h>
+#include "today-utils.h"
+#include "today-pim-journal.h"
enum {
COLUMN_ICON,
@@ -76,6 +78,25 @@
}
}
+static void
+today_pim_journal_header_clicked_cb (GtkTreeViewColumn *column, TodayData *data)
+{
+ /* TODO: Maybe just launch dialer normally here? */
+ launcher_start (data->window, today_get_launcher (
+ "openmoko-dialer -m", TRUE, TRUE));
+}
+
+static void
+today_pim_journal_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 (
+ "openmoko-dialer -m", TRUE, TRUE));
+ }
+}
+
GtkWidget *
today_pim_journal_box_new (TodayData *data)
{
@@ -119,7 +140,14 @@
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 (G_OBJECT (column), "clicked",
+ G_CALLBACK (today_pim_journal_header_clicked_cb), data);
+ g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (treeview)),
+ "changed", G_CALLBACK (today_pim_journal_selection_changed_cb),
+ data);
+
/* 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
Modified: 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-08-03 13:43:10 UTC (rev 2621)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-summary.c 2007-08-03 14:08:48 UTC (rev 2622)
@@ -3,6 +3,8 @@
#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"
@@ -104,6 +106,34 @@
"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 (
+ "openmoko-contacts", 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 (
+ "openmoko-tasks", TRUE, TRUE));
+ }
+}
+
GtkWidget *
today_pim_summary_box_new (TodayData *data)
{
@@ -147,6 +177,7 @@
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)
@@ -165,6 +196,15 @@
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;
Modified: trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-utils.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-utils.c 2007-08-03 13:43:10 UTC (rev 2621)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-utils.c 2007-08-03 14:08:48 UTC (rev 2622)
@@ -21,224 +21,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-/**
- * e_cal_component_list_free:
- * @list: the list ECalComooment to free
- *
- * Free a list of ECalComponent
- */
#include <string.h>
+#include <gtk/gtk.h>
+#include <libtaku/launcher-util.h>
#include "today-utils.h"
-#include <libical/icalcomponent.h>
-#define LOG_ERROR \
-g_warning ("Got error '%s', code '%d'", \
- error->message, error->code);
-
-#define FREE_ERROR g_error_free (error) ; error = NULL ;
-
-static ECal *calendar_db = NULL;
-static ECal *tasks_db = NULL;
-
-void
-e_cal_component_list_free (GList * list)
-{
- GList *cur = NULL;
-
- for (cur = list; cur; cur = cur->next)
- {
- /*if an element of the list is not of type ECalComponent, leak it */
- if (cur->data && E_IS_CAL_COMPONENT (cur->data))
- {
- g_object_unref (G_OBJECT (cur->data));
- cur->data = NULL;
- }
- else
- {
- g_warning ("cur->data is not of type ECalComponent !");
- }
- }
- g_list_free (list);
-}
-
-/*
- * if the timetype is today, then only display it's hour part,
- * without the seconds
- * If it's not today, then only display it's date part, without the year
- */
-gchar*
-icaltime_to_pretty_string (const icaltimetype *timetype)
-{
-#define TMP_STR_LEN 10
- icaltimetype today ;
- gboolean hour_only = FALSE ;
- gboolean date_only = FALSE ;
- gchar *result = NULL ;
- gchar tmp_str[TMP_STR_LEN+1] ;
- struct tm native_tm ;
-
- g_return_val_if_fail (timetype, NULL) ;
-
- today = icaltime_today () ;
- if (!icaltime_compare_date_only (*timetype, today))
- {
- hour_only = TRUE ;
- }
- else
- {
- date_only = TRUE ;
- }
- if (hour_only)
- {
- result = g_strdup_printf ("%d:%d", timetype->hour, timetype->minute) ;
- }
- else if (date_only)
- {
- native_tm = icaltimetype_to_tm ((icaltimetype*)timetype) ;
- memset (tmp_str, 0, TMP_STR_LEN+1) ;
- strftime (tmp_str, TMP_STR_LEN, "%d/%b", &native_tm) ;
- result = g_strdup (tmp_str) ;
- }
- return result ;
-}
-
-GList*
-today_clone_icalcomponent_list (const GList *a_list)
-{
- GList *result=NULL, *cur=NULL ;
-
- for (cur =(GList*)a_list ; cur ; cur = cur->next)
- {
- if (!icalcomponent_isa_component (cur->data))
- continue ;
- result = g_list_prepend (result, icalcomponent_new_clone (cur->data)) ;
- }
- return result ;
-}
-
-/**
- * today_get_today_events:
- *
- * Return value: a list of ECalComponents, of type VEVENT
- * or VTODO
- * must be freed with e_cal_component_list_free()
- */
-GList *
-today_get_today_events ()
-{
- GList *result=NULL, *ical_comps=NULL, *ical_comps2=NULL;
- GError *error = NULL;
- gchar *query = NULL;
-
- if (!calendar_db)
- {
- calendar_db = e_cal_new_system_calendar ();
- g_return_val_if_fail (calendar_db, NULL);
-
- if (!e_cal_open (calendar_db, TRUE, &error))
- {
- g_warning ("failed to open the calendar");
- }
- if (error)
- {
- LOG_ERROR;
- goto out;
- }
- }
-
- /*
- query = g_strdup_printf ("(occur-in-time-range? "
- "(time-day-begin (time-now)) "
- "(time-day-end (time-now)) "
- ")");
- */
- query = g_strdup_printf ("#t");
- e_cal_get_object_list (calendar_db, query, &ical_comps, &error);
- g_free (query) ;
- query = NULL ;
- if (error)
- {
- LOG_ERROR;
- FREE_ERROR;
- }
-
- if (!tasks_db)
- {
- tasks_db = e_cal_new_system_tasks ();
- g_return_val_if_fail (tasks_db, NULL);
- if (!e_cal_open (tasks_db, TRUE, &error))
- {
- g_warning ("failed to open the tasks");
- }
- if (error)
- {
- LOG_ERROR;
- goto out;
- }
- }
-
- query = g_strdup_printf ("#t");
- e_cal_get_object_list (tasks_db, query, &ical_comps2, &error);
- g_free (query) ;
- query = NULL ;
- if (error)
- {
- LOG_ERROR;
- FREE_ERROR ;
- }
- ical_comps = g_list_concat (ical_comps, ical_comps2) ;
-
- result = ical_comps;
- ical_comps = ical_comps2 = NULL;
-
-out:
- if (ical_comps)
- {
- e_cal_free_object_list (ical_comps);
- }
-
- if (ical_comps2)
- {
- e_cal_free_object_list (ical_comps);
- }
-
- /*
- the calender must stay alive during the app's lifetime
- if (ecal)
- {
- g_object_unref (G_OBJECT (ecal));
- }
- */
-
- if (error)
- {
- g_error_free (error);
- }
- if (query)
- {
- g_free (query);
- }
- return result;
-}
-
-gboolean
-icalcomponent_has_alarm (icalcomponent *a_icalcomp)
-{
- icalcompiter iter ;
-
- g_return_val_if_fail (a_icalcomp, FALSE) ;
- g_return_val_if_fail (icalcomponent_isa_component (a_icalcomp), FALSE) ;
-
- for (iter = icalcomponent_begin_component (a_icalcomp,
- ICAL_VALARM_COMPONENT);
- icalcompiter_deref (&iter) != NULL ;
- icalcompiter_next (&iter))
- {
- return TRUE ;
- }
- return FALSE ;
-}
-
GtkToolItem *
today_toolbutton_new (const gchar *icon_name)
{
@@ -248,3 +35,26 @@
gtk_tool_item_set_expand (button, TRUE);
return button;
}
+
+const LauncherData *
+today_get_launcher (const gchar *exec, gboolean use_sn, gboolean single)
+{
+ static LauncherData launcher_data;
+ static gboolean first = TRUE;
+
+ if (first) {
+ launcher_data.argv = NULL;
+ first = FALSE;
+ }
+
+ if (launcher_data.argv) g_free (launcher_data.argv);
+ launcher_data.argv = exec_to_argv (exec);
+ launcher_data.name = (gchar *)exec;
+ launcher_data.description = "";
+ launcher_data.icon = NULL;
+ launcher_data.categories = (char *[]){ "" };
+ launcher_data.use_sn = use_sn;
+ launcher_data.single_instance = single;
+
+ return &launcher_data;
+}
Modified: trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-utils.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-utils.h 2007-08-03 13:43:10 UTC (rev 2621)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-utils.h 2007-08-03 14:08:48 UTC (rev 2622)
@@ -1,4 +1,3 @@
-/* vi: set sw=2: */
/*
* Today - At a glance view of date, time, calender events, todo items and
* other images.
@@ -25,18 +24,11 @@
#define __TODAY_UTILS_H__
#include <glib.h>
-#include <libical/icalcomponent.h>
-#include <libecal/e-cal.h>
-#include <libecal/e-cal-time-util.h>
#include <gtk/gtk.h>
+#include <libtaku/launcher-util.h>
-GList* today_get_today_events () ;
-void e_cal_component_list_free (GList * list) ;
-gchar* icaltime_to_pretty_string (const icaltimetype *timetype) ;
-gboolean icalcomponent_has_alarm (icalcomponent *a_icalcomp) ;
-GList* today_clone_icalcomponent_list (const GList *a_list) ;
-
GtkToolItem *today_toolbutton_new (const gchar *icon_name);
+const LauncherData *today_get_launcher (const gchar *exec, gboolean use_sn,
+ gboolean single);
#endif /*__TODAY_UTILS_H__*/
-
More information about the commitlog
mailing list