From 63a78abdb9f4da1772d43ec5a45da26ac47677d3 Mon Sep 17 00:00:00 2001 From: Baruch Even Date: Tue, 3 Apr 2001 21:00:26 +0000 Subject: [PATCH] Gnomified FormError. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1881 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gnome/Dialogs.C | 5 +- src/frontends/gnome/FormError.C | 124 ++++-------------- src/frontends/gnome/FormError.h | 86 +++++------- src/frontends/gnome/Makefile.am | 2 + src/frontends/gnome/dialogs/diaerror.glade | 100 ++++++++++++++ .../gnome/dialogs/diainsertindex.glade | 6 +- 6 files changed, 170 insertions(+), 153 deletions(-) create mode 100644 src/frontends/gnome/dialogs/diaerror.glade diff --git a/src/frontends/gnome/Dialogs.C b/src/frontends/gnome/Dialogs.C index a64315eed5..f90f5bf91f 100644 --- a/src/frontends/gnome/Dialogs.C +++ b/src/frontends/gnome/Dialogs.C @@ -24,6 +24,7 @@ #include "ControlCitation.h" #include "ControlCopyright.h" #include "ControlCredits.h" +#include "ControlError.h" #include "ControlInclude.h" #include "ControlLog.h" #include "ControlUrl.h" @@ -34,6 +35,7 @@ #include "FormUrl.h" #include "FormCredits.h" #include "FormCopyright.h" +#include "FormError.h" /* #include "FormBibitem.h" @@ -44,7 +46,6 @@ #include "FormVCLog.h" #include "FormDocument.h" -#include "FormError.h" #include "FormExternal.h" #include "FormGraphics.h" #include "FormInclude.h" @@ -73,6 +74,7 @@ Dialogs::Dialogs(LyXView * lv) add(new GUIUrl(*lv, *this)); add(new GUICredits(*lv, *this)); add(new GUICopyright(*lv, *this)); + add(new GUIError(*lv, *this)); /* splash_.reset(new FormSplash(lv, this)); @@ -88,7 +90,6 @@ Dialogs::Dialogs(LyXView * lv) add(new FormCitation(lv, this)); add(new FormDocument(lv, this)); - add(new FormError(lv, this)); add(new FormExternal(lv, this)); add(new FormGraphics(lv, this)); add(new FormInclude(lv, this)); diff --git a/src/frontends/gnome/FormError.C b/src/frontends/gnome/FormError.C index ae8635c75e..a7dcf11c0a 100644 --- a/src/frontends/gnome/FormError.C +++ b/src/frontends/gnome/FormError.C @@ -1,130 +1,58 @@ // -*- C++ -*- /* This file is part of - * ====================================================== + * ================================================= + * + * LyX, The Document Processor + * Copyright 1995-2000 The LyX Team. * - * LyX, The Document Processor + * ================================================= * - * Copyright 2000 The LyX Team. - * - * ====================================================== + * \author Baruch Even */ -#include - #ifdef __GNUG__ #pragma implementation #endif -#include "gettext.h" -#include "Dialogs.h" +#include + +#include "gnomeBC.h" #include "FormError.h" -#include "LyXView.h" -#include "buffer.h" -#include "lyxfunc.h" -#include -#include #include -#include -#include -#include -#include +#include -// temporary solution for LyXView -#include "mainapp.h" -extern GLyxAppWin * mainAppWin; +FormError::FormError(ControlError & c) + : FormCB(c, "diaerror.glade", "DiaError") +{} -FormError::FormError(LyXView * lv, Dialogs * d) - : lv_(lv), d_(d), inset_(0), u_(0), h_(0), ih_(0), dialog_(0) +void FormError::build() { - // let the dialog be shown - // These are permanent connections so we won't bother - // storing a copy because we won't be disconnecting. - d->showError.connect(slot(this, &FormError::showInset)); -} + // Connect the buttons. + close_btn()->clicked.connect(SigC::slot(this, &FormError::CloseClicked)); + // Manage the buttons state + bc().setCancel(close_btn()); -FormError::~FormError() -{ - hide(); + // Make sure everything is in the correct state. + bc().refresh(); } -void FormError::showInset( InsetError * const inset ) -{ - if( dialog_!=0 || inset == 0 ) return; - - inset_ = inset; - ih_ = inset_->hideDialog.connect(slot(this, &FormError::hide)); - - show(); -} -void FormError::show() +void FormError::update() { - if (!dialog_) - { - using namespace Gtk::Box_Helpers; - - Gtk::Label * label = manage( new Gtk::Label(inset_->getContents()) ); - Gtk::Box * hbox = manage( new Gtk::HBox() ); - Gtk::Button * b_close = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_CLOSE) ) ); - Gtk::Alignment * alg1 = manage( new Gtk::Alignment(0.5, 0.5, 0, 0) ); - Gtk::Alignment * mbox = manage( new Gtk::Alignment(0.5, 0.5, 0, 0) ); - - // set up spacing - hbox->set_spacing(4); - - // packing - alg1->add(*b_close); - - hbox->children().push_back(Element(*label, false, false)); - hbox->children().push_back(Element(*manage(new Gtk::VSeparator()), false, false)); - hbox->children().push_back(Element(*alg1, false, false)); - - mbox->add(*hbox); - - // packing dialog to main window - dialog_ = mbox; - mainAppWin->add_action(*dialog_, _(" Error ")); - - // setting focus - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(b_close->gtkobj()), GTK_CAN_DEFAULT); - gtk_widget_grab_focus (GTK_WIDGET(b_close->gtkobj())); - gtk_widget_grab_default (GTK_WIDGET(b_close->gtkobj())); - - // connecting signals - b_close->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action)); - dialog_->destroy.connect(slot(this, &FormError::free)); - - u_ = d_->updateBufferDependent.connect(slot(this, &FormError::updateSlot)); - h_ = d_->hideBufferDependent.connect(slot(this, &FormError::hide)); - } + textarea()->insert(controller().params()); } -void FormError::updateSlot(bool buffchanged) -{ - if (buffchanged) hide(); -} -void FormError::hide() +Gtk::Button * FormError::close_btn() const { - if (dialog_!=0) mainAppWin->remove_action(); + return getWidget("button_close"); } -void FormError::free() -{ - if (dialog_!=0) - { - dialog_ = 0; - u_.disconnect(); - h_.disconnect(); - inset_ = 0; - ih_.disconnect(); - } -} -void FormError::apply() +Gtk::Text * FormError::textarea() const { + return getWidget("textarea"); } - diff --git a/src/frontends/gnome/FormError.h b/src/frontends/gnome/FormError.h index ee39e17f64..e8a57302d3 100644 --- a/src/frontends/gnome/FormError.h +++ b/src/frontends/gnome/FormError.h @@ -1,13 +1,15 @@ // -*- C++ -*- /* This file is part of - * ====================================================== + * ================================================= + * + * LyX, The Document Processor + * Copyright 1995 Matthias Ettrich. + * Copyright 1995-2000 The LyX Team. * - * LyX, The Document Processor + * ================================================= * - * Copyright 2000 The LyX Team. - * - * ====================================================== - */ + * \author Baruch Even + * */ #ifndef FORMERROR_H #define FORMERROR_H @@ -16,56 +18,40 @@ #pragma interface #endif -#include "DialogBase.h" -#include "LString.h" -#include "insets/inseterror.h" +#include "ControlError.h" +#include "GnomeBase.h" -#include +namespace Gtk { +class Button; +class Text; +} -/** This class provides an Gnome implementation of the FormError Dialog. +/** + * This class implements the dialog to show error messages. */ -class FormError : public DialogBase { +class FormError : public FormCB { public: - /// - FormError(LyXView *, Dialogs *); - /// - ~FormError(); + /// + FormError(ControlError & c); + /// + ~FormError() {}; + + void apply() {}; + void update(); + private: - /// Slot launching dialog to an existing inset - void showInset( InsetError * const ); - - /// Update dialog before showing it - virtual void update() { } - virtual void updateSlot(bool = false); - /// Apply from dialog (modify or create inset) - virtual void apply(); - /// Explicitly free the dialog. - void free(); - /// Create the dialog if necessary, update it and display it. - void show(); - /// Hide the dialog. - void hide(); - - /** Which LyXFunc do we use? - We could modify Dialogs to have a visible LyXFunc* instead and - save a couple of bytes per dialog. - */ - LyXView * lv_; - /** Which Dialogs do we belong to? - Used so we can get at the signals we have to connect to. - */ - Dialogs * d_; - /// pointer to the inset passed through showInset (if any) - InsetError * inset_; - /// Update connection. - SigC::Connection u_; - /// Hide connection. - SigC::Connection h_; - /// inset::hide connection. - SigC::Connection ih_; + /// Build the dialog + void build(); + + /// Returns true if the dialog input is in a valid state. + bool validate() const {return true;}; + - /// Real GUI implementation. - Gtk::Container * dialog_; + void CloseClicked() { CancelButton(); } + + /// The close button + Gtk::Button * close_btn() const; + Gtk::Text * textarea() const; }; #endif diff --git a/src/frontends/gnome/Makefile.am b/src/frontends/gnome/Makefile.am index c28731921e..e20ceb6c5a 100644 --- a/src/frontends/gnome/Makefile.am +++ b/src/frontends/gnome/Makefile.am @@ -83,6 +83,8 @@ libgnome_la_SOURCES = \ FormCopyright.h \ FormCredits.C \ FormCredits.h \ + FormError.C \ + FormError.h \ FormUrl.C \ FormUrl.h \ Menubar_pimpl.C \ diff --git a/src/frontends/gnome/dialogs/diaerror.glade b/src/frontends/gnome/dialogs/diaerror.glade new file mode 100644 index 0000000000..ffbec04c99 --- /dev/null +++ b/src/frontends/gnome/dialogs/diaerror.glade @@ -0,0 +1,100 @@ + + + + + diainserturl + diainserturl + + + pixmaps + C + True + True + True + False + False + True + diainserturl_interface.c + diainserturl_interface.h + diainserturl_callbacks.c + diainserturl_callbacks.h + + + + GnomeDialog + DiaError + Error + GTK_WINDOW_DIALOG + GTK_WIN_POS_NONE + False + False + True + False + False + True + + + GtkVBox + GnomeDialog:vbox + dialog-vbox1 + False + 8 + + 4 + True + True + + + + GtkHButtonBox + GnomeDialog:action_area + dialog-action_area1 + GTK_BUTTONBOX_END + 8 + 85 + 27 + 7 + 0 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + button_close + True + True + GNOME_STOCK_BUTTON_CLOSE + + + + + GtkScrolledWindow + scrolledwindow1 + GTK_POLICY_AUTOMATIC + GTK_POLICY_NEVER + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 0 + True + True + + + + GtkText + textarea + 250 + 200 + True + False + + + + + + + diff --git a/src/frontends/gnome/dialogs/diainsertindex.glade b/src/frontends/gnome/dialogs/diainsertindex.glade index 7bd4732c58..98c6b88121 100644 --- a/src/frontends/gnome/dialogs/diainsertindex.glade +++ b/src/frontends/gnome/dialogs/diainsertindex.glade @@ -21,9 +21,9 @@ GnomeDialog - DiaInsertIndex + DiaIndex 2 - Insert Index + Insert/Update Index GTK_WINDOW_DIALOG GTK_WIN_POS_NONE False @@ -123,7 +123,7 @@ GtkEntry GnomeEntry:entry - combo-entry1 + keyword True True True -- 2.39.2