SelectJackControlPgm::SelectJackControlPgm(BaseObjectType* cobject, Glib::RefPtr<GxBuilder> bld, gx_engine::GxMachineBase& m) : Gtk::Window(cobject), description(), customstarter(), startercombo(), dontask(), machine(m), close() { signal_delete_event().connect(sigc::mem_fun(*this, &SelectJackControlPgm::on_delete_event)); bld->find_widget("description", description); bld->find_widget("customstarter", customstarter); customstarter->set_text(machine.get_parameter_value<string>("ui.jack_starter")); bld->find_widget("startercombo", startercombo); const char *v_id = machine.get_parameter("ui.jack_starter_idx").getValueNames()[machine.get_parameter_value<int>("ui.jack_starter_idx")].value_id; int n = 0; Glib::RefPtr<Gtk::TreeModel> model = startercombo->get_model(); for (Gtk::TreeIter i = model->children().begin(); i; ++i, ++n) { Glib::ustring s; i->get_value(1, s); if (s == v_id) { startercombo->set_active(n); } } startercombo->signal_changed().connect(sigc::mem_fun(*this, &SelectJackControlPgm::on_starter_changed)); bld->find_widget("dontask", dontask); dontask->set_active(!machine.get_parameter_value<bool>("ui.ask_for_jack_starter")); Gtk::Button *button; bld->find_widget("ok_button", button); button->signal_clicked().connect( sigc::mem_fun(*this, &SelectJackControlPgm::on_ok_button)); bld->find_widget("cancel_button", button); button->signal_clicked().connect( sigc::mem_fun(*this, &SelectJackControlPgm::on_cancel_button)); on_starter_changed(); }
FloatingBehavior::FloatingBehavior(Dialog &dialog) : Behavior(dialog), _d (new Gtk::Dialog(_dialog._title)) #if GTK_VERSION_GE(2, 12) ,_dialog_active(_d->property_is_active()) ,_steps(0) ,_trans_focus(Inkscape::Preferences::get()->getDoubleLimited("/dialogs/transparency/on-focus", 0.95, 0.0, 1.0)) ,_trans_blur(Inkscape::Preferences::get()->getDoubleLimited("/dialogs/transparency/on-blur", 0.50, 0.0, 1.0)) ,_trans_time(Inkscape::Preferences::get()->getIntLimited("/dialogs/transparency/animate-time", 100, 0, 5000)) #endif { hide(); _d->set_has_separator(false); signal_delete_event().connect(sigc::mem_fun(_dialog, &Inkscape::UI::Dialog::Dialog::_onDeleteEvent)); sp_transientize(GTK_WIDGET(_d->gobj())); _dialog.retransientize_suppress = false; #if GTK_VERSION_GE(2, 12) _focus_event(); _dialog_active.signal_changed().connect(sigc::mem_fun(this, &FloatingBehavior::_focus_event)); #endif }
void CSendFileDlg::createWindow() { signal_delete_event().connect(SigC::slot(*this, &CSendFileDlg::on_delete_event)); set_resizable(false); if (tcpSession->isSender()) set_title(_("Sending file")); else set_title (_("Receiving file")); set_border_width(8); Gtk::VBox *vbox; vbox = Gtk::manage(new Gtk::VBox(false, 0)); add(*vbox); Glib::ustring filename; filename = Glib::filename_to_utf8(filePath); gchar *text; if (tcpSession->isSender()) text = g_strdup_printf(_("Sending file. %s size: %u bytes"), filename.c_str(), fileSize); else text = g_strdup_printf(_("Receiving file. %s size: %u bytes"), filename.c_str(), fileSize); Gtk::Label *label; label = Gtk::manage(new Gtk::Label(text)); g_free(text); vbox->pack_start(*label); vbox->pack_start(m_progressbar); m_speed_label.set_text(_("Waiting...")); vbox->pack_start(m_speed_label); Gtk::Button *button; button = Gtk::manage(new Gtk::Button(_("stop"))); vbox->pack_start(*button); button->signal_clicked().connect(SigC::slot(*this, &CSendFileDlg::on_stop_clicked)); vbox->show_all(); update_progress_timeout_conn = Glib::signal_timeout().connect(SigC::slot(*this, &CSendFileDlg::on_update_progress_timeout), 500); }
SendMsgDlg::SendMsgDlg(const char *name, time_t when, const char *text) : LinqWindow(WIN_SEND_MESSAGE) { signal_delete_event().connect(SigC::slot(*this, &SendMsgDlg::on_window_delete_event)); set_title (_("LinQ - Send message")); m_notebook.set_scrollable(true); m_notebook.popup_enable(); Gtk::VBox *vbox; vbox = Gtk::manage(new Gtk::VBox(false, 0)); Gtk::MenuBar *menubar; menubar = Gtk::manage(new Gtk::MenuBar()); Gtk::Menu *menu; menu = Gtk::manage(new Gtk::Menu()); Gtk::Menu::MenuList& menulist = menu->items(); menulist.push_back(Gtk::Menu_Helpers::MenuElem(_("View _histroy"))); menulist.push_back(Gtk::Menu_Helpers::MenuElem(_("_Close"))); menubar->items().push_back( Gtk::Menu_Helpers::MenuElem("_Conservation", *menu) ); menu = Gtk::manage(new Gtk::Menu()); menulist = menu->items(); menulist.push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Enabel _sound"))); menubar->items().push_back( Gtk::Menu_Helpers::MenuElem("_Conservation", *menu) ); vbox->pack_start(*menubar, false, true, 0); vbox->pack_start(m_notebook, true, true, 0); add(*vbox); SendMsgDlgTab *tab; tab = new SendMsgDlgTab(this, name); if (text) tab->onRecvMessage(when, text); tab->doPresent(); show_all(); }
mpGTui::mpGTui() : okButton(" OK "), layoutTableEntry(3, 2, true), layoutTableLearned(3, 2, true) { set_border_width(10); initTreeModel(); okButton.signal_clicked().connect( sigc::mem_fun(*this, &mpGTui::onOkButtonClicked)); entryTextName.signal_activate().connect( sigc::mem_fun(*this, &mpGTui::onEntryEnterKeyRelease)); signal_delete_event().connect(sigc::mem_fun(this, &mpGTui::onExit)); lblInfo.set_text("waiting for images..."); lblDescr1.set_text("Learned name:"); lblDescr2.set_text("Learned shape:"); lblDescr3.set_text("Confidence:"); lblLearningStringName.set_text("<none>"); lblLearningStringShape.set_text("<none>"); lblLearningStringConfidence.set_text("0"); lblEntryNameDescr.set_text("Name:"); lblComboDescr.set_text("Shape:"); lblEntryNameDescr.set_alignment(Gtk::AlignmentEnum::ALIGN_RIGHT); lblDescr1.set_alignment(Gtk::AlignmentEnum::ALIGN_RIGHT); lblDescr2.set_alignment(Gtk::AlignmentEnum::ALIGN_RIGHT); lblDescr3.set_alignment(Gtk::AlignmentEnum::ALIGN_RIGHT); lblComboDescr.set_alignment(Gtk::AlignmentEnum::ALIGN_RIGHT); lblEntryNameDescr.set_padding(30, 0); lblDescr1.set_padding(30, 0); lblDescr2.set_padding(30, 0); lblDescr3.set_padding(30, 0); lblComboDescr.set_padding(30, 0); layoutTableLearned.attach(lblDescr1, 0, 1, 0, 1, Gtk::AttachOptions::FILL, Gtk::AttachOptions::FILL, 0, 5); layoutTableLearned.attach(lblDescr2, 0, 1, 1, 2); layoutTableLearned.attach(lblDescr3, 0, 1, 2, 3); layoutTableLearned.attach(lblLearningStringName, 1, 2, 0, 1); layoutTableLearned.attach(lblLearningStringShape, 1, 2, 1, 2); layoutTableLearned.attach(lblLearningStringConfidence, 1, 2, 2, 3); layoutTableEntry.attach(lblEntryNameDescr, 0, 1, 0, 1); layoutTableEntry.attach(entryTextName, 1, 2, 0, 1); layoutTableEntry.attach(lblComboDescr, 0, 1, 1, 2); layoutTableEntry.attach(shapeCombo, 1, 2, 1, 2); learnedFrame.set_label("Learned data"); entryFrame.set_label("GroundTruth entry"); learnedFrame.add(layoutTableLearned); entryFrame.add(layoutTableEntry); add(vBox); vBox.pack_start(roi); vBox.pack_start(lblInfo); vBox.pack_start(hSeparator, Gtk::PackOptions::PACK_EXPAND_WIDGET, 10); vBox.pack_start(learnedFrame); vBox.pack_start(entryFrame); vBox.pack_start(okButton, Gtk::PackOptions::PACK_SHRINK, 10); initRosService(); show_all_children(); }
LayerWindow::LayerWindow(MainWindow & mw) : OptionBox("Layers"), m_currentModel(0) { // destroy.connect(slot(this, &LayerWindow::destroy_handler)); // Gtk::VBox * vbox = manage( new Gtk::VBox(false, 2) ); Gtk::VBox * vbox = this; Gtk::HBox * tophbox = manage( new Gtk::HBox() ); tophbox->pack_start(*(manage( new Gtk::Label("Model:") )), Gtk::PACK_SHRINK, 2); m_modelMenu = manage( new Gtk::OptionMenu() ); tophbox->pack_start(*m_modelMenu, Gtk::PACK_EXPAND_WIDGET, 2); tophbox->pack_start(*(manage( new Gtk::Label("WOOT") ) ), Gtk::PACK_SHRINK, 2); vbox->pack_start(*tophbox, Gtk::PACK_SHRINK, 2); m_columns = new Gtk::TreeModelColumnRecord(); m_visColumn = new Gtk::TreeModelColumn<bool>(); m_typeColumn = new Gtk::TreeModelColumn<Glib::ustring>(); m_nameColumn = new Gtk::TreeModelColumn<Glib::ustring>(); m_ptrColumn = new Gtk::TreeModelColumn<Layer*>(); m_columns->add(*m_visColumn); m_columns->add(*m_typeColumn); m_columns->add(*m_nameColumn); m_columns->add(*m_ptrColumn); m_treeModel = Gtk::ListStore::create(*m_columns); m_treeView = manage( new Gtk::TreeView() ); m_treeView->set_model( m_treeModel ); Gtk::CellRendererToggle * crt = manage( new Gtk::CellRendererToggle() ); crt->signal_toggled().connect( sigc::mem_fun(*this, &LayerWindow::visibleToggled) ); int column_no = m_treeView->append_column("Visible", *crt); Gtk::TreeViewColumn * column = m_treeView->get_column(column_no - 1); column->add_attribute(crt->property_active(), *m_visColumn); column->set_clickable(); m_treeView->append_column("Type", *m_typeColumn); m_treeView->append_column("Name", *m_nameColumn); m_refTreeSelection = m_treeView->get_selection(); m_refTreeSelection->set_mode(Gtk::SELECTION_SINGLE); m_refTreeSelection->signal_changed().connect( sigc::mem_fun(*this, &LayerWindow::selectionChanged) ); vbox->pack_start(*manage(new Gtk::HSeparator()), Gtk::PACK_SHRINK); Gtk::ScrolledWindow *scrolled_window = manage(new Gtk::ScrolledWindow()); scrolled_window->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS); scrolled_window->set_size_request(250,150); scrolled_window->add(*m_treeView); vbox->pack_start(*scrolled_window); Gtk::HBox * bothbox = manage( new Gtk::HBox() ); Gtk::Button * b = manage( new Gtk::Button() ); Glib::RefPtr<Gdk::Bitmap> pixmask; Glib::RefPtr<Gdk::Pixmap> p = Gdk::Pixmap::create_from_xpm(get_colormap(), pixmask, newlayer_xpm); b->add_pixmap(p, pixmask); b->signal_clicked().connect(sigc::mem_fun(*this, &LayerWindow::newLayerRequested)); bothbox->pack_start(*b, Gtk::PACK_EXPAND_PADDING, 6); b = manage( new Gtk::Button() ); p = Gdk::Pixmap::create_from_xpm(get_colormap(), pixmask, raise_xpm); b->add_pixmap(p, pixmask); b->signal_clicked().connect(sigc::mem_fun(*this, &LayerWindow::raiseLayer)); bothbox->pack_start(*b, Gtk::PACK_EXPAND_PADDING, 6); b = manage( new Gtk::Button() ); p = Gdk::Pixmap::create_from_xpm(get_colormap(), pixmask, lower_xpm); b->add_pixmap(p, pixmask); b->signal_clicked().connect(sigc::mem_fun(*this, &LayerWindow::lowerLayer)); bothbox->pack_start(*b, Gtk::PACK_EXPAND_PADDING, 6); b = manage( new Gtk::Button() ); p = Gdk::Pixmap::create_from_xpm(get_colormap(), pixmask, duplicate_xpm); b->add_pixmap(p, pixmask); bothbox->pack_start(*b, Gtk::PACK_EXPAND_PADDING, 6); b = manage( new Gtk::Button() ); p = Gdk::Pixmap::create_from_xpm(get_colormap(), pixmask, delete_xpm); b->add_pixmap(p, pixmask); bothbox->pack_start(*b, Gtk::PACK_EXPAND_PADDING, 6); vbox->pack_start(*bothbox, Gtk::PACK_SHRINK, 6); // add(*vbox); // set_title("Layers"); set_sensitive(false); // FIXME Organise the xpms //m_eye = gdk_pixmap_create_from_xpm_d(m_clist->gtkobj()->clist_window, //&m_eyemask, >K_WIDGET(m_clist->gtkobj())->style->white, eye_xpm); //m_null = gdk_pixmap_create_from_xpm_d(m_clist->gtkobj()->clist_window, //&m_nullmask, >K_WIDGET(m_clist->gtkobj())->style->white, null_xpm); m_newLayerWindow = new NewLayerWindow(); // show_all(); mw.modelAdded.connect(sigc::mem_fun(*this, &LayerWindow::modelAdded)); mw.currentModelChanged.connect(sigc::mem_fun(*this, &LayerWindow::currentModelChanged)); signal_delete_event().connect(sigc::mem_fun(*this, &LayerWindow::deleteEvent)); }
/** * Sets up the main window. */ GtkMainWindow::GtkMainWindow(GtkWindow *win, const Glib::RefPtr<Gtk::Builder> rbuilder) : Gtk::Window(win), builder(rbuilder), m_core(Application::getSingleton()->getCore()) { notify_init ("gTorrent"); GtkTorrentSideBar *sidebar; Gtk::Revealer *revealer; builder->get_widget( "addTorrentButton", addTorrentButton); builder->get_widget( "addTorrentButton", addTorrentButton); builder->get_widget( "addMagnetButton", addMagnetButton); builder->get_widget( "resumeButton", resumeButton); builder->get_widget( "pauseButton", pauseButton); builder->get_widget( "deleteButton", removeButton); //builder->get_widget( "preferencesButton", propertiesButton); builder->get_widget( "settingsButton", settingsButton); builder->get_widget( "panel", panel); builder->get_widget( "scrolledWindow", scrolledWindow); builder->get_widget( "vSepOne", vSeparatorOne); builder->get_widget( "vSepTwo", vSeparatorTwo); builder->get_widget( "sidebarRev", revealer); builder->get_widget_derived( "infobar", m_infobar); builder->get_widget_derived( "treeview", m_treeview); builder->get_widget_derived( "sidebar", sidebar); panel->pack2(*m_infobar); // Apparently can't use lambdas on these two unless doing something awful Glib::signal_timeout().connect_seconds(sigc::mem_fun(*this, &GtkMainWindow::onSecTick), 1); signal_delete_event().connect(sigc::mem_fun(*this, &GtkMainWindow::onDestroy)); addTorrentButton->signal_clicked().connect([this](){ onAddBtnClicked();}); pauseButton ->signal_clicked().connect([this](){ onPauseBtnClicked();}); resumeButton ->signal_clicked().connect([this](){ onResumeBtnClicked();}); removeButton ->signal_clicked().connect([this](){ onRemoveBtnClicked();}); settingsButton ->signal_clicked().connect([this](){ onSettingsBtnClicked();}); addMagnetButton ->signal_clicked().connect([this](){ onAddMagnetBtnClicked();}); //propertiesButton->signal_clicked().connect([revealer](){ revealer->set_reveal_child(!revealer->get_reveal_child());}); magEntry = Gtk::manage(new Gtk::Entry()); revealer->set_reveal_child(true); magEntry->set_visible(); magEntry->set_width_chars(75); magPopover = Gtk::manage(new Gtk::Popover()); magPopover->add(*magEntry); magPopover->set_relative_to(*addMagnetButton); addMagnetButton->set_popover(*magPopover); magPopover->set_position(Gtk::POS_LEFT); sidebar_scrolledwindow->set_min_content_width(150); for(auto tor : Application::getSingleton()->getCore()->getTorrents()) { tor->onStateChanged = [this](int oldstate, std::shared_ptr<gt::Torrent> t){ torrentStateChangedCallback(oldstate, t); }; m_treeview->addCell(tor); } if (gt::Settings::settings["FileAssociation"] == "" || gt::Settings::settings["FileAssociation"] == "-1") { GtkAssociationDialog *dialog = 0; builder->get_widget_derived("fileAssociationDialog", dialog); dialog->set_transient_for(*this); dialog->set_default_response(1); int code = dialog->run(); if(code != -1) gt::Platform::associate(dialog->aWithMagnets, dialog->aWithTorrents); gt::Settings::settings["FileAssociation"] = std::to_string(code); delete dialog; } d = new GtkSettingsDialog(this); }
AppWindow::AppWindow(int argnum, char **argcon) : Hand(Gdk::FLEUR), Watch(Gdk::WATCH), FileChooser(Gtk::FILE_CHOOSER_ACTION_OPEN), Button_Tooltips(), ImageScroller(), SaveDialog( GT( "Save Image?" ),*this,true,true), SaveErrorDialog( GT( "Saving failed." ),*this,true,true), ImageManager(argnum,argcon), NavButtonHBox_Alignment(Gtk::ALIGN_CENTER,Gtk::ALIGN_CENTER), I_Button_Previous(Gtk::StockID("gtk-go-back"), Gtk::IconSize(1)), I_Button_Next(Gtk::StockID("gtk-go-forward"), Gtk::IconSize(1)), I_Button_ZoomIn(Gtk::StockID("gtk-zoom-in"), Gtk::IconSize(1)), I_Button_ZoomOut(Gtk::StockID("gtk-zoom-out"), Gtk::IconSize(1)), I_Button_Zoom1to1( iconpath + (Glib::ustring) "1to1.png" ), I_Button_RotateAntiClockwise( iconpath + (Glib::ustring) "anticlockwise.png" ), I_Button_RotateClockwise( iconpath + (Glib::ustring) "clockwise.png" ), I_Button_Save(Gtk::StockID("gtk-floppy"), Gtk::IconSize(1)), I_Button_Print(Gtk::StockID("gtk-print"), Gtk::IconSize(1)), I_ToggleButton_ShowFileChooser(Gtk::StockID("gtk-find"), Gtk::IconSize(1)), I_Button_Quit(Gtk::StockID("gtk-quit"), Gtk::IconSize(1)) { /* // initialise printing system refPageSetup = Gtk::PageSetup::create(); refPrintSettings = Gtk::PrintSettings::create(); */ // copy command line argc = argnum; argv = argcon; load_config(); set_title("gimmage"); set_border_width(0); resize(w_width,w_height); // note, this is accessed through a pointer by some functions in ImageEventBox, be careful scalefactor = 0.6; // we will use these to use *_scroller->set_value() and get_value h_scroller = ImageScroller.get_hadjustment(); v_scroller = ImageScroller.get_vadjustment(); h_scroller->set_step_increment( 10 ); v_scroller->set_step_increment( 10 ); ImageScroller.set_shadow_type(Gtk::SHADOW_NONE); // Image objects for the navigation buttons Button_Previous.add(I_Button_Previous); Button_Next.add(I_Button_Next); Button_ZoomIn.add(I_Button_ZoomIn); Button_ZoomOut.add(I_Button_ZoomOut); Button_Zoom1to1.add(I_Button_Zoom1to1); Button_RotateAntiClockwise.add(I_Button_RotateAntiClockwise); Button_RotateClockwise.add(I_Button_RotateClockwise); Button_Save.add(I_Button_Save); Button_Print.add(I_Button_Print); ToggleButton_ShowFileChooser.add(I_ToggleButton_ShowFileChooser); Button_Quit.add(I_Button_Quit); // Initialize Tooltips for buttons Button_Tooltips.set_tip( Button_Previous , GT( "Previous Image (Backspace)" ) ); Button_Tooltips.set_tip( Button_Next , GT( "Next Image (Space)" )); Button_Tooltips.set_tip( Button_ZoomIn , GT( "Zoom In (+)" ) ); Button_Tooltips.set_tip( Button_ZoomOut , GT( "Zoom Out (-)" ) ); Button_Tooltips.set_tip( Button_Zoom1to1 , GT( "Zoom to Original Size (1)" ) ); Button_Tooltips.set_tip( Button_RotateAntiClockwise , GT( "Rotate 90 Degrees Anticlockwise (a)" ) ); Button_Tooltips.set_tip( Button_RotateClockwise , GT( "Rotate 90 Degrees Clockwise (c)" ) ); Button_Tooltips.set_tip( Button_Save , GT( "Save Modified Image (s)" ) ); Button_Tooltips.set_tip( Button_Print , GT( "Display Print Dialog (p)" ) ); Button_Tooltips.set_tip( ToggleButton_ShowFileChooser, GT( "Show File Browser (f)" ) ); Button_Tooltips.set_tip( Button_Quit , GT( "Quit. (Escape)" ) ); // the navigation buttons themselves NavButtonHBox.set_homogeneous(true); NavButtonHBox.pack_start(Button_Previous, Gtk::PACK_SHRINK, 5); NavButtonHBox.pack_start(Button_Next, Gtk::PACK_SHRINK, 5); NavButtonHBox.pack_start(Button_ZoomOut, Gtk::PACK_SHRINK, 5); NavButtonHBox.pack_start(Button_ZoomIn, Gtk::PACK_SHRINK, 5); NavButtonHBox.pack_start(Button_Zoom1to1, Gtk::PACK_SHRINK, 5); NavButtonHBox.pack_start(Button_RotateAntiClockwise, Gtk::PACK_SHRINK, 5); NavButtonHBox.pack_start(Button_RotateClockwise, Gtk::PACK_SHRINK, 5); NavButtonHBox.pack_start(Button_Save, Gtk::PACK_SHRINK, 5); NavButtonHBox.pack_start(Button_Print, Gtk::PACK_SHRINK, 5); NavButtonHBox.pack_start(ToggleButton_ShowFileChooser, Gtk::PACK_SHRINK, 5); NavButtonHBox.pack_start(Button_Quit, Gtk::PACK_SHRINK, 5); // put the nav buttons into an alignment so they're always nicely centered! NavButtonHBox_Alignment_HBox.pack_start(NavButtonHBox,Gtk::PACK_EXPAND_PADDING,0); NavButtonHBox_Alignment.add(NavButtonHBox_Alignment_HBox); // make the scrollbars dissapear when the image fits the window ImageScroller.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC); // add the imagebox to the scrolledwindow ImageScroller.add(ImageBox); VBox_Top.pack_start(ImageScroller, Gtk::PACK_EXPAND_WIDGET,0); VBox_Top.pack_start(NavButtonHBox_Alignment, Gtk::PACK_SHRINK,5); VPaned.pack1(VBox_Top); VPaned.pack2(FileChooser, Gtk::PACK_SHRINK, 10); // add toplevel container to window add(VPaned); // set up the file filter for pixbuf types ImageFilter.add_pixbuf_formats(); ImageFilter.set_name( GT( "Image Formats" ) ); FileChooser.add_filter(ImageFilter); // set up the filechooser FileChooser.set_select_multiple(false); FileChooser.set_preview_widget( Preview ); FileChooser.set_preview_widget_active(); FileChooser.set_use_preview_label(false); FileChooser.signal_file_activated().connect( sigc::mem_fun(*this,&AppWindow::on_file_activated) ); // connect the preview widget to the update_preview signal FileChooser.signal_update_preview().connect( sigc::mem_fun(*this,&AppWindow::on_update_preview) ); FileChooser.set_events( Gdk::ALL_EVENTS_MASK ); // set up event mask for ImageBox (this doesn't really seem to work but hey... ) ImageBox.set_events( Gdk::ALL_EVENTS_MASK & ~Gdk::ALL_EVENTS_MASK ); ImageBox.add_events( Gdk::EXPOSURE_MASK | Gdk::BUTTON_MOTION_MASK|Gdk::BUTTON_PRESS_MASK| Gdk::BUTTON_RELEASE_MASK|Gdk::SCROLL_MASK ); // set up drag source and drop target for filenames from filechooser filechooser std::list<Gtk::TargetEntry> dragndrop; dragndrop.push_back( Gtk::TargetEntry("text/plain") ); dragndrop.push_back( Gtk::TargetEntry("text/uri-list") ); ImageBox.drag_dest_set(dragndrop); ImageBox.signal_drag_data_received().connect( sigc::mem_fun(*this,&AppWindow::on_drag_data_received) ); // Drag scrolling the image ImageBox.signal_motion_notify_event().connect(sigc::mem_fun(*this,&AppWindow::on_button1_pressed_motion)); ImageBox.signal_button_press_event().connect(sigc::mem_fun(*this,&AppWindow::on_button_press_event)); ImageBox.signal_button_release_event().connect(sigc::mem_fun(*this,&AppWindow::on_button_release_event)); // connect signal handlers Button_Next.signal_clicked().connect(sigc::mem_fun(*this,&AppWindow::on_button_next) ); Button_Previous.signal_clicked().connect(sigc::mem_fun(*this,&AppWindow::on_button_previous) ); Button_ZoomIn.signal_clicked().connect(sigc::mem_fun(*this,&AppWindow::on_button_zoom_in) ); Button_ZoomOut.signal_clicked().connect(sigc::mem_fun(*this,&AppWindow::on_button_zoom_out) ); Button_Zoom1to1.signal_clicked().connect(sigc::mem_fun(*this,&AppWindow::on_button_zoom_1to1) ); Button_RotateAntiClockwise.signal_clicked().connect( sigc::mem_fun(*this,&AppWindow::on_button_rotate_anticlockwise) ); Button_RotateClockwise.signal_clicked().connect( sigc::mem_fun(*this,&AppWindow::on_button_rotate_clockwise) ); Button_Save.signal_clicked().connect( sigc::mem_fun(*this,&AppWindow::on_button_save) ); SaveDialog.signal_response().connect(sigc::mem_fun(*this,&AppWindow::on_save_dialog_response) ); SaveErrorDialog.signal_response().connect(sigc::mem_fun(*this,&AppWindow::on_save_error_dialog_response) ); Button_Print.signal_clicked().connect(sigc::mem_fun(*this,&AppWindow::on_button_print) ); ToggleButton_ShowFileChooser.signal_clicked(). connect(sigc::mem_fun(*this, &AppWindow::on_button_show_filechooser) ); Button_Quit.signal_clicked().connect(sigc::mem_fun(*this, &AppWindow::on_button_quit) ); signal_delete_event().connect(sigc::mem_fun(*this, &AppWindow::on_delete_event) ); // this is also triggered when the image is resized, unforunately (evenbox) //signal_check_resize().connect(sigc::mem_fun(*this,&AppWindow::on_resize)); // let's catch keystrokes ImageBox.signal_key_press_event().connect(sigc::mem_fun(*this,&AppWindow::on_key_press_event) ); // show the window in all its glory show_all_children(); // now hide the filebrowser, i'm lazy to type show for all children! // 220 as a height is appropriate for three rows in the filechooser FileChooser.set_size_request( FileChooser.get_width(), 220 ); FileChooser.hide(); // make the save button insensitive, it will be usable once it is needed. Button_Save.set_sensitive(false); Button_Print.set_sensitive(false); // we don't want to cause ruckus do we? let's check whether we have more than 1 file // and disable the next and previous button if we don't if( !ImageManager.have_multiple_files() ) { Button_Next.set_sensitive(false); Button_Previous.set_sensitive(false); } // clamp the scrollbar adjustments if( ImageBox.is_loaded() ) { v_scroller->set_upper( ImageBox.get_height() - v_scroller->get_page_size() ); h_scroller->set_upper( ImageBox.get_width() - h_scroller->get_page_size() ); } // load the first image set_title( "gimmage: " + ImageManager.get_current_file() ); ImageBox.LoadImage( ImageManager.get_current_file(), &scalefactor, v_width, v_height); set_buttons_active( ImageBox.is_loaded() ); }
CalligraphicProfileRename::CalligraphicProfileRename() : #if WITH_GTKMM_3_0 _layout_table(Gtk::manage(new Gtk::Grid())), #else _layout_table(Gtk::manage(new Gtk::Table(1, 2))), #endif _applied(false) { set_title(_("Edit profile")); #if WITH_GTKMM_3_0 Gtk::Box *mainVBox = get_content_area(); _layout_table->set_column_spacing(4); _layout_table->set_row_spacing(4); #else Gtk::Box *mainVBox = get_vbox(); _layout_table->set_spacings(4); #endif _profile_name_entry.set_activates_default(true); _profile_name_label.set_label(_("Profile name:")); _profile_name_label.set_alignment(1.0, 0.5); #if WITH_GTKMM_3_0 _layout_table->attach(_profile_name_label, 0, 0, 1, 1); _profile_name_entry.set_hexpand(); _layout_table->attach(_profile_name_entry, 1, 0, 1, 1); #else _layout_table->attach(_profile_name_label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL); _layout_table->attach(_profile_name_entry, 1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); #endif mainVBox->pack_start(*_layout_table, false, false, 4); // Buttons _close_button.set_use_stock(true); _close_button.set_label(Gtk::Stock::CANCEL.id); _close_button.set_can_default(); _delete_button.set_use_underline(true); _delete_button.set_label(_("Delete")); _delete_button.set_can_default(); _delete_button.set_visible(false); _apply_button.set_use_underline(true); _apply_button.set_label(_("Save")); _apply_button.set_can_default(); _close_button.signal_clicked() .connect(sigc::mem_fun(*this, &CalligraphicProfileRename::_close)); _delete_button.signal_clicked() .connect(sigc::mem_fun(*this, &CalligraphicProfileRename::_delete)); _apply_button.signal_clicked() .connect(sigc::mem_fun(*this, &CalligraphicProfileRename::_apply)); signal_delete_event().connect( sigc::bind_return( sigc::hide(sigc::mem_fun(*this, &CalligraphicProfileRename::_close)), true ) ); add_action_widget(_close_button, Gtk::RESPONSE_CLOSE); add_action_widget(_delete_button, Gtk::RESPONSE_DELETE_EVENT); add_action_widget(_apply_button, Gtk::RESPONSE_APPLY); _apply_button.grab_default(); show_all_children(); }
/** * 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); }
KnotPropertiesDialog::KnotPropertiesDialog() : _desktop(NULL), _knotpoint(NULL), _position_visible(false) { Gtk::Box *mainVBox = get_vbox(); _layout_table.set_spacings(4); _layout_table.resize (2, 2); _unit_name = ""; // Layer name widgets _knot_x_entry.set_activates_default(true); _knot_x_entry.set_digits(4); _knot_x_entry.set_increments(1,1); _knot_x_entry.set_range(-G_MAXDOUBLE, G_MAXDOUBLE); _knot_x_label.set_label(_("Position X:")); _knot_x_label.set_alignment(1.0, 0.5); _knot_y_entry.set_activates_default(true); _knot_y_entry.set_digits(4); _knot_y_entry.set_increments(1,1); _knot_y_entry.set_range(-G_MAXDOUBLE, G_MAXDOUBLE); _knot_y_label.set_label(_("Position Y:")); _knot_y_label.set_alignment(1.0, 0.5); _layout_table.attach(_knot_x_label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL); _layout_table.attach(_knot_x_entry, 1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); _layout_table.attach(_knot_y_label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL); _layout_table.attach(_knot_y_entry, 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); mainVBox->pack_start(_layout_table, true, true, 4); // Buttons _close_button.set_use_stock(true); _close_button.set_label(Gtk::Stock::CANCEL.id); _close_button.set_can_default(); _apply_button.set_use_underline(true); _apply_button.set_can_default(); _close_button.signal_clicked() .connect(sigc::mem_fun(*this, &KnotPropertiesDialog::_close)); _apply_button.signal_clicked() .connect(sigc::mem_fun(*this, &KnotPropertiesDialog::_apply)); signal_delete_event().connect( sigc::bind_return( sigc::hide(sigc::mem_fun(*this, &KnotPropertiesDialog::_close)), true ) ); add_action_widget(_close_button, Gtk::RESPONSE_CLOSE); add_action_widget(_apply_button, Gtk::RESPONSE_APPLY); _apply_button.grab_default(); show_all_children(); set_focus(_knot_y_entry); }