Ejemplo n.º 1
0
void Chat::setWidgets() {
  // Show user button
  showUsersBtn_.set_can_focus(false);
  showUsersBtn_.signal_clicked().connect(mem_fun(this, &Chat::ShowUsers));

  // First level
  HButtonBox * firstLvl = new HButtonBox(Gtk::BUTTONBOX_END);
  firstLvl->pack_start(showUsersBtn_);

  // Result view
  resultView_.set_wrap_mode(Gtk::WRAP_WORD);
  resultView_.set_editable(false);

  ScrolledWindow * messageScroll = new Gtk::ScrolledWindow();
  messageScroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
  messageScroll->add(resultView_);

  // User list
  users_.set_column_title(0, "Users");
  users_.set_headers_visible(false);
  users_.append("Admin");
  users_.append("Console");

  userScroll_.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
  userScroll_.add(users_);

  // Second level
  HBox * secondLvl = new HBox();
  secondLvl->pack_start(*manage(messageScroll));
  secondLvl->pack_start(userScroll_, Gtk::PACK_SHRINK);

  // Command entry
  commandEntry_.signal_activate().connect(mem_fun(this, &Chat::Submit));
  commandEntry_.signal_changed().connect(mem_fun(this, &Chat::ShowSubmit));

  // Submit button
  submitBtn_.set_can_focus(false);
  submitBtn_.signal_clicked().connect(mem_fun(this, &Chat::Submit));

  // Third level
  HBox * thirdLvl = new HBox();
  thirdLvl->pack_start(commandEntry_);
  thirdLvl->pack_start(submitBtn_, Gtk::PACK_SHRINK);

  // Vertical Align
  pack_start(*manage(firstLvl), Gtk::PACK_SHRINK);
  pack_start(*manage(secondLvl));
  pack_start(*manage(thirdLvl), Gtk::PACK_SHRINK);

  // Window Settings
  set_focus_child(commandEntry_);
  show_all();
  submitBtn_.hide();
  userScroll_.hide();
}
Ejemplo n.º 2
0
IndexPage::IndexPage(const ustring &indexName, IndexTree *pTree,
	PinotSettings &settings) :
	NotebookPageBox(indexName, NotebookPageBox::INDEX_PAGE, settings),
	m_pTree(pTree),
	m_pLabelCombobox(NULL),
	m_pBackButton(NULL),
	m_pForwardButton(NULL),
	m_docsCount(0),
	m_firstDoc(0)
{
	m_pLabelCombobox = manage(new ComboBox());

	Image *image521 = manage(new Image(StockID("gtk-media-rewind"), IconSize(4)));
	Label *label52 = manage(new Label(_("Show Previous")));
	HBox *hbox45 = manage(new HBox(false, 2));
	Alignment *alignment31 = manage(new Alignment(0.5, 0.5, 0, 0));
	m_pBackButton = manage(new Button());

	Image *image522 = manage(new Image(StockID("gtk-media-forward"), IconSize(4)));
	Label *label53 = manage(new Label(_("Show Next")));
	HBox *hbox46 = manage(new HBox(false, 2));
	Alignment *alignment32 = manage(new Alignment(0.5, 0.5, 0, 0));
	m_pForwardButton = manage(new Button());

	HButtonBox *indexHbuttonbox = manage(new HButtonBox(BUTTONBOX_START, 0));
	HBox *indexButtonsHbox = manage(new HBox(false, 0));

	// Buttons
	image521->set_alignment(0.5,0.5);
	image521->set_padding(0,0);
	label52->set_alignment(0.5,0.5);
	label52->set_padding(0,0);
	label52->set_justify(Gtk::JUSTIFY_LEFT);
	label52->set_line_wrap(false);
	label52->set_use_markup(false);
	label52->set_selectable(false);
	hbox45->pack_start(*image521, Gtk::PACK_SHRINK, 0);
	hbox45->pack_start(*label52, Gtk::PACK_SHRINK, 0);
	alignment31->add(*hbox45);
	m_pBackButton->set_flags(Gtk::CAN_FOCUS);
	m_pBackButton->set_flags(Gtk::CAN_DEFAULT);
	m_pBackButton->set_relief(Gtk::RELIEF_NORMAL);
	m_pBackButton->add(*alignment31);
	image522->set_alignment(0.5,0.5);
	image522->set_padding(0,0);
	label53->set_alignment(0.5,0.5);
	label53->set_padding(0,0);
	label53->set_justify(Gtk::JUSTIFY_LEFT);
	label53->set_line_wrap(false);
	label53->set_use_markup(false);
	label53->set_selectable(false);
	hbox46->pack_start(*image522, Gtk::PACK_SHRINK, 0);
	hbox46->pack_start(*label53, Gtk::PACK_SHRINK, 0);
	alignment32->add(*hbox46);
	m_pForwardButton->set_flags(Gtk::CAN_FOCUS);
	m_pForwardButton->set_flags(Gtk::CAN_DEFAULT);
	m_pForwardButton->set_relief(Gtk::RELIEF_NORMAL);
	m_pForwardButton->add(*alignment32);

	// Position everything
	indexHbuttonbox->pack_start(*m_pBackButton);
	indexHbuttonbox->pack_start(*m_pForwardButton);
	indexButtonsHbox->pack_start(*m_pLabelCombobox, Gtk::PACK_SHRINK, 4);
	indexButtonsHbox->pack_start(*indexHbuttonbox, Gtk::PACK_EXPAND_WIDGET, 4);
	pack_start(*indexButtonsHbox, Gtk::PACK_SHRINK, 4);
	if (pTree != NULL)
	{
		pack_start(*pTree->getScrolledWindow());
	}

	// Associate the columns model to the label combo
	m_refLabelNameTree = ListStore::create(m_labelNameColumns);
	m_pLabelCombobox->set_model(m_refLabelNameTree);
	m_pLabelCombobox->pack_start(m_labelNameColumns.m_name);
	// Populate
	populateLabelCombobox();

	// Connect the signals
	m_pLabelCombobox->signal_changed().connect(
		SigC::slot(*this, &IndexPage::onLabelChanged));
	m_pBackButton->signal_clicked().connect(
		SigC::slot(*this, &IndexPage::onBackClicked));
	m_pForwardButton->signal_clicked().connect(
		SigC::slot(*this, &IndexPage::onForwardClicked));

	// Disable the buttons until something is being shown
	m_pBackButton->set_sensitive(false);
	m_pForwardButton->set_sensitive(false);

	// Show all
	m_pLabelCombobox->show();
	image521->show();
	label52->show();
	hbox45->show();
	alignment31->show();
	m_pBackButton->show();
	image522->show();
	label53->show();
	hbox46->show();
	alignment32->show();
	m_pForwardButton->show();
	indexHbuttonbox->show();
	indexButtonsHbox->show();
	show();
}
Ejemplo n.º 3
0
BackupDialog::BackupDialog(Gtk::Window& parent, Config* ppConfig, tSectionID section)
	: Dialog("Backup", parent), mSection(section),
	mOptionDummyRun("Dummy run"),
	mpConfig(ppConfig), mpBackupThread(NULL), mOptionLevel(1.0),
	mExecButton(Stock::EXECUTE)
{
#ifdef DEBUG
	cerr << "BackupDialog constructor" << endl;
#endif

	set_default_size(650,550);
	// add close button
	add_button(Stock::CLOSE, 1);

	VBox* mainbox = get_vbox(); 
	
	// add Option frame
	Frame* poptionFrame = manage(new Frame());

	poptionFrame->set_border_width(2);
	poptionFrame->set_label("Options");
	mainbox->pack_start(*poptionFrame, false, false);	

	/// add options
	{
		ustring backupType = mpConfig->get_option(mSection, "type");
		Table* optionTable = manage(new Table(2,2));

		Label* label = manage(new Label("Level:"));
		optionTable->attach(*label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL, 5, 0);
		optionTable->attach(mOptionLevel, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL, 5, 0);						
		label->set_sensitive(false);
		mOptionLevel.set_sensitive(false);

		if(backupType == "incremental") // incremental backup
		{
//TODO: automatic level			mOptionLevel.set_value(mpConfig->get_num_option(mSection, "level"));
			mOptionLevel.set_range(1,999);
			mOptionLevel.set_increments(1,2);
			mOptionLevel.set_numeric();
			mOptionLevel.set_sensitive();
			label->set_sensitive();
		}

		// dummy run option
		mOptionDummyRun.set_active(false);
		optionTable->attach(mOptionDummyRun, 0, 2, 1, 2, FILL, FILL, 5, 0);
		
		// add option table to option frame
		poptionFrame->add(*optionTable);
	}


	// Buttons
	HButtonBox* buttons = manage(new HButtonBox(BUTTONBOX_START));
	buttons->set_border_width(2);
	buttons->set_spacing(10);
	mainbox->pack_start(*buttons, false, false);

	mExecButton.set_use_stock(true);
	mExecButton.signal_clicked().connect( sigc::mem_fun(*this, &BackupDialog::on_button_exec) );
	buttons->pack_start(mExecButton);

	// Log Frame
	Frame* logframe = manage(new Frame());
	logframe->set_border_width(2);
	logframe->set_label("Output");
	mainbox->pack_start(*logframe, true, true);
	
	ScrolledWindow* scrolled = manage(new ScrolledWindow());
	scrolled->set_policy(POLICY_AUTOMATIC, POLICY_ALWAYS);
	scrolled->set_shadow_type(SHADOW_IN);
	scrolled->set_border_width(2);
	logframe->add(*scrolled);

	// Log buffer

	mrefTag = Gtk::TextBuffer::Tag::create();
	mrefTag->property_foreground() = "red";

	Glib::RefPtr<Gtk::TextBuffer::TagTable> refTagTable = Gtk::TextBuffer::TagTable::create();
	refTagTable->add(mrefTag);
	
	mrefLogBuffer = Gtk::TextBuffer::create(refTagTable);
	mLogEnd = mrefLogBuffer->create_mark("bottom", mrefLogBuffer->end());
	mrefLogBuffer->signal_insert().connect(sigc::mem_fun(*this, &BackupDialog::on_buffer_insert));
	
	mLogView.set_buffer(mrefLogBuffer);
	mLogView.set_editable(false);
	mLogView.set_cursor_visible(false);
	scrolled->add(mLogView);

	mpLog = new TextBufferLog(mrefTag, mrefLogBuffer, &mLogView);
	signal_delete_event().connect(
			sigc::mem_fun(*this, &BackupDialog::on_delete_it));

	show_all_children();
}