// Construct the dialog ShaderChooser::ShaderChooser(const Glib::RefPtr<Gtk::Window>& parent, Gtk::Entry* targetEntry) : gtkutil::BlockingTransientWindow(_(LABEL_TITLE), parent), _targetEntry(targetEntry), _selector(Gtk::manage(new ShaderSelector(this, SHADER_PREFIXES))) { set_border_width(12); if (_targetEntry != NULL) { _initialShader = targetEntry->get_text(); // Set the cursor of the tree view to the currently selected shader _selector->setSelection(_initialShader); } // Set the default size and position of the window set_default_size(DEFAULT_SIZE_X, DEFAULT_SIZE_Y); // Connect the key handler to catch the ESC event signal_key_press_event().connect(sigc::mem_fun(*this, &ShaderChooser::onKeyPress), false); // Construct main VBox, and pack in the ShaderSelector and buttons panel Gtk::VBox* vbx = Gtk::manage(new Gtk::VBox(false, 3)); vbx->pack_start(*_selector, true, true, 0); vbx->pack_start(createButtons(), false, false, 0); add(*vbx); // Connect the window position tracker _windowPosition.loadFromPath(RKEY_WINDOW_STATE); _windowPosition.connect(this); _windowPosition.applyPosition(); }
MyClass::MyClass() { signal_key_press_event().connect(sigc::mem_fun(*this, &MyClass::on_key_pressed)); show_all_children(); }
StimResponseEditor::StimResponseEditor() : gtkutil::BlockingTransientWindow(_(WINDOW_TITLE), GlobalMainFrame().getTopLevelWindow()), _entity(NULL), _stimEditor(Gtk::manage(new StimEditor(_stimTypes))), _responseEditor(Gtk::manage(new ResponseEditor(getRefPtr(), _stimTypes))), _customStimEditor(Gtk::manage(new CustomStimEditor(_stimTypes))) { // Set the default border width in accordance to the HIG set_border_width(12); set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG); signal_key_press_event().connect(sigc::mem_fun(*this, &StimResponseEditor::onWindowKeyPress), false); // Create the widgets populateWindow(); // Connect the window position tracker _windowPosition.loadFromPath(RKEY_WINDOW_STATE); _windowPosition.connect(this); _windowPosition.applyPosition(); // Show the dialog, this enters the gtk main loop show(); }
Graph_disp::Graph_disp(const sf::VideoMode & mode, const int size_request, const sf::ContextSettings & context_settings): SFMLWidget(mode, size_request, context_settings), draw_cursor_flag(true), draw_axes_flag(true), use_orbit_cam(true), cam_light(glm::vec3(1.0f), 0.2f, glm::vec3(0.0f), 1.0f, 0.5f, 0.0f), dir_light(glm::vec3(0.5f), 0.2f, glm::vec3(-1.0f)), bkg_color(0.25f, 0.25f, 0.25f), ambient_color(0.4f, 0.4f, 0.4f), _cam(glm::vec3(0.0f, -10.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f)), _orbit_cam({10.0f, 0.0f, (float)M_PI / 2.0f}), _scale(1.0f), _perspective(1.0f), _active_graph(nullptr) { // All OpenGL initialization has to wait until the drawing context actually exists // we do this in the initialize method // connect it to the draw signal, to be run only on the first drawing request _draw_connection = signal_draw().connect(sigc::mem_fun(*this, &Graph_disp::initiaize)); // connect event signals signal_size_allocate().connect(sigc::mem_fun(*this, &Graph_disp::resize)); signal_key_press_event().connect(sigc::mem_fun(*this, &Graph_disp::key_press)); // input is checked every 10ms Glib::signal_timeout().connect(sigc::mem_fun(*this, &Graph_disp::input), 10); set_can_focus(); set_can_default(); }
NoteEditor::NoteEditor(const Glib::RefPtr<Gtk::TextBuffer> & buffer) : Gtk::TextView(buffer) { set_wrap_mode(Gtk::WRAP_WORD); set_left_margin(default_margin()); set_right_margin(default_margin()); property_can_default().set_value(true); Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE); //Set up the schema to watch the default document font Glib::RefPtr<Gio::Settings> desktop_settings = Preferences::obj() .get_schema_settings(Preferences::SCHEMA_DESKTOP_GNOME_INTERFACE); if(desktop_settings) { desktop_settings->signal_changed().connect( sigc::mem_fun(*this, &NoteEditor::on_font_setting_changed)); } // Set Font from preference if (settings->get_boolean(Preferences::ENABLE_CUSTOM_FONT)) { std::string font_string = settings->get_string(Preferences::CUSTOM_FONT_FACE); override_font (Pango::FontDescription(font_string)); } else { override_font (get_gnome_document_font_description ()); } settings->signal_changed().connect(sigc::mem_fun(*this, &NoteEditor::on_font_setting_changed)); // Set extra editor drag targets supported (in addition // to the default TextView's various text formats)... Glib::RefPtr<Gtk::TargetList> list = drag_dest_get_target_list(); list->add ("text/uri-list", (Gtk::TargetFlags)0, 1); list->add ("_NETSCAPE_URL", (Gtk::TargetFlags)0, 1); signal_key_press_event().connect(sigc::mem_fun(*this, &NoteEditor::key_pressed), false); signal_button_press_event().connect(sigc::mem_fun(*this, &NoteEditor::button_pressed), false); }
DifficultyDialog::DifficultyDialog() : gtkutil::BlockingTransientWindow(_(WINDOW_TITLE), GlobalMainFrame().getTopLevelWindow()) { // Load the settings _settingsManager.loadSettings(); // Set the default border width in accordance to the HIG set_border_width(12); set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG); set_modal(true); signal_key_press_event().connect(sigc::mem_fun(*this, &DifficultyDialog::onWindowKeyPress), false); // Create the widgets populateWindow(); // Connect the window position tracker _windowPosition.loadFromPath(RKEY_WINDOW_STATE); _windowPosition.connect(this); _windowPosition.applyPosition(); }
ConversationDialog::ConversationDialog() : gtkutil::BlockingTransientWindow(_(WINDOW_TITLE), GlobalMainFrame().getTopLevelWindow()), _convEntityList(Gtk::ListStore::create(_convEntityColumns)), _entityView(NULL), _convList(Gtk::ListStore::create(_convColumns)) { // Set the default border width in accordance to the HIG set_border_width(12); set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG); signal_key_press_event().connect(sigc::mem_fun(*this, &ConversationDialog::onWindowKeyPress), false); // Create the widgets populateWindow(); // Connect the window position tracker _windowPosition.loadFromPath(RKEY_WINDOW_STATE); _windowPosition.connect(this); _windowPosition.applyPosition(); // Show the dialog, this enters the gtk main loop show(); }
void TableofcontentsNoteAddin::on_note_opened () { m_toc_menu = manage(new Gtk::Menu); m_toc_menu->signal_hide().connect( sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_menu_hidden)); register_main_window_action_callback("tableofcontents-heading1", sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_level_1_action)); register_main_window_action_callback("tableofcontents-heading2", sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_level_2_action)); register_main_window_action_callback("tableofcontents-help", sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_toc_help_action)); register_main_window_action_callback("tableofcontents-goto-heading", sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_goto_heading)); auto win = get_window(); win->signal_foregrounded.connect(sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_foregrounded)); auto buffer = get_note()->get_buffer(); if(buffer) { buffer->signal_changed().connect(sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_note_changed)); } // Reacts to key press events win->signal_key_press_event().connect( sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_key_pressed)); // TOC can show up also in the contextual menu win->editor()->signal_populate_popup().connect( sigc::mem_fun(*this, &TableofcontentsNoteAddin::on_populate_popup)); // Heading tags m_tag_bold = get_note()->get_tag_table()->lookup ("bold"); m_tag_large = get_note()->get_tag_table()->lookup ("size:large"); m_tag_huge = get_note()->get_tag_table()->lookup ("size:huge"); }
/** * Sets up the main window. */ GtkMainWindow::GtkMainWindow() : m_core(Application::getSingleton()->getCore()) { //TODO:This needs to be refactored notify_init ("Hello world!"); set_position(Gtk::WIN_POS_CENTER); set_default_size(800, 500); magtxt->set_visible(); magtxt->set_width_chars(75); magPop->add(*magtxt); btn_add_link->set_popover(*magPop); Gtk::Paned *panel = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_VERTICAL)); m_swin = Gtk::manage(new Gtk::ScrolledWindow()); m_infobar = Gtk::manage(new GtkTorrentInfoBar()); m_treeview = Gtk::manage(new GtkTorrentTreeView(this, m_infobar)); m_infobar->set_margin_left(5); m_infobar->set_margin_right(5); m_swin->add(*m_treeview); panel->pack1(*m_swin); panel->pack2(*m_infobar); Glib::signal_timeout().connect_seconds(sigc::mem_fun(*this, &GtkMainWindow::onSecTick), 1); signal_delete_event().connect(sigc::mem_fun(*this, &GtkMainWindow::onDestroy)); signal_key_press_event().connect(sigc::mem_fun(*this, &GtkMainWindow::onKeyPress), false); header = Gtk::manage(new Gtk::HeaderBar()); header->set_show_close_button(true); header->set_title("gTorrent"); Gtk::VSeparator *separator0 = Gtk::manage(new Gtk::VSeparator()); Gtk::VSeparator *separator2 = Gtk::manage(new Gtk::VSeparator()); btn_add_link ->signal_clicked().connect(sigc::mem_fun(*this, &GtkMainWindow::onAddMagnetBtnClicked)); btn_add_torrent->signal_clicked().connect(sigc::mem_fun(*this, &GtkMainWindow::onAddBtnClicked)); btn_pause ->signal_clicked().connect(sigc::mem_fun(*this, &GtkMainWindow::onPauseBtnClicked)); btn_resume ->signal_clicked().connect(sigc::mem_fun(*this, &GtkMainWindow::onResumeBtnClicked)); btn_remove ->signal_clicked().connect(sigc::mem_fun(*this, &GtkMainWindow::onRemoveBtnClicked)); btn_settings ->signal_clicked().connect(sigc::mem_fun(*this, &GtkMainWindow::onSettingsBtnClicked)); btn_properties ->signal_clicked().connect(sigc::mem_fun(*this, &GtkMainWindow::onPropertiesBtnClicked)); btn_add_link ->set_image_from_icon_name("insert-link-symbolic"); btn_add_torrent->set_image_from_icon_name("list-add-symbolic"); btn_pause ->set_image_from_icon_name("media-playback-pause-symbolic"); btn_properties ->set_image_from_icon_name("preferences-system-symbolic"); btn_remove ->set_image_from_icon_name("edit-delete-symbolic"); btn_resume ->set_image_from_icon_name("media-playback-start-symbolic"); btn_settings ->set_image_from_icon_name("emblem-system-symbolic"); //TODO:align properties button to right of top bar //btn_properties->set_alignment(1.0f,0.0f); header->add(*btn_add_torrent); header->add(*btn_add_link); header->add(*separator0); header->add(*btn_resume); header->add(*btn_pause); header->add(*btn_remove); header->add(*separator1); header->add(*btn_properties); header->add(*separator2); header->pack_end(*btn_settings); // Let's add some DnD goodness std::vector<Gtk::TargetEntry> listTargets; listTargets.push_back(Gtk::TargetEntry("STRING")); listTargets.push_back(Gtk::TargetEntry("text/plain")); listTargets.push_back(Gtk::TargetEntry("text/uri-list")); listTargets.push_back(Gtk::TargetEntry("application/x-bittorrent")); m_treeview->drag_dest_set(listTargets, Gtk::DEST_DEFAULT_MOTION | Gtk::DEST_DEFAULT_DROP, Gdk::ACTION_COPY | Gdk::ACTION_MOVE | Gdk::ACTION_LINK | Gdk::ACTION_PRIVATE); m_treeview->signal_drag_data_received().connect(sigc::mem_fun(*this, &GtkMainWindow::onFileDropped)); set_titlebar(*header); add(*panel); show_all(); btn_pause->hide(); m_infobar->set_visible(false); // for some reason, the treeview start with its first element selected m_treeview->get_selection()->unselect_all(); for(auto tor : Application::getSingleton()->getCore()->getTorrents()) { tor->onStateChanged = std::bind(&GtkMainWindow::torrentStateChangedCallback, this, std::placeholders::_1, std::placeholders::_2); m_treeview->addCell(tor); } gt::Log::Debug(gt::Settings::settings["FileAssociation"].c_str()); if (gt::Settings::settings["FileAssociation"] == "" || gt::Settings::settings["FileAssociation"] == "-1") { GtkAssociationDialog *dialog = new GtkAssociationDialog(*this); int code = dialog->run();// code = -1 (Remind me later), 0(Do not associate), 1(Associate with torrents), 2(Associate with magnets), 3(Assiciate with both) if(code != -1) gt::Platform::associate(code & 2, code & 1); gt::Settings::settings["FileAssociation"] = std::to_string(code); delete dialog; } d = new GtkSettingsDialog(this); }
View::View(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder) : Gtk::Window(cobject), m_builder(builder) { // Menus connect_action ("OpenStl", sigc::mem_fun(*this, &View::load_stl) ); connect_action ("OpenGCode", sigc::mem_fun(*this, &View::load_gcode) ); connect_action ("Quit", sigc::ptr_fun(&Gtk::Main::quit)); connect_action ("About", sigc::mem_fun(*this, &View::about_dialog) ); connect_action ("PreferencesDialog", sigc::bind(sigc::mem_fun(*this, &View::show_dialog), "preferences_dlg")); connect_action ("LoadSettings", sigc::mem_fun(*this, &View::load_settings)); connect_action ("SaveSettings", sigc::mem_fun(*this, &View::save_settings)); connect_action ("SaveSettingsAs", sigc::mem_fun(*this, &View::save_settings_as)); #if 0 // Simple tab connect_button ("s_load_stl", sigc::mem_fun(*this, &View::load_stl) ); connect_button ("s_convert_gcode", sigc::mem_fun(*this, &View::ConvertToGCode) ); connect_button ("s_load_gcode", sigc::mem_fun(*this, &View::load_gcode) ); connect_button ("s_print", sigc::mem_fun(*this, &View::SimplePrint) ); #endif // View tab connect_button ("m_load_stl", sigc::mem_fun(*this, &View::load_stl) ); connect_button ("m_save_stl", sigc::mem_fun(*this, &View::save_stl) ); connect_button ("m_delete", sigc::mem_fun(*this, &View::delete_selected_stl) ); connect_button ("m_duplicate", sigc::mem_fun(*this, &View::duplicate_selected_stl) ); connect_button ("m_auto_rotate", sigc::mem_fun(*this, &View::auto_rotate) ); connect_button ("m_rot_x", sigc::bind(sigc::mem_fun(*this, &View::rotate_selection), Vector4f(1,0,0, M_PI/2))); connect_button ("m_rot_y", sigc::bind(sigc::mem_fun(*this, &View::rotate_selection), Vector4f(0,1,0, M_PI/2))); connect_button ("m_rot_z", sigc::bind(sigc::mem_fun(*this, &View::rotate_selection), Vector4f(0,0,1, M_PI/2))); m_builder->get_widget ("m_rfo_tree", m_rfo_tree); // Insert our keybindings all around the place signal_key_press_event().connect (sigc::mem_fun(*this, &View::key_pressed_event) ); m_rfo_tree->signal_key_press_event().connect (sigc::mem_fun(*this, &View::key_pressed_event) ); m_translation_row = new TranslationSpinRow (this, m_rfo_tree, "m_box_translate"); Gtk::HScale *scale_slider; m_builder->get_widget("m_scale_slider", scale_slider); scale_slider->set_range(0.01, 10.0); scale_slider->set_value(1.0); m_rfo_tree->get_selection()->signal_changed().connect (sigc::mem_fun(*this, &View::update_scale_slider)); scale_slider->signal_value_changed().connect (sigc::mem_fun(*this, &View::scale_object)); add_statusbar_msg("m_scale_event_box", _("Scale the selected object")); // GCode tab m_builder->get_widget ("g_gcode", m_gcode_entry); m_gcode_entry->set_activates_default(); m_gcode_entry->signal_activate().connect (sigc::mem_fun(*this, &View::send_gcode));; connect_button ("g_load_gcode", sigc::mem_fun(*this, &View::load_gcode) ); connect_button ("g_convert_gcode", sigc::mem_fun(*this, &View::convert_to_gcode) ); connect_button ("g_save_gcode", sigc::mem_fun(*this, &View::save_gcode) ); connect_button ("g_send_gcode", sigc::mem_fun(*this, &View::send_gcode) ); // Print tab connect_button ("p_kick", sigc::mem_fun(*this, &View::kick_clicked) ); m_builder->get_widget ("p_power", m_power_button); m_power_button->signal_toggled().connect (sigc::mem_fun(*this, &View::power_toggled)); m_builder->get_widget ("p_print", m_print_button); m_print_button->signal_clicked().connect (sigc::mem_fun(*this, &View::print_clicked) ); m_builder->get_widget ("p_pause", m_continue_button); m_continue_button->signal_clicked().connect (sigc::mem_fun(*this, &View::continue_clicked)); // Interactive tab connect_button ("i_home_all", sigc::mem_fun(*this, &View::home_all)); connect_toggled ("Misc.FileLoggingEnabled", sigc::mem_fun(*this, &View::enable_logging_toggled)); connect_button ("i_clear_logs", sigc::mem_fun(*this, &View::clear_logs) ); m_builder->get_widget ("i_reverse", m_extruder_reverse); m_builder->get_widget ("i_ex_speed", m_extruder_speed); m_extruder_speed->set_range(10.0, 10000.0); m_extruder_speed->set_increments (10, 100); m_extruder_speed->set_value (300.0); m_builder->get_widget ("i_ex_length", m_extruder_length); m_extruder_length->set_range(0.0, 1000.0); m_extruder_length->set_increments (1, 10); m_extruder_length->set_value (10.0); // FIXME: connect i_update_interval (etc.) connect_toggled ("i_fan_enabled", sigc::mem_fun(*this, &View::fan_enabled_toggled)); m_builder->get_widget ("i_fan_voltage", m_fan_voltage); m_fan_voltage->set_range(0.0, 255.0); m_fan_voltage->set_increments (1, 2); m_fan_voltage->set_value (180.0); connect_button ("i_extrude_length", sigc::mem_fun(*this, &View::run_extruder) ); // 3D preview of the bed Gtk::Box *pBox = NULL; m_builder->get_widget("viewarea", pBox); if (!pBox) std::cerr << "missing box!"; else { m_renderer = new Render (this, m_rfo_tree->get_selection()); pBox->add (*m_renderer); } showAllWidgets(); }
void SpinButton::connect_signals() { signal_input().connect(sigc::mem_fun(*this, &SpinButton::on_input)); signal_focus_in_event().connect(sigc::mem_fun(*this, &SpinButton::on_my_focus_in_event)); signal_key_press_event().connect(sigc::mem_fun(*this, &SpinButton::on_my_key_press_event)); };