Changeset 2622
- Timestamp:
- 08/03/07 16:08:48 (6 years ago)
- Location:
- trunk/src/target/OM-2007.2/applications/openmoko-today2
- Files:
-
- 8 edited
-
ChangeLog (modified) (1 diff)
-
libtaku/launcher-util.c (modified) (1 diff)
-
libtaku/launcher-util.h (modified) (2 diffs)
-
src/today-main.c (modified) (5 diffs)
-
src/today-pim-journal.c (modified) (3 diffs)
-
src/today-pim-summary.c (modified) (4 diffs)
-
src/today-utils.c (modified) (2 diffs)
-
src/today-utils.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/OM-2007.2/applications/openmoko-today2/ChangeLog
r2619 r2622 1 2007-08-03 Chris Lord,,, <chris@openedhand.com> 2 3 * libtaku/launcher-util.c: (launcher_start): 4 * libtaku/launcher-util.h: 5 Make the LauncherData const, it isn't changed 6 7 * src/today-main.c: (today_dial_button_clicked_cb), 8 (today_contacts_button_clicked_cb), 9 (today_messages_button_clicked_cb), 10 (today_dates_button_clicked_cb), (main): 11 * src/today-pim-journal.c: (today_pim_journal_header_clicked_cb), 12 (today_pim_journal_selection_changed_cb), 13 (today_pim_journal_box_new): 14 * src/today-pim-summary.c: (today_pim_summary_header_clicked_cb), 15 (today_pim_summary_events_selection_changed_cb), 16 (today_pim_summary_tasks_selection_changed_cb), 17 (today_pim_summary_box_new): 18 Launch the appropriate apps when clicking the summaries on the home page 19 20 * src/today-utils.c: (today_get_launcher): 21 * src/today-utils.h: 22 Make a global LauncherData filling convenience function 23 1 24 2007-08-03 Chris Lord,,, <chris@openedhand.com> 2 25 -
trunk/src/target/OM-2007.2/applications/openmoko-today2/libtaku/launcher-util.c
r2560 r2622 290 290 /* TODO: optionally link to GtkUnique and directly handle that? */ 291 291 void 292 launcher_start (GtkWidget *widget, LauncherData *data)292 launcher_start (GtkWidget *widget, const LauncherData *data) 293 293 { 294 294 GError *error = NULL; -
trunk/src/target/OM-2007.2/applications/openmoko-today2/libtaku/launcher-util.h
r2504 r2622 16 16 * Place - Suite 330, Boston, MA 02111-1307, USA. 17 17 */ 18 19 #ifndef HAVE_LAUNCHER_UTIL_H 20 #define HAVE_LAUNCHER_UTIL_H 18 21 19 22 #include <glib.h> … … 37 40 LauncherData *launcher_parse_desktop_file (const char *filename, GError **error); 38 41 39 void launcher_start (GtkWidget *widget, LauncherData *data);42 void launcher_start (GtkWidget *widget, const LauncherData *data); 40 43 41 44 char * launcher_get_icon (GtkIconTheme *icon_theme, LauncherData *data, int size); 42 45 43 46 void launcher_destroy (LauncherData *data); 47 48 #endif -
trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-main.c
r2619 r2622 33 33 } 34 34 35 /* TODO: Make this less nasty */36 static LauncherData launcher_data;37 static void38 today_fill_launcher (const gchar *exec, gboolean use_sn, gboolean single)39 {40 if (launcher_data.argv) g_free (launcher_data.argv);41 launcher_data.argv = exec_to_argv (exec);42 launcher_data.name = (gchar *)exec;43 launcher_data.description = "";44 launcher_data.icon = NULL;45 launcher_data.categories = (char *[]){ "" };46 launcher_data.use_sn = use_sn;47 launcher_data.single_instance = single;48 }49 50 35 static void 51 36 today_dial_button_clicked_cb (GtkToolButton *button, TodayData *data) 52 37 { 53 today_fill_launcher ("openmoko-dialer", TRUE, TRUE);54 launcher_start (data->window, &launcher_data);38 launcher_start (data->window, today_get_launcher ( 39 "openmoko-dialer -s", TRUE, TRUE)); 55 40 } 56 41 … … 58 43 today_contacts_button_clicked_cb (GtkToolButton *button, TodayData *data) 59 44 { 60 today_fill_launcher ("openmoko-contacts", TRUE, TRUE);61 launcher_start (data->window, &launcher_data);45 launcher_start (data->window, today_get_launcher ( 46 "openmoko-contacts", TRUE, TRUE)); 62 47 } 63 48 … … 65 50 today_messages_button_clicked_cb (GtkToolButton *button, TodayData *data) 66 51 { 67 today_fill_launcher ("openmoko-messages", TRUE, TRUE);68 launcher_start (data->window, &launcher_data);52 launcher_start (data->window, today_get_launcher ( 53 "openmoko-messages", TRUE, TRUE)); 69 54 } 70 55 … … 72 57 today_dates_button_clicked_cb (GtkToolButton *button, TodayData *data) 73 58 { 74 today_fill_launcher ("dates", TRUE, TRUE);75 launcher_start (data->window, &launcher_data);59 launcher_start (data->window, today_get_launcher ( 60 "dates", TRUE, TRUE)); 76 61 } 77 62 … … 221 206 #endif 222 207 223 launcher_data.argv = NULL;224 225 208 /* Show and start */ 226 209 gtk_widget_show (data.window); -
trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-journal.c
r2619 r2622 1 1 2 #include "today-pim-journal.h"3 2 #include <glib/gi18n.h> 4 3 #include <moko-stock.h> 4 #include <libtaku/launcher-util.h> 5 #include "today-utils.h" 6 #include "today-pim-journal.h" 5 7 6 8 enum { … … 77 79 } 78 80 81 static void 82 today_pim_journal_header_clicked_cb (GtkTreeViewColumn *column, TodayData *data) 83 { 84 /* TODO: Maybe just launch dialer normally here? */ 85 launcher_start (data->window, today_get_launcher ( 86 "openmoko-dialer -m", TRUE, TRUE)); 87 } 88 89 static void 90 today_pim_journal_selection_changed_cb (GtkTreeSelection *selection, 91 TodayData *data) 92 { 93 if (gtk_tree_selection_count_selected_rows (selection)) { 94 gtk_tree_selection_unselect_all (selection); 95 launcher_start (data->window, today_get_launcher ( 96 "openmoko-dialer -m", TRUE, TRUE)); 97 } 98 } 99 79 100 GtkWidget * 80 101 today_pim_journal_box_new (TodayData *data) … … 120 141 121 142 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), TRUE); 143 gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (treeview), TRUE); 144 145 g_signal_connect (G_OBJECT (column), "clicked", 146 G_CALLBACK (today_pim_journal_header_clicked_cb), data); 147 g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (treeview)), 148 "changed", G_CALLBACK (today_pim_journal_selection_changed_cb), 149 data); 122 150 123 151 /* Open up journal and connect to signals to find out about missed -
trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-summary.c
r2619 r2622 4 4 #include <libkoto/koto-task.h> 5 5 #include <libkoto/koto-task-view.h> 6 #include <libtaku/launcher-util.h> 7 #include "today-utils.h" 6 8 #include "today-pim-summary.h" 7 9 #include "today-events-store.h" … … 103 105 g_object_set (G_OBJECT (cell), "text", summary, 104 106 "strikethrough", done, NULL); 107 } 108 109 static void 110 today_pim_summary_header_clicked_cb (GtkTreeViewColumn *column, TodayData *data) 111 { 112 g_debug ("TODO: App to set time/date"); 113 } 114 115 static void 116 today_pim_summary_events_selection_changed_cb (GtkTreeSelection *selection, 117 TodayData *data) 118 { 119 if (gtk_tree_selection_count_selected_rows (selection)) { 120 gtk_tree_selection_unselect_all (selection); 121 launcher_start (data->window, today_get_launcher ( 122 "openmoko-contacts", TRUE, TRUE)); 123 } 124 } 125 126 static void 127 today_pim_summary_tasks_selection_changed_cb (GtkTreeSelection *selection, 128 TodayData *data) 129 { 130 if (gtk_tree_selection_count_selected_rows (selection)) { 131 gtk_tree_selection_unselect_all (selection); 132 launcher_start (data->window, today_get_launcher ( 133 "openmoko-tasks", TRUE, TRUE)); 134 } 105 135 } 106 136 … … 148 178 gtk_tree_view_insert_column (GTK_TREE_VIEW (events_tree), column, 0); 149 179 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (events_tree), TRUE); 180 gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (events_tree), TRUE); 150 181 151 182 today_pim_summary_update_date (column); … … 166 197 G_CALLBACK (today_pim_summary_row_deleted_cb), data); 167 198 199 g_signal_connect (G_OBJECT (column), "clicked", 200 G_CALLBACK (today_pim_summary_header_clicked_cb), data); 201 g_signal_connect (G_OBJECT (gtk_tree_view_get_selection ( 202 GTK_TREE_VIEW (events_tree))), "changed", G_CALLBACK ( 203 today_pim_summary_events_selection_changed_cb), data); 204 g_signal_connect (G_OBJECT (gtk_tree_view_get_selection ( 205 GTK_TREE_VIEW (tasks_tree))), "changed", G_CALLBACK ( 206 today_pim_summary_tasks_selection_changed_cb), data); 207 168 208 today_pim_summary_show_notice (data); 169 209 -
trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-utils.c
r2516 r2622 22 22 */ 23 23 24 /**25 * e_cal_component_list_free:26 * @list: the list ECalComooment to free27 *28 * Free a list of ECalComponent29 */30 24 #include <string.h> 25 #include <gtk/gtk.h> 26 #include <libtaku/launcher-util.h> 31 27 #include "today-utils.h" 32 #include <libical/icalcomponent.h>33 34 #define LOG_ERROR \35 g_warning ("Got error '%s', code '%d'", \36 error->message, error->code);37 38 #define FREE_ERROR g_error_free (error) ; error = NULL ;39 40 static ECal *calendar_db = NULL;41 static ECal *tasks_db = NULL;42 43 void44 e_cal_component_list_free (GList * list)45 {46 GList *cur = NULL;47 48 for (cur = list; cur; cur = cur->next)49 {50 /*if an element of the list is not of type ECalComponent, leak it */51 if (cur->data && E_IS_CAL_COMPONENT (cur->data))52 {53 g_object_unref (G_OBJECT (cur->data));54 cur->data = NULL;55 }56 else57 {58 g_warning ("cur->data is not of type ECalComponent !");59 }60 }61 g_list_free (list);62 }63 64 /*65 * if the timetype is today, then only display it's hour part,66 * without the seconds67 * If it's not today, then only display it's date part, without the year68 */69 gchar*70 icaltime_to_pretty_string (const icaltimetype *timetype)71 {72 #define TMP_STR_LEN 1073 icaltimetype today ;74 gboolean hour_only = FALSE ;75 gboolean date_only = FALSE ;76 gchar *result = NULL ;77 gchar tmp_str[TMP_STR_LEN+1] ;78 struct tm native_tm ;79 80 g_return_val_if_fail (timetype, NULL) ;81 82 today = icaltime_today () ;83 if (!icaltime_compare_date_only (*timetype, today))84 {85 hour_only = TRUE ;86 }87 else88 {89 date_only = TRUE ;90 }91 if (hour_only)92 {93 result = g_strdup_printf ("%d:%d", timetype->hour, timetype->minute) ;94 }95 else if (date_only)96 {97 native_tm = icaltimetype_to_tm ((icaltimetype*)timetype) ;98 memset (tmp_str, 0, TMP_STR_LEN+1) ;99 strftime (tmp_str, TMP_STR_LEN, "%d/%b", &native_tm) ;100 result = g_strdup (tmp_str) ;101 }102 return result ;103 }104 105 GList*106 today_clone_icalcomponent_list (const GList *a_list)107 {108 GList *result=NULL, *cur=NULL ;109 110 for (cur =(GList*)a_list ; cur ; cur = cur->next)111 {112 if (!icalcomponent_isa_component (cur->data))113 continue ;114 result = g_list_prepend (result, icalcomponent_new_clone (cur->data)) ;115 }116 return result ;117 }118 119 /**120 * today_get_today_events:121 *122 * Return value: a list of ECalComponents, of type VEVENT123 * or VTODO124 * must be freed with e_cal_component_list_free()125 */126 GList *127 today_get_today_events ()128 {129 GList *result=NULL, *ical_comps=NULL, *ical_comps2=NULL;130 GError *error = NULL;131 gchar *query = NULL;132 133 if (!calendar_db)134 {135 calendar_db = e_cal_new_system_calendar ();136 g_return_val_if_fail (calendar_db, NULL);137 138 if (!e_cal_open (calendar_db, TRUE, &error))139 {140 g_warning ("failed to open the calendar");141 }142 if (error)143 {144 LOG_ERROR;145 goto out;146 }147 }148 149 /*150 query = g_strdup_printf ("(occur-in-time-range? "151 "(time-day-begin (time-now)) "152 "(time-day-end (time-now)) "153 ")");154 */155 query = g_strdup_printf ("#t");156 e_cal_get_object_list (calendar_db, query, &ical_comps, &error);157 g_free (query) ;158 query = NULL ;159 if (error)160 {161 LOG_ERROR;162 FREE_ERROR;163 }164 165 if (!tasks_db)166 {167 tasks_db = e_cal_new_system_tasks ();168 g_return_val_if_fail (tasks_db, NULL);169 if (!e_cal_open (tasks_db, TRUE, &error))170 {171 g_warning ("failed to open the tasks");172 }173 if (error)174 {175 LOG_ERROR;176 goto out;177 }178 }179 180 query = g_strdup_printf ("#t");181 e_cal_get_object_list (tasks_db, query, &ical_comps2, &error);182 g_free (query) ;183 query = NULL ;184 if (error)185 {186 LOG_ERROR;187 FREE_ERROR ;188 }189 ical_comps = g_list_concat (ical_comps, ical_comps2) ;190 191 result = ical_comps;192 ical_comps = ical_comps2 = NULL;193 194 out:195 if (ical_comps)196 {197 e_cal_free_object_list (ical_comps);198 }199 200 if (ical_comps2)201 {202 e_cal_free_object_list (ical_comps);203 }204 205 /*206 the calender must stay alive during the app's lifetime207 if (ecal)208 {209 g_object_unref (G_OBJECT (ecal));210 }211 */212 213 if (error)214 {215 g_error_free (error);216 }217 if (query)218 {219 g_free (query);220 }221 return result;222 }223 224 gboolean225 icalcomponent_has_alarm (icalcomponent *a_icalcomp)226 {227 icalcompiter iter ;228 229 g_return_val_if_fail (a_icalcomp, FALSE) ;230 g_return_val_if_fail (icalcomponent_isa_component (a_icalcomp), FALSE) ;231 232 for (iter = icalcomponent_begin_component (a_icalcomp,233 ICAL_VALARM_COMPONENT);234 icalcompiter_deref (&iter) != NULL ;235 icalcompiter_next (&iter))236 {237 return TRUE ;238 }239 return FALSE ;240 }241 28 242 29 GtkToolItem * … … 249 36 return button; 250 37 } 38 39 const LauncherData * 40 today_get_launcher (const gchar *exec, gboolean use_sn, gboolean single) 41 { 42 static LauncherData launcher_data; 43 static gboolean first = TRUE; 44 45 if (first) { 46 launcher_data.argv = NULL; 47 first = FALSE; 48 } 49 50 if (launcher_data.argv) g_free (launcher_data.argv); 51 launcher_data.argv = exec_to_argv (exec); 52 launcher_data.name = (gchar *)exec; 53 launcher_data.description = ""; 54 launcher_data.icon = NULL; 55 launcher_data.categories = (char *[]){ "" }; 56 launcher_data.use_sn = use_sn; 57 launcher_data.single_instance = single; 58 59 return &launcher_data; 60 } -
trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-utils.h
r2516 r2622 1 /* vi: set sw=2: */2 1 /* 3 2 * Today - At a glance view of date, time, calender events, todo items and … … 26 25 27 26 #include <glib.h> 28 #include <libical/icalcomponent.h>29 #include <libecal/e-cal.h>30 #include <libecal/e-cal-time-util.h>31 27 #include <gtk/gtk.h> 32 33 GList* today_get_today_events () ; 34 void e_cal_component_list_free (GList * list) ; 35 gchar* icaltime_to_pretty_string (const icaltimetype *timetype) ; 36 gboolean icalcomponent_has_alarm (icalcomponent *a_icalcomp) ; 37 GList* today_clone_icalcomponent_list (const GList *a_list) ; 28 #include <libtaku/launcher-util.h> 38 29 39 30 GtkToolItem *today_toolbutton_new (const gchar *icon_name); 31 const LauncherData *today_get_launcher (const gchar *exec, gboolean use_sn, 32 gboolean single); 40 33 41 34 #endif /*__TODAY_UTILS_H__*/ 42
Note: See TracChangeset
for help on using the changeset viewer.
