Diff of /trunk/src/main.c

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

revision 165 by harbaum, Sun Nov 8 20:32:55 2009 UTC revision 168 by harbaum, Mon Nov 9 10:49:51 2009 UTC
# Line 33  Line 33 
33  #include <hildon/hildon-banner.h>  #include <hildon/hildon-banner.h>
34  #if MAEMO_VERSION_MAJOR >= 5  #if MAEMO_VERSION_MAJOR >= 5
35  #include <hildon/hildon-note.h>  #include <hildon/hildon-note.h>
36    #include <hildon/hildon-check-button.h>
37  #endif  #endif
38  #endif  #endif
39    
# Line 1366  typedef struct { Line 1367  typedef struct {
1367    GtkWidget *in_id, *in_name, *in_desc, *in_owner, *in_finds;    GtkWidget *in_id, *in_name, *in_desc, *in_owner, *in_finds;
1368  } search_context_t;  } search_context_t;
1369    
1370    
1371    static GtkWidget *check_button_new_with_label(char *label) {
1372    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
1373      return gtk_check_button_new_with_label(label);
1374    #else
1375      GtkWidget *cbut =
1376        hildon_check_button_new(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH);
1377      gtk_button_set_label(GTK_BUTTON(cbut), label);
1378      return cbut;
1379    #endif
1380    }
1381    
1382    static void check_button_set_active(GtkWidget *button, gboolean active) {
1383    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
1384      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
1385    #else
1386      hildon_check_button_set_active(HILDON_CHECK_BUTTON(button), active);
1387    #endif
1388    }
1389    
1390    static gboolean check_button_get_active(GtkWidget *button) {
1391    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
1392      return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
1393    #else
1394      return hildon_check_button_get_active(HILDON_CHECK_BUTTON(button));
1395    #endif
1396    }
1397    
1398  static void callback_finds_toggled(GtkWidget *widget, gpointer data ) {  static void callback_finds_toggled(GtkWidget *widget, gpointer data ) {
1399    search_context_t *context = (search_context_t*)data;    search_context_t *context = (search_context_t*)data;
1400    
1401    gboolean in_finds = gtk_toggle_button_get_active(    gboolean in_finds = check_button_get_active(context->in_finds);
           GTK_TOGGLE_BUTTON(context->in_finds));  
1402    
1403    gtk_widget_set_sensitive(context->entry,    !in_finds);    gtk_widget_set_sensitive(context->entry,    !in_finds);
1404    gtk_widget_set_sensitive(context->in_id,    !in_finds);    gtk_widget_set_sensitive(context->in_id,    !in_finds);
# Line 1400  cb_menu_search(GtkWidget *window, gpoint Line 1428  cb_menu_search(GtkWidget *window, gpoint
1428    GtkWidget *table = gtk_table_new(2, 2, TRUE);    GtkWidget *table = gtk_table_new(2, 2, TRUE);
1429    gtk_table_set_col_spacing(GTK_TABLE(table), 0, 8);    gtk_table_set_col_spacing(GTK_TABLE(table), 0, 8);
1430    
1431    context.in_id = gtk_check_button_new_with_label(_("Waypoint IDs"));    context.in_id = check_button_new_with_label(_("Waypoint IDs"));
1432    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context.in_id),    check_button_set_active(context.in_id, appdata->search & SEARCH_ID);
                                appdata->search & SEARCH_ID);  
1433    gtk_table_attach_defaults(GTK_TABLE(table), context.in_id, 0, 1, 0, 1);    gtk_table_attach_defaults(GTK_TABLE(table), context.in_id, 0, 1, 0, 1);
1434    
1435    context.in_name = gtk_check_button_new_with_label(_("Names"));    context.in_name = check_button_new_with_label(_("Names"));
1436    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context.in_name),    check_button_set_active(context.in_name, appdata->search & SEARCH_NAME);
                                appdata->search & SEARCH_NAME);  
1437    gtk_table_attach_defaults(GTK_TABLE(table), context.in_name, 1, 2, 0, 1);    gtk_table_attach_defaults(GTK_TABLE(table), context.in_name, 1, 2, 0, 1);
1438    
1439    context.in_desc = gtk_check_button_new_with_label(_("Descriptions"));    context.in_desc = check_button_new_with_label(_("Descriptions"));
1440    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context.in_desc),    check_button_set_active(context.in_desc, appdata->search & SEARCH_DESC);
                                appdata->search & SEARCH_DESC);  
1441    gtk_table_attach_defaults(GTK_TABLE(table), context.in_desc, 0, 1, 1, 2);    gtk_table_attach_defaults(GTK_TABLE(table), context.in_desc, 0, 1, 1, 2);
1442    
1443    context.in_owner = gtk_check_button_new_with_label(_("Owner"));    context.in_owner = check_button_new_with_label(_("Owner"));
1444    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context.in_owner),    check_button_set_active(context.in_owner, appdata->search & SEARCH_OWNER);
                                appdata->search & SEARCH_OWNER);  
1445    gtk_table_attach_defaults(GTK_TABLE(table), context.in_owner, 1, 2, 1, 2);    gtk_table_attach_defaults(GTK_TABLE(table), context.in_owner, 1, 2, 1, 2);
1446    
1447    gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table);    gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table);
# Line 1438  cb_menu_search(GtkWidget *window, gpoint Line 1462  cb_menu_search(GtkWidget *window, gpoint
1462    
1463    GtkWidget *hbox = gtk_hbox_new(FALSE, 5);    GtkWidget *hbox = gtk_hbox_new(FALSE, 5);
1464    
1465    context.in_finds = gtk_check_button_new_with_label(_("Search finds for"));    context.in_finds = check_button_new_with_label(_("Search finds for"));
1466    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context.in_finds),    check_button_set_active(context.in_finds, appdata->search & SEARCH_FINDS);
                                appdata->search & SEARCH_FINDS);  
1467    gtk_box_pack_start_defaults(GTK_BOX(hbox), context.in_finds);    gtk_box_pack_start_defaults(GTK_BOX(hbox), context.in_finds);
1468    g_signal_connect(G_OBJECT(context.in_finds), "toggled",    g_signal_connect(G_OBJECT(context.in_finds), "toggled",
1469                     G_CALLBACK(callback_finds_toggled), &context);                     G_CALLBACK(callback_finds_toggled), &context);
# Line 1480  cb_menu_search(GtkWidget *window, gpoint Line 1503  cb_menu_search(GtkWidget *window, gpoint
1503                      HILDON_NUMBER_EDITOR(context.spinner));                      HILDON_NUMBER_EDITOR(context.spinner));
1504  #endif  #endif
1505    
1506      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_finds)))      if(check_button_get_active(context.in_finds))
1507        appdata->search |=  SEARCH_FINDS;        appdata->search |=  SEARCH_FINDS;
1508      else      else
1509        appdata->search &= ~SEARCH_FINDS;        appdata->search &= ~SEARCH_FINDS;
1510    
1511      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_id)))      if(check_button_get_active(context.in_id))
1512        appdata->search |=  SEARCH_ID;        appdata->search |=  SEARCH_ID;
1513      else      else
1514        appdata->search &= ~SEARCH_ID;        appdata->search &= ~SEARCH_ID;
1515    
1516      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_name)))      if(check_button_get_active(context.in_name))
1517        appdata->search |=  SEARCH_NAME;        appdata->search |=  SEARCH_NAME;
1518      else      else
1519        appdata->search &= ~SEARCH_NAME;        appdata->search &= ~SEARCH_NAME;
1520    
1521      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_desc)))      if(check_button_get_active(context.in_desc))
1522        appdata->search |=  SEARCH_DESC;        appdata->search |=  SEARCH_DESC;
1523      else      else
1524        appdata->search &= ~SEARCH_DESC;        appdata->search &= ~SEARCH_DESC;
1525    
1526      if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context.in_owner)))      if(check_button_get_active(context.in_owner))
1527        appdata->search |=  SEARCH_OWNER;        appdata->search |=  SEARCH_OWNER;
1528      else      else
1529        appdata->search &= ~SEARCH_OWNER;        appdata->search &= ~SEARCH_OWNER;

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