AtomsDlg::AtomsDlg(QWidget* pParent, QSettings *pSettings, bool bEnableJ) : QDialog(pParent), m_pSettings(pSettings), m_bEnableJ(bEnableJ) { setupUi(this); if(m_pSettings) { QFont font; if(m_pSettings->contains("main/font_gen") && font.fromString(m_pSettings->value("main/font_gen", "").toString())) setFont(font); } if(m_bEnableJ) { tableAtoms->setColumnCount(5); tableAtoms->setHorizontalHeaderItem(static_cast<int>(AtInfo::J), new QTableWidgetItem("J (meV/K)")); } tableAtoms->setColumnWidth(0, 75); btnAdd->setIcon(load_icon("res/icons/list-add.svg")); btnDel->setIcon(load_icon("res/icons/list-remove.svg")); #if QT_VER >= 5 QObject::connect(btnAdd, &QAbstractButton::clicked, this, &AtomsDlg::AddAtom); QObject::connect(btnDel, &QAbstractButton::clicked, this, &AtomsDlg::RemoveAtom); QObject::connect(buttonBox, &QDialogButtonBox::clicked, this, &AtomsDlg::ButtonBoxClicked); #else QObject::connect(btnAdd, SIGNAL(clicked(bool)), this, SLOT(AddAtom())); QObject::connect(btnDel, SIGNAL(clicked(bool)), this, SLOT(RemoveAtom())); QObject::connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(ButtonBoxClicked(QAbstractButton*))); #endif if(m_pSettings && m_pSettings->contains("atoms/geo")) restoreGeometry(m_pSettings->value("atoms/geo").toByteArray());
void control::data_changed() { static const Glib::RefPtr<Gdk::Pixbuf> connected = load_icon("connected_plug", Gtk::ICON_SIZE_BUTTON); static const Glib::RefPtr<Gdk::Pixbuf> disconnected = load_icon("plug_tool", Gtk::ICON_SIZE_BUTTON); if(m_data->document().document().pipeline().dependency(m_data->property())) m_image->set(connected); else m_image->set(disconnected); }
void set::unserialize(core::coll_helper _coll) { set_id(_coll.get_value_as_int("id")); set_name(_coll.get_value_as_string("name")); if (_coll.is_value_exist("icon")) { core::istream* icon_stream = _coll.get_value_as_stream("icon"); if (icon_stream) { int32_t icon_size = icon_stream->size(); if (icon_size > 0) { load_icon((char*)icon_stream->read(icon_size), icon_size); } } } core::iarray* sticks = _coll.get_value_as_array("stickers"); stickers_.reserve(sticks->size()); for (int32_t i = 0; i < sticks->size(); i++) { core::coll_helper coll_sticker(sticks->get_at(i)->get_as_collection(), false); auto inserted_sticker = std::make_shared<sticker>(); inserted_sticker->unserialize(coll_sticker); inserted_sticker->set_set_id(get_id()); stickers_.push_back(inserted_sticker); } }
ico_button *make_conditional_buttons(int x,int &y) { ico_button *start_list=NULL; int h; if (current_level) // should we include a return icon? { start_list=load_icon(7,ID_RETURN,x,y,h,NULL,"ic_return"); y+=h; } ico_button *load; if (!player_list->next && show_load_icon()) { load= load_icon(1,ID_LOAD_PLAYER_GAME,x,y,h,NULL,"ic_load"); y+=h;} else load=NULL; if (start_list) start_list->next=load; else start_list=load; return start_list; }
DesktopIcon::DesktopIcon(GlobalIconSettings* gs, IconSettings* is, int bg) : Fl_Widget(is->x, is->y, ICON_SIZE_MIN_W, ICON_SIZE_MIN_H) { E_ASSERT(gs != NULL); lwidth = lheight = 0; focus = false; micon = NULL; darker_img = NULL; /* * GlobalIconSettings is shared from desktop so we only * reference it. On other hand IconSettings is not shared * and we must construct a copy from given parameter */ globals = gs; settings = new IconSettings; settings->name = is->name; settings->cmd = is->cmd; settings->icon = is->icon; settings->icon2 = is->icon2; settings->type = is->type; settings->key_name= is->key_name; settings->full_path = is->full_path; // x,y are not needed since x(), y() are filled with it // setting fonts is TODO :P #if 0 Fl::set_font((Fl_Font)20, "-windows-*-medium-r-*-*-14-*-*-*-*-*-*-*"); labelfont((Fl_Font)20); #endif label(settings->name.c_str()); imenu = new Fl_Menu_Button(0, 0, 0, 0); if(settings->type == ICON_TRASH) imenu->menu(icon_trash_menu); else imenu->menu(icon_menu); load_icon(ICON_FACE_ONE); fix_position(x(), y()); //Use desktop color as color for icon background color(bg); align(FL_ALIGN_WRAP); update_label_size(); }
static void attempt_load_pixbuf(GdkPixbuf **pixbuf, const gchar *name, gint size) { GdkPixbuf *loaded; loaded = load_icon(name, size); if (!loaded) { g_warning("failed to load %s icon", name); return; } if (*pixbuf) g_object_unref(*pixbuf); *pixbuf = loaded; }
static GdkPixbuf * icns_image_load (FILE *f, GError ** error) { GByteArray *data; GdkPixbuf *pixbuf = NULL; guint i; data = g_byte_array_new (); while (!feof (f)) { gint save_errno; guchar buf[4096]; gsize bytes; bytes = fread (buf, 1, sizeof (buf), f); save_errno = errno; data = g_byte_array_append (data, buf, bytes); if (ferror (f)) { g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (save_errno), _("Error reading ICNS image: %s"), g_strerror (save_errno)); g_byte_array_free (data, TRUE); return NULL; } } for (i = 0; i < G_N_ELEMENTS(sizes) && !pixbuf; i++) pixbuf = load_icon (sizes[i], data->data, data->len); g_byte_array_free (data, TRUE); if (!pixbuf) g_set_error_literal (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_CORRUPT_IMAGE, _("Could not decode ICNS file")); return pixbuf; }
void on_pick(viewport::control& Viewport, const GdkEventButton& Event) { const k3d::selection::record selection = Viewport.pick_node(k3d::point2(Event.x, Event.y)); if(selection.empty()) return; k3d::inode* const node = k3d::selection::get_node(selection); return_if_fail(node); if(selection::state(m_document_state.document()).is_selected(*node)) { m_set_parent = true; m_document_state.set_cursor_signal().emit(load_icon("parent_cursor", Gtk::ICON_SIZE_BUTTON)); } else { selection::state(m_document_state.document()).select(selection); } }
DesktopIcon::DesktopIcon(GlobalIconSettings* gs, IconSettings* is, int bg) : Fl_Widget(is->x, is->y, ICON_SIZE_MIN_W, ICON_SIZE_MIN_H) { E_ASSERT(gs != NULL); lwidth = lheight = 0; focus = false; micon = NULL; darker_img = NULL; gsettings = gs; settings = is; /* setting fonts is TODO :P */ #if 0 Fl::set_font((Fl_Font)20, "-windows-*-medium-r-*-*-14-*-*-*-*-*-*-*"); labelfont((Fl_Font)20); #endif label(settings->name.c_str()); imenu = new MenuButton(0, 0, 0, 0); if(settings->type == ICON_TRASH) imenu->menu(icon_trash_menu); else { icon_menu[2].image(IconLoader::get("edit-delete", ICON_SIZE_TINY)); imenu->menu(icon_menu); } load_icon(ICON_FACE_ONE); fix_position(x(), y()); /* use desktop color as color for icon background */ color(bg); align(FL_ALIGN_WRAP); update_label_size(); }
TazDlg::TazDlg(QWidget* pParent) : QMainWindow(pParent), m_settings("tobis_stuff", "takin"), m_pSettingsDlg(new SettingsDlg(this, &m_settings)), m_pStatusMsg(new QLabel(this)), m_pCoordQStatusMsg(new QLabel(this)), m_pCoordCursorStatusMsg(new QLabel(this)), m_sceneRecip(this), m_dlgRecipParam(this, &m_settings), m_dlgRealParam(this, &m_settings), m_pGotoDlg(new GotoDlg(this, &m_settings)) { //log_debug("In ", __func__, "."); const bool bSmallqVisible = 0; const bool bBZVisible = 1; const bool bWSVisible = 1; this->setupUi(this); this->setWindowTitle(s_strTitle.c_str()); this->setFont(g_fontGen); this->setWindowIcon(load_icon("res/icons/takin.svg")); btnAtoms->setEnabled(g_bHasScatlens); if(m_settings.contains("main/geo")) { QByteArray geo = m_settings.value("main/geo").toByteArray(); restoreGeometry(geo); } /*if(m_settings.contains("main/width") && m_settings.contains("main/height")) { int iW = m_settings.value("main/width").toInt(); int iH = m_settings.value("main/height").toInt(); resize(iW, iH); }*/ m_pStatusMsg->setFrameStyle(QFrame::Panel | QFrame::Sunken); m_pCoordQStatusMsg->setFrameStyle(QFrame::Panel | QFrame::Sunken); m_pCoordCursorStatusMsg->setFrameStyle(QFrame::Panel | QFrame::Sunken); for(QLabel* pLabel : {m_pStatusMsg/*, m_pCoordQStatusMsg, m_pCoordCursorStatusMsg*/}) pLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred); QStatusBar *pStatusBar = new QStatusBar(this); pStatusBar->addWidget(m_pStatusMsg, 1); pStatusBar->addPermanentWidget(m_pCoordQStatusMsg, 0); pStatusBar->addPermanentWidget(m_pCoordCursorStatusMsg, 0); m_pCoordQStatusMsg->setMinimumWidth(350); m_pCoordQStatusMsg->setAlignment(Qt::AlignCenter); m_pCoordCursorStatusMsg->setMinimumWidth(325); m_pCoordCursorStatusMsg->setAlignment(Qt::AlignCenter); this->setStatusBar(pStatusBar); // -------------------------------------------------------------------------------- m_vecEdits_real = { editA, editB, editC, editAlpha, editBeta, editGamma }; m_vecEdits_recip = { editARecip, editBRecip, editCRecip, editAlphaRecip, editBetaRecip, editGammaRecip }; m_vecEdits_plane = { editScatX0, editScatX1, editScatX2, editScatY0, editScatY1, editScatY2, editRealX0, editRealX1, editRealX2, editRealY0, editRealY1, editRealY2, }; m_vecEdits_monoana = { editMonoD, editAnaD }; //m_vecSpinBoxesSample = { spinRotPhi, spinRotTheta, spinRotPsi }; m_vecCheckBoxesSenses = { checkSenseM, checkSenseS, checkSenseA }; m_vecEditNames_real = { "sample/a", "sample/b", "sample/c", "sample/alpha", "sample/beta", "sample/gamma" }; m_vecEditNames_recip = { "sample/a_recip", "sample/b_recip", "sample/c_recip", "sample/alpha_recip", "sample/beta_recip", "sample/gamma_recip" }; m_vecEditNames_plane = { "plane/x0", "plane/x1", "plane/x2", "plane/y0", "plane/y1", "plane/y2", "plane/real_x0", "plane/real_x1", "plane/real_x2", "plane/real_y0", "plane/real_y1", "plane/real_y2", }; m_vecEditNames_monoana = { "tas/mono_d", "tas/ana_d" }; m_vecSpinBoxNamesSample = {"sample/phi", "sample/theta", "sample/psi"}; m_vecCheckBoxNamesSenses = {"tas/sense_m", "tas/sense_s", "tas/sense_a"}; // recip m_pviewRecip = new ScatteringTriangleView(groupRecip); groupRecip->addTab(m_pviewRecip, "Reciprocal Lattice"); m_pviewProjRecip = new ProjLatticeView(groupRecip); groupRecip->addTab(m_pviewProjRecip, "Projection"); m_pviewRecip->setScene(&m_sceneRecip); m_pviewProjRecip->setScene(&m_sceneProjRecip); if(m_settings.contains("main/recip_tab")) groupRecip->setCurrentIndex(m_settings.value("main/recip_tab").value<int>()); // real m_pviewRealLattice = new LatticeView(groupReal); groupReal->addTab(m_pviewRealLattice, "Real Lattice"); m_pviewReal = new TasLayoutView(groupReal); groupReal->addTab(m_pviewReal, "TAS Instrument"); m_pviewTof = new TofLayoutView(groupReal); groupReal->addTab(m_pviewTof, "TOF Instrument"); m_pviewRealLattice->setScene(&m_sceneRealLattice); m_pviewReal->setScene(&m_sceneReal); m_pviewTof->setScene(&m_sceneTof); if(m_settings.contains("main/real_tab")) groupReal->setCurrentIndex(m_settings.value("main/real_tab").value<int>()); QObject::connect(m_pSettingsDlg, SIGNAL(SettingsChanged()), this, SLOT(SettingsChanged())); QObject::connect(&m_sceneReal, SIGNAL(nodeEvent(bool)), this, SLOT(RealNodeEvent(bool))); QObject::connect(&m_sceneRecip, SIGNAL(nodeEvent(bool)), this, SLOT(RecipNodeEvent(bool))); QObject::connect(&m_sceneTof, SIGNAL(nodeEvent(bool)), this, SLOT(TofNodeEvent(bool))); // TAS QObject::connect(&m_sceneRecip, SIGNAL(triangleChanged(const TriangleOptions&)), &m_sceneReal, SLOT(triangleChanged(const TriangleOptions&))); QObject::connect(&m_sceneReal, SIGNAL(tasChanged(const TriangleOptions&)), &m_sceneRecip, SLOT(tasChanged(const TriangleOptions&))); QObject::connect(&m_sceneRecip, SIGNAL(paramsChanged(const RecipParams&)), &m_sceneReal, SLOT(recipParamsChanged(const RecipParams&))); // TOF QObject::connect(&m_sceneRecip, SIGNAL(triangleChanged(const TriangleOptions&)), &m_sceneTof, SLOT(triangleChanged(const TriangleOptions&))); QObject::connect(&m_sceneTof, SIGNAL(tasChanged(const TriangleOptions&)), &m_sceneRecip, SLOT(tasChanged(const TriangleOptions&))); QObject::connect(&m_sceneRecip, SIGNAL(paramsChanged(const RecipParams&)), &m_sceneTof, SLOT(recipParamsChanged(const RecipParams&))); // connections between instruments QObject::connect(&m_sceneTof, SIGNAL(tasChanged(const TriangleOptions&)), &m_sceneReal, SLOT(triangleChanged(const TriangleOptions&))); QObject::connect(&m_sceneReal, SIGNAL(tasChanged(const TriangleOptions&)), &m_sceneTof, SLOT(triangleChanged(const TriangleOptions&))); // scale factor if(m_pviewRecip) QObject::connect(m_pviewRecip, SIGNAL(scaleChanged(t_real_glob)), &m_sceneRecip, SLOT(scaleChanged(t_real_glob))); if(m_pviewProjRecip) QObject::connect(m_pviewProjRecip, SIGNAL(scaleChanged(t_real_glob)), &m_sceneProjRecip, SLOT(scaleChanged(t_real_glob))); if(m_pviewRealLattice) QObject::connect(m_pviewRealLattice, SIGNAL(scaleChanged(t_real_glob)), &m_sceneRealLattice, SLOT(scaleChanged(t_real_glob))); if(m_pviewReal) QObject::connect(m_pviewReal, SIGNAL(scaleChanged(t_real_glob)), &m_sceneReal, SLOT(scaleChanged(t_real_glob))); if(m_pviewTof) QObject::connect(m_pviewTof, SIGNAL(scaleChanged(t_real_glob)), &m_sceneTof, SLOT(scaleChanged(t_real_glob))); // parameter dialogs QObject::connect(&m_sceneRecip, SIGNAL(paramsChanged(const RecipParams&)), &m_dlgRecipParam, SLOT(paramsChanged(const RecipParams&))); QObject::connect(&m_sceneReal, SIGNAL(paramsChanged(const RealParams&)), &m_dlgRealParam, SLOT(paramsChanged(const RealParams&))); // cursor position QObject::connect(&m_sceneRecip, SIGNAL(coordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob)), this, SLOT(RecipCoordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob))); QObject::connect(&m_sceneProjRecip, SIGNAL(coordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob)), this, SLOT(RecipCoordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob))); QObject::connect(&m_sceneRealLattice, SIGNAL(coordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob)), this, SLOT(RealCoordsChanged(t_real_glob, t_real_glob, t_real_glob, bool, t_real_glob, t_real_glob, t_real_glob))); QObject::connect(&m_sceneRecip, SIGNAL(spurionInfo(const tl::ElasticSpurion&, const std::vector<tl::InelasticSpurion<t_real_glob>>&, const std::vector<tl::InelasticSpurion<t_real_glob>>&)), this, SLOT(spurionInfo(const tl::ElasticSpurion&, const std::vector<tl::InelasticSpurion<t_real_glob>>&, const std::vector<tl::InelasticSpurion<t_real_glob>>&))); QObject::connect(m_pGotoDlg, SIGNAL(vars_changed(const CrystalOptions&, const TriangleOptions&)), this, SLOT(VarsChanged(const CrystalOptions&, const TriangleOptions&))); QObject::connect(&m_sceneRecip, SIGNAL(paramsChanged(const RecipParams&)), m_pGotoDlg, SLOT(RecipParamsChanged(const RecipParams&))); QObject::connect(&m_sceneRecip, SIGNAL(paramsChanged(const RecipParams&)), this, SLOT(recipParamsChanged(const RecipParams&))); for(QLineEdit* pEdit : m_vecEdits_monoana) QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(UpdateDs())); for(QLineEdit* pEdit : m_vecEdits_real) { QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(CheckCrystalType())); QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(CalcPeaks())); } for(QLineEdit* pEdit : m_vecEdits_plane) { QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(CalcPeaks())); } //for(QDoubleSpinBox* pSpin : m_vecSpinBoxesSample) // QObject::connect(pSpin, SIGNAL(valueChanged(t_real)), this, SLOT(CalcPeaks())); for(QLineEdit* pEdit : m_vecEdits_recip) { QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(CheckCrystalType())); QObject::connect(pEdit, SIGNAL(textEdited(const QString&)), this, SLOT(CalcPeaksRecip())); } QObject::connect(checkSenseM, SIGNAL(stateChanged(int)), this, SLOT(UpdateMonoSense())); QObject::connect(checkSenseS, SIGNAL(stateChanged(int)), this, SLOT(UpdateSampleSense())); QObject::connect(checkSenseA, SIGNAL(stateChanged(int)), this, SLOT(UpdateAnaSense())); QObject::connect(editSpaceGroupsFilter, SIGNAL(textEdited(const QString&)), this, SLOT(RepopulateSpaceGroups())); QObject::connect(comboSpaceGroups, SIGNAL(currentIndexChanged(int)), this, SLOT(SetCrystalType())); QObject::connect(comboSpaceGroups, SIGNAL(currentIndexChanged(int)), this, SLOT(CalcPeaks())); QObject::connect(checkPowder, SIGNAL(stateChanged(int)), this, SLOT(CalcPeaks())); QObject::connect(btnAtoms, SIGNAL(clicked(bool)), this, SLOT(ShowAtomsDlg())); // -------------------------------------------------------------------------------- // file menu QMenu *pMenuFile = new QMenu("File", this); QAction *pNew = new QAction("New", this); pNew->setIcon(load_icon("res/icons/document-new.svg")); pMenuFile->addAction(pNew); pMenuFile->addSeparator(); QAction *pLoad = new QAction("Load...", this); pLoad->setIcon(load_icon("res/icons/document-open.svg")); pMenuFile->addAction(pLoad); m_pMenuRecent = new QMenu("Recently Loaded", this); tl::RecentFiles recent(&m_settings, "main/recent"); m_pMapperRecent = new QSignalMapper(m_pMenuRecent); QObject::connect(m_pMapperRecent, SIGNAL(mapped(const QString&)), this, SLOT(LoadFile(const QString&))); recent.FillMenu(m_pMenuRecent, m_pMapperRecent); pMenuFile->addMenu(m_pMenuRecent); QAction *pSave = new QAction("Save", this); pSave->setIcon(load_icon("res/icons/document-save.svg")); pMenuFile->addAction(pSave); QAction *pSaveAs = new QAction("Save as...", this); pSaveAs->setIcon(load_icon("res/icons/document-save-as.svg")); pMenuFile->addAction(pSaveAs); pMenuFile->addSeparator(); QAction *pImport = new QAction("Import...", this); pImport->setIcon(load_icon("res/icons/drive-harddisk.svg")); pMenuFile->addAction(pImport); m_pMenuRecentImport = new QMenu("Recently Imported", this); tl::RecentFiles recentimport(&m_settings, "main/recent_import"); m_pMapperRecentImport = new QSignalMapper(m_pMenuRecentImport); QObject::connect(m_pMapperRecentImport, SIGNAL(mapped(const QString&)), this, SLOT(ImportFile(const QString&))); recentimport.FillMenu(m_pMenuRecentImport, m_pMapperRecentImport); pMenuFile->addMenu(m_pMenuRecentImport); pMenuFile->addSeparator(); QAction *pSettings = new QAction("Settings...", this); pSettings->setIcon(load_icon("res/icons/preferences-system.svg")); pMenuFile->addAction(pSettings); pMenuFile->addSeparator(); QAction *pExit = new QAction("Exit", this); pExit->setIcon(load_icon("res/icons/system-log-out.svg")); pMenuFile->addAction(pExit); // -------------------------------------------------------------------------------- // recip menu m_pMenuViewRecip = new QMenu("Reciprocal Space", this); m_pGoto = new QAction("Go to Position...", this); m_pGoto->setIcon(load_icon("res/icons/goto.svg")); m_pMenuViewRecip->addAction(m_pGoto); QAction *pRecipParams = new QAction("Information...", this); m_pMenuViewRecip->addAction(pRecipParams); m_pMenuViewRecip->addSeparator(); m_pSmallq = new QAction("Show Reduced Scattering Vector q", this); m_pSmallq->setIcon(load_icon("res/icons/q.svg")); m_pSmallq->setCheckable(1); m_pSmallq->setChecked(bSmallqVisible); m_pMenuViewRecip->addAction(m_pSmallq); m_pSnapSmallq = new QAction("Snap G to Bragg Peak", this); m_pSnapSmallq->setCheckable(1); m_pSnapSmallq->setChecked(m_sceneRecip.getSnapq()); m_pMenuViewRecip->addAction(m_pSnapSmallq); QAction *pKeepAbsKiKf = new QAction("Keep |ki| and |kf| Fixed", this); pKeepAbsKiKf->setCheckable(1); pKeepAbsKiKf->setChecked(m_sceneRecip.getKeepAbsKiKf()); m_pMenuViewRecip->addAction(pKeepAbsKiKf); m_pBZ = new QAction("Show First Brillouin Zone", this); m_pBZ->setIcon(load_icon("res/icons/brillouin.svg")); m_pBZ->setCheckable(1); m_pBZ->setChecked(bBZVisible); m_pMenuViewRecip->addAction(m_pBZ); QMenu *pMenuEwald = new QMenu("Ewald Sphere", this); QActionGroup *pGroupEwald = new QActionGroup(this); m_pEwaldSphereNone = new QAction("Disabled", this); m_pEwaldSphereKi = new QAction("Around ki", this); m_pEwaldSphereKf = new QAction("Around kf", this); for(QAction* pAct : {m_pEwaldSphereNone, m_pEwaldSphereKi, m_pEwaldSphereKf}) { pAct->setCheckable(1); pGroupEwald->addAction(pAct); } m_pEwaldSphereKf->setChecked(1); pMenuEwald->addActions(pGroupEwald->actions()); m_pMenuViewRecip->addMenu(pMenuEwald); m_pMenuViewRecip->addSeparator(); QMenu *pMenuProj = new QMenu("Projection", this); pMenuProj->setTearOffEnabled(1); QActionGroup *pGroupProj = new QActionGroup(this); m_pProjGnom = new QAction("Gnomonic", this); m_pProjStereo = new QAction("Stereographic", this); m_pProjPara = new QAction("Parallel", this); m_pProjPersp = new QAction("Perspectivic", this); for(QAction *pAct : {m_pProjGnom, m_pProjStereo, m_pProjPara, m_pProjPersp}) { pAct->setCheckable(1); pGroupProj->addAction(pAct); } m_pProjStereo->setChecked(1); pMenuProj->addActions(pGroupProj->actions()); m_pMenuViewRecip->addMenu(pMenuProj); #if !defined NO_3D QAction *pView3D = new QAction("3D View...", this); //pView3D->setIcon(QIcon::fromTheme("applications-graphics")); m_pMenuViewRecip->addAction(pView3D); #endif m_pMenuViewRecip->addSeparator(); QAction *pRecipExport = new QAction("Export Lattice Graphics...", this); pRecipExport->setIcon(load_icon("res/icons/image-x-generic.svg")); m_pMenuViewRecip->addAction(pRecipExport); QAction *pProjExport = new QAction("Export Projection Graphics...", this); pProjExport->setIcon(load_icon("res/icons/image-x-generic.svg")); m_pMenuViewRecip->addAction(pProjExport); #ifdef USE_GIL QAction *pBZExport = new QAction("Export Brillouin Zone Image...", this); pBZExport->setIcon(load_icon("res/icons/image-x-generic.svg")); m_pMenuViewRecip->addAction(pBZExport); #endif // -------------------------------------------------------------------------------- // real menu m_pMenuViewReal = new QMenu("Real Space", this); m_pMenuViewReal->addAction(m_pGoto); QAction *pRealParams = new QAction("Information...", this); m_pMenuViewReal->addAction(pRealParams); m_pMenuViewReal->addSeparator(); m_pShowRealQDir = new QAction("Show Q Direction", this); m_pShowRealQDir->setCheckable(1); m_pShowRealQDir->setChecked(m_sceneReal.GetTasLayout()->GetRealQVisible()); m_pMenuViewReal->addAction(m_pShowRealQDir); m_pWS = new QAction("Show Wigner-Seitz Cell", this); m_pWS->setIcon(load_icon("res/icons/brillouin.svg")); m_pWS->setCheckable(1); m_pWS->setChecked(bWSVisible); m_pMenuViewReal->addAction(m_pWS); m_pMenuViewReal->addSeparator(); #if !defined NO_3D QAction *pView3DReal = new QAction("3D View...", this); //pView3DReal->setIcon(QIcon::fromTheme("applications-graphics")); m_pMenuViewReal->addAction(pView3DReal); m_pMenuViewReal->addSeparator(); #endif QAction *pRealLatticeExport = new QAction("Export Lattice Graphics...", this); pRealLatticeExport->setIcon(load_icon("res/icons/image-x-generic.svg")); m_pMenuViewReal->addAction(pRealLatticeExport); QAction *pRealExport = new QAction("Export TAS Layout...", this); pRealExport->setIcon(load_icon("res/icons/image-x-generic.svg")); m_pMenuViewReal->addAction(pRealExport); QAction *pTofExport = new QAction("Export TOF Layout...", this); pTofExport->setIcon(load_icon("res/icons/image-x-generic.svg")); m_pMenuViewReal->addAction(pTofExport); #ifdef USE_GIL QAction *pWSExport = new QAction("Export Wigner-Seitz Cell Image...", this); pWSExport->setIcon(load_icon("res/icons/image-x-generic.svg")); m_pMenuViewReal->addAction(pWSExport); #endif QAction *pExportUC = new QAction("Export Unit Cell Model...", this); pExportUC->setIcon(load_icon("res/icons/image-x-generic.svg")); m_pMenuViewReal->addAction(pExportUC); // -------------------------------------------------------------------------------- // resolution menu QMenu *pMenuReso = new QMenu("Resolution", this); QAction *pResoParams = new QAction("Parameters...", this); pResoParams->setIcon(load_icon("res/icons/accessories-calculator.svg")); pMenuReso->addAction(pResoParams); pMenuReso->addSeparator(); QAction *pResoEllipses = new QAction("Ellipses...", this); pResoEllipses->setIcon(load_icon("res/icons/ellipses.svg")); pMenuReso->addAction(pResoEllipses); #if !defined NO_3D QAction *pResoEllipses3D = new QAction("3D Ellipsoids...", this); pMenuReso->addAction(pResoEllipses3D); #endif pMenuReso->addSeparator(); QAction *pResoConv = new QAction("Convolution...", this); pMenuReso->addAction(pResoConv); // -------------------------------------------------------------------------------- // calc menu QMenu *pMenuCalc = new QMenu("Calculation", this); QAction *pNeutronProps = new QAction("Neutron Properties...", this); pNeutronProps->setIcon(load_icon("res/icons/x-office-spreadsheet-template.svg")); pMenuCalc->addAction(pNeutronProps); pMenuCalc->addSeparator(); QAction *pPowder = new QAction("Powder Lines...", this); pPowder->setIcon(load_icon("res/icons/weather-snow.svg")); pMenuCalc->addAction(pPowder); QAction *pDW = new QAction("Scattering Factors...", this); pMenuCalc->addAction(pDW); QAction *pFormfactor = nullptr; if(g_bHasFormfacts && g_bHasScatlens) { pFormfactor = new QAction("Form Factors...", this); pMenuCalc->addAction(pFormfactor); } QAction *pSgList = new QAction("Space Group Types...", this); pMenuCalc->addAction(pSgList); QAction *pDisp = new QAction("Dispersions...", this); //pDisp->setIcon(load_icon("disp.svg")); pMenuCalc->addAction(pDisp); pMenuCalc->addSeparator(); QAction *pDynPlane = new QAction("Kinematic Plane...", this); pMenuCalc->addAction(pDynPlane); QAction *pSpuri = new QAction("Spurious Scattering...", this); pMenuCalc->addAction(pSpuri); #if !defined NO_NET // -------------------------------------------------------------------------------- // network menu QMenu *pMenuNet = new QMenu("Network", this); QAction *pConn = new QAction("Connect to Instrument...", this); pConn->setIcon(load_icon("res/icons/network-transmit-receive.svg")); pMenuNet->addAction(pConn); QAction *pDisconn = new QAction("Disconnect", this); pDisconn->setIcon(load_icon("res/icons/network-offline.svg")); pMenuNet->addAction(pDisconn); pMenuNet->addSeparator(); QAction *pNetScanMon = new QAction("Scan Monitor...", this); pMenuNet->addAction(pNetScanMon); QAction *pNetCache = new QAction("Network Cache...", this); pMenuNet->addAction(pNetCache); QAction *pNetRefresh = new QAction("Refresh", this); pNetRefresh->setIcon(load_icon("res/icons/view-refresh.svg")); pMenuNet->addSeparator(); pMenuNet->addAction(pNetRefresh); #endif // -------------------------------------------------------------------------------- // tools menu QMenu *pMenuTools = new QMenu("Tools", this); QAction *pScanViewer = new QAction("Scan Viewer...", this); pMenuTools->addAction(pScanViewer); // -------------------------------------------------------------------------------- // help menu QMenu *pMenuHelp = new QMenu("Help", this); QAction *pHelp = new QAction("Show Help...", this); pHelp->setIcon(load_icon("res/icons/help-browser.svg")); pMenuHelp->addAction(pHelp); QAction *pDevelDoc = new QAction("Show Developer Help...", this); if(find_resource("doc/devel/html/index.html", 0) == "") pDevelDoc->setEnabled(0); pDevelDoc->setIcon(load_icon("res/icons/help-browser.svg")); pMenuHelp->addAction(pDevelDoc); pMenuHelp->addSeparator(); QAction *pAboutQt = new QAction("About Qt...", this); //pAboutQt->setIcon(QIcon::fromTheme("help-about")); pMenuHelp->addAction(pAboutQt); //pMenuHelp->addSeparator(); QAction *pAbout = new QAction("About Takin...", this); pAbout->setIcon(load_icon("res/icons/dialog-information.svg")); pMenuHelp->addAction(pAbout); // -------------------------------------------------------------------------------- QMenuBar *pMenuBar = new QMenuBar(this); pMenuBar->addMenu(pMenuFile); pMenuBar->addMenu(m_pMenuViewRecip); pMenuBar->addMenu(m_pMenuViewReal); pMenuBar->addMenu(pMenuReso); pMenuBar->addMenu(pMenuCalc); pMenuBar->addMenu(pMenuTools); #if !defined NO_NET pMenuBar->addMenu(pMenuNet); #endif pMenuBar->addMenu(pMenuHelp); QObject::connect(pNew, SIGNAL(triggered()), this, SLOT(New())); QObject::connect(pLoad, SIGNAL(triggered()), this, SLOT(Load())); QObject::connect(pSave, SIGNAL(triggered()), this, SLOT(Save())); QObject::connect(pSaveAs, SIGNAL(triggered()), this, SLOT(SaveAs())); QObject::connect(pImport, SIGNAL(triggered()), this, SLOT(Import())); QObject::connect(pScanViewer, SIGNAL(triggered()), this, SLOT(ShowScanViewer())); QObject::connect(pSettings, SIGNAL(triggered()), this, SLOT(ShowSettingsDlg())); QObject::connect(pExit, SIGNAL(triggered()), this, SLOT(close())); QObject::connect(m_pSmallq, SIGNAL(toggled(bool)), this, SLOT(EnableSmallq(bool))); QObject::connect(m_pBZ, SIGNAL(toggled(bool)), this, SLOT(EnableBZ(bool))); QObject::connect(m_pWS, SIGNAL(toggled(bool)), this, SLOT(EnableWS(bool))); for(QAction* pAct : {m_pEwaldSphereNone, m_pEwaldSphereKi, m_pEwaldSphereKf}) QObject::connect(pAct, SIGNAL(triggered()), this, SLOT(ShowEwaldSphere())); QObject::connect(m_pShowRealQDir, SIGNAL(toggled(bool)), this, SLOT(EnableRealQDir(bool))); QObject::connect(m_pSnapSmallq, SIGNAL(toggled(bool)), &m_sceneRecip, SLOT(setSnapq(bool))); QObject::connect(pKeepAbsKiKf, SIGNAL(toggled(bool)), &m_sceneRecip, SLOT(setKeepAbsKiKf(bool))); QObject::connect(pRecipParams, SIGNAL(triggered()), this, SLOT(ShowRecipParams())); QObject::connect(pRealParams, SIGNAL(triggered()), this, SLOT(ShowRealParams())); for(QAction *pProj : {m_pProjGnom, m_pProjStereo, m_pProjPara, m_pProjPersp}) QObject::connect(pProj, SIGNAL(triggered()), this, SLOT(RecipProjChanged())); #if !defined NO_3D QObject::connect(pView3D, SIGNAL(triggered()), this, SLOT(Show3D())); QObject::connect(pView3DReal, SIGNAL(triggered()), this, SLOT(Show3DReal())); QObject::connect(pResoEllipses3D, SIGNAL(triggered()), this, SLOT(ShowResoEllipses3D())); #endif QObject::connect(pRecipExport, SIGNAL(triggered()), this, SLOT(ExportRecip())); QObject::connect(pProjExport, SIGNAL(triggered()), this, SLOT(ExportProj())); QObject::connect(pRealExport, SIGNAL(triggered()), this, SLOT(ExportReal())); QObject::connect(pTofExport, SIGNAL(triggered()), this, SLOT(ExportTof())); QObject::connect(pRealLatticeExport, SIGNAL(triggered()), this, SLOT(ExportRealLattice())); QObject::connect(pExportUC, SIGNAL(triggered()), this, SLOT(ExportUCModel())); #ifdef USE_GIL QObject::connect(pBZExport, SIGNAL(triggered()), this, SLOT(ExportBZImage())); QObject::connect(pWSExport, SIGNAL(triggered()), this, SLOT(ExportWSImage())); #endif QObject::connect(pResoParams, SIGNAL(triggered()), this, SLOT(ShowResoParams())); QObject::connect(pResoEllipses, SIGNAL(triggered()), this, SLOT(ShowResoEllipses())); QObject::connect(pResoConv, SIGNAL(triggered()), this, SLOT(ShowResoConv())); QObject::connect(pNeutronProps, SIGNAL(triggered()), this, SLOT(ShowNeutronDlg())); QObject::connect(m_pGoto, SIGNAL(triggered()), this, SLOT(ShowGotoDlg())); QObject::connect(pPowder, SIGNAL(triggered()), this, SLOT(ShowPowderDlg())); QObject::connect(pDisp, SIGNAL(triggered()), this, SLOT(ShowDispDlg())); QObject::connect(pSpuri, SIGNAL(triggered()), this, SLOT(ShowSpurions())); QObject::connect(pDW, SIGNAL(triggered()), this, SLOT(ShowDWDlg())); QObject::connect(pDynPlane, SIGNAL(triggered()), this, SLOT(ShowDynPlaneDlg())); #if !defined NO_NET QObject::connect(pConn, SIGNAL(triggered()), this, SLOT(ShowConnectDlg())); QObject::connect(pDisconn, SIGNAL(triggered()), this, SLOT(Disconnect())); QObject::connect(pNetRefresh, SIGNAL(triggered()), this, SLOT(NetRefresh())); QObject::connect(pNetCache, SIGNAL(triggered()), this, SLOT(ShowNetCache())); QObject::connect(pNetScanMon, SIGNAL(triggered()), this, SLOT(ShowNetScanMonitor())); #endif QObject::connect(pSgList, SIGNAL(triggered()), this, SLOT(ShowSgListDlg())); if(pFormfactor) QObject::connect(pFormfactor, SIGNAL(triggered()), this, SLOT(ShowFormfactorDlg())); QObject::connect(pHelp, SIGNAL(triggered()), this, SLOT(ShowHelp())); QObject::connect(pDevelDoc, SIGNAL(triggered()), this, SLOT(ShowDevelDoc())); QObject::connect(pAbout, SIGNAL(triggered()), this, SLOT(ShowAbout())); QObject::connect(pAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); setMenuBar(pMenuBar); // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // context menus if(m_pviewRecip) m_pviewRecip->setContextMenuPolicy(Qt::CustomContextMenu); if(m_pviewProjRecip) m_pviewProjRecip->setContextMenuPolicy(Qt::CustomContextMenu); if(m_pviewRealLattice) m_pviewRealLattice->setContextMenuPolicy(Qt::CustomContextMenu); if(m_pviewReal) m_pviewReal->setContextMenuPolicy(Qt::CustomContextMenu); if(m_pviewTof) m_pviewTof->setContextMenuPolicy(Qt::CustomContextMenu); if(m_pviewRecip) QObject::connect(m_pviewRecip, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(RecipContextMenu(const QPoint&))); if(m_pviewProjRecip) QObject::connect(m_pviewProjRecip, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(RecipContextMenu(const QPoint&))); if(m_pviewRealLattice) QObject::connect(m_pviewRealLattice, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(RealContextMenu(const QPoint&))); if(m_pviewReal) QObject::connect(m_pviewReal, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(RealContextMenu(const QPoint&))); if(m_pviewTof) QObject::connect(m_pviewTof, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(RealContextMenu(const QPoint&))); // -------------------------------------------------------------------------------- // tool bars QToolBar *pFileTools = new QToolBar(this); pFileTools->setWindowTitle("File"); pFileTools->addAction(pNew); pFileTools->addAction(pLoad); pFileTools->addAction(pImport); pFileTools->addAction(pSave); pFileTools->addAction(pSaveAs); addToolBar(pFileTools); QToolBar *pRecipTools = new QToolBar(this); pRecipTools->setWindowTitle("Reciprocal Space"); pRecipTools->addAction(m_pGoto); pRecipTools->addAction(m_pSmallq); pRecipTools->addAction(m_pBZ); //pRecipTools->addAction(m_pEwaldSphere); addToolBar(pRecipTools); QToolBar *pResoTools = new QToolBar(this); pResoTools->setWindowTitle("Resolution"); pResoTools->addAction(pResoParams); pResoTools->addAction(pResoEllipses); addToolBar(pResoTools); QToolBar *pCalcTools = new QToolBar(this); pCalcTools->setWindowTitle("Calculation"); pCalcTools->addAction(pNeutronProps); pCalcTools->addAction(pPowder); addToolBar(pCalcTools); #if !defined NO_NET QToolBar *pNetTools = new QToolBar(this); pNetTools->setWindowTitle("Network"); pNetTools->addAction(pConn); pNetTools->addAction(pDisconn); pNetTools->addAction(pNetRefresh); addToolBar(pNetTools); #endif // -------------------------------------------------------------------------------- RepopulateSpaceGroups(); unsigned int iMaxPeaks = m_settings.value("main/max_peaks", 10).toUInt(); m_sceneRecip.GetTriangle()->SetMaxPeaks(iMaxPeaks); m_sceneRecip.GetTriangle()->SetPlaneDistTolerance(s_dPlaneDistTolerance); m_sceneProjRecip.GetLattice()->SetMaxPeaks(iMaxPeaks/2); m_sceneRealLattice.GetLattice()->SetMaxPeaks(iMaxPeaks); m_sceneRealLattice.GetLattice()->SetPlaneDistTolerance(s_dPlaneDistTolerance); #if !defined NO_3D if(m_pRecip3d) { m_pRecip3d->SetMaxPeaks((t_real)iMaxPeaks); m_pRecip3d->SetPlaneDistTolerance(s_dPlaneDistTolerance); } #endif m_bReady = 1; UpdateDs(); CalcPeaks(); m_sceneRecip.GetTriangle()->SetqVisible(bSmallqVisible); m_sceneRecip.GetTriangle()->SetBZVisible(bBZVisible); m_sceneRecip.GetTriangle()->SetEwaldSphereVisible(EWALD_KF); m_sceneRealLattice.GetLattice()->SetWSVisible(bWSVisible); m_sceneRecip.emitUpdate(); //m_sceneRecip.emitAllParams(); setAcceptDrops(1); }
gboolean gs_plugin_refine_app (GsPlugin *plugin, GsApp *app, GsPluginRefineFlags flags, GCancellable *cancellable, GError **error) { GsPluginData *priv = gs_plugin_get_data (plugin); g_autoptr(SnapdClient) client = NULL; const gchar *name; g_autoptr(SnapdSnap) local_snap = NULL; g_autoptr(SnapdSnap) store_snap = NULL; SnapdSnap *snap; const gchar *developer_name; g_autofree gchar *description = NULL; /* not us */ if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0) return TRUE; client = get_client (plugin, error); if (client == NULL) return FALSE; /* get information from local snaps and store */ local_snap = snapd_client_get_snap_sync (client, gs_app_get_metadata_item (app, "snap::name"), cancellable, NULL); if (local_snap == NULL || (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS) != 0) store_snap = get_store_snap (plugin, gs_app_get_metadata_item (app, "snap::name"), cancellable, NULL); if (local_snap == NULL && store_snap == NULL) return TRUE; if (local_snap != NULL) gs_app_set_state (app, AS_APP_STATE_INSTALLED); else gs_app_set_state (app, AS_APP_STATE_AVAILABLE); /* use store information for basic metadata over local information */ snap = store_snap != NULL ? store_snap : local_snap; name = snapd_snap_get_title (snap); if (name == NULL || g_strcmp0 (name, "") == 0) name = snapd_snap_get_name (snap); gs_app_set_name (app, GS_APP_QUALITY_NORMAL, name); gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, snapd_snap_get_summary (snap)); description = gs_plugin_snap_get_description_safe (snap); if (description != NULL) gs_app_set_description (app, GS_APP_QUALITY_NORMAL, description); gs_app_set_license (app, GS_APP_QUALITY_NORMAL, snapd_snap_get_license (snap)); developer_name = snapd_snap_get_publisher_display_name (snap); if (developer_name == NULL) developer_name = snapd_snap_get_publisher_username (snap); gs_app_set_developer_name (app, developer_name); if (snapd_snap_get_publisher_validation (snap) == SNAPD_PUBLISHER_VALIDATION_VERIFIED) gs_app_add_quirk (app, GS_APP_QUIRK_DEVELOPER_VERIFIED); snap = local_snap != NULL ? local_snap : store_snap; gs_app_set_version (app, snapd_snap_get_version (snap)); switch (snapd_snap_get_snap_type (snap)) { case SNAPD_SNAP_TYPE_APP: gs_app_set_kind (app, AS_APP_KIND_DESKTOP); break; case SNAPD_SNAP_TYPE_KERNEL: case SNAPD_SNAP_TYPE_GADGET: case SNAPD_SNAP_TYPE_OS: gs_app_set_kind (app, AS_APP_KIND_RUNTIME); break; default: case SNAPD_SNAP_TYPE_UNKNOWN: gs_app_set_kind (app, AS_APP_KIND_UNKNOWN); break; } /* add information specific to installed snaps */ if (local_snap != NULL) { SnapdApp *snap_app; GDateTime *install_date; install_date = snapd_snap_get_install_date (local_snap); gs_app_set_size_installed (app, snapd_snap_get_installed_size (local_snap)); gs_app_set_install_date (app, install_date != NULL ? g_date_time_to_unix (install_date) : GS_APP_INSTALL_DATE_UNKNOWN); snap_app = get_primary_app (local_snap); if (snap_app != NULL) { gs_app_set_metadata (app, "snap::launch-name", snapd_app_get_name (snap_app)); gs_app_set_metadata (app, "snap::launch-desktop", snapd_app_get_desktop_file (snap_app)); } else { gs_app_add_quirk (app, GS_APP_QUIRK_NOT_LAUNCHABLE); } } /* add information specific to store snaps */ if (store_snap != NULL) { gs_app_set_origin (app, priv->store_name); gs_app_set_size_download (app, snapd_snap_get_download_size (store_snap)); if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SCREENSHOTS && gs_app_get_screenshots (app)->len == 0) refine_screenshots (app, store_snap); } /* load icon if requested */ if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON && gs_app_get_pixbuf (app) == NULL) load_icon (plugin, client, app, gs_app_get_metadata_item (app, "snap::name"), local_snap, store_snap, cancellable); return TRUE; }
void DesktopIcon::use_icon2(void) { load_icon(ICON_FACE_TWO); fast_redraw(); }
void DesktopIcon::use_icon1(void) { load_icon(ICON_FACE_ONE); fast_redraw(); }
int CreateTopWindow(void) { #ifdef MOUSE_POINTER_CHANGE #ifdef WIN32 static const gchar *cr[CURSOR_MODE_3270] = { "arrow", "wait", "arrow", "sizenwse", // Top-left "sizenesw", // Top-right "sizens", // Top "sizenesw", // Bottom-left "sizenwse", // Bottom-right "sizens", // Bottom "sizewe", // Left "sizewe", // Right "sizeall" // Inside }; #else static int cr[CURSOR_MODE_3270] = { GDK_XTERM, GDK_WATCH, GDK_X_CURSOR, GDK_TOP_LEFT_CORNER, // Top-left GDK_TOP_RIGHT_CORNER, // Top-right GDK_TOP_SIDE, // Top GDK_BOTTOM_LEFT_CORNER, // Bottom-left GDK_BOTTOM_RIGHT_CORNER, // Bottom-right GDK_BOTTOM_SIDE, // Bottom GDK_LEFT_SIDE, // Left GDK_RIGHT_SIDE, // Right GDK_FLEUR // Inside }; #endif // WIN32 int f; #endif // MOUSE_POINTER_CHANGE static const struct ui_menu_setup_table widget_setup[] = { { "fontselect", setup_font_select_menu }, { "inputmethod", setup_input_methods_menu }, { "screensizes", setup_screen_size_menu }, { NULL, NULL } }; gchar *ptr; init_actions(); #ifdef MOUSE_POINTER_CHANGE // Load mouse pointers #ifdef WIN32 for(f=0;f<CURSOR_MODE_3270;f++) wCursor[f] = gdk_cursor_new_from_name(gdk_display_get_default(), cr[f]); #else for(f=0;f<CURSOR_MODE_3270;f++) wCursor[f] = gdk_cursor_new(cr[f]); #endif #endif // MOUSE_POINTER_CHANGE if(!CreateTerminalWindow()) return -1; // Load UI - Create toplevel window ptr = g_build_filename(program_data,"ui",NULL); topwindow = create_window_from_ui_files(ptr,terminal,widget_setup); g_free(ptr); // Load program logo load_icon(); /* if(program_logo && g_file_test(program_logo,G_FILE_TEST_IS_REGULAR)) { pix = gdk_pixbuf_new_from_file(program_logo,NULL); } else { gchar *filename = g_build_filename(program_data,PROGRAM_LOGO,NULL); if(g_file_test(filename,G_FILE_TEST_IS_REGULAR)) pix = gdk_pixbuf_new_from_file(filename, NULL); Trace("pixbuf(%s): %p",filename,pix); g_free(filename); } if(pix) { gtk_window_set_icon(GTK_WINDOW(topwindow),pix); g_object_set_data_full(G_OBJECT(topwindow),"logo",pix,g_object_unref); #if defined( HAVE_IGEMAC ) gtk_osxapplication_set_dock_icon_pixbuf(osxapp,pix); #endif } */ gtk_action_set_sensitive(action_by_id[ACTION_RESELECT],FALSE); g_signal_connect(G_OBJECT(topwindow),"destroy",G_CALLBACK(action_quit),0); // gtk_window_set_icon_list(GTK_WINDOW(topwindow),main_icon); gtk_window_set_default_size(GTK_WINDOW(topwindow),590,430); ptr = GetString("TopWindow","Title",""); settitle(ptr); g_free(ptr); action_restore(0); gtk_window_set_position(GTK_WINDOW(topwindow),GTK_WIN_POS_CENTER); return 0; }
/** * Build data storage by querying the X server for all input devices. * Can be called multiple times, in which case it'll clean out and re-fill * update the tree store. */ static GtkTreeStore* query_devices(GDeviceSetup* gds) { GtkTreeStore *treestore; GtkTreeModel *model; GtkTreeIter iter, child; XIDeviceInfo *devices, *dev; int ndevices; int i, j; int icontype; GdkPixbuf *icon; int valid, child_valid; int id, masterid; if (!gds->treeview) { treestore = gtk_tree_store_new(NUM_COLS, G_TYPE_UINT, /* deviceid*/ G_TYPE_STRING, /* name */ G_TYPE_UINT, GDK_TYPE_PIXBUF, G_TYPE_UINT ); model = GTK_TREE_MODEL(treestore); } else { model = gtk_tree_view_get_model(gds->treeview); treestore = GTK_TREE_STORE(model); } gds->generation++; devices = XIQueryDevice(gds->dpy, XIAllDevices, &ndevices); /* First, run through all master device and append them to the tree store */ for (i = 0; i < ndevices; i++) { dev = &devices[i]; if (dev->use != XIMasterPointer && dev->use != XIMasterKeyboard) continue; valid = gtk_tree_model_get_iter_first(model, &iter); g_debug("MD %d: %s", dev->deviceid, dev->name); while(valid) { gtk_tree_model_get(model, &iter, COL_ID, &id, -1); if (id == dev->deviceid) { gtk_tree_store_set(treestore, &iter, COL_GENERATION, gds->generation, -1); valid = 0xFF; break; } valid = gtk_tree_model_iter_next(model, &iter); } if (valid != 0xFF) /* new MD */ { icontype = (dev->use == XIMasterPointer) ? ICON_MOUSE : ICON_KEYBOARD; icon = load_icon(icontype); gtk_tree_store_append(treestore, &iter, NULL); gtk_tree_store_set(treestore, &iter, COL_ID, dev->deviceid, COL_NAME, dev->name, COL_USE, dev->use, COL_ICON, icon, COL_GENERATION, gds->generation, -1); g_object_unref(icon); } } /* search for Floating fake master device */ valid = gtk_tree_model_get_iter_first(model, &iter); while(valid) { gtk_tree_model_get(model, &iter, COL_ID, &id, -1); if (id == ID_FLOATING) break; valid = gtk_tree_model_iter_next(model, &iter); } if (!valid) { /* Attach a fake master device for "Floating" */ icon = load_icon(ICON_FLOATING); gtk_tree_store_append(treestore, &iter, NULL); gtk_tree_store_set(treestore, &iter, COL_ID, ID_FLOATING, COL_NAME, "Floating", COL_USE, ID_FLOATING, COL_ICON, icon, COL_GENERATION, gds->generation, -1); g_object_unref(icon); } else { GtkTreeIter prev; GtkTreeIter pos = iter; /* current position of Floating */ /* always move Floating fake device to end of list */ while(valid) { prev = iter; valid = gtk_tree_model_iter_next(model, &iter); } gtk_tree_store_move_after(treestore, &pos, &prev); /* update generation too */ gtk_tree_store_set(treestore, &pos, COL_GENERATION, gds->generation, -1); } /* now that we added all MDs, run through again and add SDs to the * respective MD */ for (i = 0; i < ndevices; i++) { dev = &devices[i]; if (dev->use == XIMasterPointer || dev->use == XIMasterKeyboard) continue; g_debug("SD %d: %s", dev->deviceid, dev->name); valid = gtk_tree_model_get_iter_first(model, &iter); while(valid) { gtk_tree_model_get(model, &iter, COL_ID, &masterid, -1); if(dev->attachment == masterid || (dev->use == XIFloatingSlave && masterid == ID_FLOATING)) { /* found master, check if we're already attached to it in * the tree model */ child_valid = gtk_tree_model_iter_children(model, &child, &iter); while (child_valid) { gtk_tree_model_get(model, &child, COL_ID, &id); if (id == dev->deviceid) { gtk_tree_store_set(treestore, &child, COL_GENERATION, gds->generation, -1); child_valid = 0xFF; break; } child_valid = gtk_tree_model_iter_next(model, &child); } /* new slave device, attach */ if (child_valid != 0xFF) { gtk_tree_store_append(treestore, &child, &iter); gtk_tree_store_set(treestore, &child, COL_ID, dev->deviceid, COL_NAME, dev->name, COL_USE, dev->use, COL_GENERATION, gds->generation, -1); } break; } valid = gtk_tree_model_iter_next(model, &iter); } } XIFreeDeviceInfo(devices); /* clean tree store of anything that doesn't have the current server generation */ valid = gtk_tree_model_get_iter_first(model, &iter); while(valid) { int gen; child_valid = gtk_tree_model_iter_children(model, &child, &iter); while(child_valid) { gtk_tree_model_get(model, &child, COL_GENERATION, &gen, -1); if (gen < gds->generation) child_valid = gtk_tree_store_remove(treestore, &child); else child_valid = gtk_tree_model_iter_next(model, &child); } gtk_tree_model_get(model, &iter, COL_GENERATION, &gen, -1); if (gen < gds->generation) valid = gtk_tree_store_remove(treestore, &iter); else valid = gtk_tree_model_iter_next(model, &iter); } return treestore; }
int OnObjectNotifyAlb(void *w, int obj) { GEM_WINDOW *wprog ; GEM_WINDOW *wnd = (GEM_WINDOW *) w ; WEXTENSION_ALBUM *wext = wnd->DlgData->UserData ; OBJECT *adr_album = wnd->DlgData->BaseObject ; float pc ; int i, y, clicked, bs, err, code = -1 ; int mx, my, dummy ; int valid, must_crash = 0 ; char *c, *n ; char buf[PATH_MAX] ; char vss_name[PATH_MAX] ; char is_registered = IsRegistered ; bs = obj ; obj &= 32767 ; if ( !(adr_album[obj].ob_state & DISABLED) && obj ) { read_text(adr_album, ALBUM_COMMENT, buf) ; if ( strcmp(buf, wext->img_comment ) ) { catalog_setimgcomment( wext->last_num, buf ) ; strcpy( wext->img_comment, buf ) ; } } switch( obj ) { case ALBUM_INFOS : show_infos( wext->categorie ) ; deselect( adr_album, obj ) ; xobjc_draw( wnd->window_handle, adr_album, obj ) ; break ; case ALBUM_NEW : i = get_newalbum( wext->album_name ) ; switch( i ) { case 0 : write_text(adr_album, ALBUM_NAME, catalog_header.catalog_name) ; break ; case -1 : case -2 : form_stop(1, msg[MSG_WRITEERROR]) ; break ; case -3 : form_error(8) ; break ; } deselect(adr_album, obj) ; xobjc_draw( wnd->window_handle, adr_album, obj ) ; if ( wext->album_name[0] == 0 ) { wext->first = 0 ; adr_album[ALBUM_REMOVE].ob_state |= DISABLED ; adr_album[ALBUM_ADDIMG].ob_state |= DISABLED ; adr_album[ALBUM_ADDFOLDER].ob_state |= DISABLED ; adr_album[ALBUM_INFOS].ob_state |= DISABLED ; adr_album[ALBUM_CATEGORIE1].ob_state |= DISABLED ; adr_album[ALBUM_CATEGORIE2].ob_state |= DISABLED ; adr_album[ALBUM_CATEGORIE3].ob_state |= DISABLED ; adr_album[ALBUM_INFOIMG].ob_state |= DISABLED ; adr_album[ALBUM_CONFIG].ob_state |= DISABLED ; adr_album[ALBUM_UPDATE].ob_state |= DISABLED ; adr_album[ALBUM_WINDOW].ob_state |= DISABLED ; adr_album[ALBUM_TOVSS].ob_state |= DISABLED ; } else { adr_album[ALBUM_REMOVE].ob_state &= ~DISABLED ; adr_album[ALBUM_ADDIMG].ob_state &= ~DISABLED ; adr_album[ALBUM_ADDFOLDER].ob_state &= ~DISABLED ; adr_album[ALBUM_INFOS].ob_state &= ~DISABLED ; adr_album[ALBUM_CATEGORIE1].ob_state &= ~DISABLED ; adr_album[ALBUM_CATEGORIE2].ob_state &= ~DISABLED ; adr_album[ALBUM_CATEGORIE3].ob_state &= ~DISABLED ; adr_album[ALBUM_INFOIMG].ob_state &= ~DISABLED ; adr_album[ALBUM_CONFIG].ob_state &= ~DISABLED ; adr_album[ALBUM_UPDATE].ob_state &= ~DISABLED ; adr_album[ALBUM_WINDOW].ob_state &= ~DISABLED ; adr_album[ALBUM_TOVSS].ob_state &= ~DISABLED ; } if (i == 0) { wext->first = 0 ; wext->last_num = -1 ; for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) deselect(adr_album, i) ; select(adr_album, ALBUM_ITEM1) ; make_category_popup( wnd ) ; update_list( wnd, 1 ) ; load_icon( wnd, wext->first ) ; xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ; } wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ; break ; case ALBUM_OPEN : strcpy(buf, config.path_album) ; strcat(buf, "\\*.VIC") ; if ( file_name(buf, "", buf) ) { c = strrchr(buf, '\\') ; c++ ; n = wext->nom ; while ((*c != 0) && (*c != '.')) *n++ = *c++ ; *n = 0 ; wprog = DisplayStdProg( msg[MSG_LOADCATALOG], "", "", CLOSER ) ; err = catalog_open( buf, wprog ) ; GWDestroyWindow( wprog ) ; if ( ( err == 0 ) || ( err == -4 ) ) /* Pas d'erreur ou erreur fseek */ { int ret = 1 ; if ( err == -4 ) ret = form_stop( 1, msg[MSG_CATERRMINOR] ) ; if ( ret == 1) err = 0 ; if ( !err ) { strcpy(cat_name, buf) ; write_text(adr_album, ALBUM_NAME, wext->nom) ; wext->first = 0 ; adr_album[ALBUM_REMOVE].ob_state &= ~DISABLED ; adr_album[ALBUM_ADDIMG].ob_state &= ~DISABLED ; adr_album[ALBUM_ADDFOLDER].ob_state &= ~DISABLED ; adr_album[ALBUM_INFOS].ob_state &= ~DISABLED ; adr_album[ALBUM_CATEGORIE1].ob_state &= ~DISABLED ; adr_album[ALBUM_CATEGORIE2].ob_state &= ~DISABLED ; adr_album[ALBUM_CATEGORIE3].ob_state &= ~DISABLED ; adr_album[ALBUM_INFOIMG].ob_state &= ~DISABLED ; adr_album[ALBUM_CONFIG].ob_state &= ~DISABLED ; adr_album[ALBUM_UPDATE].ob_state &= ~DISABLED ; adr_album[ALBUM_WINDOW].ob_state &= ~DISABLED ; adr_album[ALBUM_TOVSS].ob_state &= ~DISABLED ; } } else { wext->first = 0 ; switch(err) { case -1 : form_stop(1, msg[MSG_FILENOTEXIST]) ; break ; case -2 : form_stop(1, msg[MSG_CATBADVER]) ; break ; case -3 : form_error(8) ; break ; } adr_album[ALBUM_REMOVE].ob_state |= DISABLED ; adr_album[ALBUM_ADDIMG].ob_state |= DISABLED ; adr_album[ALBUM_ADDFOLDER].ob_state |= DISABLED ; adr_album[ALBUM_INFOS].ob_state |= DISABLED ; adr_album[ALBUM_CATEGORIE1].ob_state |= DISABLED ; adr_album[ALBUM_CATEGORIE2].ob_state |= DISABLED ; adr_album[ALBUM_CATEGORIE3].ob_state |= DISABLED ; adr_album[ALBUM_INFOIMG].ob_state |= DISABLED ; adr_album[ALBUM_CONFIG].ob_state |= DISABLED ; adr_album[ALBUM_UPDATE].ob_state |= DISABLED ; adr_album[ALBUM_WINDOW].ob_state |= DISABLED ; adr_album[ALBUM_TOVSS].ob_state |= DISABLED ; } } deselect(adr_album, obj) ; xobjc_draw( wnd->window_handle, adr_album, obj ) ; wext->first = 0 ; wext->last_num = -1 ; for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) deselect(adr_album, i) ; if ( !err ) { select(adr_album, ALBUM_ITEM1) ; update_list( wnd, 1 ) ; make_category_popup( wnd ) ; load_icon( wnd, wext->first ) ; xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ; wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ; } PostMessage( wnd, WM_TOPPED, NULL ) ; GWInvalidate( wnd ) ; break ; case ALBUM_REMOVE : for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) if (selected(adr_album, i)) break ; if (i != 1+ALBUM_ITEM10) { err = catalog_remove(wext->first+i-ALBUM_ITEM1) ; inv_select(adr_album, obj) ; wext->first-- ; if (wext->first < 0) wext->first = 0 ; wext->last_num = -1 ; load_icon( wnd, wext->first+i-ALBUM_ITEM1 ) ; update_list( wnd, 1 ) ; xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ; wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ; } break ; case ALBUM_ADDIMG : strcpy(buf, config.path_img) ; strcat(buf, "\\*.*") ; if (file_name(buf, "", buf)) { wprog = DisplayStdProg( msg[MSG_LOADINGIMG], "", buf, 0 ) ; err = catalog_add( buf, wprog ) ; GWDestroyWindow( wprog ) ; switch(err) { case ECAT_FILENOTFOUND : form_stop(1, msg[MSG_FILENOTEXIST]) ; break ; case ECAT_NOMEMORY : form_error(8) ; break ; case ECAT_ITEMEXIST : form_stop(1, msg[MSG_CATITEMEXIST]) ; break ; default : if (err) form_stop(1, msg[MSG_CATADDERR]) ; break ; } } deselect(adr_album, obj) ; xobjc_draw( wnd->window_handle, adr_album, obj ) ; update_list( wnd, 1 ) ; xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ; wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ; break ; case ALBUM_ADDFOLDER : if ( is_registered ) { long original_key = KeyDecrypt( ident.crypted_key ) ; long second_key = KeyDecrypt( ident.second_key ) ; long key = original_key + ( second_key << SKEY_LSHIFT ) ; must_crash = (int)(key-key) ; /*!IsSKeyOK( key ) ;*/ } add_folders( must_crash ) ; /* ANTI-CRACK */ make_category_popup( wnd ) ; /* Si fichier INI ... */ deselect(adr_album, obj) ; xobjc_draw( wnd->window_handle, adr_album, obj ) ; update_list( wnd, 1 ) ; xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ; wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ; break ; case ALBUM_ITEM1 : case ALBUM_ITEM2 : case ALBUM_ITEM3 : case ALBUM_ITEM4 : case ALBUM_ITEM5 : case ALBUM_ITEM6 : case ALBUM_ITEM7 : case ALBUM_ITEM8 : case ALBUM_ITEM9 : case ALBUM_ITEM10 : read_text( adr_album, obj, buf ) ; if ( buf[0] ) { if ( bs > 0 ) { load_icon( wnd, wext->first+obj-ALBUM_ITEM1 ) ; xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ; } else { catalog_getfullname(wext->first+obj-ALBUM_ITEM1, buf) ; config.color_protect = wext->cconfig ; load_wpicture( buf, 0 ) ; config.color_protect = selected(adr_album, ALBUM_PPAL) ; } } break ; case ALBUM_INFOIMG : deselect(adr_album, obj) ; xobjc_draw( wnd->window_handle, adr_album, obj ) ; for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) if (selected(adr_album, i)) break ; if (i != 1+ALBUM_ITEM10) show_imginfo(wext->first+i-ALBUM_ITEM1, wext->img_comment) ; break ; case ALBUM_IMAGE : deselect(adr_album, obj) ; for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) if (selected(adr_album, i)) break ; if (i != 1+ALBUM_ITEM10) { catalog_getfullname(wext->first+i-ALBUM_ITEM1, buf) ; config.color_protect = wext->cconfig ; load_wpicture( buf, 0 ) ; config.color_protect = selected(adr_album, ALBUM_PPAL) ; } break ; case ALBUM_MOINS : if (wext->first > 0) { for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) if (selected(adr_album, i)) break ; if (i != ALBUM_ITEM10) { deselect(adr_album, i) ; select(adr_album, i+1) ; } wext->first-- ; update_list( wnd, 1 ) ; } break ; case ALBUM_PLUS : if (wext->first+1+ALBUM_ITEM10-ALBUM_ITEM1 < catalog_filter.nb_visibles) { for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) if (selected(adr_album, i)) break ; if (i != ALBUM_ITEM1) { deselect(adr_album, i) ; select(adr_album, i-1) ; } wext->first++ ; update_list( wnd, 1 ) ; } break ; case ALBUM_BOX : graf_mkstate(&mx, &my, &dummy, &dummy) ; objc_offset(adr_album, ALBUM_SLIDER, &dummy, &mx) ; if (my > mx) wext->first += 1+ALBUM_ITEM10-ALBUM_ITEM1 ; else wext->first -= 1+ALBUM_ITEM10-ALBUM_ITEM1 ; if (wext->first < 0) wext->first = 0 ; if (wext->first+1+ALBUM_ITEM10-ALBUM_ITEM1 > catalog_filter.nb_visibles) wext->first = (int) (catalog_filter.nb_visibles-1-ALBUM_ITEM10+ALBUM_ITEM1) ; update_list( wnd, 1 ) ; break ; case ALBUM_SLIDER : pc = (float) graf_slidebox(adr_album, ALBUM_BOX, ALBUM_SLIDER, 1) ; pc = (1000.0-pc)/10.0 ; y = (int) ((100.0-pc)*(float)wext->hf/100.0) ; adr_album[ALBUM_SLIDER].ob_y = y ; wext->first = (int) ((float)y*(float)(catalog_filter.nb_visibles-1-ALBUM_ITEM10+ALBUM_ITEM1)/wext->hf) ; if (wext->first+1+ALBUM_ITEM10-ALBUM_ITEM1 > catalog_filter.nb_visibles) wext->first = (int) (catalog_filter.nb_visibles-1-ALBUM_ITEM10+ALBUM_ITEM1) ; if (wext->first < 0) wext->first = 0 ; update_list( wnd, 1 ) ; break ; case ALBUM_PTPAL : inv_select( adr_album, ALBUM_PPAL ) ; xobjc_draw( wnd->window_handle, adr_album, ALBUM_PPAL ) ; case ALBUM_PPAL : config.color_protect = selected( adr_album, ALBUM_PPAL ) ; set_palette(&wext->imginf) ; break ; case ALBUM_CATEGORIE1: case ALBUM_CATEGORIE2: case ALBUM_CATEGORIE3: for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) if (selected(adr_album, i)) break ; if ((tab_index == NULL) || (i == 1+ALBUM_ITEM10)) break ; deselect(adr_album, obj) ; objc_offset(adr_album, obj, &mx, &my) ; switch(obj) { case ALBUM_CATEGORIE1 : clicked = popup_formdo( &wext->categorie, mx, my, 2+tab_index[wext->first+i-ALBUM_ITEM1].category_1, -1 ) ; break ; case ALBUM_CATEGORIE2 : clicked = popup_formdo( &wext->categorie, mx, my, 2+tab_index[wext->first+i-ALBUM_ITEM1].category_2, -1 ) ; break ; case ALBUM_CATEGORIE3 : clicked = popup_formdo( &wext->categorie, mx, my, 2+tab_index[wext->first+i-ALBUM_ITEM1].category_3, -1 ) ; break ; } if (clicked > 1) { sprintf(buf, " %s", catalog_header.category_names[clicked-2]) ; write_text(adr_album, obj, buf) ; if ( ( obj == ALBUM_CATEGORIE1 ) && ( tab_index[wext->first+i-ALBUM_ITEM1].category_1 == tab_index[wext->first+i-ALBUM_ITEM1].category_2 ) && ( tab_index[wext->first+i-ALBUM_ITEM1].category_2 == tab_index[wext->first+i-ALBUM_ITEM1].category_3 ) ) { int j ; for (j = 1; j <= 3 ; j++ ) catalog_setcategory( wext->first+i-ALBUM_ITEM1, clicked-2, j ) ; } else catalog_setcategory(wext->first+i-ALBUM_ITEM1, clicked-2, 1+obj-ALBUM_CATEGORIE1) ; } else if (clicked == 1) { int index_category ; char buffer[80] ; lstd_input( msg[MSG_CATENEW], buffer ) ; if (buffer[0]) { index_category = catalog_addcategory(buffer) ; make_category_popup( wnd ) ; sprintf(buf, " %s", buffer) ; write_text(adr_album, obj, buf) ; catalog_setcategory(wext->first+i-ALBUM_ITEM1, index_category, 1+obj-ALBUM_CATEGORIE1) ; } } wext->last_num = -1 ; load_icon( wnd, wext->first+i-ALBUM_ITEM1 ) ; break ; case ALBUM_CONFIG : if (album_config() == 1) { mouse_busy() ; sort_index() ; wext->first = 0 ; mouse_restore() ; } deselect(adr_album, obj) ; xobjc_draw( wnd->window_handle, adr_album, obj ) ; update_list( wnd, 1 ) ; wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ; for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) if (selected(adr_album, i)) break ; wext->last_num = -1 ; load_icon( wnd, wext->first+i-ALBUM_ITEM1 ) ; if (catalog_filter.nb_visibles <= 0) adr_album[ALBUM_WINDOW].ob_state |= DISABLED ; else adr_album[ALBUM_WINDOW].ob_state &= ~DISABLED ; xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ; xobjc_draw( wnd->window_handle, adr_album, ALBUM_WINDOW ) ; break ; case ALBUM_UPDATE : catalog_update( msg[MSG_UPDATECAT] ) ; deselect(adr_album, obj) ; xobjc_draw( wnd->window_handle, adr_album, obj ) ; update_list( wnd, 1 ) ; wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ; for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) if (selected(adr_album, i)) break ; wext->last_num = -1 ; load_icon( wnd, wext->first+i-ALBUM_ITEM1 ) ; xobjc_draw( wnd->window_handle, adr_album, ALBUM_IMAGE ) ; break ; case ALBUM_WINDOW : if ( WndAlbum == NULL ) album_window() ; deselect(adr_album, obj) ; xobjc_draw( wnd->window_handle, adr_album, obj ) ; wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ; for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) if (selected(adr_album, i)) break ; wext->last_num = -1 ; load_icon( wnd, wext->first+i-ALBUM_ITEM1 ) ; break ; case ALBUM_TOVSS : sprintf( vss_name, "%s\\*.VSS", config.path_album ) ; valid = file_name(vss_name, "", vss_name) ; if ( valid ) { GEM_WINDOW *wprog ; FILE *stream ; long num ; int r ; char full_name[200] ; char buf[50] ; if ( FileExist( vss_name ) ) r = form_interrogation(2, msg[MSG_FILEEXISTS]) ; if ( r == 2 ) break ; stream = fopen( vss_name, "wb" ) ; if ( stream == NULL ) { form_stop(1,msg[MSG_WRITEERROR]) ; break ; } wprog = DisplayStdProg( msg[MSG_SAVEVSS], "", "", CLOSER ) ; for ( num = 0; num < catalog_filter.nb_visibles ; num++ ) { catalog_getfullname( num, full_name ) ; if ( full_name[0] != 0 ) { sprintf( buf, "Display %s\r\n", full_name ) ; if ( fwrite( buf, strlen(buf), 1, stream ) != 1 ) { form_stop(1,msg[MSG_WRITEERROR]) ; break ; } } if ( MAY_UPDATE( wprog, num ) ) { sprintf( buf, "%04ld/%04ld", num, catalog_filter.nb_visibles ) ; wprog->ProgPc( wprog, (int) ((100L*num)/(long)catalog_filter.nb_visibles), buf ) ; } } fclose( stream ) ; GWDestroyWindow( wprog ) ; } deselect(adr_album, obj) ; xobjc_draw( wnd->window_handle, adr_album, obj ) ; break ; case ALBUM_OK : code = IDOK ; break ; } if ( code == IDOK ) { } return( code ) ; }
void OnInitDialogAlb(void *w) { GEM_WINDOW *wprog ; GEM_WINDOW *wnd = (GEM_WINDOW *) w ; WEXTENSION_ALBUM *wext = wnd->DlgData->UserData ; OBJECT *adr_album = wnd->DlgData->BaseObject ; int i, err ; char *c, *n ; if ( WndAlbum ) return ; adr_album[ALBUM_IMAGE].ob_spec.userblk->ub_code = draw_albumimg ; adr_album[ALBUM_IMAGE].ob_spec.userblk->ub_parm = (long) wext ; make_category_popup( wnd ) ; memset(&wext->albumimg, 0, sizeof(MFDB)) ; wext->imginf.palette = NULL ; write_text(adr_album, ALBUM_NAME, "") ; write_text(adr_album, ALBUM_CATEGORIE1, "") ; write_text(adr_album, ALBUM_CATEGORIE2, "") ; write_text(adr_album, ALBUM_CATEGORIE3, "") ; for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) deselect(adr_album, i) ; select(adr_album, ALBUM_ITEM1) ; wext->album_name[0] = 0 ; wext->first = 0 ; adr_album[ALBUM_REMOVE].ob_state |= DISABLED ; adr_album[ALBUM_ADDIMG].ob_state |= DISABLED ; adr_album[ALBUM_ADDFOLDER].ob_state |= DISABLED ; adr_album[ALBUM_INFOS].ob_state |= DISABLED ; adr_album[ALBUM_CATEGORIE1].ob_state |= DISABLED ; adr_album[ALBUM_CATEGORIE2].ob_state |= DISABLED ; adr_album[ALBUM_CATEGORIE3].ob_state |= DISABLED ; adr_album[ALBUM_INFOIMG].ob_state |= DISABLED ; adr_album[ALBUM_CONFIG].ob_state |= DISABLED ; adr_album[ALBUM_UPDATE].ob_state |= DISABLED ; adr_album[ALBUM_WINDOW].ob_state |= DISABLED ; adr_album[ALBUM_TOVSS].ob_state |= DISABLED ; if (Truecolor) { adr_album[ALBUM_PPAL].ob_state |= DISABLED ; adr_album[ALBUM_PTPAL].ob_state |= DISABLED ; } else { adr_album[ALBUM_PPAL].ob_state &= ~DISABLED ; adr_album[ALBUM_PTPAL].ob_state &= ~DISABLED ; select(adr_album, ALBUM_PPAL) ; } update_list( wnd, 0 ) ; wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ; wext->last_num = -1 ; wext->cconfig = config.color_protect ; config.color_protect = selected(adr_album, ALBUM_PPAL) ; strcpy( wext->img_comment, "" ) ; write_text( adr_album, ALBUM_COMMENT, wext->img_comment ) ; /* Chargement du nom pass‚ en paramŠtre */ if ( wext->name || (cat_name[0] != 0)) { if ( wext->name ) c = strrchr( wext->name, '\\' ) ; else c = strrchr( cat_name, '\\' ) ; if (c == NULL) c = wext->name ; else c++ ; n = wext->nom ; while ( *c && ( *c != '.' ) ) *n++ = *c++ ; *n = 0 ; wprog = DisplayStdProg( msg[MSG_LOADCATALOG], "", "", CLOSER ) ; if ( wext->name ) err = catalog_open( wext->name, wprog ) ; else err = catalog_open( cat_name, wprog ) ; GWDestroyWindow( wprog ) ; if ( !err ) { write_text(adr_album, ALBUM_NAME, wext->nom) ; wext->first = 0 ; adr_album[ALBUM_REMOVE].ob_state &= ~DISABLED ; adr_album[ALBUM_ADDIMG].ob_state &= ~DISABLED ; adr_album[ALBUM_ADDFOLDER].ob_state &= ~DISABLED ; adr_album[ALBUM_INFOS].ob_state &= ~DISABLED ; adr_album[ALBUM_CATEGORIE1].ob_state &= ~DISABLED ; adr_album[ALBUM_CATEGORIE2].ob_state &= ~DISABLED ; adr_album[ALBUM_CATEGORIE3].ob_state &= ~DISABLED ; adr_album[ALBUM_INFOIMG].ob_state &= ~DISABLED ; adr_album[ALBUM_CONFIG].ob_state &= ~DISABLED ; adr_album[ALBUM_UPDATE].ob_state &= ~DISABLED ; adr_album[ALBUM_WINDOW].ob_state &= ~DISABLED ; adr_album[ALBUM_TOVSS].ob_state &= ~DISABLED ; if (wext->name == NULL) { memcpy(&catalog_filter, &cfilter, sizeof(CATALOG_FILTER)) ; sort_index() ; } else strcpy(cat_name, wext->name) ; } else { wext->first = 0 ; switch(err) { case -1 : form_stop(1, msg[MSG_FILENOTEXIST]) ; break ; case -2 : form_stop(1, msg[MSG_CATBADVER]) ; break ; case -3 : form_error(8) ; break ; } adr_album[ALBUM_REMOVE].ob_state |= DISABLED ; adr_album[ALBUM_ADDIMG].ob_state |= DISABLED ; adr_album[ALBUM_ADDFOLDER].ob_state |= DISABLED ; adr_album[ALBUM_INFOS].ob_state |= DISABLED ; adr_album[ALBUM_CATEGORIE1].ob_state |= DISABLED ; adr_album[ALBUM_CATEGORIE2].ob_state |= DISABLED ; adr_album[ALBUM_CATEGORIE3].ob_state |= DISABLED ; adr_album[ALBUM_INFOIMG].ob_state |= DISABLED ; adr_album[ALBUM_CONFIG].ob_state |= DISABLED ; adr_album[ALBUM_UPDATE].ob_state |= DISABLED ; adr_album[ALBUM_WINDOW].ob_state |= DISABLED ; adr_album[ALBUM_TOVSS].ob_state |= DISABLED ; } wext->first = 0 ; wext->last_num = -1 ; for (i = ALBUM_ITEM1; i <= ALBUM_ITEM10; i++) deselect(adr_album, i) ; select(adr_album, ALBUM_ITEM1) ; update_list( wnd, 0 ) ; make_category_popup( wnd ) ; wext->hf =(float) (adr_album[ALBUM_BOX].ob_height-adr_album[ALBUM_SLIDER].ob_height) ; load_icon( wnd, wext->first ) ; } GWSetWndRscIcon( wnd, FORM_ALBUM, ALBUM_ADDFOLDER ) ; adr_album[ALBUM_PPAL].ob_flags |= TOUCHEXIT ; /* Evite modif RSC */ }
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { static HWND last_focus=0; if(FALSE) //if(msg!=WM_MOUSEFIRST&&msg!=WM_NCHITTEST&&msg!=WM_SETCURSOR&&msg!=WM_ENTERIDLE&&msg!=WM_NOTIFY) if(msg!=WM_NCHITTEST&&msg!=WM_SETCURSOR&&msg!=WM_ENTERIDLE&&msg!=WM_MOUSEMOVE&&msg!=WM_NCMOUSEMOVE) { static DWORD tick=0; if((GetTickCount()-tick)>500) printf("--\n"); print_msg(msg,lparam,wparam,hwnd); tick=GetTickCount(); } switch(msg) { case WM_MENUSELECT: break; case WM_CREATE: { RECT rect={0}; extern int keep_closed,trim_trailing,left_justify; get_ini_value("SETTINGS","KEEP_CLOSED",&keep_closed); get_ini_value("SETTINGS","TRIM_TRAILING",&trim_trailing); get_ini_value("SETTINGS","LEFT_JUSTIFY",&left_justify); load_icon(hwnd); load_window_size(hwnd,"MAIN_WINDOW"); GetClientRect(hwnd,&rect); get_ini_value("SETTINGS","TREE_WIDTH",&tree_width); if(tree_width>rect.right-10 || tree_width<10){ tree_width=rect.right/4; if(tree_width<12) tree_width=12; } ghmdiclient=create_mdiclient(hwnd,ghmenu,ghinstance); ghdbview=create_dbview(hwnd,ghinstance); ghstatusbar=CreateStatusWindow(WS_CHILD|WS_VISIBLE,"ready",hwnd,IDC_STATUS); create_status_bar_parts(hwnd,ghstatusbar); resize_main_window(hwnd,tree_width); } break; case WM_DROPFILES: process_drop(hwnd,wparam); break; case WM_COPYDATA: if(lparam!=0){ COPYDATASTRUCT *cd=lparam; process_cmd_line(cd->lpData); } break; case WM_USER: debug_window_focus(lparam,"WM_USER"); switch(wparam){ case IDC_TREEVIEW: if(lparam!=0) SetFocus(lparam); break; case IDC_MDI_LISTVIEW: if(lparam!=0){ last_focus=lparam; SetFocus(lparam); } break; case IDC_LV_EDIT: if(lparam!=0) last_focus=lparam; break; } break; case WM_USER+1: debug_window_focus(last_focus,"WMUSER+1"); if(last_focus!=0) SetFocus(last_focus); break; case WM_NCACTIVATE: debug_window_focus(last_focus,"NCACTIVATE wparam=%08X",wparam); if(wparam==0){ last_focus=GetFocus(); } else{ PostMessage(hwnd,WM_USER+1,0,0); } break; case WM_ACTIVATEAPP: //close any tooltip on app switch debug_window_focus(last_focus,"ACTIVATEAPP wparam=%08X",wparam); if(wparam){ PostMessage(hwnd,WM_USER+1,0,0); } break; case WM_KILLFOCUS: case WM_RBUTTONDOWN: case WM_LBUTTONUP: if(main_drag){ ReleaseCapture(); main_drag=FALSE; write_ini_value("SETTINGS","TREE_WIDTH",tree_width); } break; case WM_LBUTTONDOWN: { int x=LOWORD(lparam); if(x>=(tree_width-10) && x<(tree_width+10)){ SetCapture(hwnd); SetCursor(LoadCursor(NULL,IDC_SIZEWE)); main_drag=TRUE; } } break; case WM_MOUSEFIRST: { int x=LOWORD(lparam); if(x>=(tree_width-10) && x<(tree_width+10)) SetCursor(LoadCursor(NULL,IDC_SIZEWE)); if(main_drag){ RECT rect; GetClientRect(ghmainframe,&rect); if(x>10 && x<rect.right-10){ tree_width=x; resize_main_window(hwnd,tree_width); } } } break; case WM_COMMAND: switch(LOWORD(wparam)){ case IDM_OPEN: if((GetKeyState(VK_SHIFT)&0x8000) || GetKeyState(VK_CONTROL)&0x8000) task_open_db(""); else{ if(does_key_exist("SOFTWARE\\ODBC\\ODBC.INI\\ODBC Data Sources","Journal")) task_open_db("UID=dba;PWD=sql;DSN=Journal"); else task_open_db(""); } break; case IDM_CLOSE: { HANDLE hroot=0; if(tree_find_focused_root(&hroot)){ char str[MAX_PATH]={0}; tree_get_db_table(hroot,str,sizeof(str),0,0,0); if(str[0]!=0){ set_status_bar_text(ghstatusbar,0,"closing %s",str); task_close_db(str); } } else set_status_bar_text(ghstatusbar,0,"select a DB"); } break; case IDM_SETTINGS: DialogBox(ghinstance,MAKEINTRESOURCE(IDD_SETTINGS),hwnd,settings_proc); break; case IDM_RECENT: DialogBox(ghinstance,MAKEINTRESOURCE(IDD_RECENT),hwnd,recent_proc); break; case IDM_STOP_THREAD: { int click=MessageBox(hwnd,"Are you sure you want to terminate the task?","Warning",MB_OKCANCEL|MB_SYSTEMMODAL); if(click==IDOK){ terminate_worker_thread(); stop_thread_menu(FALSE); } } break; case IDM_QUERY: task_new_query(); break; case IDC_EXECUTE_SQL: task_execute_query(NULL); break; case IDM_TILE_DIALOG: tile_select_dialog(hwnd); break; case IDM_WINDOW_TILE: mdi_tile_windows_vert(); break; case IDM_WINDOW_CASCADE: mdi_cascade_win_vert(); break; case IDM_WINDOW_LRTILE: mdi_tile_windows_horo(); break; case IDM_REFRESH_ALL: refresh_all_dialog(hwnd); break; case IDM_REORDER: reorder_win_dialog(hwnd); break; } break; case WM_SIZE: resize_main_window(hwnd,tree_width); create_status_bar_parts(ghmainframe,ghstatusbar); return 0; break; case WM_QUERYENDSESSION: return 1; //ok to end session break; case WM_ENDSESSION: if(wparam){ if(!(GetKeyState(VK_SHIFT)&0x8000)) save_window_size(hwnd,"MAIN_WINDOW"); } return 0; case WM_CLOSE: break; case WM_DESTROY: if(!(GetKeyState(VK_SHIFT)&0x8000)) save_window_size(hwnd,"MAIN_WINDOW"); PostQuitMessage(0); break; } return DefFrameProc(hwnd, ghmdiclient, msg, wparam, lparam); }
/** * @fn int main (int argc, char **argv) * @brief Main program & Gtk thread. * * Create window and all widgets, then set there parameters to be the <br> * ROS params. */ int main (int argc, char **argv) { GtkBuilder *builder; GdkColor black = { 0, 0, 0, 0 }; GError *error = NULL; char glade_gui_file[FILENAME_MAX]; int start_zoom = 15; char *mapcachedir; OsmGpsMapPoint ccny_coord = { 40.818551, -73.948674 }; struct arg param; param.argc = argc; param.argv = argv; pthread_t rosThread; // **** init threads g_thread_init (NULL); gdk_threads_init (); gdk_threads_enter (); // **** init gtk gtk_init (&argc, &argv); // **** allocate data structure data = g_slice_new (AppData); // **** set the glade gui file & set icon directory std::string package_path = ros::package::getPath (ROS_PACKAGE_NAME); sprintf (glade_gui_file, "%s/gui/%s", package_path.c_str (), "gui.glade"); sprintf (data->icon_directory, "%s/gui/icon", package_path.c_str ()); std::string rosbag_path = ros::package::getPath("rosbag"); sprintf (data->rosbag_rec_path, "%s/bin/record", rosbag_path.c_str ()); data->current_page = 0; data->telemetry_opt_popup_state = false; data->gps_opt_popup_state = false; data->fullscreen = false; load_icon (); // **** Create new GtkBuilder object builder = gtk_builder_new (); // **** Load UI from file if (!gtk_builder_add_from_file (builder, glade_gui_file, &error)) { g_warning ("%s", error->message); g_free (error); exit (-1); } // **** Get main window pointer from UI data->window = GTK_WIDGET (gtk_builder_get_object (builder, "window1")); gtk_window_set_title (GTK_WINDOW (data->window), "CityFlyer Ground Station"); gtk_window_set_position (GTK_WINDOW (data->window), GTK_WIN_POS_CENTER); gtk_window_set_default_size (GTK_WINDOW (data->window), 1024, 576); // **** create ROS thread pthread_create (&rosThread, NULL, startROS, ¶m); // **** wait ros finish read params while (!data->ros_param_read) { ROS_DEBUG ("Waiting ROS params"); } // **** Get GtkNotebook objsect data->notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook1")); // ##################################################################### // ##################################################################### // **** Tab 1: Telemetry // **** create altimeter widgets data->alt = gtk_altimeter_new (); g_object_set (GTK_ALTIMETER (data->alt), "grayscale-color", data->grayscale_color, "unit-is-feet", data->altimeter_unit_is_feet, "unit-step-value", data->altimeter_step_value, "radial-color", data->radial_color, NULL); // **** create compass widgets data->comp = gtk_compass_new (); g_object_set (GTK_COMPASS (data->comp), "grayscale-color", data->grayscale_color, "radial-color", data->radial_color, NULL); data->comp2 = gtk_compass_new (); g_object_set (GTK_COMPASS (data->comp2), "grayscale-color", data->grayscale_color, "radial-color", data->radial_color, NULL); data->gauge1 = gtk_gauge_new (); g_object_set (GTK_GAUGE (data->gauge1), "name", data->gauge1_name_f, NULL); g_object_set (GTK_GAUGE (data->gauge1), "grayscale-color", data->grayscale_color, "radial-color", data->radial_color, "start-value", data->gauge1_start_value, "end-value", data->gauge1_end_value, "initial-step", data->gauge1_initial_step, "sub-step", (gdouble) data->gauge1_sub_step, "drawing-step", data->gauge1_drawing_step, "color-strip-order", data->gauge1_color_strip_order, "green-strip-start", data->gauge1_green_strip_start, "yellow-strip-start", data->gauge1_yellow_strip_start, "red-strip-start", data->gauge1_red_strip_start, NULL); // **** create artificial horizon widgets data->arh = gtk_artificial_horizon_new (); g_object_set (GTK_ARTIFICIAL_HORIZON (data->arh), "grayscale-color", data->grayscale_color, "radial-color", data->radial_color, NULL); // **** create variometer widgets data->vario = gtk_variometer_new (); g_object_set (GTK_VARIOMETER (data->vario), "grayscale-color", data->grayscale_color, "unit-is-feet", data->variometer_unit_is_feet, "unit-step-value", data->variometer_step_value, "radial-color", data->radial_color, NULL); data->widget_table = GTK_WIDGET (gtk_builder_get_object (builder, "table_Widgets")); gtk_table_attach_defaults (GTK_TABLE (data->widget_table), data->alt, 0, 1, 0, 1); gtk_table_attach_defaults (GTK_TABLE (data->widget_table), data->arh, 1, 2, 0, 1); gtk_table_attach_defaults (GTK_TABLE (data->widget_table), data->comp, 2, 3, 0, 1); gtk_table_attach_defaults (GTK_TABLE (data->widget_table), data->vario, 0, 1, 1, 2); gtk_table_attach_defaults (GTK_TABLE (data->widget_table), data->comp2, 1, 2, 1, 2); gtk_table_attach_defaults (GTK_TABLE (data->widget_table), data->gauge1, 2, 3, 1, 2); gtk_widget_modify_bg (data->alt, GTK_STATE_NORMAL, &black); gtk_widget_modify_bg (data->comp, GTK_STATE_NORMAL, &black); gtk_widget_modify_bg (data->comp2, GTK_STATE_NORMAL, &black); gtk_widget_modify_bg (data->arh, GTK_STATE_NORMAL, &black); gtk_widget_modify_bg (data->gauge1, GTK_STATE_NORMAL, &black); gtk_widget_modify_bg (data->vario, GTK_STATE_NORMAL, &black); data->telemetry_option_popup = GTK_WIDGET (gtk_builder_get_object (builder, "hbox_TelemetryOption")); data->btn_open_telemetry_option_popup = GTK_WIDGET (gtk_builder_get_object (builder, "button_OpenTelemetryOptionPopup")); data->btn_close_telemetry_option_popup = GTK_WIDGET (gtk_builder_get_object (builder, "button_CloseTelemetryOptionPopup")); gtk_button_set_image (GTK_BUTTON (data->btn_open_telemetry_option_popup), gtk_image_new_from_pixbuf (gdk_pixbuf_scale_simple (data->leftarrow_icon_64, 24, 50, GDK_INTERP_HYPER))); gtk_button_set_image (GTK_BUTTON (data->btn_close_telemetry_option_popup), gtk_image_new_from_pixbuf (gdk_pixbuf_scale_simple (data->rightarrow_icon_64, 24, 50, GDK_INTERP_HYPER))); // ##################################################################### // ##################################################################### // **** Tab 2: Gps // Some GpsdViewer initialisation data->draw_path = false; data->map_provider = OSM_GPS_MAP_SOURCE_OPENSTREETMAP; data->map_zoom_max = 18; data->map_current_zoom = start_zoom; data->repo_uri = osm_gps_map_source_get_repo_uri (data->map_provider); data->friendly_name = osm_gps_map_source_get_friendly_name (data->map_provider); data->uav_track = osm_gps_map_track_new (); mapcachedir = osm_gps_map_get_default_cache_directory (); data->cachedir = g_build_filename (mapcachedir, data->friendly_name, NULL); g_free (mapcachedir); // Create the OsmGpsMap object data->map = (OsmGpsMap *) g_object_new (OSM_TYPE_GPS_MAP, "map-source", data->map_provider, "tile-cache", data->cachedir, "proxy-uri", g_getenv ("http_proxy"), NULL); //Set the starting coordinates and zoom level for the map osm_gps_map_set_zoom (data->map, start_zoom); osm_gps_map_set_center (data->map, ccny_coord.rlat, ccny_coord.rlon); data->osd = gpsd_viewer_osd_new (); g_object_set (GPSD_VIEWER_OSD (data->osd), "show-scale", true, "show-coordinates", true, "show-dpad", true, "show-zoom", true, "show-gps-in-dpad", true, "show-gps-in-zoom", false, "dpad-radius", 30, NULL); osm_gps_map_layer_add (OSM_GPS_MAP (data->map), OSM_GPS_MAP_LAYER (data->osd)); data->map_box = GTK_WIDGET (gtk_builder_get_object (builder, "hbox_map_box")); data->map_container = GTK_WIDGET (gtk_builder_get_object (builder, "hbox_map_container")); gtk_box_pack_start (GTK_BOX (data->map_box), GTK_WIDGET (data->map), TRUE, TRUE, 0); data->gpsd_option_popup = GTK_WIDGET (gtk_builder_get_object (builder, "hbox_GpsdOptionPopup")); data->btn_open_gpsd_option_popup = GTK_WIDGET (gtk_builder_get_object (builder, "button_OpenGpsdOptionPopup")); data->btn_close_gpsd_option_popup = GTK_WIDGET (gtk_builder_get_object (builder, "button_CloseGpsdOptionPopup")); gtk_button_set_image (GTK_BUTTON (data->btn_open_gpsd_option_popup), gtk_image_new_from_pixbuf (gdk_pixbuf_scale_simple (data->leftarrow_icon_64, 24, 50, GDK_INTERP_HYPER))); gtk_button_set_image (GTK_BUTTON (data->btn_close_gpsd_option_popup), gtk_image_new_from_pixbuf (gdk_pixbuf_scale_simple (data->rightarrow_icon_64, 24, 50, GDK_INTERP_HYPER))); // ##################################################################### // ##################################################################### // **** Tab 3: Rec data->recording = 0; data->rosbag_record_cmd = "rosbag record"; data->topicsList = GTK_LIST_STORE (gtk_builder_get_object (builder, "liststore_TopicList")); data->cmd_line_entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry_CommandLine")); data->prefix_entry = GTK_WIDGET (gtk_builder_get_object (builder, "entry_Prefix")); data->info_textview = GTK_WIDGET (gtk_builder_get_object (builder, "textview_BagInfo")); data->update_btn = GTK_WIDGET (gtk_builder_get_object (builder, "button_UpdateTopicList")); data->box_MotorStatus = GTK_WIDGET (gtk_builder_get_object (builder, "hbox_MotorStatus")); data->box_Flying = GTK_WIDGET (gtk_builder_get_object (builder, "hbox_Flying")); data->box_Gps = GTK_WIDGET (gtk_builder_get_object (builder, "hbox_Gps")); data->flightMode_label = GTK_WIDGET (gtk_builder_get_object (builder, "label_FlightModeValue")); data->upTime_label = GTK_WIDGET (gtk_builder_get_object (builder, "label_UpTimeValue")); data->cpuLoad_label = GTK_WIDGET (gtk_builder_get_object (builder, "label_CpuLoadValue")); data->box_RecordStatus = GTK_WIDGET (gtk_builder_get_object (builder, "hbox_RecordStatus")); data->record_stop_btn = GTK_WIDGET (gtk_builder_get_object (builder, "button_RecordStop")); gtk_box_pack_end (GTK_BOX (data->box_MotorStatus), data->status_ok_icon_motor, TRUE, TRUE, 0); gtk_box_pack_end (GTK_BOX (data->box_MotorStatus), data->status_fail_icon_motor, TRUE, TRUE, 0); gtk_box_pack_end (GTK_BOX (data->box_Flying), data->status_ok_icon_flying, TRUE, TRUE, 0); gtk_box_pack_end (GTK_BOX (data->box_Flying), data->status_fail_icon_flying, TRUE, TRUE, 0); gtk_box_pack_end (GTK_BOX (data->box_Gps), data->status_ok_icon_gps, TRUE, TRUE, 0); gtk_box_pack_end (GTK_BOX (data->box_Gps), data->status_fail_icon_gps, TRUE, TRUE, 0); gtk_box_pack_end (GTK_BOX (data->box_RecordStatus), data->record_icon, TRUE, TRUE, 0); gtk_box_pack_end (GTK_BOX (data->box_RecordStatus), data->record_g_icon, TRUE, TRUE, 0); gtk_button_set_image (GTK_BUTTON (data->update_btn), gtk_image_new_from_pixbuf (gdk_pixbuf_scale_simple (data->refresh_icon_64, 24, 24, GDK_INTERP_HYPER))); gtk_button_set_image (GTK_BUTTON (data->record_stop_btn), gtk_image_new_from_pixbuf (gdk_pixbuf_scale_simple (data->record_icon_64, 40, 40, GDK_INTERP_HYPER))); // Connect signals gtk_builder_connect_signals (builder, data); // Destroy builder, since we don't need it anymore g_object_unref (G_OBJECT (builder)); // Show window. All other widgets are automatically shown by GtkBuilder gtk_widget_show_all (data->window); gtk_widget_hide(data->record_icon); gtk_widget_hide(data->status_ok_icon_motor); gtk_widget_hide(data->status_ok_icon_flying); gtk_widget_hide(data->status_ok_icon_gps); gtk_widget_hide_all(data->telemetry_option_popup); gtk_widget_hide_all(data->gpsd_option_popup); // **** allow ROS spinning data->widget_created = true; // **** udpate all widgets g_timeout_add (data->telemetry_refresh_rate, widgets_update, NULL); gtk_main (); gdk_threads_leave (); return 0; }
ico_button *make_default_buttons(int x,int &y, ico_button *append_list) { int h; int diff_on; if (DEFINEDP(symbol_value(l_difficulty))) { if (symbol_value(l_difficulty)==l_extreme) diff_on=3; else if (symbol_value(l_difficulty)==l_hard) diff_on=2; else if (symbol_value(l_difficulty)==l_easy) diff_on=0; else diff_on=1; } else diff_on=3; ico_button *start; ifield **cur=(ifield **)&start; if (!player_list->next) { *cur=load_icon(0,ID_START_GAME,x,y,h,NULL,"ic_start"); cur=&((*cur)->next); y+=h; } ico_switch_button *set=NULL; if (!main_net_cfg || (main_net_cfg->state!=net_configuration::SERVER && main_net_cfg->state!=net_configuration::CLIENT)) { *cur=new ico_switch_button(x,y,ID_NULL,diff_on, load_icon(3,ID_EASY,x,y,h, load_icon(8,ID_MEDIUM,x,y,h, load_icon(9,ID_HARD,x,y,h, load_icon(10,ID_EXTREME,x,y,h,NULL,"ic_extreme"), "ic_hard"),"ic_medium"),"ic_easy"),NULL); cur=&((*cur)->next); y+=h; } *cur=load_icon(4,ID_LIGHT_OFF,x,y,h,NULL,"ic_gamma"); cur=&((*cur)->next); y+=h; *cur=load_icon(5,ID_VOLUME,x,y,h,NULL,"ic_volume"); cur=&((*cur)->next); y+=h; if (registered && prot) { *cur = load_icon(11,ID_NETWORKING,x,y,h,NULL,"ic_networking"); cur=&((*cur)->next); y+=h; } *cur = load_icon(2,ID_SHOW_SELL,x,y,h,NULL,"ic_sell"); cur=&((*cur)->next); y+=h; *cur = load_icon(12,ID_MACCONF,x,y,h,NULL,"ic_macconf"); cur=&((*cur)->next); y+=h; *cur = load_icon(13,ID_MACKEYS,x,y,h,NULL,"ic_mackeys"); cur=&((*cur)->next); y+=h; *cur=load_icon(6,ID_QUIT,x,y,h,NULL,"ic_quit"); cur=&((*cur)->next); y+=h; ico_button *list=append_list; if (append_list) { while (append_list->next) append_list=(ico_button *)append_list->next; append_list->next=start; } else list=start; return list; }
/****************************************************************************** * MAIN function ******************************************************************************/ int main ( int argc, char **argv ) { trace_main = TRACE_MAIN; XtAppContext app; m_init(); XtSetLanguageProc (NULL, NULL, NULL); XawInitializeWidgetSet(); /* -- Intialize Toolkit creating the application shell */ Widget appShell = XtOpenApplication (&app, APP_NAME, /* resources: can be set from argv */ options, XtNumber(options), &argc, argv, fallback_resources, sessionShellWidgetClass, NULL, 0 ); load_icon(XtDisplay(appShell)); // load_icon_default(); /* -- Enable Editres support */ XtAddEventHandler(appShell, (EventMask) 0, True, _XEditResCheckMessages, NULL); XtAddCallback( appShell, XtNdieCallback, quit_cb, NULL ); /* -- not parsed options are removed by XtOpenApplication the only entry left should be the program name */ if (argc != 1) { m_destruct(); syntax(); exit(1); } TopLevel = appShell; /* -- Register all application specific callbacks and widget classes */ RegisterApplication ( appShell ); /* -- Register all Athena and Public widget classes, CBs, ACTs */ XpRegisterAll ( app ); /* -- Create widget tree below toplevel shell using Xrm database */ WcWidgetCreation ( appShell ); /* -- Get application resources and widget ptrs */ XtGetApplicationResources( appShell, (XtPointer)&CWRI, CWRI_CONFIG_RES, XtNumber(CWRI_CONFIG_RES), (ArgList)0, 0 ); InitializeApplication(appShell); /* -- Realize the widget tree and enter the main application loop */ XtRealizeWidget ( appShell ); /* -- Set Icon for Window */ set_app_icon(appShell); grab_window_quit( appShell ); XtAppMainLoop ( app ); /* use XtAppSetExitFlag */ XtDestroyWidget(appShell); m_destruct(); return EXIT_SUCCESS; }