static void project_popup_any_cb(ExplorerUI *eui, int type) { TreeItemList items; Quark *q; GraceApp *gapp; GProject *gp; TreeGetHighlighted(eui->tree, &items); if (!items.count || items.count > 1) { xfree(items.items); return; } q = TreeGetQuark(items.items[0]); gapp = gapp_from_quark(q); gp = gproject_from_quark(q); switch (type) { case PROJECT_SHOW_CB: gapp_set_active_gproject(gapp, gp); xdrawgraph(gp); update_all(); break; case PROJECT_SAVE_CB: project_save(gp); break; case PROJECT_SAVE_AS_CB: project_save_as(gp); break; case PROJECT_REVERT_TO_SAVED_CB: revert_project(gapp, gp); xdrawgraph(gapp->gp); update_all(); break; case PROJECT_CLOSE_CB: if (gapp->gpcount == 1) { errmsg("Can't close the last project"); return; } if (gp && gproject_get_top(gp) && quark_dirtystate_get(gproject_get_top(gp)) && !yesno("Abandon unsaved changes?", NULL, NULL, NULL)) { return; } gapp_delete_gproject(gapp, gp); if (gapp->gp == NULL) { gapp_set_active_gproject(gapp, gapp->gplist[0]); } xdrawgraph(gapp->gp); update_all(); break; } xfree(items.items); }
void radare_project_info (const char* file) { #line 14 "project.vala" g_return_if_fail (file != NULL); #line 16 "project.vala" project_save (file); }
void osm_upload(appdata_t *appdata, osm_t *osm, project_t *project) { printf("starting upload\n"); /* upload config and confirmation dialog */ /* count nodes */ osm_dirty_t dirty; memset(&dirty, 0, sizeof(dirty)); const node_t *node = osm->node; while(node) { object_counter(OSM_BASE(node), &dirty.nodes); node = node->next; } printf("nodes: new %2d, dirty %2d, deleted %2d\n", dirty.nodes.added, dirty.nodes.dirty, dirty.nodes.deleted); /* count ways */ const way_t *way = osm->way; while(way) { object_counter(OSM_BASE(way), &dirty.ways); way = way->next; } printf("ways: new %2d, dirty %2d, deleted %2d\n", dirty.ways.added, dirty.ways.dirty, dirty.ways.deleted); /* count relations */ const relation_t *relation = osm->relation; while(relation) { object_counter(OSM_BASE(relation), &dirty.relations); relation = relation->next; } printf("relations: new %2d, dirty %2d, deleted %2d\n", dirty.relations.added, dirty.relations.dirty, dirty.relations.deleted); GtkWidget *dialog = misc_dialog_new(MISC_DIALOG_MEDIUM, _("Upload to OSM"), GTK_WINDOW(appdata->window), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); GtkWidget *table = gtk_table_new(4, 5, TRUE); table_attach_label_c(table, _("Total"), 1, 2, 0, 1); table_attach_label_c(table, _("New"), 2, 3, 0, 1); table_attach_label_c(table, _("Modified"), 3, 4, 0, 1); table_attach_label_c(table, _("Deleted"), 4, 5, 0, 1); int row = 1; table_attach_label_l(table, _("Nodes:"), 0, 1, row, row + 1); table_insert_count(table, &dirty.nodes, row++); table_attach_label_l(table, _("Ways:"), 0, 1, row, row + 1); table_insert_count(table, &dirty.ways, row++); table_attach_label_l(table, _("Relations:"), 0, 1, row, row + 1); table_insert_count(table, &dirty.relations, row++); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table, FALSE, FALSE, 0); /* ------------------------------------------------------ */ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), gtk_hseparator_new(), FALSE, FALSE, 0); /* ------- add username and password entries ------------ */ table = gtk_table_new(2, 2, FALSE); table_attach_label_l(table, _("Username:"******"Password:"******"Please add a comment"), -1); /* disable ok button until user edited the comment */ gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT, FALSE); g_signal_connect(G_OBJECT(buffer), "changed", G_CALLBACK(callback_buffer_modified), dialog); #ifndef FREMANTLE GtkWidget *view = gtk_text_view_new_with_buffer(buffer); #else GtkWidget *view = hildon_text_view_new(); hildon_text_view_set_buffer(HILDON_TEXT_VIEW(view), buffer); #endif gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD); gtk_text_view_set_editable(GTK_TEXT_VIEW(view), TRUE); gtk_text_view_set_left_margin(GTK_TEXT_VIEW(view), 2 ); gtk_text_view_set_right_margin(GTK_TEXT_VIEW(view), 2 ); g_object_set_data(G_OBJECT(view), "first_click", GINT_TO_POINTER(TRUE)); g_signal_connect(G_OBJECT(view), "focus-in-event", G_CALLBACK(cb_focus_in), buffer); gtk_container_add(GTK_CONTAINER(scrolled_win), view); gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), scrolled_win); gtk_widget_show_all(dialog); if(GTK_RESPONSE_ACCEPT != gtk_dialog_run(GTK_DIALOG(dialog))) { printf("upload cancelled\n"); gtk_widget_destroy(dialog); return; } printf("clicked ok\n"); /* retrieve username and password */ g_free(appdata->settings->username); appdata->settings->username = g_strdup(gtk_entry_get_text(GTK_ENTRY(uentry))); g_free(appdata->settings->password); appdata->settings->password = g_strdup(gtk_entry_get_text(GTK_ENTRY(pentry))); /* osm upload itself also has a gui */ osm_upload_context_t *context = g_new0(osm_upload_context_t, 1); context->appdata = appdata; context->osm = osm; context->project = project; /* add proxy settings if required */ if(appdata->settings) context->proxy = appdata->settings->proxy; /* fetch comment from dialog */ GtkTextIter start, end; gtk_text_buffer_get_start_iter(buffer, &start); gtk_text_buffer_get_end_iter(buffer, &end); char *text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); context->comment = g_strdup(text); gtk_widget_destroy(dialog); project_save(GTK_WIDGET(appdata->window), project); context->dialog = misc_dialog_new(MISC_DIALOG_LARGE,_("Uploading"), GTK_WINDOW(appdata->window), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); gtk_dialog_set_response_sensitive(GTK_DIALOG(context->dialog), GTK_RESPONSE_CLOSE, FALSE); /* ------- main ui element is this text view --------------- */ GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); context->log.buffer = gtk_text_buffer_new(NULL); context->log.view = gtk_text_view_new_with_buffer(context->log.buffer); gtk_text_view_set_editable(GTK_TEXT_VIEW(context->log.view), FALSE); gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(context->log.view), FALSE); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(context->log.view), GTK_WRAP_WORD); gtk_container_add(GTK_CONTAINER(scrolled_window), context->log.view); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), GTK_SHADOW_IN); gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), scrolled_window); gtk_widget_show_all(context->dialog); /* server url should not end with a slash */ if(project->rserver && project->rserver[strlen(project->rserver)-1] == '/') { printf("removing trailing slash\n"); project->rserver[strlen(project->rserver)-1] = 0; } appendf(&context->log, NULL, _("Log generated by %s v%s using API 0.6\n"), PACKAGE, VERSION); appendf(&context->log, NULL, _("User comment: %s\n"), context->comment); /* check if server name contains string "0.5" and adjust it */ if(project->rserver && strstr(project->rserver, "0.5") != NULL) { strstr(project->rserver, "0.5")[2] = '6'; appendf(&context->log, NULL, _("Adjusting server name to v0.6\n")); } appendf(&context->log, NULL, _("Uploading to %s\n"), project->server); /* create a new changeset */ gchar *cred; if(osm_create_changeset(context, &cred)) { /* check for dirty entries */ appendf(&context->log, NULL, _("Uploading nodes:\n")); osm_upload_nodes(context, cred); appendf(&context->log, NULL, _("Uploading ways:\n")); osm_upload_ways(context, cred); appendf(&context->log, NULL, _("Uploading relations:\n")); osm_upload_relations(context, cred); appendf(&context->log, NULL, _("Deleting relations:\n")); osm_delete_relations(context, cred); appendf(&context->log, NULL, _("Deleting ways:\n")); osm_delete_ways(context, cred); appendf(&context->log, NULL, _("Deleting nodes:\n")); osm_delete_nodes(context, cred); /* close changeset */ osm_close_changeset(context, cred); } appendf(&context->log, NULL, _("Upload done.\n")); gboolean reload_map = FALSE; if(project->data_dirty) { appendf(&context->log, NULL, _("Server data has been modified.\n")); appendf(&context->log, NULL, _("Downloading updated osm data ...\n")); if(osm_download(context->dialog, appdata->settings, project)) { appendf(&context->log, NULL, _("Download successful!\n")); appendf(&context->log, NULL, _("The map will be reloaded.\n")); project->data_dirty = FALSE; reload_map = TRUE; } else appendf(&context->log, NULL, _("Download failed!\n")); project_save(context->dialog, project); if(reload_map) { /* this kind of rather brute force reload is useful as the moment */ /* after the upload is a nice moment to bring everything in sync again. */ /* we basically restart the entire map with fresh data from the server */ /* and the diff will hopefully be empty (if the upload was successful) */ appendf(&context->log, NULL, _("Reloading map ...\n")); if(!diff_is_clean(appdata->osm, FALSE)) { appendf(&context->log, COLOR_ERR, _("*** DIFF IS NOT CLEAN ***\n")); appendf(&context->log, COLOR_ERR, _("Something went wrong during upload,\n")); appendf(&context->log, COLOR_ERR, _("proceed with care!\n")); } /* redraw the entire map by destroying all map items and redrawing them */ appendf(&context->log, NULL, _("Cleaning up ...\n")); diff_save(appdata->project, appdata->osm); map_clear(appdata, MAP_LAYER_OBJECTS_ONLY); osm_free(appdata->osm); appendf(&context->log, NULL, _("Loading OSM ...\n")); appdata->osm = osm_parse(appdata->project->path, appdata->project->osm, &appdata->icon); appendf(&context->log, NULL, _("Applying diff ...\n")); diff_restore(appdata, appdata->project, appdata->osm); appendf(&context->log, NULL, _("Painting ...\n")); map_paint(appdata); appendf(&context->log, NULL, _("Done!\n")); } } /* tell the user that he can stop waiting ... */ appendf(&context->log, NULL, _("Process finished.\n")); gtk_dialog_set_response_sensitive(GTK_DIALOG(context->dialog), GTK_RESPONSE_CLOSE, TRUE); gtk_dialog_run(GTK_DIALOG(context->dialog)); gtk_widget_destroy(context->dialog); g_free(context->comment); g_free(context); }
gboolean radare_project_save (const char* file) { #line 9 "project.vala" g_return_val_if_fail (file != NULL, FALSE); #line 11 "project.vala" return project_save (file); }