Diff of /trunk/src/relation_edit.c

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

revision 152 by harbaum, Sun Mar 29 19:19:30 2009 UTC revision 153 by harbaum, Mon Mar 30 11:14:20 2009 UTC
# Line 228  static char *relation_get_descriptive_na Line 228  static char *relation_get_descriptive_na
228    return name;    return name;
229  }  }
230    
231    static gboolean relation_info_dialog(GtkWidget *parent, appdata_t *appdata,
232                                         relation_t *relation) {
233    
234      object_t object = { .type = RELATION };
235      object.relation = relation;
236      return info_dialog(parent, appdata, &object);
237    }
238    
239  static void on_relation_item_add(GtkWidget *but, relitem_context_t *context) {  static void on_relation_item_add(GtkWidget *but, relitem_context_t *context) {
240    /* create a new relation */    /* create a new relation */
241    
242    relation_t *relation = osm_relation_new();    relation_t *relation = osm_relation_new();
243    if(!info_dialog(context->dialog, context->appdata, relation)) {    if(!relation_info_dialog(context->dialog, context->appdata, relation)) {
244      printf("tag edit cancelled\n");      printf("tag edit cancelled\n");
245      osm_relation_free(relation);      osm_relation_free(relation);
246    } else {    } else {
# Line 277  static void on_relation_item_edit(GtkWid Line 285  static void on_relation_item_edit(GtkWid
285    
286    printf("edit relation item #%ld\n", sel->id);    printf("edit relation item #%ld\n", sel->id);
287    
288    if (!info_dialog(context->dialog, context->appdata, sel))    if (!relation_info_dialog(context->dialog, context->appdata, sel))
289      return;      return;
290    
291    // Locate the changed item    // Locate the changed item
# Line 464  static GtkWidget *relation_item_list_wid Line 472  static GtkWidget *relation_item_list_wid
472    g_object_unref(context->store);    g_object_unref(context->store);
473    
474    list_set_static_buttons(context->list, G_CALLBACK(on_relation_item_add),    list_set_static_buttons(context->list, G_CALLBACK(on_relation_item_add),
475            G_CALLBACK(on_relation_item_edit),G_CALLBACK(on_relation_item_remove), context);          G_CALLBACK(on_relation_item_edit),G_CALLBACK(on_relation_item_remove),
476            context);
477    
478    relation_item_list_selected(context, FALSE);    relation_item_list_selected(context, FALSE);
479    
# Line 520  void relation_add_dialog(appdata_t *appd Line 529  void relation_add_dialog(appdata_t *appd
529    
530  typedef struct {  typedef struct {
531    appdata_t *appdata;    appdata_t *appdata;
532    GtkWidget *dialog, *list;    GtkWidget *dialog, *list, *show_btn;
533    GtkListStore *store;    GtkListStore *store;
534  } relation_context_t;  } relation_context_t;
535    
# Line 552  static void relation_list_selected(relat Line 561  static void relation_list_selected(relat
561    
562    list_button_enable(context->list, LIST_BUTTON_USER0,    list_button_enable(context->list, LIST_BUTTON_USER0,
563                       (selected != NULL) && (selected->member != NULL));                       (selected != NULL) && (selected->member != NULL));
564      gtk_widget_set_sensitive(context->show_btn,
565                         (selected != NULL) && (selected->member != NULL));
566    
567    list_button_enable(context->list, LIST_BUTTON_REMOVE, selected != NULL);    list_button_enable(context->list, LIST_BUTTON_REMOVE, selected != NULL);
568    list_button_enable(context->list, LIST_BUTTON_EDIT, selected != NULL);    list_button_enable(context->list, LIST_BUTTON_EDIT, selected != NULL);
# Line 747  static void on_relation_add(GtkWidget *b Line 758  static void on_relation_add(GtkWidget *b
758    /* create a new relation */    /* create a new relation */
759    
760    relation_t *relation = osm_relation_new();    relation_t *relation = osm_relation_new();
761    if(!info_dialog(context->dialog, context->appdata, relation)) {    if(!relation_info_dialog(context->dialog, context->appdata, relation)) {
762      printf("tag edit cancelled\n");      printf("tag edit cancelled\n");
763      osm_relation_free(relation);      osm_relation_free(relation);
764    } else {    } else {
# Line 786  static void on_relation_edit(GtkWidget * Line 797  static void on_relation_edit(GtkWidget *
797    
798    printf("edit relation #%ld\n", sel->id);    printf("edit relation #%ld\n", sel->id);
799    
800    if (!info_dialog(context->dialog, context->appdata, sel))    if (!relation_info_dialog(context->dialog, context->appdata, sel))
801      return;      return;
802    
803    // Locate the changed item    // Locate the changed item
# Line 849  static void on_relation_remove(GtkWidget Line 860  static void on_relation_remove(GtkWidget
860  static GtkWidget *relation_list_widget(relation_context_t *context) {  static GtkWidget *relation_list_widget(relation_context_t *context) {
861    context->list = list_new(LIST_HILDON_WITH_HEADERS);    context->list = list_new(LIST_HILDON_WITH_HEADERS);
862    
863    list_set_selection_function(context->list, relation_list_selection_func, context);    list_set_selection_function(context->list, relation_list_selection_func,
864                                  context);
865    
866    list_set_columns(context->list,    list_set_columns(context->list,
867                     _("Id"),      RELATION_COL_ID, 0,                     _("Id"),      RELATION_COL_ID, 0,
# Line 925  void relation_list(appdata_t *appdata) { Line 937  void relation_list(appdata_t *appdata) {
937                                LIST_OF_RELATIONS_DIALOG_WIDTH,                                LIST_OF_RELATIONS_DIALOG_WIDTH,
938                                LIST_OF_RELATIONS_DIALOG_HEIGHT);                                LIST_OF_RELATIONS_DIALOG_HEIGHT);
939    
940      context->show_btn = gtk_dialog_add_button(GTK_DIALOG(context->dialog),
941                                                _("Select"), GTK_RESPONSE_HELP);
942    
943    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context->dialog)->vbox),    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context->dialog)->vbox),
944                       relation_list_widget(context), TRUE, TRUE, 0);                       relation_list_widget(context), TRUE, TRUE, 0);
945    
946    /* ----------------------------------- */    /* ----------------------------------- */
947    
948    
949    gtk_widget_show_all(context->dialog);    gtk_widget_show_all(context->dialog);
950    gtk_dialog_run(GTK_DIALOG(context->dialog));    if(gtk_dialog_run(GTK_DIALOG(context->dialog)) == GTK_RESPONSE_HELP) {
951    gtk_widget_destroy(context->dialog);      map_item_deselect(appdata);
952    
953        relation_t *sel = get_selected_relation(context);
954        if(sel) map_relation_select(appdata, sel);
955      }
956    
957      gtk_widget_destroy(context->dialog);
958    g_free(context);    g_free(context);
959  }  }
960    

Legend:
Removed from v.152  
changed lines
  Added in v.153