コード例 #1
0
ファイル: Control.cpp プロジェクト: enra64/DesktopCropper
Gtk::Window *Control::init(Glib::RefPtr<Gtk::Builder> builder) {
    Gtk::Window *window;
    Gtk::Paned *pane;

    builder->get_widget("main_window", window);
    builder->get_widget("main_pane", pane);

    init_find_all(builder);
    init_spin_buttons(builder);
    init_scales(builder);
    init_menu(builder);

    pane->add2(_drawArea);

    window->add_events(Gdk::KEY_PRESS_MASK);
    window->signal_key_release_event().connect(sigc::mem_fun(this, &Control::on_shortcut));

    Gtk::Label *label;
    builder->get_widget("scale_warning_label", label);
    _drawArea.set_scale_warning_label(label);

    window->set_size_request(1920, 1080);

    return window;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: Klendathu/minichan
void listView() {
	///Hide/show items for viewing the board list
	
	Gtk::ScrolledWindow *boardlist = 0;
	builder->get_widget("scrolledwindow1", boardlist);
	boardlist->set_visible(true);
	boardlist->show();
	
	gtk_widget_destroy(GTK_WIDGET(pWebKitView));
	
	Gtk::Paned *threadview = 0;
	builder->get_widget("paned1", threadview);
	threadview->set_visible(false);
	threadview->hide();
	
	Gtk::ToolItem *boardback = 0;
	builder->get_widget("toolbutton3", boardback);
	boardback->set_visible(false);
	boardback->hide();
	
	Gtk::Label *title = 0;
	builder->get_widget("label2", title);
	title->set_text("Boards");
	
	Gtk::ToolItem *refresh1 = 0;
	builder->get_widget("toolbutton5", refresh1);
	refresh1->set_visible(false);
	refresh1->hide();
	
	Gtk::ToolItem *refresh2 = 0;
	builder->get_widget("toolbutton6", refresh2);
	refresh2->set_visible(false);
	refresh2->hide();
	
	Gtk::MenuItem *item3 = 0;
	builder->get_widget("menuitem3", item3);
	item3->set_sensitive(false);

	Gtk::Grid *post_grid;
	builder->get_widget("grid1", post_grid);
	post_grid->set_visible(false);
	post_grid->hide();
	
	Gtk::ToggleToolButton *post_but;
	builder->get_widget("toolbutton8", post_but);
	post_but->set_visible(false);
	post_but->hide();
	post_but->set_active(false);
}
コード例 #3
0
/**
* Sets up the main window.
*/
GtkMainWindow::GtkMainWindow() :
	m_core(Application::getSingleton()->getCore())
{
	//TODO:This needs to be refactored
	this->set_position(Gtk::WIN_POS_CENTER);
	this->set_default_size(800, 500);
	Gtk::Paned *panel = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_VERTICAL));

	m_infobar =  Gtk::manage(new GtkTorrentInfoBar());
	m_treeview = Gtk::manage(new GtkTorrentTreeView(m_infobar));

	panel->pack1(*m_treeview);
	panel->pack2(*m_infobar);

	Glib::     signal_timeout().connect(sigc::mem_fun(*this, &GtkMainWindow::onSecTick), 1000);
	this->signal_delete_event().connect(sigc::mem_fun(*this, &GtkMainWindow::onDestroy));

	header = Gtk::manage(new Gtk::HeaderBar());
	header->set_show_close_button(true);
	header->set_title("gTorrent");

	Gtk::Button *btn_add_link    = Gtk::manage(new Gtk::Button());
	Gtk::Button *btn_add_torrent = Gtk::manage(new Gtk::Button());
	Gtk::Button *btn_connect     = Gtk::manage(new Gtk::Button());
	Gtk::Button *btn_pause       = Gtk::manage(new Gtk::Button());
	Gtk::Button *btn_properties  = Gtk::manage(new Gtk::Button());
	Gtk::Button *btn_remove      = Gtk::manage(new Gtk::Button());
	Gtk::Button *btn_resume      = Gtk::manage(new Gtk::Button());
	Gtk::Button *btn_settings    = Gtk::manage(new Gtk::Button());
	Gtk::VSeparator *separator0  = Gtk::manage(new Gtk::VSeparator());
	Gtk::VSeparator *separator1  = 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_add_link   ->set_image_from_icon_name("edit-paste");
	btn_add_torrent->set_image_from_icon_name("gtk-add");
	btn_connect    ->set_image_from_icon_name("gtk-directory");
	btn_pause      ->set_image_from_icon_name("media-playback-pause");
	btn_properties ->set_image_from_icon_name("gtk-properties");
	btn_remove     ->set_image_from_icon_name("gtk-cancel");
	btn_resume     ->set_image_from_icon_name("media-playback-start");
	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(*btn_connect);
	header->add(*separator0);
	header->add(*btn_pause);
	header->add(*btn_resume);
	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
	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();
	m_infobar->set_visible(false);

	if (gt::Settings::getOptionAsString("FileAssociation") == "" ||
		gt::Settings::getOptionAsInt("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::setOption("FileAssociation", code);
		delete dialog;
	}

	d = new GtkSettingsDialog(this);
}
コード例 #4
0
ファイル: main.cpp プロジェクト: Klendathu/minichan
void threadView() {
	///Hide or show widgets for viewing a thread
	
	Gtk::ScrolledWindow *boardlist = 0;
	builder->get_widget("scrolledwindow1", boardlist);
	boardlist->set_visible(false);
	boardlist->hide();
	
	Gtk::Paned *threadview = 0;
	builder->get_widget("paned1", threadview);
	threadview->set_visible(true);
	threadview->show();
	
	Gtk::ToolItem *boardback = 0;
	builder->get_widget("toolbutton4", boardback);
	boardback->set_visible(true);
	boardback->show();
	
	Gtk::ToolItem *listback = 0;
	builder->get_widget("toolbutton3", listback);
	listback->set_visible(false);
	listback->hide();
	
	Gtk::Button* button;
	builder->get_widget("button2", button);
	button->signal_clicked().connect(sigc::ptr_fun(&on_thread_back_clicked));
	button->set_visible(true);
	button->show();
	
	Gtk::ScrolledWindow *threadlist = 0;
	builder->get_widget("scrolledwindow2", threadlist);
	threadlist->set_visible(false);
	threadlist->hide();
	
	Gtk::ScrolledWindow *postlist = 0;
	builder->get_widget("scrolledwindow4", postlist);
	postlist->set_visible(true);
	postlist->show();
	postlist->get_vadjustment()->set_value(0);
	
	Gtk::Label *title = 0;
	builder->get_widget("label2", title);
	title->set_text("#"+THREAD+" - "+BOARD+" - "+LONGBOARD);
	
	Gtk::ToolItem *refresh1 = 0;
	builder->get_widget("toolbutton5", refresh1);
	refresh1->set_visible(false);
	refresh1->hide();
	
	Gtk::ToolItem *refresh2 = 0;
	builder->get_widget("toolbutton6", refresh2);
	refresh2->set_visible(true);
	refresh2->show();
	
	Gtk::MenuItem *item3 = 0;
	builder->get_widget("menuitem3", item3);
	item3->set_sensitive(true);
	
	Gtk::ToolButton *post_but;
	builder->get_widget("toolbutton8", post_but);
	post_but->set_visible(true);
	post_but->show();
}
コード例 #5
0
ファイル: main.cpp プロジェクト: Klendathu/minichan
void boardView(bool destroy=true) {
	///Show/hide widgets for viewing all of the threads on a board
	
	Gtk::ScrolledWindow *boardlist = 0;
	builder->get_widget("scrolledwindow1", boardlist);
	boardlist->set_visible(false);
	boardlist->hide();
	
	Gtk::Paned *threadview = 0;
	builder->get_widget("paned1", threadview);
	threadview->set_visible(true);
	threadview->show();
	
	if(INIT) { //To be run only the first time a board is viewed
		Gtk::Window *window = 0;
		builder->get_widget("window1", window);
		int w = 0;
		int h = 0;
		window->get_size(w, h);
		threadview->set_position((1-2/(1+sqrt(5)))*w);
		
		Gtk::TextView *view = 0;
		builder->get_widget("textview1", view);
		GtkSpellChecker* spell = gtk_spell_checker_new ();
		gtk_spell_checker_set_language (spell, setlocale(LC_ALL,NULL), NULL);
		gtk_spell_checker_attach (spell, GTK_TEXT_VIEW (view->gobj()));
		
		INIT = false;
	}
	
	Gtk::ToolItem *boardback = 0;
	builder->get_widget("toolbutton3", boardback);
	boardback->set_visible(true);
	boardback->show();
	
	Gtk::ToolItem *threadback = 0;
	builder->get_widget("toolbutton4", threadback);
	threadback->set_visible(false);
	threadback->hide();
	
	Gtk::Button* button;
	builder->get_widget("button1", button);
	button->signal_clicked().connect(sigc::ptr_fun(&on_board_back_clicked));
	button->set_visible(true);
	button->show();
	
	Gtk::ScrolledWindow *threadlist = 0;
	builder->get_widget("scrolledwindow2", threadlist);
	threadlist->set_visible(true);
	threadlist->show();
	
	Gtk::ScrolledWindow *postlist = 0;
	builder->get_widget("scrolledwindow4", postlist);
	postlist->set_visible(false);
	postlist->hide();
	
	Gtk::ScrolledWindow *webview = 0;
	builder->get_widget("scrolledwindow3", webview);
	webview->set_visible(true);
	webview->show();
	
	Gtk::ToolButton* refresh;
	builder->get_widget("toolbutton5", refresh);
	refresh->set_visible(true);
	refresh->show();
	
	gtk_widget_show(GTK_WIDGET(pWebKitView));
	
	Gtk::Label *title = 0;
	builder->get_widget("label2", title);
	title->set_text(BOARD+" - "+LONGBOARD);
	
	Gtk::ToolButton *refresh1 = 0;
	builder->get_widget("toolbutton5", refresh1);
	refresh1->set_visible(true);
	refresh1->show();
	
	Gtk::ToolItem *refresh2 = 0;
	builder->get_widget("toolbutton6", refresh2);
	refresh2->set_visible(false);
	refresh2->hide();
	
	Gtk::MenuItem *item3 = 0;
	builder->get_widget("menuitem3", item3);
	item3->set_sensitive(false);
	
	Gtk::ToolButton *post_but;
	builder->get_widget("toolbutton8", post_but);
	post_but->set_visible(true);
	post_but->show();
}
コード例 #6
0
/**
* 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);
}
コード例 #7
0
ファイル: test8.cpp プロジェクト: tschoonj/gtkmm-plplot
    Window() :
      show_edges_label("Show edges"),
      show_labels_label("Show contour labels"),
      edge_color_label("Contour edge color"),
      edge_color(Gdk::RGBA("Red")),
      edge_width_label("Contour edge width"),
      edge_width_adj(Gtk::Adjustment::create(1.0, 0.1, 10.0, 0.1, 1.0, 0.0)),
      edge_width_spin(edge_width_adj, 0.1, 1),
      nlevels_label("Number of contour edges"),
      nlevels_adj(Gtk::Adjustment::create(7, 3, 20, 1, 5)),
      nlevels_spin(nlevels_adj, 1, 0),
      colormap_palette_label("Colormap palette"),
      area_fill_pattern_label("Fill pattern"),
      area_lines_width_label("Fill pattern width"),
      area_lines_width_adj(Gtk::Adjustment::create(1.0, 0.1, 10.0, 0.1, 1.0, 0.0)),
      area_lines_width_spin(area_lines_width_adj, 0.1, 1),
      colorbar_label("Show colorbar"),
      paned(Gtk::ORIENTATION_VERTICAL),
      aspect_frame(Glib::ustring(), Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER, 1.5, false)
      {

      Glib::ustring x_title = "X-axis";
      Glib::ustring y_title = "Y-axis";
      Glib::ustring plot_title = "Intensity vs detector position";

      // general window and canvas settings
      set_default_size(720, 720);
      Gdk::Geometry geometry;
      geometry.min_aspect = geometry.max_aspect = double(720)/double(720);
      set_geometry_hints(*this, geometry, Gdk::HINT_ASPECT);
      set_title("Gtkmm-PLplot test8");
      canvas.set_hexpand(true);
      canvas.set_vexpand(true);

      //read in our dataset
      std::ifstream fs;
      fs.exceptions(std::ifstream::failbit | std::ifstream::badbit | std::ifstream::eofbit);

      // 11 x 11 dataset (I know the file layout and the data dimensions already)
      const int nx = 11;
      const int ny = 11;
      std::vector<double> x(nx);
      std::vector<double> y(ny);
#ifdef GTKMM_PLPLOT_BOOST_ENABLED
      boost::multi_array<double, 2> z(boost::extents[nx][ny]);
      std::cout << "Using Boost multi_array!" << std::endl;
#else
      double **z = Gtk::PLplot::calloc_array2d(nx, ny);
#endif

      fs.open(TEST_CSV);
      std::string line;
      std::getline(fs, line);
      gchar **splitted = g_strsplit(line.c_str(), ",", 0);

      //first line contains the x values
      for (int i = 1 ; i < nx + 1 ; i++) {
        x[i-1] = g_ascii_strtod(splitted[i], NULL);
      }

      g_strfreev(splitted);

      for (int i = 0 ; i < ny ; i++) {
        line.clear();
        std::getline(fs, line);
        splitted = g_strsplit(line.c_str(), ",", 0);
        y[i] = g_ascii_strtod(splitted[0], NULL);
        for (int j = 1 ; j < nx + 1 ; j++) {
          z[j-1][i] = g_ascii_strtod(splitted[j], NULL);
        }
        g_strfreev(splitted);
      }

      //construct the plot
      auto plot = Gtk::manage(new Gtk::PLplot::PlotContourShades(
        *Gtk::manage(new Gtk::PLplot::PlotDataSurface(
          x,
          y,
          z
        )),
        x_title,
        y_title,
        plot_title,
        7,
        Gtk::PLplot::ColormapPalette::BLUE_RED,
        edge_color.get_rgba(),
        1.0
      ));

      canvas.add_plot(*plot);

      plot->set_background_color(Gdk::RGBA("Yellow Green"));

      //now let's set up the grid
      grid.set_column_homogeneous(true);
      grid.set_column_spacing(5);
      grid.set_row_homogeneous(false);
      grid.set_row_spacing(5);

      int row_counter = 0;

      show_edges_label.set_hexpand(true);
      show_edges_label.set_vexpand(false);
      show_edges_label.set_valign(Gtk::ALIGN_CENTER);
      show_edges_label.set_halign(Gtk::ALIGN_END);
      show_edges_switch.set_hexpand(true);
      show_edges_switch.set_vexpand(false);
      show_edges_switch.set_halign(Gtk::ALIGN_START);
      show_edges_switch.set_valign(Gtk::ALIGN_CENTER);
      show_edges_switch.set_active(plot->is_showing_edges());
      show_edges_switch.property_active().signal_changed().connect([this, plot](){
        if (show_edges_switch.get_active()) {
          edge_color.set_sensitive();
          edge_width_spin.set_sensitive();
          show_labels_switch.set_sensitive();
          plot->show_edges();
        }
        else {
          edge_color.set_sensitive(false);
          edge_width_spin.set_sensitive(false);
          show_labels_switch.set_sensitive(false);
          plot->hide_edges();
        }
      });

      grid.attach(show_edges_label, 0, row_counter, 1, 1);
      grid.attach(show_edges_switch, 1, row_counter++, 1, 1);

      // show contour labels
      show_labels_label.set_hexpand(true);
      show_labels_label.set_vexpand(false);
      show_labels_label.set_valign(Gtk::ALIGN_CENTER);
      show_labels_label.set_halign(Gtk::ALIGN_END);
      show_labels_switch.set_hexpand(true);
      show_labels_switch.set_vexpand(false);
      show_labels_switch.set_halign(Gtk::ALIGN_START);
      show_labels_switch.set_valign(Gtk::ALIGN_CENTER);
      show_labels_switch.set_active(plot->is_showing_labels());
      show_labels_switch.property_active().signal_changed().connect([this, plot](){
        if (show_labels_switch.get_active()) {
          plot->show_labels();
        }
        else {
          plot->hide_labels();
        }
      });

      grid.attach(show_labels_label, 0, row_counter, 1, 1);
      grid.attach(show_labels_switch, 1, row_counter++, 1, 1);

      //color button
      edge_color_label.set_hexpand(true);
      edge_color_label.set_vexpand(false);
      edge_color_label.set_valign(Gtk::ALIGN_CENTER);
      edge_color_label.set_halign(Gtk::ALIGN_END);

      edge_color.set_rgba(plot->get_edge_color());
      edge_color.set_use_alpha(true);
      edge_color.set_hexpand(true);
      edge_color.set_vexpand(false);
      edge_color.set_halign(Gtk::ALIGN_START);
      edge_color.set_valign(Gtk::ALIGN_CENTER);
      edge_color.signal_color_set().connect([this, plot](){plot->set_edge_color(edge_color.get_rgba());});

      grid.attach(edge_color_label, 0, row_counter, 1, 1);
      grid.attach(edge_color, 1, row_counter++, 1, 1);

      //the edge width spinbutton
      edge_width_label.set_hexpand(true);
      edge_width_label.set_vexpand(false);
      edge_width_label.set_valign(Gtk::ALIGN_CENTER);
      edge_width_label.set_halign(Gtk::ALIGN_END);

      edge_width_spin.set_hexpand(true);
      edge_width_spin.set_vexpand(false);
      edge_width_spin.set_halign(Gtk::ALIGN_START);
      edge_width_spin.set_valign(Gtk::ALIGN_CENTER);
      edge_width_spin.set_wrap(true);
      edge_width_spin.set_snap_to_ticks(true);
      edge_width_spin.set_numeric(true);
      edge_width_spin.set_value(plot->get_edge_width());
      edge_width_spin.signal_value_changed().connect([this, plot](){
        plot->set_edge_width(edge_width_spin.get_value());
      });

      grid.attach(edge_width_label, 0, row_counter, 1, 1);
      grid.attach(edge_width_spin, 1, row_counter++, 1, 1);

      //nlevels
      nlevels_label.set_hexpand(true);
      nlevels_label.set_vexpand(false);
      nlevels_label.set_valign(Gtk::ALIGN_CENTER);
      nlevels_label.set_halign(Gtk::ALIGN_END);
      nlevels_spin.set_hexpand(true);
      nlevels_spin.set_vexpand(false);
      nlevels_spin.set_halign(Gtk::ALIGN_START);
      nlevels_spin.set_valign(Gtk::ALIGN_CENTER);
      nlevels_spin.set_wrap(true);
      nlevels_spin.set_snap_to_ticks(true);
      nlevels_spin.set_numeric(true);
      nlevels_spin.set_value(plot->get_nlevels());
      nlevels_spin.signal_value_changed().connect([this, plot](){
        plot->set_nlevels(nlevels_spin.get_value());
      });

      grid.attach(nlevels_label, 0, row_counter, 1, 1);
      grid.attach(nlevels_spin, 1, row_counter++, 1, 1);

      // colormap palette
      colormap_palette_label.set_hexpand(true);
      colormap_palette_label.set_vexpand(false);
      colormap_palette_label.set_valign(Gtk::ALIGN_CENTER);
      colormap_palette_label.set_halign(Gtk::ALIGN_END);
      colormap_palette_combo.set_hexpand(true);
      colormap_palette_combo.set_vexpand(false);
      colormap_palette_combo.set_halign(Gtk::ALIGN_START);
      colormap_palette_combo.set_valign(Gtk::ALIGN_CENTER);

      colormap_palette_combo.append("Default");
      colormap_palette_combo.append("Blue → Red");
      colormap_palette_combo.append("Blue → Yellow");
      colormap_palette_combo.append("Gray");
      colormap_palette_combo.append("High frequencies");
      colormap_palette_combo.append("Low frequencies");
      colormap_palette_combo.append("Radar");

      colormap_palette_combo.set_active(plot->get_colormap_palette());
      colormap_palette_combo.signal_changed().connect([this, plot](){
        plot->set_colormap_palette(static_cast<Gtk::PLplot::ColormapPalette>(colormap_palette_combo.get_active_row_number()));
      });

      grid.attach(colormap_palette_label, 0, row_counter, 1, 1);
      grid.attach(colormap_palette_combo, 1, row_counter++, 1, 1);

      //area fill pattern
      area_fill_pattern_label.set_hexpand(true);
      area_fill_pattern_label.set_vexpand(false);
      area_fill_pattern_label.set_valign(Gtk::ALIGN_CENTER);
      area_fill_pattern_label.set_halign(Gtk::ALIGN_END);
      area_fill_pattern_combo.set_hexpand(true);
      area_fill_pattern_combo.set_vexpand(false);
      area_fill_pattern_combo.set_halign(Gtk::ALIGN_START);
      area_fill_pattern_combo.set_valign(Gtk::ALIGN_CENTER);

      area_fill_pattern_combo.append("Solid");
      area_fill_pattern_combo.append("Horizontal lines");
      area_fill_pattern_combo.append("Vertical lines");
      area_fill_pattern_combo.append("Upward lines at 45 degrees");
      area_fill_pattern_combo.append("Downward lines at 45 degrees");
      area_fill_pattern_combo.append("Upward lines at 30 degrees");
      area_fill_pattern_combo.append("Downward lines at 30 degrees");
      area_fill_pattern_combo.append("Horizontal and vertical lines");
      area_fill_pattern_combo.append("Upward and downward lines at 45 degrees");
      area_fill_pattern_combo.set_active(plot->get_area_fill_pattern());
      area_fill_pattern_combo.signal_changed().connect([this, plot](){
        plot->set_area_fill_pattern(static_cast<Gtk::PLplot::AreaFillPattern>(area_fill_pattern_combo.get_active_row_number()));
        if (area_fill_pattern_combo.get_active_row_number() == 0 /* SOLID */) {
          area_lines_width_spin.set_sensitive(false);
        }
        else {
          area_lines_width_spin.set_sensitive();
        }
      });

      grid.attach(area_fill_pattern_label, 0, row_counter, 1, 1);
      grid.attach(area_fill_pattern_combo, 1, row_counter++, 1, 1);

      //the area lines width spinbutton
      area_lines_width_label.set_hexpand(true);
      area_lines_width_label.set_vexpand(false);
      area_lines_width_label.set_valign(Gtk::ALIGN_CENTER);
      area_lines_width_label.set_halign(Gtk::ALIGN_END);

      area_lines_width_spin.set_hexpand(true);
      area_lines_width_spin.set_vexpand(false);
      area_lines_width_spin.set_halign(Gtk::ALIGN_START);
      area_lines_width_spin.set_valign(Gtk::ALIGN_CENTER);
      area_lines_width_spin.set_wrap(true);
      area_lines_width_spin.set_snap_to_ticks(true);
      area_lines_width_spin.set_numeric(true);
      area_lines_width_spin.set_value(plot->get_area_lines_width());
      area_lines_width_spin.signal_value_changed().connect([this, plot](){
        plot->set_area_lines_width(area_lines_width_spin.get_value());
      });

      area_lines_width_spin.set_sensitive(false);

      grid.attach(area_lines_width_label, 0, row_counter, 1, 1);
      grid.attach(area_lines_width_spin, 1, row_counter++, 1, 1);

      //colorbar
      colorbar_label.set_hexpand(true);
      colorbar_label.set_vexpand(false);
      colorbar_label.set_valign(Gtk::ALIGN_CENTER);
      colorbar_label.set_halign(Gtk::ALIGN_END);
      colorbar_switch.set_hexpand(true);
      colorbar_switch.set_vexpand(false);
      colorbar_switch.set_halign(Gtk::ALIGN_START);
      colorbar_switch.set_valign(Gtk::ALIGN_CENTER);
      colorbar_switch.set_active(plot->is_showing_colorbar());
      colorbar_switch.property_active().signal_changed().connect([this, plot](){
        if (colorbar_switch.get_active()) {
          plot->show_colorbar();
        }
        else {
          plot->hide_colorbar();
        }
      });

      grid.attach(colorbar_label, 0, row_counter, 1, 1);
      grid.attach(colorbar_switch, 1, row_counter++, 1, 1);
      paned.add1(grid);

      //add canvas to grid
      aspect_frame.add(canvas);
      paned.add2(aspect_frame);

      //finishing up
      add(paned);
      set_border_width(10);
#if GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION >= 18
      paned.set_wide_handle(true);
#endif
      paned.show_all();

    }
コード例 #8
0
/**
* Sets up the main window.
*/
GtkMainWindow::GtkMainWindow() :
	m_core(Application::getSingleton()->getCore())
{
	//TODO:This needs to be refactored
	this->set_position(Gtk::WIN_POS_CENTER);
	this->set_default_size(800, 500);
	Gtk::Paned *panel = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_VERTICAL));

	m_infobar =  Gtk::manage(new GtkTorrentInfoBar());
	m_treeview = Gtk::manage(new GtkTorrentTreeView(m_infobar));

	panel->pack1(*m_treeview);
	panel->pack2(*m_infobar);

	Glib::     signal_timeout().connect(sigc::mem_fun(*this, &GtkMainWindow::onSecTick), 1000);
	this->signal_delete_event().connect(sigc::mem_fun(*this, &GtkMainWindow::onDestroy));

	header = Gtk::manage(new Gtk::HeaderBar());
	header->set_show_close_button(true);
	header->set_title("gTorrent");

	Glib::RefPtr<Gtk::ActionGroup> action_group = Gtk::ActionGroup::create();

	action_group->add(Gtk::Action::create( "Properties", Gtk::Stock::PROPERTIES));
	action_group->add(Gtk::Action::create(   "Add Link", Gtk::Stock::PASTE),       sigc::mem_fun(*this, &GtkMainWindow::onAddMagnetBtnClicked));
	action_group->add(Gtk::Action::create("Add Torrent", Gtk::Stock::ADD),         sigc::mem_fun(*this, &GtkMainWindow::onAddBtnClicked));
	action_group->add(Gtk::Action::create(     "Remove", Gtk::Stock::CANCEL),      sigc::mem_fun(*this, &GtkMainWindow::onRemoveBtnClicked));
	action_group->add(Gtk::Action::create(     "Resume", Gtk::Stock::MEDIA_PLAY),  sigc::mem_fun(*this, &GtkMainWindow::onResumeBtnClicked));
	action_group->add(Gtk::Action::create(      "Pause", Gtk::Stock::MEDIA_PAUSE), sigc::mem_fun(*this, &GtkMainWindow::onPauseBtnClicked));
	action_group->add(Gtk::Action::create(         "Up", Gtk::Stock::GO_UP));
	action_group->add(Gtk::Action::create(       "Down", Gtk::Stock::GO_DOWN));

	Glib::RefPtr<Gtk::UIManager> ui_manager = Gtk::UIManager::create();
	ui_manager->insert_action_group(action_group);
	add_accel_group(ui_manager->get_accel_group());

	Glib::ustring ui_info =
	    "<ui>"
	    "	<toolbar  name='ToolBar'>"
	    "		<toolitem action='Properties' />"
	    "		<separator />"
	    "		<toolitem action='Add Link' />"
	    "		<toolitem action='Add Torrent' />"
	    "		<separator />"
	    "		<toolitem action='Remove' />"
	    "		<toolitem action='Pause' />"
	    "		<toolitem action='Resume' />"
	    "		<separator />"
	    "		<toolitem action='Down' />"
	    "		<toolitem action='Up' />"
	    "		<separator />"
	    "	</toolbar>"
	    "</ui>";

	ui_manager->add_ui_from_string(ui_info);
	this->add(*panel);
	Gtk::Widget* pToolBar = ui_manager->get_widget("/ToolBar");
	pToolBar->override_background_color(Gdk::RGBA("0, 0, 0, 0"));
	header->add(*pToolBar);

	// Let's add some DnD goodness
	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));

	this->set_titlebar(*header);
	this->show_all();

	panel->set_position(this->get_height() * 0.5);
}