mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 12:32:26 +00:00
add gtk TOC dialog
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9034 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2cd0b94b86
commit
ae8999aeba
@ -1,3 +1,8 @@
|
||||
2004-10-02 John Spray <spray_john@users.sourceforge.net>
|
||||
|
||||
* The Table of Contents dialog
|
||||
* Dialogs.C, GToc.C, GToc.h, Makefile.am
|
||||
|
||||
2004-09-29 John Spray <spray_john@users.sourceforge.net>
|
||||
|
||||
* The Paragraph dialog
|
||||
|
@ -85,7 +85,7 @@
|
||||
#include "FormShowFile.h"
|
||||
#include "FormSpellchecker.h"
|
||||
#include "GTableCreate.h"
|
||||
#include "FormToc.h"
|
||||
#include "GToc.h"
|
||||
#include "GUrl.h"
|
||||
#include "FormVSpace.h"
|
||||
#include "FormWrap.h"
|
||||
@ -501,8 +501,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name)
|
||||
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
|
||||
#endif
|
||||
} else if (name == "toc") {
|
||||
dialog->bc().view(new GBC(dialog->bc()));
|
||||
dialog->setController(new ControlToc(*dialog));
|
||||
dialog->setView(new FormToc(*dialog));
|
||||
dialog->setView(new GToc(*dialog));
|
||||
dialog->bc().bp(new OkCancelPolicy);
|
||||
} else if (name == "url") {
|
||||
dialog->bc().view(new GBC(dialog->bc()));
|
||||
|
170
src/frontends/gtk/GToc.C
Normal file
170
src/frontends/gtk/GToc.C
Normal file
@ -0,0 +1,170 @@
|
||||
/**
|
||||
* \file GToc.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Spray
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "GToc.h"
|
||||
#include "ControlToc.h"
|
||||
|
||||
#include "ghelpers.h"
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
GToc::GToc(Dialog & parent)
|
||||
: GViewCB<ControlToc, GViewGladeB>(parent, _("Table of Contents"), false)
|
||||
{}
|
||||
|
||||
|
||||
void GToc::doBuild()
|
||||
{
|
||||
string const gladeName = findGladeFile("toc");
|
||||
xml_ = Gnome::Glade::Xml::create(gladeName);
|
||||
|
||||
Gtk::Button * button;
|
||||
xml_->get_widget("Close", button);
|
||||
setCancel(button);
|
||||
xml_->get_widget("Refresh", button);
|
||||
button->signal_clicked().connect(
|
||||
sigc::mem_fun(*this, >oc::updateContents));
|
||||
|
||||
changing_views_ = true;
|
||||
|
||||
// For both liststores
|
||||
listCols_.add(listCol_);
|
||||
listCols_.add(listColIndex_);
|
||||
|
||||
// TOC ListView
|
||||
xml_->get_widget("Contents", tocview_);
|
||||
tocstore_ = Gtk::ListStore::create(listCols_);
|
||||
tocview_->set_model(tocstore_);
|
||||
tocview_->append_column("Entry", listCol_);
|
||||
|
||||
listSel_ = tocview_->get_selection();
|
||||
listSel_->signal_changed().connect(
|
||||
sigc::mem_fun(*this, >oc::onTocViewSelected));
|
||||
|
||||
// Type Selection Combobox
|
||||
xml_->get_widget("Type", typecombo_);
|
||||
typestore_ = Gtk::ListStore::create(listCols_);
|
||||
typecombo_->set_model(typestore_);
|
||||
Gtk::CellRendererText * cell = Gtk::manage(new Gtk::CellRendererText);
|
||||
typecombo_->pack_start(*cell, true);
|
||||
typecombo_->add_attribute(*cell,"text",0);
|
||||
typecombo_->set_size_request(130,-1);
|
||||
|
||||
typecombo_->signal_changed().connect(
|
||||
sigc::mem_fun(*this, >oc::onTypeComboChanged));
|
||||
|
||||
changing_views_ = false;
|
||||
}
|
||||
|
||||
|
||||
void GToc::update()
|
||||
{
|
||||
updateType();
|
||||
updateContents();
|
||||
}
|
||||
|
||||
|
||||
void GToc::updateType()
|
||||
{
|
||||
changing_views_ = true;
|
||||
string const targettype =
|
||||
toc::getType(controller().params().getCmdName());
|
||||
|
||||
typestore_->clear();
|
||||
vector<string> types = controller().getTypes();
|
||||
|
||||
// Because tiny empty ComboBoxes just look silly
|
||||
int const emptycombosize = 130;
|
||||
typecombo_->set_size_request(types.empty() ? emptycombosize : -1, -1);
|
||||
|
||||
vector<string>::iterator it = types.begin();
|
||||
vector<string>::iterator end = types.end();
|
||||
for(;it != end; ++it) {
|
||||
Gtk::TreeModel::iterator row = typestore_->append();
|
||||
(*row)[listCol_] = *it;
|
||||
if (*it == targettype)
|
||||
typecombo_->set_active(row);
|
||||
}
|
||||
changing_views_ = false;
|
||||
}
|
||||
|
||||
|
||||
void GToc::updateContents()
|
||||
{
|
||||
if (typestore_->children().empty()) {
|
||||
tocstore_->clear();
|
||||
(*tocstore_->append())[listCol_] = _("*** No Lists ***");
|
||||
tocview_->set_sensitive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
Gtk::TreeModel::iterator it = typecombo_->get_active();
|
||||
Glib::ustring const type = (*it)[listCol_];
|
||||
toc::Toc const contents = controller().getContents(type);
|
||||
|
||||
// Check if all elements are the same.
|
||||
if (toc_ == contents) {
|
||||
return;
|
||||
}
|
||||
|
||||
// List has changed, so let's update our view
|
||||
toc_ = contents;
|
||||
|
||||
if (contents.empty()) {
|
||||
tocstore_->clear();
|
||||
(*tocstore_->append())[listCol_] = _("*** No Items ***");
|
||||
tocview_->set_sensitive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Okay, we're definitely going to put stuff in now
|
||||
changing_views_ = true;
|
||||
tocview_->set_sensitive(true);
|
||||
tocstore_->clear();
|
||||
|
||||
toc::Toc::const_iterator cit = contents.begin();
|
||||
toc::Toc::const_iterator end = contents.end();
|
||||
|
||||
for (int rowindex = 0; cit != end; ++cit, ++rowindex) {
|
||||
Gtk::ListStore::iterator row = tocstore_->append();
|
||||
(*row)[listCol_] = cit->asString();
|
||||
(*row)[listColIndex_] = rowindex;
|
||||
}
|
||||
changing_views_ = false;
|
||||
}
|
||||
|
||||
|
||||
void GToc::onTocViewSelected()
|
||||
{
|
||||
// If we always do this, then an item is jumped to without
|
||||
// the user clicking on one when he changes type from TOC->figures or so
|
||||
if (!changing_views_) {
|
||||
unsigned int choice = (*listSel_->get_selected())[listColIndex_];
|
||||
if (choice < toc_.size()) {
|
||||
controller().goTo(toc_[choice]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GToc::onTypeComboChanged()
|
||||
{
|
||||
updateContents();
|
||||
}
|
||||
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
61
src/frontends/gtk/GToc.h
Normal file
61
src/frontends/gtk/GToc.h
Normal file
@ -0,0 +1,61 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file GToc.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Spray
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef GTOC_H
|
||||
#define GTOC_H
|
||||
|
||||
#include "GViewBase.h"
|
||||
#include "toc.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class ControlToc;
|
||||
|
||||
/** This class provides a GTK+ implementation of the Toc Dialog.
|
||||
*/
|
||||
class GToc : public GViewCB<ControlToc, GViewGladeB> {
|
||||
public:
|
||||
///
|
||||
GToc(Dialog &);
|
||||
private:
|
||||
/// not needed
|
||||
virtual void apply() {}
|
||||
/// Build the dialog
|
||||
virtual void doBuild();
|
||||
/// Update dialog
|
||||
virtual void update();
|
||||
|
||||
void updateType();
|
||||
void updateContents();
|
||||
|
||||
void onTocViewSelected();
|
||||
void onTypeComboChanged();
|
||||
|
||||
// Makes TocViewSelected ignore events
|
||||
bool changing_views_;
|
||||
|
||||
Gtk::TreeView * tocview_;
|
||||
Gtk::ComboBox * typecombo_;
|
||||
Gtk::TreeModelColumn<Glib::ustring> listCol_;
|
||||
Gtk::TreeModelColumn<unsigned int> listColIndex_;
|
||||
Gtk::TreeModel::ColumnRecord listCols_;
|
||||
Glib::RefPtr<Gtk::ListStore> tocstore_;
|
||||
Glib::RefPtr<Gtk::ListStore> typestore_;
|
||||
Glib::RefPtr<Gtk::TreeSelection> listSel_;
|
||||
|
||||
toc::Toc toc_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // GTOC_H
|
@ -52,6 +52,8 @@ libgtk_la_SOURCES = \
|
||||
GText.h \
|
||||
GTimeout.C \
|
||||
GTimeout.h \
|
||||
GToc.C \
|
||||
GToc.h \
|
||||
GToolbar.C \
|
||||
GToolbar.h \
|
||||
GUrl.C \
|
||||
@ -122,7 +124,6 @@ xforms_objects = \
|
||||
../xforms/FormTexinfo.lo \
|
||||
../xforms/FormText.lo \
|
||||
../xforms/FormThesaurus.lo \
|
||||
../xforms/FormToc.lo \
|
||||
../xforms/FormVSpace.lo \
|
||||
../xforms/FormWrap.lo \
|
||||
../xforms/freebrowser.lo \
|
||||
|
181
src/frontends/gtk/glade/toc.glade
Normal file
181
src/frontends/gtk/glade/toc.glade
Normal file
@ -0,0 +1,181 @@
|
||||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
|
||||
<widget class="GtkDialog" id="dialog">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">Table of Contents</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="default_width">400</property>
|
||||
<property name="default_height">300</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="has_separator">False</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child internal-child="action_area">
|
||||
<widget class="GtkHButtonBox" id="dialog-action_area1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="Refresh">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="has_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-refresh</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="Close">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-close</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">-7</property>
|
||||
<accelerator key="Escape" modifiers="0" signal="clicked"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox1">
|
||||
<property name="border_width">12</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"> </property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Type:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">6</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="Type">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="Contents">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<property name="rules_hint">False</property>
|
||||
<property name="reorderable">False</property>
|
||||
<property name="enable_search">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">6</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
Loading…
Reference in New Issue
Block a user