Gtk::VBox *
Extension::get_info_widget(void)
{
    Gtk::VBox * retval = Gtk::manage(new Gtk::VBox());

    Gtk::Frame * info = Gtk::manage(new Gtk::Frame("General Extension Information"));
    retval->pack_start(*info, true, true, 5);

#if WITH_GTKMM_3_0
    Gtk::Grid * table = Gtk::manage(new Gtk::Grid());
#else
    Gtk::Table * table = Gtk::manage(new Gtk::Table());
#endif

    info->add(*table);

    int row = 0;
    add_val(_("Name:"), _(name), table, &row);
    add_val(_("ID:"), id, table, &row);
    add_val(_("State:"), _state == STATE_LOADED ? _("Loaded") : _state == STATE_UNLOADED ? _("Unloaded") : _("Deactivated"), table, &row);


    retval->show_all();
    return retval;
}
Beispiel #2
0
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);	
}
void DocumentProperties::setupFields (Glib::ustring const &docType)
{
	Gtk::VBox *metadataBox;
  xml_->get_widget ("MetadataBox", metadataBox);
	if (metadataBox->children().size()) {
		metadataBox->children().erase(metadataBox->children().begin());
	}

	DocumentType type = typeManager_.getType (docType);

	int const nRows = type.requiredFields_.size() + type.optionalFields_.size();
	Gtk::Table *metadataTable = new Gtk::Table (nRows, 4, false);
	metadataTable->set_col_spacings (6);
	metadataTable->set_row_spacings (6);

	fieldEntries_.clear ();

	Gtk::Label *typeLabel = Gtk::manage (new Gtk::Label (_("_Type:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, true));
	
	if (typecombochanged_)
		typecombochanged_.disconnect();

	typeCombo_ = Gtk::manage (new Gtk::ComboBox);
	typeCombo_->set_model(typecombostore_);
	typeCombo_->pack_start(typelabelcol_, true);
	typeCombo_->pack_start(typebibtexnamecol_, false);

	typeLabel->set_mnemonic_widget (*typeCombo_);
	metadataTable->attach (*typeLabel, 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK | Gtk::FILL, 0, 0);
	metadataTable->attach (*typeCombo_, 1, 4, 0, 1, Gtk::FILL, Gtk::SHRINK | Gtk::FILL, 0, 0);

	typecombostore_->clear();
	for (DocumentTypeManager::TypesMap::iterator it = typeManager_.getTypes().begin();
			it != typeManager_.getTypes().end();
			++it) {

		Gtk::TreeModel::Row row = *(typecombostore_->append());
		row[typelabelcol_] = (*it).second.displayName_;
		row[typebibtexnamecol_] = (*it).second.bibtexName_;
	}

	typecombochanged_ = typeCombo_->signal_changed().connect (
			sigc::mem_fun (*this, &DocumentProperties::onTypeChanged));

	int row = 1;
	for (
	     std::vector<DocumentField>::iterator it = type.requiredFields_.begin();
	     it != type.requiredFields_.end();
	     ++it) {

		if (it->shortField_)
			continue;

		Gtk::Label *label = Gtk::manage (new Gtk::Label (it->displayName_ + ":", Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
		Gtk::Entry *entry = Gtk::manage (new Gtk::Entry ());

		/* [bert] Minor change to actually implement and register
		 * a callback for changes to the DOI field. This is a bit
		 * ugly here since it assumes we know whether DOI is 
		 * required or not.
		 */
		if (it->internalName_ == "doi") {
		  entry->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::onDoiEntryChanged));
		}

		fieldEntries_[it->internalName_] = entry;

		metadataTable->attach (*label, 0, 1, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK | Gtk::FILL, 0, 0);
		metadataTable->attach (*entry, 1, 4, row, row + 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK | Gtk::FILL, 0, 0);
		++row;
	}
	for (
	     std::vector<DocumentField>::iterator it = type.optionalFields_.begin();
	     it != type.optionalFields_.end();
	     ++it) {

		if (it->shortField_)
			continue;

		Gtk::Label *label = Gtk::manage (new Gtk::Label (it->displayName_ + ":", Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
		Gtk::Entry *entry = Gtk::manage (new Gtk::Entry ());

		fieldEntries_[it->internalName_] = entry;

		metadataTable->attach (*label, 0, 1, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK | Gtk::FILL, 0, 0);
		metadataTable->attach (*entry, 1, 4, row, row + 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK | Gtk::FILL, 0, 0);
		++row;
	}

	int col = 0;
	for (
	     std::vector<DocumentField>::iterator it = type.requiredFields_.begin();
	     it != type.requiredFields_.end();
	     ++it) {

		if (!it->shortField_)
			continue;

		Gtk::Label *label = Gtk::manage (new Gtk::Label (it->displayName_ + ":", Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
		Gtk::Entry *entry = Gtk::manage (new Gtk::Entry ());

		fieldEntries_[it->internalName_] = entry;

		metadataTable->attach (*label, 0 + col * 2, 1 + col * 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK | Gtk::FILL, 0, 0);
		metadataTable->attach (*entry, 1 + col * 2, 2 + col * 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK | Gtk::FILL, 0, 0);
		++col;
		if (col > 1) {
			++row;
			col = 0;
		}
	}
	for (
	     std::vector<DocumentField>::iterator it = type.optionalFields_.begin();
	     it != type.optionalFields_.end();
	     ++it) {

		if (!it->shortField_)
			continue;

		Gtk::Label *label = Gtk::manage (new Gtk::Label (it->displayName_ + ":", Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
		Gtk::Entry *entry = Gtk::manage (new Gtk::Entry ());

		fieldEntries_[it->internalName_] = entry;

		metadataTable->attach (*label, 0 + col * 2, 1 + col * 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK | Gtk::FILL, 0, 0);
		metadataTable->attach (*entry, 1 + col * 2, 2 + col * 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK | Gtk::FILL, 0, 0);
		++col;
		if (col > 1) {
			++row;
			col = 0;
		}
	}

	metadataBox->pack_start (*metadataTable);
	metadataBox->show_all ();
}
bool gui_show_text_entry_dialog(const std::string& title, const std::string& message, const std::string& sec_message,
		std::string& result, const std::string& default_str, Gtk::Window* parent, bool sec_msg_markup)
{
	int response = 0;
	std::string input_str;

	{  // the dialog hides at the end of scope
		Gtk::Dialog dialog(title, true);  // modal

		dialog.set_resizable(false);
		dialog.set_skip_taskbar_hint(true);
		dialog.set_border_width(5);

		if (parent) {
			dialog.set_transient_for(*parent);
			dialog.set_position(Gtk::WIN_POS_CENTER_ON_PARENT);
		} else {
			dialog.set_position(Gtk::WIN_POS_MOUSE);
		}


		Gtk::Label main_label;
		main_label.set_markup("<big><b>" + Glib::Markup::escape_text(message)
				+ (sec_message.empty() ? "\n" : "") + "</b></big>");
		main_label.set_line_wrap(true);
		main_label.set_selectable(true);
		main_label.set_alignment(0.0, 0.0);

		Gtk::Label sec_label;
		if (sec_msg_markup) {
			sec_label.set_markup(sec_message);
		} else {
			sec_label.set_text(sec_message);
		}
		sec_label.set_line_wrap(true);
		sec_label.set_selectable(true);
		sec_label.set_alignment(0.0, 0.0);

		Gtk::Entry input_entry;
		input_entry.set_activates_default(true);


		Gtk::VBox vbox;
		vbox.set_spacing(12);
		vbox.pack_start(main_label, false, false, 0);
		vbox.pack_start(sec_label, true, true, 0);
		vbox.pack_start(input_entry, true, true, 0);
		vbox.show_all();

		dialog.get_action_area()->set_border_width(5);
		dialog.get_action_area()->set_spacing(6);

		dialog.get_vbox()->set_spacing(14);  // as in MessageDialog
		dialog.get_vbox()->pack_start(vbox, false, false, 0);


		dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);

		Gtk::Button ok_button(Gtk::Stock::OK);
		ok_button.set_flags(ok_button.get_flags() | Gtk::CAN_DEFAULT);
		ok_button.show_all();
		dialog.add_action_widget(ok_button, Gtk::RESPONSE_OK);
		ok_button.grab_default();  // make it the default widget

		response = dialog.run();  // blocks until the dialog is closed

		input_str = input_entry.get_text();
	}

	if (response == Gtk::RESPONSE_OK) {
		result = input_str;
		return true;
	}

	return false;
}