Changeset 2622


Ignore:
Timestamp:
08/03/07 16:08:48 (6 years ago)
Author:
chris
Message:

Launch the appropriate apps when clicking the summaries on the home page

Location:
trunk/src/target/OM-2007.2/applications/openmoko-today2
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/OM-2007.2/applications/openmoko-today2/ChangeLog

    r2619 r2622  
     12007-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 
    1242007-08-03  Chris Lord,,,  <chris@openedhand.com> 
    225 
  • trunk/src/target/OM-2007.2/applications/openmoko-today2/libtaku/launcher-util.c

    r2560 r2622  
    290290/* TODO: optionally link to GtkUnique and directly handle that? */ 
    291291void 
    292 launcher_start (GtkWidget *widget, LauncherData *data) 
     292launcher_start (GtkWidget *widget, const LauncherData *data) 
    293293{ 
    294294  GError *error = NULL; 
  • trunk/src/target/OM-2007.2/applications/openmoko-today2/libtaku/launcher-util.h

    r2504 r2622  
    1616 * Place - Suite 330, Boston, MA 02111-1307, USA. 
    1717 */ 
     18 
     19#ifndef HAVE_LAUNCHER_UTIL_H 
     20#define HAVE_LAUNCHER_UTIL_H 
    1821 
    1922#include <glib.h> 
     
    3740LauncherData *launcher_parse_desktop_file (const char *filename, GError **error); 
    3841 
    39 void launcher_start (GtkWidget *widget, LauncherData *data); 
     42void launcher_start (GtkWidget *widget, const LauncherData *data); 
    4043 
    4144char * launcher_get_icon (GtkIconTheme *icon_theme, LauncherData *data, int size); 
    4245 
    4346void launcher_destroy (LauncherData *data); 
     47 
     48#endif 
  • trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-main.c

    r2619 r2622  
    3333} 
    3434 
    35 /* TODO: Make this less nasty */ 
    36 static LauncherData launcher_data; 
    37 static void 
    38 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  
    5035static void 
    5136today_dial_button_clicked_cb (GtkToolButton *button, TodayData *data) 
    5237{ 
    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)); 
    5540} 
    5641 
     
    5843today_contacts_button_clicked_cb (GtkToolButton *button, TodayData *data) 
    5944{ 
    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)); 
    6247} 
    6348 
     
    6550today_messages_button_clicked_cb (GtkToolButton *button, TodayData *data) 
    6651{ 
    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)); 
    6954} 
    7055 
     
    7257today_dates_button_clicked_cb (GtkToolButton *button, TodayData *data) 
    7358{ 
    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)); 
    7661} 
    7762 
     
    221206#endif 
    222207         
    223         launcher_data.argv = NULL; 
    224          
    225208        /* Show and start */ 
    226209        gtk_widget_show (data.window); 
  • trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-pim-journal.c

    r2619 r2622  
    11 
    2 #include "today-pim-journal.h" 
    32#include <glib/gi18n.h> 
    43#include <moko-stock.h> 
     4#include <libtaku/launcher-util.h> 
     5#include "today-utils.h" 
     6#include "today-pim-journal.h" 
    57 
    68enum { 
     
    7779} 
    7880 
     81static void 
     82today_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 
     89static void 
     90today_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 
    79100GtkWidget * 
    80101today_pim_journal_box_new (TodayData *data) 
     
    120141 
    121142        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); 
    122150         
    123151        /* 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  
    44#include <libkoto/koto-task.h> 
    55#include <libkoto/koto-task-view.h> 
     6#include <libtaku/launcher-util.h> 
     7#include "today-utils.h" 
    68#include "today-pim-summary.h" 
    79#include "today-events-store.h" 
     
    103105        g_object_set (G_OBJECT (cell), "text", summary, 
    104106                "strikethrough", done, NULL); 
     107} 
     108 
     109static void 
     110today_pim_summary_header_clicked_cb (GtkTreeViewColumn *column, TodayData *data) 
     111{ 
     112        g_debug ("TODO: App to set time/date"); 
     113} 
     114 
     115static void 
     116today_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 
     126static void 
     127today_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        } 
    105135} 
    106136 
     
    148178        gtk_tree_view_insert_column (GTK_TREE_VIEW (events_tree), column, 0);    
    149179        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); 
    150181 
    151182        today_pim_summary_update_date (column); 
     
    166197                G_CALLBACK (today_pim_summary_row_deleted_cb), data); 
    167198         
     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 
    168208        today_pim_summary_show_notice (data); 
    169209 
  • trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-utils.c

    r2516 r2622  
    2222 */ 
    2323 
    24 /** 
    25  * e_cal_component_list_free: 
    26  * @list: the list ECalComooment to free 
    27  * 
    28  * Free a list of ECalComponent 
    29  */ 
    3024#include <string.h> 
     25#include <gtk/gtk.h> 
     26#include <libtaku/launcher-util.h> 
    3127#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 void 
    44 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     else 
    57     { 
    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 seconds 
    67  * If it's not today, then only display it's date part, without the year 
    68  */ 
    69 gchar* 
    70 icaltime_to_pretty_string (const icaltimetype *timetype) 
    71 { 
    72 #define TMP_STR_LEN 10 
    73     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     else 
    88     { 
    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 VEVENT 
    123  * or VTODO 
    124  * 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 lifetime 
    207   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 gboolean 
    225 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 } 
    24128 
    24229GtkToolItem * 
     
    24936        return button; 
    25037} 
     38 
     39const LauncherData * 
     40today_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: */ 
    21/* 
    32 *  Today - At a glance view of date, time, calender events, todo items and 
     
    2625 
    2726#include <glib.h> 
    28 #include <libical/icalcomponent.h> 
    29 #include <libecal/e-cal.h> 
    30 #include <libecal/e-cal-time-util.h> 
    3127#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> 
    3829 
    3930GtkToolItem *today_toolbutton_new (const gchar *icon_name); 
     31const LauncherData *today_get_launcher (const gchar *exec, gboolean use_sn, 
     32                                        gboolean single); 
    4033 
    4134#endif /*__TODAY_UTILS_H__*/ 
    42  
Note: See TracChangeset for help on using the changeset viewer.