static void on_refresh(void) { GeanyDocument *doc = document_get_current(); g_return_if_fail(doc); g_return_if_fail(edit_window.sci); set_editor(&edit_window, doc->editor); }
static gboolean do_select_current(gpointer data) { GeanyDocument *doc; /* guard out for the unlikely case we get called after another unsplitting */ if (plugin_state == STATE_UNSPLIT) return FALSE; doc = document_get_current(); if (doc) set_editor(&edit_window, doc->editor); else on_unsplit(NULL, NULL); return FALSE; }
static void split_view(gboolean horizontal) { GtkWidget *notebook = geany_data->main_widgets->notebook; GtkWidget *parent = gtk_widget_get_parent(notebook); GtkWidget *pane, *toolbar, *box, *splitwin_notebook; GeanyDocument *doc = document_get_current(); gint width = gtk_widget_get_allocated_width(notebook) / 2; gint height = gtk_widget_get_allocated_height(notebook) / 2; g_return_if_fail(doc); g_return_if_fail(edit_window.editor == NULL); set_state(horizontal ? STATE_SPLIT_HORIZONTAL : STATE_SPLIT_VERTICAL); g_object_ref(notebook); gtk_container_remove(GTK_CONTAINER(parent), notebook); pane = horizontal ? gtk_hpaned_new() : gtk_vpaned_new(); gtk_container_add(GTK_CONTAINER(parent), pane); gtk_container_add(GTK_CONTAINER(pane), notebook); g_object_unref(notebook); box = gtk_vbox_new(FALSE, 0); toolbar = create_toolbar(); gtk_box_pack_start(GTK_BOX(box), toolbar, FALSE, FALSE, 0); edit_window.vbox = box; /* used just to make the split window look the same as the main editor */ splitwin_notebook = gtk_notebook_new(); gtk_notebook_set_show_tabs(GTK_NOTEBOOK(splitwin_notebook), FALSE); gtk_notebook_append_page(GTK_NOTEBOOK(splitwin_notebook), box, NULL); gtk_container_add(GTK_CONTAINER(pane), splitwin_notebook); set_editor(&edit_window, doc->editor); if (horizontal) { gtk_paned_set_position(GTK_PANED(pane), width); } else { gtk_paned_set_position(GTK_PANED(pane), height); } gtk_widget_show_all(pane); }
static void split_view(gboolean horizontal) { GtkWidget *notebook = geany_data->main_widgets->notebook; GtkWidget *parent = gtk_widget_get_parent(notebook); GtkWidget *pane, *toolbar, *box; GeanyDocument *doc = document_get_current(); gint width = notebook->allocation.width / 2; gint height = notebook->allocation.height / 2; g_return_if_fail(doc); g_return_if_fail(edit_window.editor == NULL); set_state(horizontal ? STATE_SPLIT_HORIZONTAL : STATE_SPLIT_VERTICAL); gtk_widget_ref(notebook); gtk_container_remove(GTK_CONTAINER(parent), notebook); pane = horizontal ? gtk_hpaned_new() : gtk_vpaned_new(); gtk_container_add(GTK_CONTAINER(parent), pane); gtk_container_add(GTK_CONTAINER(pane), notebook); gtk_widget_unref(notebook); box = gtk_vbox_new(FALSE, 0); toolbar = create_toolbar(); gtk_box_pack_start(GTK_BOX(box), toolbar, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(pane), box); edit_window.vbox = box; set_editor(&edit_window, doc->editor); if (horizontal) { gtk_paned_set_position(GTK_PANED(pane), width); } else { gtk_paned_set_position(GTK_PANED(pane), height); } gtk_widget_show_all(pane); }
int read_doumlrc() { QSettings settings(QSettings::IniFormat, QSettings::UserScope, "DoUML", "settings"); settings.setIniCodec(QTextCodec::codecForName("UTF-8")); int id = settings.value("Main/id", -1).toInt(); set_manual_dir(settings.value("Main/manual", "").toString()); set_navigator_path(settings.value("Main/navigator", "").toString()); set_editor(settings.value("Main/editor", "").toString()); set_template_project(settings.value("Main/template", "").toString()); set_lang(settings.value("Main/lang").toString()); QString s = settings.value("Main/encoding", "UTF-8").toString(); set_codec(s); QTextCodec::setCodecForTr(QTextCodec::codecForName(s)); QTextCodec::setCodecForLocale(QTextCodec::codecForName(s)); int l, t, r, b; l = settings.value("Desktop/left", -1).toInt(); r = settings.value("Desktop/right", -1).toInt(); t = settings.value("Desktop/top", -1).toInt(); b = settings.value("Desktop/bottom", -1).toInt(); if(l != -1 && r != -1 && t != -1 && b != -1) { UmlDesktop::set_limits(l, t, r, b); } else { UmlDesktop::set_limits(0, 0, 0, 0); } if (id == -1) { QMessageBox::critical(0, "Douml", TR("Own identifier missing or invalid")); EnvDialog::edit(FALSE, TRUE); return read_doumlrc(); } return id; }
static void on_doc_menu_item_clicked(gpointer item, GeanyDocument *doc) { if (doc->is_valid) set_editor(&edit_window, doc->editor); }
int read_boumlrc() { // note : QFile fp(QDir::home().absFilePath(".boumlrc")) doesn't work // if the path contains non latin1 characters, for instance cyrillic ! QString s = QDir::home().absFilePath(".boumlrc"); FILE * fp = fopen((const char *) s, "r"); if (fp == 0) { QMessageBox::critical(0, "Bouml", TR("cannot read '%1'", s)); exit(-1); } set_manual_dir(""); set_navigator_path(""); set_template_project(""); set_editor(""); set_codec(""); UmlDesktop::set_limits(0, 0, 0, 0); int id = -1; char line[512]; bool lang_set = FALSE; bool nolang = FALSE; while (fgets(line, sizeof(line) - 1, fp) != 0) { remove_crlf(line); if (!strncmp(line, "ID ", 3)) sscanf(line+3, "%d", &id); else if (!strncmp(line, "MANUAL ", 7)) set_manual_dir(line+7); else if (!strncmp(line, "NAVIGATOR ", 10)) set_navigator_path(line+10); else if (!strncmp(line, "TEMPLATE ",9 )) set_template_project(line+9); else if (!strncmp(line, "EDITOR ", 7)) set_editor(line+7); else if (!strncmp(line, "CHARSET ", 8)) set_codec(line+8); else if (!strncmp(line, "DESKTOP ", 8)) { int l, t, r, b; if (sscanf(line+8, "%d %d %d %d", &l, &t, &r, &b) == 4) UmlDesktop::set_limits(l, t, r, b); } else if (!strncmp(line, "LANG ", 5)) { set_lang(line+5); lang_set = TRUE; } else if (!strncmp(line, "NOLANG", 6)) { nolang = TRUE; } } fclose(fp); if (! lang_set) { set_lang(""); if (! nolang) propose_lang(); } if (id == -1) { QMessageBox::critical(0, "Bouml", TR("Own identifier missing or invalid")); EnvDialog::edit(FALSE, TRUE); return read_boumlrc(); } return id; }
int main(int argc, char ** argv) { ExitOnError = FALSE; QApplication a(argc, argv); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); //#ifdef DEBUG QsLogging::Logger & logger = QsLogging::Logger::instance(); logger.setLoggingLevel(QsLogging::TraceLevel); QDir dir; dir.setPath(qApp->applicationDirPath()); dir.remove(QString("douml") + QString(".log")); const QString sLogPath(QDir(qApp->applicationDirPath()).filePath(QString("douml") + QString(".log"))); QsLogging::DestinationPtr fileDestination(QsLogging::DestinationFactory::MakeFileDestination(sLogPath)); QsLogging::DestinationPtr debugDestination(QsLogging::DestinationFactory::MakeDebugOutputDestination()); logger.addDestination(debugDestination.get()); logger.addDestination(fileDestination.get()); QLOG_INFO() << "Starting the log"; //#endif An<EdgeMenuFactory> factory; factory->AddFactory(TypeIdentifier<ClassDialog>::id(), CreateClassDialogMenu); factory->AddConnectionFunctor(TypeIdentifier<ClassDialog>::id(), ConnectToClassDialog<EdgeMenuDialog>); factory->AddFactory(TypeIdentifier<OperationDialog>::id(), CreateClassDialogMenu); factory->AddConnectionFunctor(TypeIdentifier<OperationDialog>::id(), ConnectToClassDialog<EdgeMenuDialog>); factory->AddFactory(TypeIdentifier<ArtifactDialog>::id(), CreateLimitedDialogMenu); factory->AddConnectionFunctor(TypeIdentifier<ArtifactDialog>::id(), ConnectToLimitedDialog<EdgeMenuDialog>); factory->AddFactory(TypeIdentifier<ConstructorInitializerDialog>::id(), CreateLimitedDialogMenu); factory->AddConnectionFunctorQt4(TypeIdentifier<ConstructorInitializerDialog>::id(), ConnectToLimitedDialog<EdgeMenuDialogQt4>); UmlDesktop::init(); QSettings settings("settings.ini", QSettings::IniFormat); settings.setIniCodec(QTextCodec::codecForName("UTF-8")); bool overridePresent = QFileInfo("override_transition.txt").exists(); if(settings.value("Main/compatibility_save") .toInt() == 1 && !overridePresent) { QMessageBox::warning(0, QObject::tr("Warning"), QObject::tr("Douml is working in transitional mode.\n All UI improvements are yours to use, " "but saving is done in the format of Bouml 4.22 " "which loses all new c++11 and hierarchy specifiers\n\n" "To suppress this warning place empty file override_transition.txt into the application folder\n" "To disable the mode - change compatibility_save parameter to 0 in settings.ini\n")); } // note : bool conv_env = !QDir::home().exists(".doumlrc") doesn't work // if the path contains non latin1 characters, for instance cyrillic ! QString s = QDir::home().absFilePath(".doumlrc"); FILE * fp = fopen((const char *) s, "r"); bool conv_env = (fp == 0); if (conv_env) EnvDialog::edit(TRUE); else fclose(fp); read_doumlrc(); // for virtual desktop init_pixmaps(); init_font(); Shortcut::init(conv_env); bool exec = FALSE; bool no_gui = FALSE; if (argc > 3) { if (!strcmp(argv[2], "-execnogui")) exec = no_gui = TRUE; else exec = !strcmp(argv[2], "-exec"); } UmlWindow * uw = new UmlWindow(exec); if (no_gui) UmlDesktop::set_nogui(); else { uw->showMaximized(); } if (argc > 1) { try { if ((argc == 3) && !strcmp(argv[2], "-root") && (msg_critical(TR("DO NOT CONFIRM"), TR("Root mode protection\n\n" "This mode allows me to develop BOUML\n\n" "do NOT confirm to avoid a disaster !!!\n\n" "confirm ?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)) { set_user_id(0); set_editor(getenv("BOUML_EDITOR")); // no environment file argc = 1; } uw->load_it(argv[1]); } catch (...) { // cannot read a file return -1; } } QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); try { if (argc > 2) { if (exec) { bool with_exit = FALSE; if (!strcmp(argv[argc - 1], "-exit")) { with_exit = TRUE; argc -= 1; } WrapperStr cmd = argv[3]; WrapperStr space = " "; int index; for (index = 4; index != argc; index += 1) cmd += space + WrapperStr(argv[index]); ToolCom::run((const char *) cmd, BrowserView::get_project(), with_exit); } else msg_warning(TR("Error"), TR("Bouml was called with wrong parameters, ignore them")); } ExitOnError = TRUE; a.exec(); } catch (...) { ; } return exit_value(); }
static void hndlmenu(int title, int item, int kstate) { int qbutton; /* DjV 013 291202 */ if ((menu[item].ob_state & DISABLED) == 0) { switch (item) { case MINFO: info(); break; case MQUIT: /* DjV 013 291202 ---vvv--- */ qbutton = alert_printf(3,QUITALRT); /* DjV 013 090203 shutdown revived */ switch (qbutton) { case 3: break; case 2: shutdown=TRUE; /* no effect yet */ /* break;DjV 013 090203 only without shutdown */ case 1: /* DjV 013 291202 ---^^^--- */ menu_tnormal(menu, title, 1); quit = TRUE; break; } /* DjV 013 291202 */ break; case MOPTIONS: setpreferences(); break; case MPRGOPT: prg_setprefs(); break; case MSAVESET: save_options(); break; case MLOADOPT: load_settings(); break; case MSAVEAS: save_options_as(); break; case MAPPLIK: app_install(); break; case MIDSKICN: dsk_insticon(); break; case MIWDICN: icnt_settypes(); break; case MCHNGICN: dsk_chngicon(); break; case MREMICON: dsk_remicon(); break; case MEDITOR: set_editor(); break; /* DjV 016 050103 ---vvv--- */ case MCOPTS: copyprefs(); break; /* DjV 016 050103 ---^^^--- */ case MWDOPT: dsk_options(); break; /* DjV 007 250102 ---vvv--- */ case MVOPTS: chrez=voptions(); if ( chrez ) quit=TRUE; break; /* DjV 007 250102 ---^^^--- */ default: wd_hndlmenu(item, kstate); /* handle all the rest in window.c */ break; } } menu_tnormal(menu, title, 1); }