mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
Move some functions from ghelpers into gtklengthentry
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10818 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f3341d73ee
commit
f3adb6ad82
@ -3,6 +3,8 @@
|
||||
* GGraphics.[Ch], glade/graphics.glade: Use GtkLengthEntry, touch up glade
|
||||
* GDocument.[Ch], glade/document.glade: Only Bullet options left to do
|
||||
* GBibtex.[Ch], glade/bibtex.glade: Implement bibtex dialog
|
||||
* ghelpers.[Ch], GtkLengthEntry.[Ch]: Move some old stuff out of
|
||||
ghelpers into GtkLengthEntry
|
||||
|
||||
2006-02-05 John Spray <spray@lyx.org>
|
||||
|
||||
|
@ -11,6 +11,13 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "ghelpers.h"
|
||||
|
||||
#include "GtkLengthEntry.h"
|
||||
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
// Too hard to make concept checks work with this file
|
||||
#ifdef _GLIBCXX_CONCEPT_CHECKS
|
||||
#undef _GLIBCXX_CONCEPT_CHECKS
|
||||
@ -19,12 +26,49 @@
|
||||
#undef _GLIBCPP_CONCEPT_CHECKS
|
||||
#endif
|
||||
|
||||
#include "GtkLengthEntry.h"
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
namespace {
|
||||
|
||||
string const getLengthFromWidgets(Gtk::Adjustment const & adj, Gtk::ComboBoxText const & combo)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << adj.get_value();
|
||||
os << combo.get_active_text();
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
void setWidgetsFromLength(Gtk::Adjustment & adj, Gtk::ComboBoxText & combo, LyXLength const & length)
|
||||
{
|
||||
adj.set_value(length.value());
|
||||
|
||||
string unit = stringFromUnit(length.unit());
|
||||
if (unit.empty())
|
||||
unit = getDefaultUnit();
|
||||
|
||||
comboBoxTextSet(combo,unit);
|
||||
}
|
||||
|
||||
|
||||
void populateUnitCombo(Gtk::ComboBoxText & combo, bool const userelative)
|
||||
{
|
||||
vector<string> const units = buildLengthUnitList(userelative);
|
||||
|
||||
vector<string>::const_iterator it = units.begin();
|
||||
vector<string>::const_iterator const end = units.end();
|
||||
for(; it != end; ++it)
|
||||
combo.append_text(*it);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
GtkLengthEntry::GtkLengthEntry(
|
||||
BaseObjectType* cobject,
|
||||
|
@ -14,7 +14,6 @@
|
||||
#define GLENGTHENTRY_H
|
||||
|
||||
|
||||
#include "ghelpers.h"
|
||||
#include "lengthcommon.h"
|
||||
|
||||
#include <gtkmm.h>
|
||||
|
@ -36,38 +36,8 @@ using std::vector;
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
string const getLengthFromWidgets(Gtk::Adjustment const & adj, Gtk::ComboBoxText const & combo)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << adj.get_value();
|
||||
os << combo.get_active_text();
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
void setWidgetsFromLength(Gtk::Adjustment & adj, Gtk::ComboBoxText & combo, LyXLength const & length)
|
||||
{
|
||||
adj.set_value(length.value());
|
||||
|
||||
string unit = stringFromUnit(length.unit());
|
||||
if (unit.empty())
|
||||
unit = getDefaultUnit();
|
||||
|
||||
comboBoxTextSet(combo,unit);
|
||||
}
|
||||
|
||||
|
||||
void populateUnitCombo(Gtk::ComboBoxText & combo, bool const userelative)
|
||||
{
|
||||
vector<string> units = buildLengthUnitList(userelative);
|
||||
|
||||
vector<string>::const_iterator it = units.begin();
|
||||
vector<string>::const_iterator end = units.end();
|
||||
for(; it != end; ++it)
|
||||
combo.append_text(*it);
|
||||
}
|
||||
|
||||
|
||||
// This function should be replaced by Gtk::ComboBoxText::set_active_text
|
||||
// Which was introduced in gtkmm 2.6
|
||||
int comboBoxTextSet(Gtk::ComboBoxText & combo, Glib::ustring target)
|
||||
{
|
||||
int const children = combo.get_model()->children().size();
|
||||
@ -164,7 +134,6 @@ void unitsComboFromLength(Gtk::ComboBox * combo,
|
||||
|
||||
vector<string> const buildLengthUnitList(bool const userelative)
|
||||
{
|
||||
//vector<string> data(unit_name_gui, unit_name_gui + num_units);
|
||||
vector<string> data;
|
||||
if (userelative) {
|
||||
data = vector<string>(unit_name_gui, unit_name_gui + num_units);
|
||||
|
@ -24,19 +24,8 @@ class FuncRequest;
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
std::string const getLengthFromWidgets(
|
||||
Gtk::Adjustment const & adj,
|
||||
Gtk::ComboBoxText const & combo);
|
||||
|
||||
void setWidgetsFromLength(
|
||||
Gtk::Adjustment & adj,
|
||||
Gtk::ComboBoxText & combo,
|
||||
LyXLength const & length);
|
||||
|
||||
int comboBoxTextSet(Gtk::ComboBoxText & combo, Glib::ustring target);
|
||||
|
||||
void populateUnitCombo(Gtk::ComboBoxText & combo, bool userelative);
|
||||
|
||||
// Get a GTK stockID from a lyx function id.
|
||||
// Return Gtk::Stock::MISSING_IMAGE if no suitable stock found
|
||||
Gtk::BuiltinStockID getGTKStockIcon(FuncRequest const & func);
|
||||
|
Loading…
Reference in New Issue
Block a user