Diff of /trunk/src/main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 130 by harbaum, Wed Sep 30 12:11:22 2009 UTC revision 165 by harbaum, Sun Nov 8 20:32:55 2009 UTC
# Line 19  Line 19 
19  #include <string.h>  #include <string.h>
20  #include <math.h>  #include <math.h>
21    
22    #include <curl/curl.h>
23    
24  #include <time.h>  #include <time.h>
25  #include <sys/time.h>  #include <sys/time.h>
26    
# Line 29  Line 31 
31    
32  #ifdef USE_MAEMO  #ifdef USE_MAEMO
33  #include <hildon/hildon-banner.h>  #include <hildon/hildon-banner.h>
34    #if MAEMO_VERSION_MAJOR >= 5
35    #include <hildon/hildon-note.h>
36    #endif
37  #endif  #endif
38    
39  #include <locale.h>  #include <locale.h>
# Line 92  void errorf(const char *fmt, ...) { Line 97  void errorf(const char *fmt, ...) {
97      }      }
98    }    }
99    
100    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
101    GtkWidget *dialog = gtk_message_dialog_new(    GtkWidget *dialog = gtk_message_dialog_new(
102                             GTK_WINDOW(NULL),                             GTK_WINDOW(NULL),
103                             GTK_DIALOG_DESTROY_WITH_PARENT,                             GTK_DIALOG_DESTROY_WITH_PARENT,
 #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)  
104                             GTK_MESSAGE_ERROR,                             GTK_MESSAGE_ERROR,
 #else  
                            GTK_MESSAGE_OTHER,  
 #endif  
105                             GTK_BUTTONS_CLOSE, buf);                             GTK_BUTTONS_CLOSE, buf);
106    
107    gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR"));    gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR"));
108    #else
109      GtkWidget *dialog =
110        hildon_note_new_information(GTK_WINDOW(NULL), buf);
111    #endif
112    
113    gtk_dialog_run(GTK_DIALOG(dialog));    gtk_dialog_run(GTK_DIALOG(dialog));
114    gtk_widget_destroy(dialog);    gtk_widget_destroy(dialog);
# Line 209  enum { Line 215  enum {
215    CACHELIST_NUM_COLS    CACHELIST_NUM_COLS
216  } ;  } ;
217    
218  void cachelist_view_onRowActivated(GtkTreeView        *treeview,  void cachelist_goto_cache(appdata_t *appdata, cache_t *cache) {
219    #if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT)
220        cache_dialog(appdata, cache);
221    #else
222        gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);
223        appdata->cur_view = cache_view(appdata, cache);
224        gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view);
225        gtk_widget_show_all(appdata->vbox);
226    
227        crumb_add(appdata, cache->name, CRUMB_CACHE, cache);
228    #endif
229    }
230    
231    static void cachelist_view_onRowActivated(GtkTreeView        *treeview,
232                                     GtkTreePath        *path,                                     GtkTreePath        *path,
233                                     GtkTreeViewColumn  *col,                                     GtkTreeViewColumn  *col,
234                                     gpointer            userdata) {                                     gpointer            userdata) {
# Line 226  void cachelist_view_onRowActivated(GtkTr Line 245  void cachelist_view_onRowActivated(GtkTr
245    if(gtk_tree_model_get_iter(model, &iter, path)) {    if(gtk_tree_model_get_iter(model, &iter, path)) {
246      cache_t *cache;      cache_t *cache;
247      gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1);      gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1);
248  #if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT)      cachelist_goto_cache(appdata, cache);
     cache_dialog(appdata, cache);  
 #else  
     gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);  
     appdata->cur_view = cache_view(appdata, cache);  
     gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view);  
     gtk_widget_show_all(appdata->vbox);  
   
     crumb_add(appdata, cache->name, CRUMB_CACHE, cache);  
 #endif  
249    }    }
250  }  }
251    
# Line 724  static void gpxlist_close(appdata_t *app Line 734  static void gpxlist_close(appdata_t *app
734    gconf_save_closed_name(appdata, gpx->filename, gpx->name);    gconf_save_closed_name(appdata, gpx->filename, gpx->name);
735  }  }
736    
737    void gpxlist_goto_cachelist(appdata_t *appdata, gpx_t *gpx) {
738    #if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT)
739    #ifdef USE_STACKABLE_WINDOW
740      if(!appdata->cur_gpx)
741    #endif
742        cachelist_dialog(appdata, gpx);
743    #ifdef USE_STACKABLE_WINDOW
744      else
745        printf("selected gpx, but cachelist window already present\n");
746    #endif
747    #else
748      gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);
749      appdata->cur_view = cachelist_create(appdata, gpx, NULL);
750      gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view);
751      gtk_widget_show_all(appdata->vbox);
752    
753      crumb_add(appdata, gpx->name, CRUMB_CACHELIST, gpx);
754    #endif
755    }
756    
757  static void gpxlist_view_onRowActivated(GtkTreeView *treeview,  static void gpxlist_view_onRowActivated(GtkTreeView *treeview,
758                            GtkTreePath        *path,                            GtkTreePath        *path,
759                            GtkTreeViewColumn  *col,                            GtkTreeViewColumn  *col,
# Line 750  static void gpxlist_view_onRowActivated( Line 780  static void gpxlist_view_onRowActivated(
780      if(col_name && !strcmp(col_name, "Del")) {      if(col_name && !strcmp(col_name, "Del")) {
781        printf("clicked delete\n");        printf("clicked delete\n");
782    
783    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
784        /* ask user what he wants */        /* ask user what he wants */
785        GtkWidget *dialog = gtk_message_dialog_new(        GtkWidget *dialog = gtk_message_dialog_new(
786                   GTK_WINDOW(appdata->window),                   GTK_WINDOW(appdata->window),
787                   GTK_DIALOG_DESTROY_WITH_PARENT,                   GTK_DIALOG_DESTROY_WITH_PARENT,
788                   GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL,                   GTK_MESSAGE_QUESTION,
789                     GTK_BUTTONS_CANCEL,
790                   _("Do you want to close this entry only or do "                   _("Do you want to close this entry only or do "
791                     "you want to remove it completely from the list?"));                     "you want to remove it completely from the list?"));
792    
# Line 763  static void gpxlist_view_onRowActivated( Line 795  static void gpxlist_view_onRowActivated(
795                               _("Close"), 2,                               _("Close"), 2,
796                               NULL);                               NULL);
797    
798          gtk_window_set_title(GTK_WINDOW(dialog), _("Close or remove entry?"));
799    #else
800    
801          GtkWidget *dialog =
802            gtk_dialog_new_with_buttons(_("Close or remove entry?"),
803                                GTK_WINDOW(appdata->window),
804                                GTK_DIALOG_DESTROY_WITH_PARENT,
805                                GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
806                                _("Remove"), 1,
807                                _("Close"), 2,
808                                NULL);
809    
810          GtkWidget *content_area =
811            gtk_dialog_get_content_area (GTK_DIALOG (dialog));
812    
813          GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
814    
815          gtk_box_pack_start(GTK_BOX(hbox),
816             gtk_image_new_from_stock( GTK_STOCK_DIALOG_QUESTION,
817                                       GTK_ICON_SIZE_DIALOG),
818                             FALSE, FALSE, 0);
819    
820          GtkWidget *label = gtk_label_new(
821                      _("Do you want to close this entry only or do "
822                        "you want to remove it completely from the list?"));
823    
824          gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
825          gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD);
826    
827          gtk_box_pack_start_defaults(GTK_BOX(hbox), label);
828          gtk_container_add (GTK_CONTAINER (content_area), hbox);
829    
830          gtk_widget_show_all (dialog);
831    #endif
832    
833        if(gpx->closed)        if(gpx->closed)
834          gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE);          gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 2, FALSE);
835    
       gtk_window_set_title(GTK_WINDOW(dialog), _("Remove entry?"));  
   
836        /* set the active flag again if the user answered "no" */        /* set the active flag again if the user answered "no" */
837        switch(gtk_dialog_run(GTK_DIALOG(dialog))) {        switch(gtk_dialog_run(GTK_DIALOG(dialog))) {
838    
# Line 835  static void gpxlist_view_onRowActivated( Line 900  static void gpxlist_view_onRowActivated(
900    
901          gpx_busy_dialog_destroy(dialog);          gpx_busy_dialog_destroy(dialog);
902        }        }
903  #if !defined(USE_BREAD_CRUMB_TRAIL) && !defined(BCT)  
904  #ifdef USE_STACKABLE_WINDOW        gpxlist_goto_cachelist(appdata, gpx);
       if(!appdata->cur_gpx)  
 #endif  
         cachelist_dialog(appdata, gpx);  
 #ifdef USE_STACKABLE_WINDOW  
       else  
         printf("selected gpx, but cachelist window already present\n");  
 #endif  
 #else  
       gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view);  
       appdata->cur_view = cachelist_create(appdata, gpx, NULL);  
       gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view);  
       gtk_widget_show_all(appdata->vbox);  
   
       crumb_add(appdata, gpx->name, CRUMB_CACHELIST, gpx);  
 #endif  
905      }      }
906    }    }
907  }  }
# Line 906  static GtkWidget *gpxlist_create_view_an Line 956  static GtkWidget *gpxlist_create_view_an
956    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview),    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview),
957                    -1, "Icon", renderer,                    -1, "Icon", renderer,
958                    "pixbuf", GPXLIST_COL_ICON,                    "pixbuf", GPXLIST_COL_ICON,
959                //                  "sensitive", GPXLIST_COL_OPEN,  #ifdef USE_PANNABLE_AREA
960            /* at least one entry needs to be sensitive. */
961            /* This is the delete icon if the PANNABLE_AREA is used */
962                      "sensitive", GPXLIST_COL_OPEN,
963    #endif
964                    NULL);                    NULL);
965    
966    /* --- "FileName" column --- */    /* --- "FileName" column --- */
# Line 962  static GtkWidget *gpxlist_create_view_an Line 1016  static GtkWidget *gpxlist_create_view_an
1016    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview),    gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(appdata->gpxview),
1017                    -1, "Del", renderer,                    -1, "Del", renderer,
1018                    "pixbuf", GPXLIST_COL_DELETE,                    "pixbuf", GPXLIST_COL_DELETE,
1019                    "sensitive", GPXLIST_COL_OPEN,                //                  "sensitive", GPXLIST_COL_OPEN,
1020                    NULL);                    NULL);
1021  #endif  #endif
1022    
# Line 1073  cb_menu_about(GtkWidget *window, gpointe Line 1127  cb_menu_about(GtkWidget *window, gpointe
1127    const gchar *authors[] = {    const gchar *authors[] = {
1128      "Till Harbaum <till@harbaum.org>",      "Till Harbaum <till@harbaum.org>",
1129      "John Stowers <john.stowers@gmail.com>",      "John Stowers <john.stowers@gmail.com>",
1130        "GCVote: Guido Wegener <guido.wegener@gmx.de>",
1131      NULL };      NULL };
1132    
1133    context.dialog = g_object_new(GTK_TYPE_ABOUT_DIALOG,    context.dialog = g_object_new(GTK_TYPE_ABOUT_DIALOG,
# Line 1281  gpx_t *search_do(appdata_t *appdata, gpx Line 1336  gpx_t *search_do(appdata_t *appdata, gpx
1336        else if(cache->long_description && (what & SEARCH_DESC) &&        else if(cache->long_description && (what & SEARCH_DESC) &&
1337                strcasestr(cache->long_description, phrase))                strcasestr(cache->long_description, phrase))
1338          hit = 1;          hit = 1;
1339        else if(cache->owner && (what & SEARCH_OWNER) &&        else if(cache->owner && cache->owner->name && (what & SEARCH_OWNER) &&
1340                strcasestr(cache->owner, phrase))                strcasestr(cache->owner->name, phrase))
1341          hit = 1;          hit = 1;
1342    
1343        if(hit) {        if(hit) {
# Line 1850  void menu_create(appdata_t *appdata) { Line 1905  void menu_create(appdata_t *appdata) {
1905    
1906    gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());    gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
1907    
 #ifndef NO_COPY_N_PASTE  
1908    /* ----------- copy'n paste submenu ----------------- */    /* ----------- copy'n paste submenu ----------------- */
1909    appdata->clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);  #ifndef NO_COPY_N_PASTE
   gtk_clipboard_set_can_store(appdata->clipboard, NULL, 0);  
   
1910    item = gtk_menu_item_new_with_label(_("Edit"));    item = gtk_menu_item_new_with_label(_("Edit"));
1911    gtk_menu_append(GTK_MENU_SHELL(menu), item);    gtk_menu_append(GTK_MENU_SHELL(menu), item);
1912    submenu = gtk_menu_new();    submenu = gtk_menu_new();
# Line 2279  int main(int argc, char *argv[]) { Line 2331  int main(int argc, char *argv[]) {
2331    
2332    gtk_init (&argc, &argv);    gtk_init (&argc, &argv);
2333    
2334      curl_global_init(CURL_GLOBAL_ALL);
2335    
2336  #ifdef USE_MAEMO  #ifdef USE_MAEMO
2337    printf("Installing osso context for \"org.harbaum." APP "\"\n");    printf("Installing osso context for \"org.harbaum." APP "\"\n");
2338    appdata.osso_context = osso_initialize("org.harbaum."APP,    appdata.osso_context = osso_initialize("org.harbaum."APP,
# Line 2327  int main(int argc, char *argv[]) { Line 2381  int main(int argc, char *argv[]) {
2381    g_signal_connect(G_OBJECT(appdata.window), "key_press_event",    g_signal_connect(G_OBJECT(appdata.window), "key_press_event",
2382                     G_CALLBACK(on_window_key_press), &appdata);                     G_CALLBACK(on_window_key_press), &appdata);
2383    
2384      /* prepare clipboard */
2385      appdata.clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
2386      gtk_clipboard_set_can_store(appdata.clipboard, NULL, 0);
2387    
2388    appdata.vbox = gtk_vbox_new(FALSE, 2);    appdata.vbox = gtk_vbox_new(FALSE, 2);
2389    gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox);    gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox);
2390  #ifndef USE_STACKABLE_WINDOW  #ifndef USE_STACKABLE_WINDOW

Legend:
Removed from v.130  
changed lines
  Added in v.165