From 06a4854e94c80c427def504f3a7db655ad0b22ba Mon Sep 17 00:00:00 2001 From: Bryan Quigley Date: Tue, 29 Dec 2020 21:39:27 -0800 Subject: [PATCH] Drop WINGS gui --- configure.ac | 21 - po/POTFILES.skip | 14 - wings/Makefile.am | 45 - wings/rwaboutpanel.cc | 117 -- wings/rwaboutpanel.h | 38 - wings/rwcacheprogress.cc | 80 -- wings/rwcacheprogress.h | 50 - wings/rwconfigwindow.cc | 230 ---- wings/rwconfigwindow.h | 46 - wings/rwdummyinstallprogress.cc | 59 - wings/rwdummyinstallprogress.h | 45 - wings/rwfetchprogress.cc | 518 -------- wings/rwfetchprogress.h | 69 - wings/rwfiltereditor.cc | 503 -------- wings/rwfiltereditor.h | 111 -- wings/rwfiltermanager.cc | 280 ---- wings/rwfiltermanager.h | 75 -- wings/rwfilterwindow.cc | 164 --- wings/rwfilterwindow.h | 73 -- wings/rwinstallprogress.cc | 116 -- wings/rwinstallprogress.h | 53 - wings/rwmainwindow.cc | 2121 ------------------------------- wings/rwmainwindow.h | 203 --- wings/rwsourceswindow.cc | 168 --- wings/rwsourceswindow.h | 35 - wings/rwsummarywindow.cc | 332 ----- wings/rwsummarywindow.h | 58 - wings/rwuserdialog.cc | 88 -- wings/rwuserdialog.h | 51 - wings/rwwindow.cc | 96 -- wings/rwwindow.h | 58 - wings/synaptic.cc | 125 -- 32 files changed, 6042 deletions(-) delete mode 100644 wings/Makefile.am delete mode 100644 wings/rwaboutpanel.cc delete mode 100644 wings/rwaboutpanel.h delete mode 100644 wings/rwcacheprogress.cc delete mode 100644 wings/rwcacheprogress.h delete mode 100644 wings/rwconfigwindow.cc delete mode 100644 wings/rwconfigwindow.h delete mode 100644 wings/rwdummyinstallprogress.cc delete mode 100644 wings/rwdummyinstallprogress.h delete mode 100644 wings/rwfetchprogress.cc delete mode 100644 wings/rwfetchprogress.h delete mode 100644 wings/rwfiltereditor.cc delete mode 100644 wings/rwfiltereditor.h delete mode 100644 wings/rwfiltermanager.cc delete mode 100644 wings/rwfiltermanager.h delete mode 100644 wings/rwfilterwindow.cc delete mode 100644 wings/rwfilterwindow.h delete mode 100644 wings/rwinstallprogress.cc delete mode 100644 wings/rwinstallprogress.h delete mode 100644 wings/rwmainwindow.cc delete mode 100644 wings/rwmainwindow.h delete mode 100644 wings/rwsourceswindow.cc delete mode 100644 wings/rwsourceswindow.h delete mode 100644 wings/rwsummarywindow.cc delete mode 100644 wings/rwsummarywindow.h delete mode 100644 wings/rwuserdialog.cc delete mode 100644 wings/rwuserdialog.h delete mode 100644 wings/rwwindow.cc delete mode 100644 wings/rwwindow.h delete mode 100644 wings/synaptic.cc diff --git a/configure.ac b/configure.ac index 6b5034e0e..ab6bb4903 100644 --- a/configure.ac +++ b/configure.ac @@ -25,26 +25,6 @@ AC_PROG_INTLTOOL([0.23]) synapticlocaledir='${prefix}/${DATADIRNAME}/locale' AC_SUBST(synapticlocaledir) - -dnl ask for wings -dnl AC_ARG_WITH(wings, -dnl [--with-wings build with WINGs gui (obsolete)], -dnl [AC_CHECK_PROG(WINGS, get-wings-flags, yes, no) -dnl if test x"$WINGS" == xno; then -dnl AC_MSG_ERROR([WINGs is not installed]) -dnl fi -dnl ] -dnl ) -dnl if test x"$WINGS" = xyes; then -dnl BUILD_wings="wings" -dnl WINGS_LIBS=`get-wings-flags --ldflags` -dnl WINGS_LIBS="$GUI_LIBS `get-wings-flags --libs`" -dnl WINGS_HDRS=`get-wings-flags --cflags` -dnl AC_SUBST(WINGS_LIBS) -dnl AC_SUBST(WINGS_HDRS) -dnl fi -dnl AC_SUBST(BUILD_wings) - dnl we build for gtk3 by default now pkg_modules="gtk+-3.0 >= 3.4.0, pango >= 1.0.0, glib-2.0" vte_modules="vte-2.91" @@ -56,7 +36,6 @@ AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) AC_SUBST(BUILD_gtk) -dnl if test x"$WINGS" = xno; then if test x"$GTK" = xno; then AC_MSG_ERROR([ Gtk is not installed, you need to install it to get a GUI]) fi diff --git a/po/POTFILES.skip b/po/POTFILES.skip index d15f87e09..10de9c69a 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -1,19 +1,5 @@ common/pkg_acqfile.cc -# deprecated UI -wings/rwaboutpanel.cc -wings/rwconfigwindow.cc -wings/rwfetchprogress.cc -wings/rwfiltereditor.cc -wings/rwfiltermanager.cc -wings/rwfilterwindow.cc -wings/rwinstallprogress.cc -wings/rwmainwindow.cc -wings/rwsourceswindow.cc -wings/rwsummarywindow.cc -wings/rwuserdialog.cc -wings/synaptic.cc - # unused gtkbuilder files gtk/gtkbuilder/dialog_columns.ui gtk/gtkbuilder/dialog_example.ui diff --git a/wings/Makefile.am b/wings/Makefile.am deleted file mode 100644 index f59034f1d..000000000 --- a/wings/Makefile.am +++ /dev/null @@ -1,45 +0,0 @@ -INCLUDES=@WINGS_HDRS@ -I${top_srcdir}/common -I${top_srcdir}/pixmaps \ - $(LIBTAGCOLL_CFLAGS) - -sbin_PROGRAMS=wsynaptic - - -wsynaptic_LDADD =-lExtraWINGs @WINGS_LIBS@ \ - ${top_builddir}/common/libsynaptic.a\ - -lapt-pkg @RPM_LIBS@ @DEB_LIBS@\ - -lpthread -L/usr/X11R6/lib $(LIBTAGCOLL_LIBS) - - - -wsynaptic_SOURCES=\ - synaptic.cc\ - rwaboutpanel.cc\ - rwaboutpanel.h\ - rwcacheprogress.cc\ - rwcacheprogress.h\ - rwconfigwindow.h\ - rwconfigwindow.cc\ - rwfetchprogress.cc\ - rwfetchprogress.h\ - rwfiltereditor.cc\ - rwfiltereditor.h\ - rwfiltermanager.cc\ - rwfiltermanager.h\ - rwfilterwindow.cc\ - rwfilterwindow.h\ - rwdummyinstallprogress.h\ - rwdummyinstallprogress.cc\ - rwinstallprogress.h\ - rwinstallprogress.cc\ - rwmainwindow.cc\ - rwmainwindow.h\ - rwsourceswindow.cc\ - rwsourceswindow.h\ - rwsummarywindow.cc\ - rwsummarywindow.h\ - rwuserdialog.cc\ - rwuserdialog.h\ - rwwindow.cc\ - rwwindow.h - - diff --git a/wings/rwaboutpanel.cc b/wings/rwaboutpanel.cc deleted file mode 100644 index 43c7fa780..000000000 --- a/wings/rwaboutpanel.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* rwaboutpanel.cc - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#include "config.h" - -#include "i18n.h" - -#include "rwaboutpanel.h" - - -#include "cnc.xpm" -#include "deb.xpm" -#include "logo.xpm" - - -static void closeWindow(WMWidget *self, void *data) -{ - RWAboutPanel *about = (RWAboutPanel*)data; - - about->hide(); -} - - -RWAboutPanel::RWAboutPanel(RWWindow *parent) - : RWWindow(parent, "about") -{ - WMBox *vbox, *hbox; - WMScreen *scr = WMWidgetScreen(parent->window()); - WMLabel *label; - WMLabel *icon; - WMPixmap *pix; - WMColor *white = WMWhiteColor(scr); - - - WMSetWindowMinSize(_win, 360, 240); - WMSetWindowMaxSize(_win, 360, 240); - - vbox = _topBox; - WMSetBoxBorderWidth(vbox, 10); - WMSetWidgetBackgroundColor(vbox, white); - WMMapWidget(vbox); - - hbox = WMCreateBox(vbox); - WMSetBoxHorizontal(hbox, True); - WMSetWidgetBackgroundColor(hbox, white); - WMAddBoxSubview(vbox, WMWidgetView(hbox), False, True, 60, 0, 5); - - icon = WMCreateLabel(hbox); - WMSetWidgetBackgroundColor(icon, white); - pix = WMCreatePixmapFromXPMData(scr, cnc_xpm); - WMSetLabelImagePosition(icon, WIPImageOnly); - WMSetLabelImage(icon, pix); - WMReleasePixmap(pix); - WMAddBoxSubview(hbox, WMWidgetView(icon), False, True, 100, 0, 5); - - icon = WMCreateLabel(hbox); - WMSetWidgetBackgroundColor(icon, white); - pix = WMCreatePixmapFromXPMData(scr, logo_xpm); - WMSetLabelImagePosition(icon, WIPImageOnly); - WMSetLabelImage(icon, pix); - WMReleasePixmap(pix); - WMAddBoxSubview(hbox, WMWidgetView(icon), True, True, 100, 0, 5); - - icon = WMCreateLabel(hbox); - WMSetWidgetBackgroundColor(icon, white); - pix = WMCreatePixmapFromXPMData(scr, deb_xpm); - WMSetLabelImagePosition(icon, WIPImageOnly); - WMSetLabelImage(icon, pix); - WMReleasePixmap(pix); - WMAddBoxSubview(hbox, WMWidgetView(icon), False, True, 50, 0, 5); - - label = WMCreateLabel(vbox); - WMSetWidgetBackgroundColor(label, WMWhiteColor(scr)); -// WMCreateNamedColor(scr, "#ddddee", False)); - WMSetLabelRelief(label, WRFlat); - WMSetLabelText(label, _("Copyright (c) 2001 Conectiva S/A\n\n" - "Author: Alfredo K. Kojima \n" - "Icons shamelessly ripped from KDE\n" - "APT backend: Jason Gunthorpe \n\n" - "This software is licensed under the terms of the\n" - "GNU General Public License, Version 2")); - - WMAddBoxSubview(vbox, WMWidgetView(label), True, True, 125, 0, 5); - - WMButton *button = WMCreateCommandButton(vbox); - WMMapWidget(button); - WMSetButtonText(button, _("Dismiss")); - WMAddBoxSubview(vbox, WMWidgetView(button), False, True, 24, 0, 0); - WMSetButtonAction(button, closeWindow, this); - - WMMapSubwidgets(hbox); - WMMapSubwidgets(vbox); - - setTitle(PACKAGE" version "VERSION); - - WMRealizeWidget(_win); -} diff --git a/wings/rwaboutpanel.h b/wings/rwaboutpanel.h deleted file mode 100644 index 0e6506c3b..000000000 --- a/wings/rwaboutpanel.h +++ /dev/null @@ -1,38 +0,0 @@ -/* rwaboutpanel.h - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef _RWABOUTPANEL_H_ -#define _RWABOUTPANEL_H_ - -#include "rwwindow.h" - -class RWAboutPanel : public RWWindow { - -public: - RWAboutPanel(RWWindow *parent); - virtual ~RWAboutPanel() {}; -}; - - -#endif - diff --git a/wings/rwcacheprogress.cc b/wings/rwcacheprogress.cc deleted file mode 100644 index 01917f941..000000000 --- a/wings/rwcacheprogress.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* rwcacheprogress.cc - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "config.h" -#include "i18n.h" - -#include "rwcacheprogress.h" - -extern void RWFlushInterface(); - - -RWCacheProgress::RWCacheProgress(WMBox *parent, WMLabel *label) - : _parent(parent), _label(label) -{ - _prog = WMCreateProgressIndicator(parent); - - WMSetLabelText(label, (char*)Op.c_str()); - - _mapped = false; -} - - -RWCacheProgress::~RWCacheProgress() -{ - WMDestroyWidget(_prog); -} - - -void RWCacheProgress::Update() -{ - if (!CheckChange()) { - RWFlushInterface(); - return; - } - - if (!_mapped) { - WMMapWidget(_prog); - WMAddBoxSubview(_parent, WMWidgetView(_prog), True, True, 100, 0, 0); - _mapped = true; - } - - if (MajorChange) - WMSetLabelText(_label, (char*)Op.c_str()); - - WMSetProgressIndicatorValue(_prog, (int)Percent); - - RWFlushInterface(); - -} - - -void RWCacheProgress::Done() -{ - WMSetProgressIndicatorValue(_prog, 100); - RWFlushInterface(); - - WMUnmapWidget(_prog); - WMRemoveBoxSubview(_parent, WMWidgetView(_prog)); - - _mapped = false; -} diff --git a/wings/rwcacheprogress.h b/wings/rwcacheprogress.h deleted file mode 100644 index 4b7a85a04..000000000 --- a/wings/rwcacheprogress.h +++ /dev/null @@ -1,50 +0,0 @@ -/* rwcacheprogress.h - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef _RWCACHEPROGRESS_H_ -#define _RWCACHEPROGRESS_H_ - -#include - -#include - -class RWCacheProgress : public OpProgress -{ - WMBox *_parent; - WMLabel *_label; - WMProgressIndicator *_prog; - - - bool _mapped; - -public: - RWCacheProgress(WMBox *parent, WMLabel *label); - ~RWCacheProgress(); - - inline WMWidget *widget() { return _prog; }; - - virtual void Update(); - virtual void Done(); -}; - - -#endif diff --git a/wings/rwconfigwindow.cc b/wings/rwconfigwindow.cc deleted file mode 100644 index d977592e8..000000000 --- a/wings/rwconfigwindow.cc +++ /dev/null @@ -1,230 +0,0 @@ -/* rwconfigwindow.cc - * - * Copyright (c) 2000-2003 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "config.h" -#include "i18n.h" - -#include -#include - -#include "rconfiguration.h" - -#include "rwconfigwindow.h" - - - -void RWConfigWindow::saveAction(WMWidget *self, void *data) -{ - RWConfigWindow *me = (RWConfigWindow*)data; - - _config->Set("Synaptic::UseRegexp", - WMGetButtonSelected(me->_optionB[0]) ? "true" : "false"); - - bool newval = WMGetButtonSelected(me->_optionB[1]); - - _config->Set("Synaptic::TextButtons", - newval ? "true" : "false"); - - bool postClean, postAutoClean; - - postClean = WMGetButtonSelected(me->_cacheB[1]) == True; - postAutoClean = WMGetButtonSelected(me->_cacheB[2]) == True; - - _config->Set("Synaptic::CleanCache", postClean ? "true" : "false"); - _config->Set("Synaptic::AutoCleanCache", postAutoClean ? "true" : "false"); - - if (!RWriteConfigFile(*_config)) { - _error->DumpErrors(); - WMRunAlertPanel(WMWidgetScreen(self), me->_win, - _("Error"), _("An error occurred while saving configurations."), - _("OK"), NULL, NULL); - } -} - - - -void RWConfigWindow::show() -{ - string str; - - WMSetButtonSelected(_optionB[0], - _config->FindB("Synaptic::UseRegexp", false)); - - WMSetButtonSelected(_optionB[1], - _config->FindB("Synaptic::TextButtons", false)); - - - bool postClean = _config->FindB("Synaptic::CleanCache", false); - bool postAutoClean = _config->FindB("Synaptic::AutoCleanCache", false); - - if (postClean) - WMPerformButtonClick(_cacheB[1]); - else if (postAutoClean) - WMPerformButtonClick(_cacheB[2]); - else - WMPerformButtonClick(_cacheB[0]); - -// str = _config->FindDir("Dir::Cache::Archives"); -// WMSetTextFieldText(_pathT, (char*)str.c_str()); - -// str = _config->Find("Synaptic::CacheSize"); -// if (str.empty()) -// str = "50"; - -// WMSetTextFieldText(_pathT, (char*)str); - - RWWindow::show(); -} - - - - -RWConfigWindow::RWConfigWindow(RWWindow *win) - : RWWindow(win, "options") -{ - WMButton *button; - WMBox *box; - int b = -1; - - WMSetBoxHorizontal(_topBox, False); - WMResizeWidget(_win, 400, 250); - - WMTabView *tab; - - tab = WMCreateTabView(_topBox); - WMMapWidget(tab); - WMAddBoxSubview(_topBox, WMWidgetView(tab), True, True, 50, 0, 5); - box = WMCreateBox(tab); - WMSetBoxHorizontal(box, False); - - - { - WMSetBoxBorderWidth(box, 10); - - _optionB[++b] = WMCreateSwitchButton(box); - WMSetButtonText(_optionB[b], - _("Use regular expressions during searches or matching")); - WMAddBoxSubview(box, WMWidgetView(_optionB[b]), False, True, - 20, 0, 0); - - _optionB[++b] = WMCreateSwitchButton(box); - WMSetButtonText(_optionB[b], - _("Use text-only buttons in main window\n(requires a restart to take effect)")); - WMAddBoxSubview(box, WMWidgetView(_optionB[b]), False, True, - 40, 0, 0); - - WMMapSubwidgets(box); - WMAddTabViewItemWithView(tab, WMWidgetView(box), 0, _("Options")); - } - - { - WMBox *vbox = WMCreateBox(tab); - WMSetBoxBorderWidth(vbox, 10); -/* - WMLabel *label; - label = WMCreateLabel(vbox); - WMSetLabelText(label, - _("Packages are stored in the cache when downloaded.")); - * - WMAddBoxSubview(vbox, WMWidgetView(label), False, True, 40, 0, 5); - */ - _cacheB[0] = button = WMCreateRadioButton(vbox); - WMSetButtonText(button, _("Leave downloaded packages in the cache")); - WMAddBoxSubview(vbox, WMWidgetView(button), False, True, 20, 0, 0); - - _cacheB[1] = button = WMCreateRadioButton(vbox); - WMSetButtonText(button, _("Delete downloaded packages after installation")); - WMAddBoxSubview(vbox, WMWidgetView(button), False, True, 20, 0, 0); - - _cacheB[2] = button = WMCreateRadioButton(vbox); - WMSetButtonText(button, _("Delete obsoleted packages from cache")); - WMAddBoxSubview(vbox, WMWidgetView(button), False, True, 20, 0, 10); - - WMGroupButtons(_cacheB[0], _cacheB[1]); - WMGroupButtons(_cacheB[0], _cacheB[2]); - -/* box = WMCreateBox(vbox); - WMSetBoxHorizontal(box, True); - WMAddBoxSubviewAtEnd(vbox, WMWidgetView(box), False, True, 20, 0, 0); - - label = WMCreateLabel(box); - WMSetLabelText(label, _("Max. Cache Size:")); - WMAddBoxSubview(box, WMWidgetView(label), False, True, 120, 0, 0); - - _sizeT = WMCreateTextField(box); - WMAddBoxSubview(box, WMWidgetView(_sizeT), True, True, 80, 0, 2); - - label = WMCreateLabel(box); - WMSetLabelText(label, _("Mbytes")); - WMAddBoxSubview(box, WMWidgetView(label), False, True, 50, 0, 5); - - button = WMCreateCommandButton(box); - WMSetButtonText(button, _("Clear Cache")); - WMAddBoxSubview(box, WMWidgetView(button), False, True, 100, 0, 0); - WMMapSubwidgets(box); - - - box = WMCreateBox(vbox); - WMSetBoxHorizontal(box, True); - WMAddBoxSubviewAtEnd(vbox, WMWidgetView(box), False, True, 20, 0, 5); - - label = WMCreateLabel(box); - WMSetLabelText(label, _("Cache Directory:")); - WMAddBoxSubview(box, WMWidgetView(label), False, True, 120, 0, 0); - - _pathT = WMCreateTextField(box); - WMAddBoxSubview(box, WMWidgetView(_pathT), True, True, 80, 0, 5); - - button = WMCreateCommandButton(box); - WMSetButtonText(button, _("Browse...")); - WMAddBoxSubview(box, WMWidgetView(button), False, True, 70, 0, 0); - - */ - WMMapSubwidgets(vbox); - WMAddTabViewItemWithView(tab, WMWidgetView(vbox), 1, _("Cache")); - } - - - box = WMCreateBox(_topBox); - WMAddBoxSubview(_topBox, WMWidgetView(box), False, True, 24, 0, 0); - WMSetBoxHorizontal(box, True); - - button = WMCreateCommandButton(box); - WMSetButtonText(button, _("Close")); - WMSetButtonAction(button, windowCloseAction, this); - WMAddBoxSubviewAtEnd(box, WMWidgetView(button), False, True, 80, 0, 0); - - button = WMCreateCommandButton(box); - WMSetButtonText(button, _("Save")); - WMSetButtonAction(button, saveAction, this); - WMAddBoxSubviewAtEnd(box, WMWidgetView(button), False, True, 80, 0, 5); - - WMMapSubwidgets(box); - WMMapWidget(box); - - - setTitle(_("Preferences")); - - WMRealizeWidget(_win); -} - - diff --git a/wings/rwconfigwindow.h b/wings/rwconfigwindow.h deleted file mode 100644 index bcb35e236..000000000 --- a/wings/rwconfigwindow.h +++ /dev/null @@ -1,46 +0,0 @@ -/* rwconfigwindow.h - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#include "rwwindow.h" - - -class RWConfigWindow : public RWWindow { - - WMButton *_optionB[5]; - - WMButton *_cacheB[3]; - - WMTextField *_pathT; - WMTextField *_sizeT; - - static void saveAction(WMWidget *self, void *data); - -public: - RWConfigWindow(RWWindow *owner); - virtual ~RWConfigWindow() {}; - - virtual void show(); -}; - - - diff --git a/wings/rwdummyinstallprogress.cc b/wings/rwdummyinstallprogress.cc deleted file mode 100644 index f4cec6fc3..000000000 --- a/wings/rwdummyinstallprogress.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* rwdummyinstallprogress.cc - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "config.h" - -#include "i18n.h" - - -#include "rwdummyinstallprogress.h" - -#include -#include - -extern void RWFlushInterface(); - - -void RWDummyInstallProgress::startUpdate() -{ - RWFlushInterface(); -} - - -void RWDummyInstallProgress::finishUpdate() -{ - RWFlushInterface(); -} - - -void RWDummyInstallProgress::updateInterface() -{ - if (XPending(WMScreenDisplay(_scr)) > 0) { - XEvent ev; - - WMNextEvent(WMScreenDisplay(_scr), &ev); - WMHandleEvent(&ev); - } else { - wusleep(1000); - } -} - diff --git a/wings/rwdummyinstallprogress.h b/wings/rwdummyinstallprogress.h deleted file mode 100644 index f584d7993..000000000 --- a/wings/rwdummyinstallprogress.h +++ /dev/null @@ -1,45 +0,0 @@ -/* rwdummyinstallprogress.h - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef _RWDUMMYINSTALLPROGRESS_H_ -#define _RWDUMMYINSTALLPROGRESS_H_ - - -#include "rinstallprogress.h" -#include "rwwindow.h" - - - -class RWDummyInstallProgress : public RInstallProgress { - WMScreen *_scr; - -protected: - virtual void startUpdate(); - virtual void updateInterface(); - virtual void finishUpdate(); - -public: - RWDummyInstallProgress(WMScreen *scr) : RInstallProgress(), _scr(scr) {}; -}; - -#endif diff --git a/wings/rwfetchprogress.cc b/wings/rwfetchprogress.cc deleted file mode 100644 index de7b7c3f0..000000000 --- a/wings/rwfetchprogress.cc +++ /dev/null @@ -1,518 +0,0 @@ -/* rwfetchprogress.cc - * - * Copyright (c) 2000-2003 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "config.h" - -#include "i18n.h" - -#include -#include -#include -#include - -#include "rwfetchprogress.h" - -#include -#include - -#include "stop.xpm" - -#include - -extern void RWFlushInterface(); - - - -enum { - DLDone = -1, - DLQueued = -2, - DLFailed = -3, - DLHit = -4 -}; - - - - -static WMTableColumnDelegate *WTCreateDLProgressDelegate(WMTableView *parent); -static WMTableColumnDelegate *WTCreateRStringDelegate(WMTableView *parent); - - -RWFetchProgress::RWFetchProgress(RWWindow *wwin) - : RWWindow(wwin, "fetchProgress") -{ - WMTableColumn *column; - WMTableColumnDelegate *cdeleg; - static WMTableViewDelegate delegate = { - NULL, - numberOfRows, - valueForCell, - NULL - }; - - setTitle(_("Fetching Files")); - - WMResizeWidget(_win, 550, 250); - - _table = WMCreateTableView(_topBox); - WMMapWidget(_table); - WMAddBoxSubview(_topBox, WMWidgetView(_table), True, True, 20, 0, 5); - - WMSetTableViewDataSource(_table, this); - WMSetTableViewHeaderHeight(_table, 20); - WMSetTableViewDelegate(_table, &delegate); - - - cdeleg = WTCreateRStringDelegate(_table); - - column = WMCreateTableColumn(_("URL")); - WMSetTableColumnWidth(column, 365); - WMAddTableViewColumn(_table, column); - WMSetTableColumnDelegate(column, cdeleg); - WMSetTableColumnId(column, (void*)0); - - column = WMCreateTableColumn(_("Size")); - WMSetTableColumnWidth(column, 60); - WMAddTableViewColumn(_table, column); - WMSetTableColumnDelegate(column, cdeleg); - WMSetTableColumnId(column, (void*)1); - - - cdeleg = WTCreateDLProgressDelegate(_table); - - column = WMCreateTableColumn(_("Status")); - WMSetTableColumnWidth(column, 90); - WMAddTableViewColumn(_table, column); - WMSetTableColumnDelegate(column, cdeleg); - WMSetTableColumnId(column, (void*)2); - WMSetTableViewGridColor(_table, WMBlackColor(WMWidgetScreen(_win))); - - WMBox *hbox = WMCreateBox(_topBox); - WMSetBoxHorizontal(hbox, True); - WMAddBoxSubview(_topBox, WMWidgetView(hbox), False, True, 35, 0, 0); - - _statusL = WMCreateLabel(hbox); - - WMSetLabelRelief(_statusL, WRSunken); - WMAddBoxSubview(hbox, WMWidgetView(_statusL), True, True, 15, 0, 5); - - WMButton *btn; - btn = WMCreateCommandButton(hbox); -// WMSetButtonText(btn, _("Stop")); - WMSetButtonImagePosition(btn, WIPImageOnly); - WMSetButtonImage(btn, WMCreatePixmapFromXPMData(WMWidgetScreen(_win), - stop_xpm)); - WMSetButtonAction(btn, stopDownload, this); - WMAddBoxSubview(hbox, WMWidgetView(btn), False, True, 35, 0, 0); - - WMMapSubwidgets(hbox); - - WMMapSubwidgets(_topBox); - WMMapWidget(_topBox); - WMRealizeWidget(_win); -} - - -bool RWFetchProgress::MediaChange(string Media,string Drive) -{ - string msg; - int res; - - msg = _("Please insert the disk labeled:\n")+Media+_("\nin drive ")+Drive; - - res = WMRunAlertPanel(WMWidgetScreen(_win), _win, - _("Disk Change"), (char*)msg.c_str(), - _("Continue"), _("Cancel"), NULL); - - Update = true; - - RWFlushInterface(); - - if (res != WAPRDefault) - _cancelled = true; - - return (res == WAPRDefault) ? true : false; -} - - -void RWFetchProgress::updateStatus(pkgAcquire::ItemDesc &Itm, - int status) -{ - bool reload = false; - - if (Itm.Owner->ID == 0) { - Item item; - item.uri = Itm.Description; - item.size = string(SizeToStr(Itm.Owner->FileSize)); - _items.push_back(item); - Itm.Owner->ID = _items.size(); - reload = true; - } - _items[Itm.Owner->ID-1].status = status; - - if (reload) { - WMReloadTableView(_table); - WMScrollTableViewRowToVisible(_table, _items.size()-1); - } else { - WMRedisplayWidget(_table); - } -} - - -void RWFetchProgress::IMSHit(pkgAcquire::ItemDesc &Itm) -{ - updateStatus(Itm, DLHit); - - RWFlushInterface(); -} - - -void RWFetchProgress::Fetch(pkgAcquire::ItemDesc &Itm) -{ - updateStatus(Itm, DLQueued); - - RWFlushInterface(); -} - - -void RWFetchProgress::Done(pkgAcquire::ItemDesc &Itm) -{ - updateStatus(Itm, DLDone); - - RWFlushInterface(); -} - - -void RWFetchProgress::Fail(pkgAcquire::ItemDesc &Itm) -{ - updateStatus(Itm, DLFailed); - - RWFlushInterface(); -} - - -bool RWFetchProgress::Pulse(pkgAcquire *Owner) -{ - string str; - pkgAcquireStatus::Pulse(Owner); - - if (CurrentCPS != 0) { - char buf[128]; - unsigned long ETA = (unsigned long)((TotalBytes - CurrentBytes)/CurrentCPS); - long i; - i = CurrentItems < TotalItems ? CurrentItems+1 : CurrentItems; - snprintf(buf, sizeof(buf), _("%-3li/%-3li files %4sB/s ETA %6s\n"), - i, TotalItems, - SizeToStr(CurrentCPS).c_str(), - TimeToStr(ETA).c_str()); - - str = string(buf); - } else { - str = _("(stalled)\n"); - } - - - for (pkgAcquire::Worker *I = Owner->WorkersBegin(); I != 0; - I = Owner->WorkerStep(I)) { - -#undef Status // damn Xlib - if (I->CurrentItem == 0) { - if (!I->Status.empty()) { - str = str + '[' + I->Status.c_str() + "] "; - } else { - str = str + _("[Working] "); - } - continue; - } - - str = str + _("[Receiving] "); - - if (I->TotalSize > 0) - updateStatus(*I->CurrentItem, I->CurrentSize*100 / I->TotalSize); - else - updateStatus(*I->CurrentItem, 100); - } - - WMSetLabelText(_statusL, (char*)str.c_str()); - WMReloadTableView(_table); - - - RWFlushInterface(); - - return !_cancelled; -} - - -void RWFetchProgress::Start() -{ - pkgAcquireStatus::Start(); - - _cancelled = false; - - show(); - - RWFlushInterface(); -} - - -void RWFetchProgress::Stop() -{ - hide(); - - RWFlushInterface(); - - pkgAcquireStatus::Stop(); -} - - - -void RWFetchProgress::stopDownload(WMWidget *self, void *data) -{ - RWFetchProgress *me = (RWFetchProgress*)data; - - me->_cancelled = true; -} - - -int RWFetchProgress::numberOfRows(WMTableViewDelegate *self, - WMTableView *table) -{ - RWFetchProgress *me = (RWFetchProgress*)WMGetTableViewDataSource(table); - - return me->_items.size(); -} - - -void *RWFetchProgress::valueForCell(WMTableViewDelegate *self, - WMTableColumn *column, int row) -{ - WMTableView *table = (WMTableView*)WMGetTableColumnTableView(column); - RWFetchProgress *me = (RWFetchProgress*)WMGetTableViewDataSource(table); - int c = (int)WMGetTableColumnId(column); - - switch (c) { - case 0: - return (void*)me->_items[row].uri.c_str(); - case 1: - return (void*)me->_items[row].size.c_str(); - case 2: - return (void*)me->_items[row].status; - } - - return NULL; -} - - - - -/* ---------------------------------------------------------------------- */ - - -typedef struct { - WMTableView *table; - WMFont *font; - GC gc; - GC textGc; -} StringData; - - -typedef struct { - WMTableView *table; - WMFont *font; - GC gc; - GC textGc; - GC barGc; -} DLProgressData; - - - -//static char *SelectionColor = "#bbbbcc"; - -static void progressDraw(WMScreen *scr, Drawable d, GC gc, GC barGc, GC textGc, - WMFont *font, void *data, - WMRect rect) -{ - int x, y; - XRectangle rects[1]; - Display *dpy = WMScreenDisplay(scr); - char *str; - int status = (int)data; - - rects[0].x = rect.pos.x+1; - rects[0].y = rect.pos.y+1; - rects[0].width = rect.size.width-1; - rects[0].height = rect.size.height-1; - XSetClipRectangles(dpy, gc, 0, 0, rects, 1, YXSorted); - - str = ""; - - int px, pw; - - px = rects[0].x; - pw = status * rects[0].width / 100; - - if (status < 0) { - XFillRectangle(dpy, d, status == DLDone ? barGc : gc, - px, rects[0].y, pw, rects[0].height); - - switch (status) { - case DLQueued: - str = _("Queued"); - break; - case DLDone: - str = _("Done"); - break; - case DLHit: - str = _("Hit"); - break; - case DLFailed: - str = _("Failed"); - break; - } - } else { - static char buf[16]; - - XFillRectangle(dpy, d, barGc, px, rects[0].y, pw, rects[0].height); - XFillRectangle(dpy, d, gc, px+pw, rects[0].y, - rects[0].width - pw - 2, rects[0].height); - - snprintf(buf, sizeof(buf), "%d%%", status); - str = buf; - } - - x = rect.pos.x + (rect.size.width - WMWidthOfString(font, str, strlen(str))) / 2; - y = rect.pos.y + (rect.size.height - WMFontHeight(font))/2; - - WMDrawString(scr, d, textGc, font, x, y, str, strlen(str)); - - XSetClipMask(dpy, gc, None); -} - - - - -static void DLCellPainter(WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d) -{ - DLProgressData *strdata = (DLProgressData*)self->data; - WMTableView *table = WMGetTableColumnTableView(column); - - progressDraw(WMWidgetScreen(table), d, - strdata->gc, strdata->barGc, strdata->textGc, strdata->font, - WMTableViewDataForCell(table, column, row), - WMTableViewRectForCell(table, column, row)); -} - - - -static WMTableColumnDelegate *WTCreateDLProgressDelegate(WMTableView *parent) -{ - WMTableColumnDelegate *delegate; - WMScreen *scr = WMWidgetScreen(parent); - DLProgressData *data = (DLProgressData*)wmalloc(sizeof(DLProgressData)); - - delegate = (WMTableColumnDelegate*)wmalloc(sizeof(WMTableColumnDelegate)); - - data->table = parent; - data->font = WMSystemFontOfSize(scr, 12); - data->gc = WMColorGC(WMGrayColor(scr)); - data->textGc = WMColorGC(WMBlackColor(scr)); - data->barGc = WMColorGC(WMWhiteColor(scr)); - - delegate->data = data; - delegate->drawCell = DLCellPainter; - delegate->drawSelectedCell = DLCellPainter; - delegate->beginCellEdit = NULL; - delegate->endCellEdit = NULL; - - return delegate; -} - - - - - - - - -static void stringDraw(WMScreen *scr, Drawable d, GC gc, - GC stgc, WMFont *font, char *data, - WMRect rect, Bool selected) -{ - int x, y; - XRectangle rects[1]; - Display *dpy = WMScreenDisplay(scr); - - x = rect.pos.x + 5; - y = rect.pos.y + (rect.size.height - WMFontHeight(font))/2; - - if ((unsigned)WMWidthOfString(font, data, strlen(data)) > rect.size.width - 10) - x -= (WMWidthOfString(font, data, strlen(data)) - rect.size.width + 10); - - rects[0].x = rect.pos.x+1; - rects[0].y = rect.pos.y+1; - rects[0].width = rect.size.width-1; - rects[0].height = rect.size.height-1; - XSetClipRectangles(dpy, gc, 0, 0, rects, 1, YXSorted); - - XFillRectangles(dpy, d, gc, rects, 1); - - WMDrawString(scr, d, stgc, font, x, y, - data, strlen(data)); - - XSetClipMask(dpy, gc, None); -} - - - -static void SCellPainter(WMTableColumnDelegate *self, - WMTableColumn *column, int row, Drawable d) -{ - StringData *strdata = (StringData*)self->data; - WMTableView *table = WMGetTableColumnTableView(column); - - stringDraw(WMWidgetScreen(table), d, - strdata->gc, strdata->textGc, strdata->font, - (char*)WMTableViewDataForCell(table, column, row), - WMTableViewRectForCell(table, column, row), - False); -} - - -static WMTableColumnDelegate *WTCreateRStringDelegate(WMTableView *parent) -{ - WMTableColumnDelegate *delegate = (WMTableColumnDelegate*)wmalloc(sizeof(WMTableColumnDelegate)); - WMScreen *scr = WMWidgetScreen(parent); - StringData *data = (StringData*)wmalloc(sizeof(StringData)); - - data->table = parent; - data->font = WMSystemFontOfSize(scr, 12); - data->textGc = WMColorGC(WMBlackColor(scr)); - data->gc = WMColorGC(WMGrayColor(scr)); - - delegate->data = data; - delegate->drawCell = SCellPainter; - delegate->drawSelectedCell = SCellPainter; - delegate->beginCellEdit = NULL; - delegate->endCellEdit = NULL; - - return delegate; -} diff --git a/wings/rwfetchprogress.h b/wings/rwfetchprogress.h deleted file mode 100644 index 2d4c79615..000000000 --- a/wings/rwfetchprogress.h +++ /dev/null @@ -1,69 +0,0 @@ -/* rwfetchprogress.h - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#include - -#include - -#include "rwwindow.h" - -#include - - -class RWFetchProgress : public pkgAcquireStatus, public RWWindow -{ - struct Item { - string uri; - string size; - int status; - }; - - vector _items; - - WMTableView *_table; - WMLabel *_statusL; - - bool _cancelled; - - void updateStatus(pkgAcquire::ItemDesc &Itm, int status); - - static void stopDownload(WMWidget *self, void *data); - - static int numberOfRows(WMTableViewDelegate *self, WMTableView *table); - - static void *valueForCell(WMTableViewDelegate *self, - WMTableColumn *column, int row); -public: - - virtual bool MediaChange(string Media,string Drive); - virtual void IMSHit(pkgAcquire::ItemDesc &Itm); - virtual void Fetch(pkgAcquire::ItemDesc &Itm); - virtual void Done(pkgAcquire::ItemDesc &Itm); - virtual void Fail(pkgAcquire::ItemDesc &Itm); - virtual void Start(); - virtual void Stop(); - - bool Pulse(pkgAcquire *Owner); - - RWFetchProgress(RWWindow *win); -}; diff --git a/wings/rwfiltereditor.cc b/wings/rwfiltereditor.cc deleted file mode 100644 index 8d3ee09cf..000000000 --- a/wings/rwfiltereditor.cc +++ /dev/null @@ -1,503 +0,0 @@ -/* rwfiltereditor.cc - * - * Copyright (c) 2000, 2001 Conectiva S/A - * 2002 Michael Vogt - * - * Author: Alfredo K. Kojima - * Michael Vogt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include - -#include "config.h" -#include "i18n.h" - - -#include "rpackagelister.h" - -#include "rwfiltereditor.h" - -#include - - - -enum { - CNExclude, - CNPattern, - CNWhere -}; - - -// must be in the same order as of the check buttons -static RStatusPackageFilter::Types StatusMasks[] = { - RStatusPackageFilter::NotInstalled, - RStatusPackageFilter::Upgradable, - RStatusPackageFilter::Installed, - RStatusPackageFilter::MarkKeep, - RStatusPackageFilter::MarkInstall, - RStatusPackageFilter::MarkRemove, - RStatusPackageFilter::Broken -}; - - - - -int RWFilterEditor::numberOfRows(WMTableViewDelegate *self, - WMTableView *table) -{ - RWFilterEditor *fwin = (RWFilterEditor*)self->data; - - return fwin->_patternL.size(); -} - - -void *RWFilterEditor::valueForCell(WMTableViewDelegate *self, - WMTableColumn *column, int row) -{ - RWFilterEditor *fwin = (RWFilterEditor*)self->data; - - switch ((int)WMGetTableColumnId(column)) { - case CNExclude: - return (void*)fwin->_patternL[row].exclude; - - case CNPattern: - return (void*)fwin->_patternL[row].pattern.c_str(); - - case CNWhere: - return (void*)fwin->_patternL[row].type; - - default: - return (void*)"???"; - } -} - - -void RWFilterEditor::setValueForCell(WMTableViewDelegate *self, - WMTableColumn *column, int row, - void *data) -{ - RWFilterEditor *fwin = (RWFilterEditor*)self->data; - - switch ((int)WMGetTableColumnId(column)) { - case CNExclude: - fwin->_patternL[row].exclude = data != NULL; - break; - - case CNPattern: - if (data) - fwin->_patternL[row].pattern = string((char*)data); - else - fwin->_patternL[row].pattern = ""; - break; - - case CNWhere: - fwin->_patternL[row].type = (int)data; - break; - } -} - - -RWFilterEditor::RWFilterEditor(WMWidget *parent) -{ - _tabview = WMCreateTabView(parent); - WMMapWidget(_tabview); - - makeSectionFilterPanel(_tabview); - - makeStatusFilterPanel(_tabview); - - makePatternFilterPanel(_tabview); -} - - -RWFilterEditor::~RWFilterEditor() -{ - delete _tableDelegate; -} - - -void RWFilterEditor::resetFilter() -{ - WMUnselectAllListItems(_groupL); - - WMPerformButtonClick(_exclGB); - - for (int i = 0; i < 7; i++) { - WMSetButtonSelected(_statusB[i], True); - } -} - - -void RWFilterEditor::editFilter(RFilter *filter) -{ - resetFilter(); - - _filter = filter; - - setSectionFilter(filter->section); - - setStatusFilter(filter->status); - - setPatternFilter(filter->pattern); -} - - -void RWFilterEditor::applyChanges() -{ - getSectionFilter(_filter->section); - - getStatusFilter(_filter->status); - - getPatternFilter(_filter->pattern); -} - - - -void RWFilterEditor::setSectionFilter(RSectionPackageFilter &f) -{ - string section; - int row; - - WMUnselectAllListItems(_groupL); - - for (int i = f.count()-1; i >= 0; i--) { - section = f.section(i); - - row = WMFindRowOfListItemWithTitle(_groupL, (char*)section.c_str()); - if (row >= 0) - WMSelectListItem(_groupL, row); - } - - if (f.inclusive()) { - WMPerformButtonClick(_inclGB); - } else { - WMPerformButtonClick(_exclGB); - } -} - - -void RWFilterEditor::getSectionFilter(RSectionPackageFilter &f) -{ - WMArray *list; - - f.setInclusive(WMGetButtonSelected(_inclGB) == True); - - f.clear(); - - list = WMGetListSelectedItems(_groupL); - - for (int i = 0; i < WMGetArrayItemCount(list); i++) { - WMListItem *item = (WMListItem*)WMGetFromArray(list, i); - f.addSection(string(item->text)); - } -} - - -void RWFilterEditor::setStatusFilter(RStatusPackageFilter &f) -{ - int i; - int type = f.status(); - - for (i = 0; i < 7; i++) { - WMSetButtonSelected(_statusB[i], - (type & StatusMasks[i]) ? True : False); - } -} - - -void RWFilterEditor::getStatusFilter(RStatusPackageFilter &f) -{ - int i; - int type = 0; - - for (i = 0; i < 7; i++) { - if (WMGetButtonSelected(_statusB[i])) - type |= StatusMasks[i]; - } - - f.setStatus(type); -} - - - -void RWFilterEditor::setPatternFilter(RPatternPackageFilter &f) -{ - int i; - - _patternL.erase(_patternL.begin(), _patternL.end()); - - for (i = 0; i < f.count(); i++) { - PatternFilterItem item; - RPatternPackageFilter::DepType type; - - f.getPattern(i, type, item.pattern, item.exclude); - item.type = (int)type; - - _patternL.push_back(item); - } - WMNoteTableViewNumberOfRowsChanged(_patT); -} - - -void RWFilterEditor::getPatternFilter(RPatternPackageFilter &f) -{ - WMEditTableViewRow(_patT, -1); - - f.reset(); - - for (vector::const_iterator iter = _patternL.begin(); - iter != _patternL.end(); iter++) { - - f.addPattern((RPatternPackageFilter::DepType)iter->type, - iter->pattern, iter->exclude); - } -} - - - -void RWFilterEditor::makeSectionFilterPanel(WMTabView *tabview) -{ - WMBox *box = WMCreateBox(_tabview); - - WMSetBoxBorderWidth(box, 5); - - _groupL = WMCreateList(box); - WMSetListAllowMultipleSelection(_groupL, True); - WMSetListAllowEmptySelection(_groupL, True); - WMAddBoxSubview(box, WMWidgetView(_groupL), True, True, 40, 0, 5); - - _inclGB = WMCreateRadioButton(box); - WMSetButtonText(_inclGB, _("Include Only Selected Sections")); - WMAddBoxSubview(box, WMWidgetView(_inclGB), False, True, 16, 0, 5); - - _exclGB = WMCreateRadioButton(box); - WMSetButtonText(_exclGB, _("Exclude Selected Sections")); - WMAddBoxSubview(box, WMWidgetView(_exclGB), False, True, 16, 0, 0); - WMGroupButtons(_inclGB, _exclGB); - - WMMapSubwidgets(box); - WMAddTabViewItemWithView(_tabview, WMWidgetView(box), 0, _("by Section")); -} - - - -void RWFilterEditor::makeStatusFilterPanel(WMTabView *tabview) -{ - WMBox *box = WMCreateBox(_tabview); - WMButton *but; - WMLabel *label; - int i = 0; - - WMSetBoxBorderWidth(box, 10); - - label = WMCreateLabel(box); - WMSetLabelText(label, _("Include packages that are...")); - WMAddBoxSubview(box, WMWidgetView(label), False, True, 15, 0, 5); - - but = WMCreateSwitchButton(box); - WMSetButtonText(but, _("Not Installed")); - WMAddBoxSubview(box, WMWidgetView(but), False, True, 16, 0, 5); - _statusB[i++] = but; - - but = WMCreateSwitchButton(box); - WMSetButtonText(but, _("Installed and Upgradable")); - WMAddBoxSubview(box, WMWidgetView(but), False, True, 16, 0, 5); - _statusB[i++] = but; - - but = WMCreateSwitchButton(box); - WMSetButtonText(but, _("Installed")); - WMAddBoxSubview(box, WMWidgetView(but), False, True, 16, 0, 5); - _statusB[i++] = but; - - but = WMCreateSwitchButton(box); - WMSetButtonText(but, _("Marked to Keep")); - WMAddBoxSubview(box, WMWidgetView(but), False, True, 16, 0, 5); - _statusB[i++] = but; - - but = WMCreateSwitchButton(box); - WMSetButtonText(but, _("Marked to Install/Upgrade")); - WMAddBoxSubview(box, WMWidgetView(but), False, True, 16, 0, 5); - _statusB[i++] = but; - - but = WMCreateSwitchButton(box); - WMSetButtonText(but, _("Marked to Remove")); - WMAddBoxSubview(box, WMWidgetView(but), False, True, 16, 0, 5); - _statusB[i++] = but; - - but = WMCreateSwitchButton(box); - WMSetButtonText(but, _("Broken")); - WMAddBoxSubview(box, WMWidgetView(but), False, True, 16, 0, 0); - _statusB[i++] = but; - - - WMMapSubwidgets(box); - WMAddTabViewItemWithView(_tabview, WMWidgetView(box), 0, _("by Status")); -} - - -void RWFilterEditor::setPackageSections(vector §ions) -{ - for (vector::const_iterator iter = sections.begin(); - iter != sections.end(); - iter++) { - WMAddListItem(_groupL, (char*)iter->c_str()); - } - - WMSortListItems(_groupL); -} - - - -void RWFilterEditor::newPatternAction(WMWidget *w, void *data) -{ - RWFilterEditor *fwin = (RWFilterEditor*)data; - PatternFilterItem item; - - item.type = 0; - item.pattern = ""; - item.exclude = false; - - fwin->_patternL.push_back(item); - - WMNoteTableViewNumberOfRowsChanged(fwin->_patT); - - WMScrollTableViewRowToVisible(fwin->_patT, fwin->_patternL.size()-1); -} - - -void RWFilterEditor::removePatternAction(WMWidget *w, void *data) -{ - RWFilterEditor *fwin = (RWFilterEditor*)data; - int row = WMGetTableViewClickedRow((WMTableView*)w); - - assert(row >= 0); - fwin->_patternL.erase(fwin->_patternL.begin() + row); - - WMNoteTableViewNumberOfRowsChanged(fwin->_patT); -} - - -void RWFilterEditor::selectedPatternRow(WMWidget *w, void *data) -{ - RWFilterEditor *fwin = (RWFilterEditor*)data; - int row = WMGetTableViewClickedRow((WMTableView*)w); - - if (row >= 0) { - WMEditTableViewRow((WMTableView*)w, row); - WMSetButtonEnabled(fwin->_removePB, True); - } else { - WMSetButtonEnabled(fwin->_removePB, False); - } -} - - -void RWFilterEditor::makePatternFilterPanel(WMTabView *tabview) -{ - WMBox *box = WMCreateBox(_tabview); - WMBox *hbox; - WMButton *button; - WMScreen *scr = WMWidgetScreen(tabview); - WMTableColumn *col; - static char *options[] = { - N_("are Named"), - N_("in Description"), - N_("Depends on"), // depends, predepends etc - N_("Provides"), // provides and name - N_("Conflicts with"), // conflicts - N_("Replaces"), // replaces/obsoletes - N_("Suggests") // suggests/recommends - }; - - _tableDelegate = new WMTableViewDelegate; - - _tableDelegate->data = this; - _tableDelegate->numberOfRows = numberOfRows; - _tableDelegate->valueForCell = valueForCell; - _tableDelegate->setValueForCell = setValueForCell; - - - WMSetBoxBorderWidth(box, 5); - - _patT = WMCreateTableView(box); - WMMapWidget(_patT); -// WMSetTableViewDataSource(_patT, _lister); - WMSetTableViewBackgroundColor(_patT, WMWhiteColor(scr)); - WMSetTableViewGridColor(_patT, WMGrayColor(scr)); - WMSetTableViewHeaderHeight(_patT, 18); - WMSetTableViewRowHeight(_patT, 18); - WMSetTableViewDelegate(_patT, _tableDelegate); - WMSetTableViewAction(_patT, selectedPatternRow, this); - WMAddBoxSubview(box, WMWidgetView(_patT), True, True, 200, 0, 5); - - WMTableColumnDelegate *colDeleg; - - - colDeleg = WTCreateBooleanSwitchDelegate(_patT); - - col = WMCreateTableColumn(_("Excl.")); - WMAddTableViewColumn(_patT, col); - WMSetTableColumnWidth(col, 50); - WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)CNExclude); - - for (unsigned int i = 0; i < sizeof(options)/sizeof(char*); i++) { - options[i] = _(options[i]); - } - colDeleg = WTCreateEnumSelectorDelegate(_patT); - WTSetEnumSelectorOptions(colDeleg, options, - 2);//sizeof(options)/sizeof(char*)); - - col = WMCreateTableColumn(_("Packages that")); - WMSetTableColumnWidth(col, 100); - WMAddTableViewColumn(_patT, col); - WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)CNWhere); - - - colDeleg = WTCreateStringEditorDelegate(_patT); - col = WMCreateTableColumn(_("Pattern")); - - WMSetTableColumnWidth(col, 300); - WMAddTableViewColumn(_patT, col); - WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)CNPattern); - - - hbox = WMCreateBox(box); - WMSetBoxHorizontal(hbox, True); - WMAddBoxSubview(box, WMWidgetView(hbox), False, True, 20, 0, 0); - - button = WMCreateCommandButton(hbox); - WMSetButtonText(button, _("New")); - WMAddBoxSubviewAtEnd(hbox, WMWidgetView(button), False, True, 80, 0, 0); - WMSetButtonAction(button, newPatternAction, this); - - _removePB = button = WMCreateCommandButton(hbox); - WMSetButtonEnabled(_removePB, False); - WMSetButtonText(button, _("Remove")); - WMAddBoxSubviewAtEnd(hbox, WMWidgetView(button), False, True, 80, 0, 5); - WMSetButtonAction(button, removePatternAction, this); - - - WMMapSubwidgets(hbox); - WMMapWidget(hbox); - WMMapWidget(box); - - WMAddTabViewItemWithView(_tabview, WMWidgetView(box), 0, _("by Package")); -} - diff --git a/wings/rwfiltereditor.h b/wings/rwfiltereditor.h deleted file mode 100644 index 00744b67f..000000000 --- a/wings/rwfiltereditor.h +++ /dev/null @@ -1,111 +0,0 @@ -/* rwfiltereditor.h - * - * Copyright (c) 2000, 2001 Conectiva S/A - * 2002 Michael Vogt - * - * Author: Alfredo K. Kojima - * Michael Vogt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef _RWFILTEREDITOR_H_ -#define _RWFILTEREDITOR_H_ - -#include -#include - -#include -#include - -#include "rpackagefilter.h" - -struct RFilter; - -class RWFilterEditor -{ -private: - struct PatternFilterItem { - int type; - string pattern; - bool exclude; - }; - - static int numberOfRows(WMTableViewDelegate *self, WMTableView *table); - static void *valueForCell(WMTableViewDelegate *self, - WMTableColumn *column, int row); - static void setValueForCell(WMTableViewDelegate *self, - WMTableColumn *column, int row, - void *data); - - static void newPatternAction(WMWidget *w, void *data); - static void removePatternAction(WMWidget *w, void *data); - - static void selectedPatternRow(WMWidget *w, void *data); - - - WMTabView *_tabview; - - WMTableViewDelegate *_tableDelegate; - - RFilter *_filter; - - // group/section list - WMList *_groupL; - WMButton *_inclGB; - WMButton *_exclGB; - - void setSectionFilter(RSectionPackageFilter &f); - void getSectionFilter(RSectionPackageFilter &f); - - // by status - WMButton *_statusB[7]; - - void setStatusFilter(RStatusPackageFilter &f); - void getStatusFilter(RStatusPackageFilter &f); - - // by pattern - WMTableView *_patT; - WMButton *_removePB; - - vector _patternL; - - void setPatternFilter(RPatternPackageFilter &f); - void getPatternFilter(RPatternPackageFilter &f); - - - void makeSectionFilterPanel(WMTabView *tabview); - void makePatternFilterPanel(WMTabView *tabview); - void makeStatusFilterPanel(WMTabView *tabview); - - -public: - RWFilterEditor(WMWidget *parent); - virtual ~RWFilterEditor(); - - inline WMWidget *widget() { return _tabview; }; - - void resetFilter(); - void editFilter(RFilter *filter); -// void makeNewFilter(); - - void applyChanges(); - - void setPackageSections(vector §ions); -}; - - -#endif diff --git a/wings/rwfiltermanager.cc b/wings/rwfiltermanager.cc deleted file mode 100644 index f6722e0e9..000000000 --- a/wings/rwfiltermanager.cc +++ /dev/null @@ -1,280 +0,0 @@ -/* rwfiltermanager.cc - * - * Copyright (c) 2000, 2001 Conectiva S/A - * 2002 Michael Vogt - * - * Author: Alfredo K. Kojima - * Michael Vogt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "config.h" -#include "i18n.h" - -#include "rpackagelister.h" - -#include "rwfiltereditor.h" -#include "rwfiltermanager.h" - - - -RWFilterManagerWindow::RWFilterManagerWindow(RWWindow *win, - RPackageLister *lister) - : RWWindow(win, "filterManager"), _lister(lister) -{ - WMBox *box; - WMBox *vbox; - WMBox *hbox; - - - WMSetWindowCloseAction(_win, closeAction, this); - - setTitle(_("Package Filters")); - - WMSetWindowMinSize(_win, 400, 240); - WMResizeWidget(_win, 500, 250); - - WMSetBoxHorizontal(_topBox, False); - WMSetBoxBorderWidth(_topBox, 5); - - box = WMCreateBox(_topBox); - WMMapWidget(box); - WMSetBoxHorizontal(box, True); - WMAddBoxSubview(_topBox, WMWidgetView(box), True, True, 80, 0, 5); - - vbox = WMCreateBox(box); - WMMapWidget(vbox); - WMSetBoxHorizontal(vbox, False); - WMAddBoxSubview(box, WMWidgetView(vbox), False, True, 160, 0, 10); - - - _nameT = WMCreateTextField(vbox); - WMMapWidget(_nameT); - WMAddBoxSubview(vbox, WMWidgetView(_nameT), False, True, 20, 0, 5); - - _filterL = WMCreateList(vbox); - WMMapWidget(_filterL); - WMSetListAction(_filterL, editFilterAction, this); - WMAddBoxSubview(vbox, WMWidgetView(_filterL), True, True, 120, 0, 0); - - - hbox = WMCreateBox(_topBox); - WMMapWidget(hbox); - WMSetBoxHorizontal(hbox, True); - WMAddBoxSubview(_topBox, WMWidgetView(hbox), False, True, 20, 0, 0); - - for (int i = 0; i < 5; i++) { - WMButton *button; - - button = WMCreateCommandButton(hbox); - switch (i) { - case 0: - _newB = button; - WMSetButtonText(button, _("New")); - WMSetButtonAction(button, newFilterAction, this); - break; - case 1: - WMSetButtonText(button, _("Delete")); - WMSetButtonAction(button, deleteFilterAction, this); - break; - case 2: - WMSetButtonText(button, _("Clear")); - WMSetButtonAction(button, clearFilterAction, this); - break; - case 3: - WMSetButtonText(button, _("Save")); - WMSetButtonAction(button, applyFilterAction, this); - break; - case 4: - WMSetButtonText(button, _("Close")); - WMSetButtonAction(button, closeAction, this); - break; - } - if (i < 4) - WMAddBoxSubview(hbox, WMWidgetView(button), False, True, 80, 0, 5); - else - WMAddBoxSubviewAtEnd(hbox, WMWidgetView(button), False, True, 80, 0, 5); - } - WMMapSubwidgets(hbox); - - _editor = new RWFilterEditor(box); - WMMapWidget(_editor->widget()); - WMAddBoxSubview(box, WMWidgetView(_editor->widget()), True, True, - 100, 0, 0); - - { - vector tmp; - tmp = _lister->getSections(); - _editor->setPackageSections(tmp); - } - - WMMapWidget(_topBox); - - WMRealizeWidget(_win); -} - - -RWFilterManagerWindow::~RWFilterManagerWindow() -{ - delete _editor; -} - - -void RWFilterManagerWindow::show() -{ - WMClearList(_filterL); - - vector filters; - - filters = _lister->getFilterNames(); - - int i = 1; - for (vector::const_iterator iter = filters.begin()+1; - iter != filters.end(); - iter++, i++) { - WMListItem *item; - RFilter *filter = _lister->findFilter(i); - - item = WMAddListItem(_filterL, (char*)(*iter).c_str()); - - item->clientData = filter; - } - - WMSelectListItem(_filterL, 0); - editFilterAction(_filterL, this); - - RWWindow::show(); -} - - - - - - -void RWFilterManagerWindow::newFilterAction(WMWidget *self, void *data) -{ - RWFilterManagerWindow *me = (RWFilterManagerWindow*)data; - RFilter *filter; - - filter = new RFilter(me->_lister); - - filter->setName(_("A New Filter")); - me->_lister->registerFilter(filter); - - WMListItem *item = WMAddListItem(me->_filterL, - (char*)filter->getName().c_str()); - item->clientData = filter; - WMSelectListItem(me->_filterL, WMGetListNumberOfRows(me->_filterL)-1); - editFilterAction(NULL, me); -} - - -void RWFilterManagerWindow::editFilterAction(WMWidget *self, void *data) -{ - RWFilterManagerWindow *me = (RWFilterManagerWindow*)data; - //RFilter *filter; - - WMListItem *item = WMGetListSelectedItem(me->_filterL); - if (item) { - RFilter *filter = (RFilter*)item->clientData; - - WMSetTextFieldText(me->_nameT, (char*)filter->getName().c_str()); - - me->_editor->editFilter(filter); - } -} - - -void RWFilterManagerWindow::applyFilterAction(WMWidget *self, void *data) -{ - RWFilterManagerWindow *me = (RWFilterManagerWindow*)data; - //RFilter *filter; - - WMListItem *item = WMGetListSelectedItem(me->_filterL); - if (item) { - RFilter *filter = (RFilter*)item->clientData; - - filter->setName(string(WMGetTextFieldText(me->_nameT))); - - me->_editor->applyChanges(); - - wfree(item->text); - item->text = wstrdup((char*)filter->getName().c_str()); - WMRedisplayWidget(me->_filterL); - } -} - - - -void RWFilterManagerWindow::deleteFilterAction(WMWidget *self, void *data) -{ - RWFilterManagerWindow *me = (RWFilterManagerWindow*)data; - //RFilter *filter; - - WMListItem *item = WMGetListSelectedItem(me->_filterL); - if (item) { - RFilter *filter = (RFilter*)item->clientData; - int row; - - me->_lister->unregisterFilter(filter); - - delete filter; - - row = WMGetListSelectedItemRow(me->_filterL); - - WMRemoveListItem(me->_filterL, row); - - if (row >= WMGetListNumberOfRows(me->_filterL)) - row--; - - if (row < 0) { - WMSetTextFieldText(me->_nameT, ""); - clearFilterAction(NULL, me); - } else { - WMSelectListItem(me->_filterL, row); - me->editFilterAction(me->_filterL, me); - } - } -} - - -void RWFilterManagerWindow::closeAction(WMWidget *self, void *data) -{ - RWFilterManagerWindow *me = (RWFilterManagerWindow*)data; - - me->_closeAction(me->_closeData, me); - - me->close(); -} - - -void RWFilterManagerWindow::clearFilterAction(WMWidget *self, void *data) -{ - RWFilterManagerWindow *me = (RWFilterManagerWindow*)data; - - me->_editor->resetFilter(); -} - - - -void RWFilterManagerWindow::setCloseCallback(RWFilterEditorCloseAction *action, - void *data) -{ - _closeAction = action; - _closeData = data; -} - diff --git a/wings/rwfiltermanager.h b/wings/rwfiltermanager.h deleted file mode 100644 index 26f2fc8fa..000000000 --- a/wings/rwfiltermanager.h +++ /dev/null @@ -1,75 +0,0 @@ -/* rwfiltermanager.h - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef _RWFILTERMANAGER_H_ -#define _RWFILTERMANAGER_H_ - -#include - -#include "rwwindow.h" - - - -class RPackageLister; - -class RWFilterEditor; - -class RWFilterManagerWindow; - - -typedef void RWFilterEditorCloseAction(void *self, RWFilterManagerWindow *win); - - -class RWFilterManagerWindow : public RWWindow -{ - static void newFilterAction(WMWidget *self, void *data); - static void editFilterAction(WMWidget *self, void *data); - static void deleteFilterAction(WMWidget *self, void *data); - static void closeAction(WMWidget *self, void *data); - static void applyFilterAction(WMWidget *self, void *data); - static void clearFilterAction(WMWidget *self, void *data); - - RWFilterEditorCloseAction *_closeAction; - void *_closeData; - - WMButton *_newB; - - WMList *_filterL; - WMTextField *_nameT; - - RPackageLister *_lister; - - RWFilterEditor *_editor; - -public: - RWFilterManagerWindow(RWWindow *win, RPackageLister *lister); - virtual ~RWFilterManagerWindow(); - - void setCloseCallback(RWFilterEditorCloseAction *action, void *data); - - virtual void show(); - -}; - - -#endif - diff --git a/wings/rwfilterwindow.cc b/wings/rwfilterwindow.cc deleted file mode 100644 index a0245b333..000000000 --- a/wings/rwfilterwindow.cc +++ /dev/null @@ -1,164 +0,0 @@ -/* rwfilterwindow.cc - * - * Copyright (c) 2000, 2001 Conectiva S/A - * 2002 Michael Vogt - * - * Author: Alfredo K. Kojima - * Michael Vogt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "config.h" - -#include "i18n.h" - - -#include "rpackagelister.h" - -#include "rwfilterwindow.h" -#include "rwfiltereditor.h" - -#include - - - -enum { - CNExclude, - CNPattern, - CNWhere -}; - - -void RWFilterWindow::windowCloseAction(WMWidget *win, void *data) -{ - RWFilterWindow *rwin = (RWFilterWindow*)data; - - rwin->_closeAction(rwin->_closeObject, rwin); -} - - -void RWFilterWindow::clearFilterAction(WMWidget *self, void *data) -{ - RWFilterWindow *rwin = (RWFilterWindow*)data; - - rwin->_editor->resetFilter(); -} - - -void RWFilterWindow::saveFilterAction(WMWidget *self, void *data) -{ - RWFilterWindow *rwin = (RWFilterWindow*)data; - - rwin->_editor->applyChanges(); - - rwin->_saveAction(rwin->_saveObject, rwin); -} - - - -RWFilterWindow::RWFilterWindow(RWWindow *win, RPackageLister *lister) - : RWWindow(win, "filter"), _lister(lister) -{ - WMBox *hbox; - WMButton *button; - - - WMSetWindowCloseAction(_win, windowCloseAction, this); - - WMSetWindowMinSize(_win, 320, 240); - - WMResizeWidget(_win, 350, 240); - - - _editor = new RWFilterEditor(_topBox); - - { - vector tmp; - tmp = _lister->getSections(); - _editor->setPackageSections(tmp); - } - WMMapWidget(_editor->widget()); - WMAddBoxSubview(_topBox, WMWidgetView(_editor->widget()), True, True, - 200, 0, 5); - - // bottom buttons - hbox = WMCreateBox(_topBox); - WMSetBoxHorizontal(hbox, True); - WMAddBoxSubview(_topBox, WMWidgetView(hbox), False, True, 22, 0, 0); - - button = WMCreateCommandButton(hbox); - WMSetButtonText(button, _("Cancel")); - WMAddBoxSubview(hbox, WMWidgetView(button), True, True, 80, 0, 5); - WMSetButtonAction(button, windowCloseAction, this); - - button = WMCreateCommandButton(hbox); - WMSetButtonText(button, _("Clear")); - WMSetButtonAction(button, clearFilterAction, this); - WMAddBoxSubview(hbox, WMWidgetView(button), True, True, 80, 0, 5); - - button = WMCreateCommandButton(hbox); - WMSetButtonText(button, _("Set")); - WMSetButtonAction(button, saveFilterAction, this); - WMSetButtonImagePosition(button, WIPRight); - WMSetButtonImage(button, WMGetSystemPixmap(WMWidgetScreen(button), - WSIReturnArrow)); - WMSetButtonAltImage(button, WMGetSystemPixmap(WMWidgetScreen(button), - WSIHighlightedReturnArrow)); - WMAddBoxSubview(hbox, WMWidgetView(button), True, True, 80, 0, 0); - - WMMapSubwidgets(hbox); - WMMapWidget(hbox); - - WMMapWidget(_topBox); - - WMRealizeWidget(_win); -} - - -RWFilterWindow::~RWFilterWindow() -{ - delete _editor; -} - - - -void RWFilterWindow::editFilter(RFilter *filter) -{ - setTitle(_("Package Listing Filter - ") + filter->getName()); - - _editor->editFilter(filter); - - show(); -} - - -void RWFilterWindow::setCloseCallback(RWFilterWindowCloseAction *action, - void *data) -{ - _closeAction = action; - _closeObject = data; -} - - -void RWFilterWindow::setSaveCallback(RWFilterWindowSaveAction *action, - void *data) -{ - _saveAction = action; - _saveObject = data; -} - - diff --git a/wings/rwfilterwindow.h b/wings/rwfilterwindow.h deleted file mode 100644 index 7b8de029f..000000000 --- a/wings/rwfilterwindow.h +++ /dev/null @@ -1,73 +0,0 @@ -/* rwfilterwindow.h - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef _RWFILTERWINDOW_H_ -#define _RWFILTERWINDOW_H_ - -#include -#include - -#include -#include - -#include "rwwindow.h" - -#include "rpackagefilter.h" - -struct RFilter; -class RPackageLister; -class RWFilterEditor; - -class RWFilterWindow; - -typedef void RWFilterWindowCloseAction(void *self, RWFilterWindow *win); - -typedef void RWFilterWindowSaveAction(void *self, RWFilterWindow *win); - -class RWFilterWindow : public RWWindow -{ -private: - - RPackageLister *_lister; - RWFilterEditor *_editor; - - static void saveFilterAction(WMWidget *win, void *data); - static void clearFilterAction(WMWidget *self, void *data); - static void windowCloseAction(WMWidget *win, void *data); - - RWFilterWindowCloseAction *_closeAction; - void *_closeObject; - RWFilterWindowSaveAction *_saveAction; - void *_saveObject; - -public: - RWFilterWindow(RWWindow *win, RPackageLister *lister); - virtual ~RWFilterWindow(); - - void editFilter(RFilter *filter); - - void setCloseCallback(RWFilterWindowCloseAction *action, void *data); - void setSaveCallback(RWFilterWindowSaveAction *action, void *data); -}; - - -#endif diff --git a/wings/rwinstallprogress.cc b/wings/rwinstallprogress.cc deleted file mode 100644 index 6cb860dfb..000000000 --- a/wings/rwinstallprogress.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* rwinstallprogress.cc - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "config.h" - -#include "i18n.h" - -#include "rwmainwindow.h" - -#include "rwinstallprogress.h" - -#include -#include - -extern void RWFlushInterface(); - - -void RWInstallProgress::startUpdate() -{ - show(); - RWFlushInterface(); -} - - -void RWInstallProgress::finishUpdate() -{ - WMSetProgressIndicatorValue(_pbar, 1000); - - RWFlushInterface(); - - hide(); -} - - -void RWInstallProgress::updateInterface() -{ - char buf[2]; - static char line[128] = ""; - - while (1) { - int len = read(_childin, buf, 1); - if (len < 1) - break; - if (buf[0] == '\n') { - if (line[0] != '%') { - WMSetLabelText(_label, line); - WMSetProgressIndicatorValue(_pbar, 0); - } else { - float val; - - sscanf(line + 3, "%f", &val); - WMSetProgressIndicatorValue(_pbar, (int)(val * 10.0)); - } - line[0] = 0; - } else { - buf[1] = 0; - strcat(line, buf); - } - } - - if (XPending(WMScreenDisplay(_scr)) > 0) { - XEvent ev; - - WMNextEvent(WMScreenDisplay(_scr), &ev); - WMHandleEvent(&ev); - } else { - wusleep(1000); - } -} - - -RWInstallProgress::RWInstallProgress(RWMainWindow *main) - : RInstallProgress(), RWWindow(main, "installProgress", true, false) -{ - setTitle(_("Performing Changes")); - _scr = WMWidgetScreen(_win); - - - WMResizeWidget(_win, 320, 80); - - WMSetBoxBorderWidth(_topBox, 10); - - WMSetBoxHorizontal(_topBox, False); - - _label = WMCreateLabel(_topBox); - WMMapWidget(_label); - WMAddBoxSubview(_topBox, WMWidgetView(_label), True, True, 20, 0, 10); - - _pbar = WMCreateProgressIndicator(_topBox); - WMSetProgressIndicatorMaxValue(_pbar, 1000); - WMMapWidget(_pbar); - WMAddBoxSubview(_topBox, WMWidgetView(_pbar), False, True, 25, 0, 0); - - WMRealizeWidget(_win); -} - - diff --git a/wings/rwinstallprogress.h b/wings/rwinstallprogress.h deleted file mode 100644 index ba632ef66..000000000 --- a/wings/rwinstallprogress.h +++ /dev/null @@ -1,53 +0,0 @@ -/* rwinstallprogress.h - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef _RWINSTALLPROGRESS_H_ -#define _RWINSTALLPROGRESS_H_ - - -#include "rinstallprogress.h" -#include "rwwindow.h" - - -#include - -class RWMainWindow; - -class RWInstallProgress : public RInstallProgress, public RWWindow { - WMScreen *_scr; - - WMLabel *_label; - - WMProgressIndicator *_pbar; - -protected: - virtual void startUpdate(); - virtual void updateInterface(); - virtual void finishUpdate(); - -public: - RWInstallProgress(RWMainWindow *main); - virtual ~RWInstallProgress() {}; -}; - -#endif diff --git a/wings/rwmainwindow.cc b/wings/rwmainwindow.cc deleted file mode 100644 index 3da3bd2e5..000000000 --- a/wings/rwmainwindow.cc +++ /dev/null @@ -1,2121 +0,0 @@ -/* rwmainwindow.cc - main window of the app - * - * Copyright (c) 2000-2003 Conectiva S/A - * 2002 Michael Vogt - * - * Author: Alfredo K. Kojima - * Michael Vogt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#define DEBUGUI - -#include "config.h" - -#include "i18n.h" - -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -//#include "raptoptions.h" - -#include "rwmainwindow.h" - -#include "rpackagefilter.h" - - -#include "rwfiltermanager.h" -#include "rwfilterwindow.h" -#include "rwsourceswindow.h" -#include "rwconfigwindow.h" -#include "rwaboutpanel.h" -#include "rwsummarywindow.h" - -#include "rwfetchprogress.h" -#include "rwcacheprogress.h" -#include "rwuserdialog.h" -#include "rwinstallprogress.h" -#include "rwdummyinstallprogress.h" - -#include - - -// icons and pixmaps - -#include "logo.xpm" - -#include "proceed.xpm" -#include "options.xpm" -#include "upgrade.xpm" -#include "distupgrade.xpm" -#include "update.xpm" -#include "sources.xpm" -#include "fixbroken.xpm" - -#include "alert.xpm" - -#include "brokenM.xpm" -#include "downgradeM.xpm" -#include "heldM.xpm" -#include "installM.xpm" -#include "removeM.xpm" -#include "upgradeM.xpm" - - -#include "find.xpm" -#include "filter.xpm" - - -extern void RWFlushInterface(); - - -static char *ImportanceNames[] = { - N_("Unknown"), - N_("Normal"), - N_("Critical"), - N_("Security") -}; - - -static WMPixmap *StatusPixmaps[10]; - - - -// list columns -enum { - CStatus, - CSection, - CName, - CInstalled, - CNewest, - CSummary -}; - - -int RWMainWindow::numberOfRows(WMTableViewDelegate *self, WMTableView *table) -{ - RWMainWindow *me = (RWMainWindow*)WMGetTableViewDataSource(table); - - return me->_lister->packagesSize(); -} - - -// TODO: add displayPackages set like in (rgmainwindow) -void *RWMainWindow::valueForCell(WMTableViewDelegate *self, - WMTableColumn *column, int row) -{ - WMTableView *table = (WMTableView*)WMGetTableColumnTableView(column); - RWMainWindow *me = (RWMainWindow*)WMGetTableViewDataSource(table); - RPackage *elem = me->_lister->getPackage(row); - const char *text = NULL; - static char buffer[256]; - static void *data[2]; - - assert(elem); - - switch ((int)WMGetTableColumnId(column)) { - case CStatus: - { - int s = elem->getFlags(); - if (elem->wouldBreak()) - return StatusPixmaps[7]; - - if ((s & RPackage::FKeep) - && (s & RPackage::FOutdated)) { - return StatusPixmaps[/*RPackage::FHeld*/0]; - } - - return StatusPixmaps[/*s*/0]; - } - case CSection: - text = elem->section(); - break; - - case CName: - text = elem->name(); - break; - - case CInstalled: - text = elem->installedVersion(); - if (!text) - text = ""; - break; - - case CNewest: - text = elem->availableVersion(); - if (!text) - text = ""; - break; - - case CSummary: - strncpy(buffer, elem->summary(), sizeof(buffer)); - data[0] = (void*)buffer; - data[1] = NULL; - - if (me->_showUpdateInfo && - elem->updateImportance() == RPackage::ISecurity) - data[1] = (void*)StatusPixmaps[8]; - return data; - - default: - text = ""; - break; - } - - return (void*)text; -} - - -static void splitViewConstrain(WMSplitView *split, int index, - int *minSize, int *maxSize) -{ - switch (index) { - case 1: - *minSize = 400; - break; - case 0: - *minSize = 150; - break; - } -} - - -void RWMainWindow::changedDepView(WMWidget *self, void *data) -{ - RWMainWindow *me = (RWMainWindow*)data; - int index = WMGetPopUpButtonSelectedItem((WMPopUpButton*)self); - - WMSelectTabViewItemAtIndex(me->_depTab, index); -} - - -void RWMainWindow::clickedDepList(WMWidget *self, void *data) -{ - RWMainWindow *me = (RWMainWindow*)data; - WMListItem *item = WMGetListSelectedItem(me->_depList); - - WMSetLabelText(me->_depInfoL, strchr(item->text, '\001')+1); -} - - -void RWMainWindow::showAboutPanel(WMWidget *self, void *data) -{ - RWMainWindow *win = (RWMainWindow*)data; - - if (win->_aboutPanel == NULL) - win->_aboutPanel = new RWAboutPanel(win); - win->_aboutPanel->show(); -} - - -void RWMainWindow::findPackageObserver(void *self, WMNotification *notif) -{ - RWMainWindow *me = (RWMainWindow*)self; - char *text = WMGetTextFieldText(me->_findText); - int row; - - if (WMGetNotificationName(notif) == WMTextDidEndEditingNotification - && (int)WMGetNotificationClientData(notif) != WMReturnTextMovement) - return; - - row = me->_lister->findPackage(text); - if (row >= 0) { - WMSelectTableViewRow(me->_table, row); - WMScrollTableViewRowToVisible(me->_table, row); - me->setStatusText(); - } else { - me->setStatusText(_("No match.")); - } -} - - -void RWMainWindow::findNextAction(WMWidget *self, void *data) -{ - RWMainWindow *me = (RWMainWindow*)data; - - int row = me->_lister->findNextPackage(); - if (row >= 0) { - WMSelectTableViewRow(me->_table, row); - WMScrollTableViewRowToVisible(me->_table, row); - me->setStatusText(); - } else { - me->setStatusText(_("No more matches.")); - } -} - - -void RWMainWindow::makeFinderFilterAction(WMWidget *self, void *data) -{ - RWMainWindow *me = (RWMainWindow*)data; - RFilter *filter; - - filter = me->_lister->findFilter(0); - - char *pattern = WMGetTextFieldText(me->_findText); - - if (pattern && *pattern) { - filter->reset(); - filter->pattern.addPattern(RPatternPackageFilter::Name, - string(pattern), false); - - WMSetPopUpButtonSelectedItem(me->_popup, 1); - changedFilter(me->_popup, me); - } -} - - -void RWMainWindow::saveFilterAction(void *self, RWFilterWindow *rwin) -{ - RWMainWindow *me = (RWMainWindow*)self; - RPackage *pkg = me->selectedPackage(); - Bool filterEditable; - - filterEditable = WMGetPopUpButtonSelectedItem(me->_popup) != 0; - - WMSetButtonEnabled(me->_filtersB, True); - WMSetButtonEnabled(me->_editFilterB, filterEditable); - WMSetPopUpButtonEnabled(me->_popup, True); - - me->_lister->reapplyFilter(); - me->setStatusText(); - - me->refreshTable(pkg); - - rwin->hide(); -} - - - -void RWMainWindow::closeFilterAction(void *self, RWFilterWindow *rwin) -{ - RWMainWindow *me = (RWMainWindow*)self; - //RPackage *pkg = me->selectedPackage(); - Bool filterEditable; - - filterEditable = WMGetPopUpButtonSelectedItem(me->_popup) != 0; - - WMSetButtonEnabled(me->_editFilterB, filterEditable); - WMSetButtonEnabled(me->_filtersB, True); - WMSetPopUpButtonEnabled(me->_popup, True); - - rwin->hide(); -} - - -void RWMainWindow::showFilterWindow(WMWidget *self, void *data) -{ - RWMainWindow *win = (RWMainWindow*)data; - - if (win->_filterWin == NULL) { - win->_filterWin = new RWFilterWindow(win, win->_lister); - - win->_filterWin->setSaveCallback(saveFilterAction, win); - win->_filterWin->setCloseCallback(closeFilterAction, win); - } - - if (win->_lister->getFilter() == 0) - return; - - win->_filterWin->editFilter(win->_lister->getFilter()); - - WMSetButtonEnabled(win->_editFilterB, False); - WMSetButtonEnabled(win->_filtersB, False); - WMSetPopUpButtonEnabled(win->_popup, False); -} - - -void RWMainWindow::closeFilterManagerAction(void *self, - RWFilterManagerWindow *win) -{ - RWMainWindow *me = (RWMainWindow*)self; - Bool filterEditable; - - // select 0, because they may have deleted the current filter - WMSetPopUpButtonSelectedItem(me->_popup, 0); - changedFilter(me->_popup, me); - - me->refreshFilterMenu(); - - filterEditable = WMGetPopUpButtonSelectedItem(me->_popup) != 0; - - WMSetButtonEnabled(me->_editFilterB, filterEditable); - WMSetButtonEnabled(me->_filtersB, True); - WMSetPopUpButtonEnabled(me->_popup, True); -} - - -void RWMainWindow::showFilterManagerWindow(WMWidget *self, void *data) -{ - RWMainWindow *win = (RWMainWindow*)data; - - if (win->_fmanagerWin == NULL) { - win->_fmanagerWin = new RWFilterManagerWindow(win, win->_lister); - - win->_fmanagerWin->setCloseCallback(closeFilterManagerAction, win); - } - - win->_fmanagerWin->show(); - - WMSetButtonEnabled(win->_filtersB, False); - WMSetButtonEnabled(win->_editFilterB, False); - WMSetPopUpButtonEnabled(win->_popup, False); -} - - -void RWMainWindow::showSourcesWindow(WMWidget *self, void *data) -{ - RWMainWindow *win = (RWMainWindow*)data; - - if (win->_sourcesWin == NULL) - win->_sourcesWin = new RWSourcesWindow(win); - win->_sourcesWin->show(); -} - - - -void RWMainWindow::showConfigWindow(WMWidget *self, void *data) -{ - RWMainWindow *win = (RWMainWindow*)data; - - if (win->_configWin == NULL) - win->_configWin = new RWConfigWindow(win); - win->_configWin->show(); -} - - - -void RWMainWindow::changedFilter(WMWidget *self, void *data) -{ - int filter = WMGetPopUpButtonSelectedItem((WMPopUpButton*)self); - RWMainWindow *mainw = (RWMainWindow*)data; - RPackage *pkg = mainw->selectedPackage(); - //int i; - - mainw->setInterfaceLocked(true); - - if (filter == 0) { // no filter - mainw->_lister->setFilter(); - - WMSetButtonEnabled(mainw->_editFilterB, False); - } else { - mainw->_lister->setFilter(filter-1); - - WMSetButtonEnabled(mainw->_editFilterB, True); - } - - mainw->refreshTable(pkg); - - int index = -1; - - if (pkg) { - index = mainw->_lister->getPackageIndex(pkg); - } - - if (index >= 0) - WMScrollTableViewRowToVisible(mainw->_table, index); - else - mainw->updatePackageInfo(NULL); - - mainw->setInterfaceLocked(false); - - mainw->setStatusText(); -} - - -void RWMainWindow::switchCommandPanel(WMWidget *self, void *data) -{ - RWMainWindow *mainw = (RWMainWindow*)data; - - if (mainw->_panelSwitched) { - WMSelectPreviousTabViewItem(mainw->_cmdPanel); - mainw->_panelSwitched = false; - } else { - WMSelectNextTabViewItem(mainw->_cmdPanel); - mainw->_panelSwitched = true; - } -} - - -void RWMainWindow::updateClicked(WMWidget *self, void *data) -{ - RWMainWindow *me = (RWMainWindow*)data; - RPackage *pkg = me->selectedPackage(); - - - // need to delete dialogs, as they might have data pointing - // to old stuff - delete me->_filterWin; - delete me->_fmanagerWin; - me->_fmanagerWin = NULL; - me->_filterWin = NULL; - - - RWFetchProgress *progress = new RWFetchProgress(me); - progress->setTitle(_("Retrieving Index Files")); - - - me->setStatusText(_("Updating Package Lists from Servers...")); - - me->setInterfaceLocked(true); - - if (!me->_lister->updateCache(progress)) { - me->showErrors(); - } - - delete progress; - - if (me->_lister->openCache(true)) { - me->showErrors(); - } - - me->refreshTable(pkg); - - me->setInterfaceLocked(false); - - me->setStatusText(); -} - - -RPackage *RWMainWindow::selectedPackage() -{ - int index; - WMArray *array; - - array = WMGetTableViewSelectedRows(_table); - - if (WMGetArrayItemCount(array) != 1) - return NULL; - - index = (int)WMGetFromArray(array, 0); - - if (index >= 0) - return _lister->getPackage(index); - else - return NULL; -} - - -void RWMainWindow::fixBrokenClicked(WMWidget *self, void *data) -{ - RWMainWindow *me = (RWMainWindow*)data; - RPackage *pkg = me->selectedPackage(); - - bool res = me->_lister->fixBroken(); - - me->setInterfaceLocked(true); - - me->refreshTable(pkg); - - if (!res) - me->setStatusText(_("Dependency problem resolver failed.")); - else - me->setStatusText(_("Dependency problems successfully fixed.")); - - me->setInterfaceLocked(false); - - me->showErrors(); -} - - -void RWMainWindow::upgradeClicked(WMWidget *self, void *data) -{ - RWMainWindow *me = (RWMainWindow*)data; - RPackage *pkg = me->selectedPackage(); - bool res; - - if (!me->_lister->check()) { - WMRunAlertPanel(WMWidgetScreen(self), me->window(), - _("Error"), _("Automatic upgrade selection not possible\n" - "with broken packages. Please fix them first."), - _("Ok"), NULL, NULL); - return; - } - - me->setInterfaceLocked(true); - - me->setStatusText(_("Performing automatic selection of upgradadable packages...")); - - res = me->_lister->upgrade(); - - me->refreshTable(pkg); - - if (res) - me->setStatusText(_("Automatic selection of upgradadable packages done.")); - else - me->setStatusText(_("Automatic upgrade selection failed.")); - - me->setInterfaceLocked(false); - - me->showErrors(); -} - - - -void RWMainWindow::distUpgradeClicked(WMWidget *self, void *data) -{ - RWMainWindow *me = (RWMainWindow*)data; - RPackage *pkg = me->selectedPackage(); - bool res; - - - if (!me->_lister->check()) { - WMRunAlertPanel(WMWidgetScreen(self), me->window(), - _("Error"), _("Automatic upgrade selection not possible\n" - "with broken packages. Please fix them first."), - _("Ok"), NULL, NULL); - return; - } - - me->setInterfaceLocked(true); - - me->setStatusText(_("Performing selection for distribution upgrade...")); - - res = me->_lister->distUpgrade(); - - me->refreshTable(pkg); - - if (res) - me->setStatusText(_("Selection for distribution upgrade done.")); - else - me->setStatusText(_("Selection for distribution upgrade failed.")); - - me->setInterfaceLocked(false); - - me->showErrors(); -} - - - -void RWMainWindow::proceedClicked(WMWidget *self, void *data) -{ - RWMainWindow *me = (RWMainWindow*)data; - RPackage *pkg = me->selectedPackage(); - RWSummaryWindow *summ; - - // check whether we can really do it - if (!me->_lister->check()) { - WMRunAlertPanel(WMWidgetScreen(self), me->window(), _("Error"), - _("Operation not possible with broken packages.\n" - "Please fix them first."), - _("Ok"), NULL, NULL); - return; - } - - // show a summary of what's gonna happen - summ = new RWSummaryWindow(me, me->_lister); - if (!summ->showAndConfirm()) { - // canceled operation - delete summ; - return; - } - delete summ; - - me->setInterfaceLocked(true); - me->updatePackageInfo(NULL); - - me->setStatusText(_("Performing selected changes... See the terminal from where you started Synaptic for more information.")); - - // fetch packages - RWFetchProgress *fprogress = new RWFetchProgress(me); - fprogress->setTitle(_("Retrieving Package Files")); - -#ifdef HAVE_RPM - RWInstallProgress *iprogress = new RWInstallProgress(me); -#else - RWDummyInstallProgress *iprogress = - new RWDummyInstallProgress(WMWidgetScreen(me->_win)); -#endif - - //bool result = me->_lister->commitChanges(fprogress, iprogress); - me->_lister->commitChanges(fprogress, iprogress); - - delete fprogress; - delete iprogress; - - me->showErrors(); - - if (_config->FindB("Synaptic::Download-Only", false) == false) { - // reset the cache - if (!me->_lister->openCache(true)) { - me->showErrors(); - exit(1); - } - } - - me->refreshTable(pkg); - - me->setInterfaceLocked(false); - - me->setStatusText(); -} - - -bool RWMainWindow::showErrors() -{ - WMGenericPanel *panel; - WMScreen *scr = WMWidgetScreen(_win); - WMScrollView *sbox; - WMLabel *label; - string message; - WMFont *font; - unsigned int widest = 0; - int lines; - char *type; - int theight; - - if (_error->empty()) - return false; - - if (_error->PendingError()) - type = _("Error"); - else - type = _("Warning"); - - panel = WMCreateGenericPanel(scr, _win, type, _("OK"), NULL); - - sbox = WMCreateScrollView(panel->content); - WMMapWidget(sbox); - WMSetViewExpandsToParent(WMWidgetView(sbox), 10, 0, 10, 0); - WMSetScrollViewRelief(sbox, WRSunken); - - label = WMCreateLabel(sbox); - WMSetLabelWraps(label, True); - WMSetScrollViewContentView(sbox, WMWidgetView(label)); - WMMapWidget(label); - - font = WMSystemFontOfSize(scr, 12); - WMSetLabelFont(label, font); - - WMRealizeWidget(sbox); - - lines = 0; - message = ""; - while (!_error->empty()) { - string tmp; - - _error->PopMessage(tmp); - - // ignore some stupid error messages - if (tmp == _("Tried to dequeue a fetching object")) - continue; - - if (message.empty()) - message = tmp; - else - message = message + "\n\n" + tmp; - } - - { - const char *b, *e = message.c_str(); - unsigned int w; - - while (e) { - b = e + 1; - e = strchr(b, '\n'); - if (e) { - w = WMWidthOfString(font, (char*)b, e-b); - if (w > widest) - widest = w; - if (w > WMWidgetWidth(sbox) - 25) - lines += w / (WMWidgetWidth(sbox) - 25); - } - lines++; - } - w = WMWidthOfString(font, (char*)b, strlen(b)); - if (w > widest) - widest = w; - if (w > WMWidgetWidth(sbox) - 25) - lines += w / (WMWidgetWidth(sbox) - 25); - } - - WMSetLabelText(label, (char*)message.c_str()); - - theight = lines * WMFontHeight(font); - - WMResizeWidget(label, WMWidgetWidth(sbox) - 25, theight + 10); - - if (theight > 40) { - int dy; - - dy = WMWidgetHeight(panel->win) - WMWidgetHeight(panel->content); - - WMResizeWidget(panel->win, WMWidgetWidth(panel->win), - WMIN(theight + dy + 20, 340)); - if (theight + dy + 20 > 340) { - WMSetScrollViewHasVerticalScroller(sbox, True); - WMSetScrollViewRelief(sbox, WRSunken); - } - } - - WMMapWidget(panel->win); - WMRunModalLoop(scr, WMWidgetView(panel->win)); - WMDestroyGenericPanel(panel); - - return true; -} - - -static WMButton *makeButton(WMWidget *parent, char *label, - char **image, WMFont *font) -{ - WMButton *button; - WMPixmap *pix; - - button = WMCreateCommandButton(parent); - - WMSetButtonFont(button, font); - WMSetButtonText(button, label); - - if (image) { - pix = WMCreatePixmapFromXPMData(WMWidgetScreen(parent), image); - WMSetButtonImagePosition(button, WIPAbove); - WMSetButtonImage(button, pix); - WMReleasePixmap(pix); - } - - return button; -} - - - -static void appendTag(char *&buf, unsigned &size, const char *tag, - const char *value) -{ - if (!value) - value = _("N/A"); - if (strlen(tag) + strlen(value) + 8 > size) - return; - - buf = buf + sprintf(buf, "%s: %s\n", tag, value); -} - - -static void appendText(char *&buf, unsigned &size, const char *text) -{ - unsigned l = strlen(text); - if (l > size) - return; - - strcpy(buf, text); - buf = buf + l; -} - - -void RWMainWindow::clickedRow(WMWidget *self, void *data) -{ - RWMainWindow *me = (RWMainWindow*)data; - int row = WMGetTableViewClickedRow((WMTableView*)self); - - if (me->_tempKluge) - return; - - if (row < 0) { - me->updatePackageInfo(NULL); - return; - } - RPackage *pkg = me->_lister->getPackage(row); - if (pkg == NULL) - return; - - me->updatePackageInfo(pkg); -} - - -void RWMainWindow::notifyChange(RPackage *pkg) -{ - // we changed pkg's status - updateDynPackageInfo(pkg); - - refreshTable(pkg); - - setStatusText(); -} - - -void RWMainWindow::refreshTable(RPackage *selectedPkg) -{ - static bool first_run = true; - _tempKluge = true; - - WMReloadTableView(_table); - - _tempKluge = false; - - if (selectedPkg != NULL) { - int index = _lister->getPackageIndex(selectedPkg); - - if (index >= 0) - WMSelectTableViewRow(_table, index); - } - if(first_run) - first_run=false; - -} - - -void RWMainWindow::updatePackageStatus(RPackage *pkg) -{ - bool installed = false; - int flags = pkg->getFlags(); -// bool locked = _config->getPackageLock(pkg->name()); - -// WMSetButtonSelected(_holdB, locked ? True : False); - - WMSetButtonEnabled(_actionB[0], True); - - if(RPackage::FInstalled & flags) { - WMSetButtonEnabled(_actionB[1], False); - WMSetButtonEnabled(_actionB[2], True); - installed = true; - } else if(RPackage::FOutdated & flags) { - WMSetButtonEnabled(_actionB[1], True); - WMSetButtonEnabled(_actionB[2], True); - installed = true; - } else if(RPackage::FInstBroken & flags) { - WMSetButtonEnabled(_actionB[1], False); - WMSetButtonEnabled(_actionB[2], True); - installed = true; - } else { - WMSetButtonEnabled(_actionB[1], True); - WMSetButtonEnabled(_actionB[2], False); - } - - _currentB = NULL; - if((RPackage::FKeep & flags) || (RPackage::FHeld & flags)) { - _currentB = _actionB[0]; - if (installed) - WMSetLabelText(_stateL, _("Package is installed.")); - else - WMSetLabelText(_stateL, _("Package is not installed.")); - } else if(RPackage::FInstall & flags) { - WMSetLabelText(_stateL, _("Package will be installed.")); - _currentB = _actionB[1]; - } else if(RPackage::FUpgrade & flags) { - _currentB = _actionB[1]; - WMSetLabelText(_stateL, _("Package will be upgraded.")); - } else if(RPackage::FDowngrade & flags) { - // not handled yet - puts(_("OH SHIT!!")); - } else if(RPackage::FRemove & flags) { - _currentB = _actionB[2]; - WMSetLabelText(_stateL, _("Package will be uninstalled.")); - } - - if (pkg->wouldBreak()) { - WMSetLabelText(_stateL, _("Broken dependencies.")); - - WMSetLabelImage(_stateL, StatusPixmaps[7]); - } else { - if ((flags & RPackage::FKeep) && (flags & RPackage::FOutdated)) { - WMSetLabelImage(_stateL, StatusPixmaps[0/*RPackage::FHeld*/]); - } else - WMSetLabelImage(_stateL, StatusPixmaps[0/*flags*/]); - } - - WMSetButtonSelected(_currentB, True); -} - - -void RWMainWindow::navigateTable(char direction) -{ - WMArray *array = WMGetTableViewSelectedRows(_table); - unsigned int index; - - if (WMGetArrayItemCount(array) == 0) - index = 0; - else - index = (int)WMGetFromArray(array, 0); - - switch (direction) { - case 'u': - index = index-1; - if (index < 0) - index = 0; - break; - case 'd': - index = index+1; - if (index >= _lister->packagesSize()) - index = _lister->packagesSize()-1; - break; - case 'n': - index += 10; - if (index >= _lister->packagesSize()) - index = _lister->packagesSize()-1; - break; - case 'p': - index -= 10; - if (index < 0) - index = 0; - break; - case 'h': - index = 0; - break; - case 'e': - index = _lister->packagesSize()-1; - break; - default: - assert(0); - } - - WMSelectTableViewRow(_table, index); - WMScrollTableViewRowToVisible(_table, index); -} - - -void RWMainWindow::keyPressHandler(XEvent *event, void *data) -{ - RWMainWindow *me = (RWMainWindow*)data; - //Display *dpy = event->xany.display; - char buffer[32]; - int count; - KeySym ksym; - - if (event->type == KeyRelease) - return; - - buffer[0] = 0; - count = XLookupString(&event->xkey, buffer, sizeof(buffer), &ksym, NULL); - - if (event->xkey.state & ControlMask) { - switch (ksym) { - case XK_k: // keep - WMPerformButtonClick(me->_actionB[0]); - break; - case XK_i: // install - WMPerformButtonClick(me->_actionB[1]); - break; - case XK_r: // remove - WMPerformButtonClick(me->_actionB[2]); - break; - case XK_g: // find next - WMPerformButtonClick(me->_findNextB); - break; - case XK_p: // proceed - WMPerformButtonClick(me->_proceedB); - break; - } - } else { - switch (ksym) { - case XK_Up: - me->navigateTable('u'); - break; - case XK_Down: - me->navigateTable('d'); - break; - case XK_Next: - me->navigateTable('n'); - break; - case XK_Prior: - me->navigateTable('p'); - break; - case XK_Home: - me->navigateTable('h'); - break; - case XK_End: - me->navigateTable('e'); - break; - } - } -} - - -void RWMainWindow::updateDynPackageInfo(RPackage *pkg) -{ - updatePackageStatus(pkg); - - // dependencies - WMSetLabelText(_depInfoL, ""); - - WMClearList(_depList); - - bool byProvider = true; - - const char *depType, *depPkg, *depName, *depVer; - char *summary; - bool ok; - if (pkg->enumDeps(depType, depName, depPkg, depVer, summary, ok)) { - do { - char buffer[512]; - - if (byProvider) { - snprintf(buffer, sizeof(buffer), "%c%s: %s %s%c%s", ok ? '+' : '*', - depType, depPkg ? depPkg : depName, depVer, - '\001', summary); // kluge - } else { - snprintf(buffer, sizeof(buffer), "%c%s: %s %s[%s]%c%s", ok ? '+' : '*', - depType, depName, depVer, - depPkg ? depPkg : "-", - '\001', summary); // kluge - } - - // check if this item is duplicated - bool dup = false; - for (int i = 0; i < WMGetListNumberOfRows(_depList); i++) { - char *str; - - str = WMGetListItem(_depList, i)->text; - if (strcmp(str, buffer) == 0) { - dup = true; - break; - } - } - - if (!dup) - WMAddListItem(_depList, buffer); - - } while (pkg->nextDeps(depType, depName, depPkg, depVer, summary, ok)); - } - - // reverse dependencies - - WMClearList(_rdepList); - - if (pkg->enumRDeps(depName, depPkg)) { - do { - char buffer[512]; - - snprintf(buffer, sizeof(buffer), "%s (%s)", depName, depPkg); - WMAddListItem(_rdepList, buffer); - - } while (pkg->nextRDeps(depName, depPkg)); - } - - // weak dependencies - - WMClearList(_recList); - - if (pkg->enumWDeps(depType, depPkg, ok)) { - do { - char buffer[512]; - - snprintf(buffer, sizeof(buffer), "%c%s: %s", ok ? '+' : '*', - depType, depPkg); - WMAddListItem(_recList, buffer); - - } while (pkg->nextWDeps(depName, depPkg, ok)); - } - - int flags = pkg->getFlags(); - if (!((flags & RPackage::FInstalled) || (flags & RPackage::FOutdated))) - WMSetButtonEnabled(_removeDepsB, True); - else - WMSetButtonEnabled(_removeDepsB, False); -} - - -void RWMainWindow::updatePackageInfo(RPackage *pkg) -{ - char buffer[512] = ""; - char *bufPtr = (char*)buffer; - unsigned bufSize = sizeof(buffer); - long size; - RPackage::UpdateImportance importance; - int flags; - - if (!pkg) { - WMSetLabelText(_nameL, NULL); - WMSetLabelText(_summL, NULL); - WMSetLabelText(_infoL, NULL); - WMSetLabelText(_stateL, NULL); - WMSetLabelImage(_stateL, NULL); - if (_showUpdateInfo) - WMSetLabelText(_importL, NULL); - - WMSelectTabViewItemAtIndex(_tabview, 0); - WMSetTabViewEnabled(_tabview, False); - - return; - } - - WMSetTabViewEnabled(_tabview, True); - - flags = pkg->getFlags(); - - - if (!((flags&RPackage::FInstalled)||(flags&RPackage::FOutdated))) { - WMSetButtonText(_actionB[1], _("Install")); - } else { - WMSetButtonText(_actionB[1], _("Upgrade")); - } - - importance = pkg->updateImportance(); - - // name/summary - WMSetLabelText(_nameL, (char*)pkg->name()); - WMSetLabelText(_summL, (char*)pkg->summary()); - - // package info - - // common information regardless of state - appendTag(bufPtr, bufSize, _("Section"), pkg->section()); - appendTag(bufPtr, bufSize, _("Priority"), pkg->priority()); - /*XXX - appendTag(bufPtr, bufSize, _("Maintainer"), pkg->maintainer().c_str()); - appendTag(bufPtr, bufSize, _("Vendor"), pkg->vendor()); - */ - - // installed version info - - appendText(bufPtr, bufSize, _("\nInstalled Package:\n")); - - appendTag(bufPtr, bufSize, _(" Version"), pkg->installedVersion()); - size = pkg->installedSize(); - appendTag(bufPtr, bufSize, _(" Size"), - size < 0 ? _("N/A") : SizeToStr(size).c_str()); - - - appendText(bufPtr, bufSize, _("\nAvailable Package:\n")); - - - appendTag(bufPtr, bufSize, _(" Version"), pkg->availableVersion()); - size = pkg->availableInstalledSize(); - appendTag(bufPtr, bufSize, _(" Size"), - size < 0 ? _("N/A") : SizeToStr(size).c_str()); - - size = pkg->availablePackageSize(); - appendTag(bufPtr, bufSize, _(" Package Size"), - size < 0 ? _("N/A") : SizeToStr(size).c_str()); - - WMSetLabelText(_infoL, buffer); -#if 0 - if (_showUpdateInfo) { - // importance of update - char *text; - - bufPtr = (char*)buffer; - bufSize = sizeof(buffer); - *bufPtr = 0; - - switch (status) { - case RPackage::SNotInstalled: - text = _("Not Relevant"); - break; - case RPackage::SInstalledBroken: - text = _("Unknown"); - break; - default: - if (importance == RPackage::ISecurity || - importance == RPackage::ICritical) - text = _("Recommended"); - else - text = _("Possible"); - break; - } - appendTag(bufPtr, bufSize, _("Package Upgrade"), text); - - appendTag(bufPtr, bufSize, _(" Importance"), - _(ImportanceNames[(int)importance])); - appendTag(bufPtr, bufSize, _(" Date"), pkg->updateDate()); - WMSetLabelText(_importL, buffer); - - if (importance == RPackage::ISecurity) { - WMSetLabelImage(_importL, _alertPix); - } else { - WMSetLabelImage(_importL, NULL); - } - } - - // update information - if (_showUpdateInfo) { -// const char *updateText = pkg->updateSummary(); - - } -#endif - - // description - void *tmp; - while ((tmp = WMRemoveTextBlock(_text)) != NULL) - WMDestroyTextBlock(_text, tmp); - - WMAppendTextStream(_text, (char*)pkg->description()); - WMRedisplayWidget(_text); - - - updateDynPackageInfo(pkg); - - setStatusText(); -} - - - -void RWMainWindow::holdClicked(WMWidget *self, void *data) -{ - RWMainWindow *me = (RWMainWindow*)data; - int row = WMGetTableViewClickedRow(me->_table); - - if (row < 0) - return; - RPackage *pkg = me->_lister->getPackage(row); - if (pkg == NULL) - return; -/*XXX - if (WMGetButtonSelected((WMButton*)self)) { - _options->setPackageLock(pkg->name(), true); - pkg->setHeld(true); - } else { - _options->setPackageLock(pkg->name(), false); - pkg->setHeld(false); - } - */ -} - - -void RWMainWindow::actionClicked(WMWidget *self, void *data) -{ - RWMainWindow *me = (RWMainWindow*)data; - WMButton *clickedB = (WMButton*)self; - int row = WMGetTableViewClickedRow(me->_table); - int i; - - if (me->_currentB == clickedB) - return; - - if (row < 0) - return; - RPackage *pkg = me->_lister->getPackage(row); - if (pkg == NULL) - return; - - for (i = 0; i < 3 && me->_actionB[i] != clickedB; i++); - - me->setInterfaceLocked(true); - - switch (i) { - case 0: // keep - pkg->setKeep(); - break; - case 1: // install - pkg->setInstall(); - // check whether something broke - if (!me->_lister->check()) { - me->_lister->fixBroken(); - me->refreshTable(pkg); - } - break; - case 2: // remove - if (pkg->getFlags()&RPackage::FImportant) { - int res; - res = WMRunAlertPanel(WMWidgetScreen(self), me->window(), _("Warning"), - _("Removing this package may render the system unusable.\n" - "Are you sure you want to do that?"), - _("Cancel"), _("Remove"), NULL); - if (res == WAPRDefault) { - clickedB = me->_currentB; - WMSetButtonSelected(me->_currentB, True); - } else { - pkg->setRemove(); - } - } else { - pkg->setRemove(); - } - break; - } - me->_currentB = clickedB; - - me->setInterfaceLocked(false); -} - - - -void RWMainWindow::removeDepsClicked(WMWidget *self, void *data) -{ - RWMainWindow *me = (RWMainWindow*)data; - RPackage *pkg; - - pkg = me->selectedPackage(); - if (!pkg) - return; - - me->setInterfaceLocked(true); - - if (pkg->getFlags() & RPackage::FImportant) { - int res; - res = WMRunAlertPanel(WMWidgetScreen(self), me->window(), _("Warning"), - _("Removing this package may render the system unusable.\n" - "Are you sure you want to do that?"), - _("Cancel"), _("Remove"), NULL); - if (res == WAPRDefault) { - WMSetButtonSelected(me->_currentB, True); - } else { - pkg->setRemoveWithDeps(true); - } - } else { - pkg->setRemoveWithDeps(true); - } - - WMSelectTableViewRow(me->_table, me->_lister->getPackageIndex(pkg)); - - me->setInterfaceLocked(false); -} - - -void RWMainWindow::dependListDraw(WMList *lPtr, int index, Drawable d, - char *text, int state, WMRect *rect) -{ - WMScreen *scr = WMWidgetScreen(lPtr); - Display *dpy = WMScreenDisplay(scr); - static WMColor *yellow = NULL, *red = NULL; - WMColor *color; - static WMFont *font = NULL; - - if (!font) { - font = WMSystemFontOfSize(scr, 12); - } - - if (state & WLDSSelected) { - XFillRectangle(dpy, d, WMColorGC(WMWhiteColor(scr)), - rect->pos.x, rect->pos.y, - rect->size.width, rect->size.height); - } else { - XClearArea(dpy, d, rect->pos.x, rect->pos.y, - rect->size.width, rect->size.height, False); - } - - switch (*text) { - case '+': - color = WMBlackColor(scr); - break; - - case '-': - if (!yellow) - yellow = WMCreateNamedColor(scr, "yellow3", False); - color = yellow; - break; - - case '*': - if (!red) - red = WMCreateNamedColor(scr, "red3", False); - color = red; - break; - } - - GC gc = WMColorGC(color); - WMDrawString(scr, d, gc, font, rect->pos.x+4, rect->pos.y, - text+1, strchr(text, '\001') - (text + 1)); -} - - - -RWMainWindow::RWMainWindow(WMScreen *scr, RPackageLister *packLister) - : RWWindow(scr, "main"), _lister(packLister) -{ -#if !defined(DEBUGUI) || defined(HAVE_RPM) - _showUpdateInfo = true; // xxx conectiva only, for now -#else - _showUpdateInfo = false; -#endif - _tempKluge = false; - - _unsavedChanges = false; - - _interfaceLocked = 0; - _lockWindow = None; - - _lister->registerObserver(this); - - _busyCursor = XCreateFontCursor(WMScreenDisplay(scr), XC_watch); - - buildInterface(scr); - - refreshFilterMenu(); - - _userDialog = new RWUserDialog(scr); - - packLister->setUserDialog(_userDialog); - - packLister->setProgressMeter(_cacheProgress); - - _filterWin = NULL; - _sourcesWin = NULL; - _configWin = NULL; - _aboutPanel = NULL; - _fmanagerWin = NULL; - -#if 0 // PORTME - StatusPixmaps[(int)RPackage::MKeep] = NULL; - StatusPixmaps[(int)RPackage::MInstall] = - WMCreatePixmapFromXPMData(scr, (char**)installM_xpm); - StatusPixmaps[(int)RPackage::MUpgrade] = - WMCreatePixmapFromXPMData(scr, (char**)upgradeM_xpm); - StatusPixmaps[(int)RPackage::MDowngrade] = - WMCreatePixmapFromXPMData(scr, (char**)downgradeM_xpm); - StatusPixmaps[(int)RPackage::MRemove] = - WMCreatePixmapFromXPMData(scr, (char**)removeM_xpm); - StatusPixmaps[(int)RPackage::MHeld] = - WMCreatePixmapFromXPMData(scr, (char**)heldM_xpm); - StatusPixmaps[7] = - WMCreatePixmapFromXPMData(scr, (char**)brokenM_xpm); - StatusPixmaps[8] = _alertPix; -#else - StatusPixmaps[0] = NULL; - StatusPixmaps[1] = NULL; - StatusPixmaps[2] = NULL; - StatusPixmaps[3] = NULL; - StatusPixmaps[4] = NULL; - StatusPixmaps[5] = NULL; - StatusPixmaps[6] = NULL; - StatusPixmaps[7] = NULL; - StatusPixmaps[8] = NULL; -#endif - -} - - - -void RWMainWindow::buildInterface(WMScreen *scr) -{ - WMSplitView *hsplit; - WMBox *hbox, *vbox; - WMBox *ubox; - WMButton *button; - WMFont *font; - WMFont *bfont; - bool largeBtns = !_config->FindB("Synaptic::TextButtons", false); - static WMTableViewDelegate delegate = { - NULL, - numberOfRows, - valueForCell, - NULL - }; - - WMCreateEventHandler(WMWidgetView(_win), KeyPressMask|KeyReleaseMask, - keyPressHandler, this); - - - _alertPix = WMCreatePixmapFromXPMData(scr, (char**)alert_xpm); - - font = WMSystemFontOfSize(scr, 10); - bfont = WMBoldSystemFontOfSize(scr, 12); - - - WMSetWindowMinSize(_win, 550, 360); - - WMResizeWidget(_win, 640, 480); - - WMSetBoxBorderWidth(_topBox, 0); - - ubox = WMCreateBox(_topBox); - WMMapWidget(ubox); - WMSetBoxBorderWidth(ubox, 5); - WMAddBoxSubview(_topBox, WMWidgetView(ubox), True, True, 64, 0, 0); - - // top button bar - hbox = WMCreateBox(ubox); - WMSetBoxHorizontal(hbox, True); - WMAddBoxSubview(ubox, WMWidgetView(hbox), False, True, - largeBtns ? 64 : 20, 0, 10); - - - - int buttonWidth = largeBtns ? 70 : 80; - - // about - button = WMCreateCommandButton(hbox); - WMSetButtonBordered(button, False); - WMSetButtonFont(button, font); - WMSetButtonText(button, _("About")); - WMAddBoxSubviewAtEnd(hbox, WMWidgetView(button), False, True, - buttonWidth, 0, 5); - WMSetButtonAction(button, showAboutPanel, this); - if (largeBtns) { - WMPixmap *pix = WMCreatePixmapFromXPMData(scr, logo_xpm); - WMSetButtonImagePosition(button, WIPImageOnly); - WMSetButtonImage(button, pix); - } - - button = makeButton(hbox, _("Update"), largeBtns ? update_xpm : NULL, font); - WMSetButtonAction(button, updateClicked, this); - WMSetBalloonTextForView(_("Update package cache"), - WMWidgetView(button)); - WMAddBoxSubview(hbox, WMWidgetView(button), False, True, - buttonWidth, 0, 10); - - button = makeButton(hbox, _("Fix Broken"), largeBtns ? fixbroken_xpm : NULL, font); - WMSetButtonAction(button, fixBrokenClicked, this); - WMSetBalloonTextForView(_("Fix dependency problems"), - WMWidgetView(button)); - WMAddBoxSubview(hbox, WMWidgetView(button), False, True, - buttonWidth, 0, 10); - - button = makeButton(hbox, _("Upgrade"), largeBtns ? upgrade_xpm : NULL, font); - WMSetButtonAction(button, upgradeClicked, this); - WMSetBalloonTextForView(_("Mark packages for upgrade, except those with new dependencies"), - WMWidgetView(button)); - - WMAddBoxSubview(hbox, WMWidgetView(button), False, True, - buttonWidth, 0, 5); - - button = makeButton(hbox, _("DistUpgrade"), largeBtns ? distupgrade_xpm : NULL, font); - WMSetButtonAction(button, distUpgradeClicked, this); - WMSetBalloonTextForView(_("Upgrade installed distribution, including packages with new dependencies"), - WMWidgetView(button)); - - WMAddBoxSubview(hbox, WMWidgetView(button), False, True, - buttonWidth, 0, 10); - - button = makeButton(hbox, _("Proceed!"), largeBtns ? proceed_xpm : NULL, font); - WMSetButtonAction(button, proceedClicked, this); - WMSetBalloonTextForView(_("Commit (and download if necessary) selected changes on packages"), - WMWidgetView(button)); - WMAddBoxSubview(hbox, WMWidgetView(button), False, True, - buttonWidth, 0, 5); - _proceedB = button; - - - - button = makeButton(hbox, _("Options"), largeBtns ? options_xpm : NULL, font); - WMSetButtonAction(button, showConfigWindow, this); - WMSetBalloonTextForView(_("Configure Synaptic options"), - WMWidgetView(button)); - WMAddBoxSubviewAtEnd(hbox, WMWidgetView(button), False, True, - buttonWidth, 0, 5); - -// button = makeButton(hbox, _("Repositories"), largeBtns ? sources_xpm : NULL, font); -// WMSetButtonAction(button, showSourcesWindow, this); -// WMSetBalloonTextForView(_("Manage package repositories"), -// WMWidgetView(button)); -// WMAddBoxSubviewAtEnd(hbox, WMWidgetView(button), False, True, -// buttonWidth, 0, 5); - - WMReleaseFont(font); - - WMMapSubwidgets(hbox); - WMMapWidget(hbox); - - // splitview - hsplit = WMCreateSplitView(ubox); - WMMapWidget(hsplit); - WMAddBoxSubview(ubox, WMWidgetView(hsplit), True, True, 200, 0, 0); - WMSetSplitViewVertical(hsplit, True); - WMSetSplitViewConstrainProc(hsplit, splitViewConstrain); - - - // right part - vbox = WMCreateBox(_win); - WMMapWidget(vbox); - WMSetBoxHorizontal(vbox, False); - WMAddSplitViewSubview(hsplit, WMWidgetView(vbox)); - - - _nameL = WMCreateLabel(vbox); - WMAddBoxSubview(vbox, WMWidgetView(_nameL), False, True, 20, 0, 0); - WMSetLabelFont(_nameL, bfont); - WMSetLabelTextAlignment(_nameL, WACenter); - - - _summL = WMCreateLabel(vbox); - WMSetLabelFont(_summL, font); - WMSetLabelWraps(_summL, True); - WMAddBoxSubview(vbox, WMWidgetView(_summL), False, True, 25, 0, 5); - WMSetLabelTextAlignment(_summL, WACenter); - - hbox = WMCreateBox(vbox); - WMSetBoxHorizontal(hbox, True); - WMAddBoxSubview(vbox, WMWidgetView(hbox), False, True, 20, 0, 5); - - _actionB[0] = button = WMCreateButton(hbox, WBTPushOnPushOff); - WMSetButtonText(button, _("Keep")); - WMSetButtonAction(button, actionClicked, this); - WMSetBalloonTextForView(_("Keep selected package as is in the system, unmarking selections over it"), - WMWidgetView(button)); - WMSetButtonImagePosition(button, WIPLeft); - WMAddBoxSubview(hbox, WMWidgetView(button), True, True, 30, 0, 2); - - _actionB[1] = button = WMCreateButton(hbox, WBTPushOnPushOff); - WMSetButtonText(button, _("Install")); - WMSetButtonAction(button, actionClicked, this); - WMSetBalloonTextForView(_("Mark selected package for installation/upgrade"), - WMWidgetView(button)); - WMAddBoxSubview(hbox, WMWidgetView(button), True, True, 30, 0, 2); - WMGroupButtons(_actionB[0], _actionB[1]); - - _actionB[2] = button = WMCreateButton(hbox, WBTPushOnPushOff); - WMSetButtonText(button, _("Remove")); - WMSetBalloonTextForView(_("Mark selected package for removal from system"), - WMWidgetView(button)); - WMSetButtonAction(button, actionClicked, this); - WMAddBoxSubview(hbox, WMWidgetView(button), True, True, 30, 0, 5); - WMGroupButtons(_actionB[0], _actionB[2]); - - WMMapSubwidgets(hbox); - WMMapWidget(hbox); - - _tabview = WMCreateTabView(vbox); - WMAddBoxSubview(vbox, WMWidgetView(_tabview), True, True, 50, 0, 0); - - WMBox *infoBox = WMCreateBox(_win); - WMSetBoxBorderWidth(infoBox, 10); - WMSetBoxHorizontal(infoBox, False); - WMMapWidget(infoBox); - WMAddTabViewItemWithView(_tabview, WMWidgetView(infoBox), 0, _("General")); - - _stateL = WMCreateLabel(infoBox); - WMMapWidget(_stateL); - WMSetLabelText(_stateL, NULL); - WMSetLabelImagePosition(_stateL, WIPLeft); - WMAddBoxSubview(infoBox, WMWidgetView(_stateL), False, True, 14, 0, 0); - - _infoL = WMCreateLabel(infoBox); - WMAddBoxSubview(infoBox, WMWidgetView(_infoL), False, True, 162, 0, 10); - WMMapWidget(_infoL); - - - if (_showUpdateInfo) { - _importL = WMCreateLabel(infoBox); - WMSetLabelImagePosition(_importL, WIPRight); - WMAddBoxSubview(infoBox, WMWidgetView(_importL), False, True, 45, 0, 5); - WMMapWidget(_importL); - } - - _holdB = button = WMCreateSwitchButton(infoBox); - WMSetButtonEnabled(button, False); -// WMMapWidget(button); - WMSetButtonText(button, _("No automatic upgrade (hold)")); - WMSetButtonAction(button, holdClicked, this); - WMAddBoxSubviewAtEnd(infoBox, WMWidgetView(button), False, True, 18, 0, 0); - - - _text = WMCreateText(_win); - WMSetViewNextResponder(WMWidgetView(_text), WMWidgetView(_win)); - WMSetTextEditable(_text, False); - WMSetTextHasVerticalScroller(_text, True); - WMAddTabViewItemWithView(_tabview, WMWidgetView(_text), 1, _("Descr.")); - - { - WMBox *vb = WMCreateBox(_win); - WMBox *vb2; - - WMMapWidget(vb); - - WMSetBoxBorderWidth(vb, 5); - WMSetBoxHorizontal(vb, False); - - WMAddTabViewItemWithView(_tabview, WMWidgetView(vb), 2, _("Depends.")); - - _depP = WMCreatePopUpButton(vb); - WMSetPopUpButtonAction(_depP, changedDepView, this); - WMMapWidget(_depP); - WMAddBoxSubview(vb, WMWidgetView(_depP), False, True, 20, 0, 5); - WMAddPopUpButtonItem(_depP, _("What it depends on")); - WMAddPopUpButtonItem(_depP, _("What depends on it")); -#ifndef HAVE_RPM - WMAddPopUpButtonItem(_depP, _("Suggested and Recommended")); -#endif - WMSetPopUpButtonSelectedItem(_depP, 0); - - _depTab = WMCreateTabView(vb); - WMMapWidget(_depTab); - WMSetTabViewType(_depTab, WTNoTabsNoBorder); - WMAddBoxSubview(vb, WMWidgetView(_depTab), True, True, 100, 0, 0); - - // dependencies - - vb2 = WMCreateBox(vb); - - _depList = WMCreateList(vb2); - WMSetListUserDrawProc(_depList, dependListDraw); - WMSetListAction(_depList, clickedDepList, this); - WMAddBoxSubview(vb2, WMWidgetView(_depList), True, True, 100, 0, 5); - - _depInfoL = WMCreateLabel(vb2); - WMAddBoxSubview(vb2, WMWidgetView(_depInfoL), False, True, 20, 0, 0); - - _removeDepsB = button = WMCreateCommandButton(vb2); - WMSetButtonText(button, _("Remove With Dependencies")); - WMSetButtonAction(button, removeDepsClicked, this); - WMSetBalloonTextForView(_("Remove all packages that this one depends on"), - WMWidgetView(button)); - WMAddBoxSubview(vb2, WMWidgetView(button), False, True, 20, 0, 0); - - WMMapSubwidgets(vb2); - - WMAddTabViewItemWithView(_depTab, WMWidgetView(vb2), 0, NULL); - - // reverse dependencies - - vb2 = WMCreateBox(vb); - - _rdepList = WMCreateList(vb2); - WMAddBoxSubview(vb2, WMWidgetView(_rdepList), True, True, 100, 0, 0); - - WMMapSubwidgets(vb2); - - WMAddTabViewItemWithView(_depTab, WMWidgetView(vb2), 1, NULL); - - // suggests and recommends - vb2 = WMCreateBox(vb); - _recList = WMCreateList(vb2); - WMAddBoxSubview(vb2, WMWidgetView(_recList), True, True, 100, 0, 5); - - WMPopUpButton *pop; - pop = WMCreatePopUpButton(vb2); - WMSetPopUpButtonText(pop, _("Commands")); - WMSetPopUpButtonPullsDown(pop, True); - WMAddPopUpButtonItem(pop, _("Install Recommended")); - WMAddPopUpButtonItem(pop, _("Install Suggested")); - WMAddPopUpButtonItem(pop, _("Install Selected")); - - WMAddBoxSubview(vb2, WMWidgetView(pop), False, True, 20, 0, 0); - - WMMapSubwidgets(vb2); - - WMAddTabViewItemWithView(_depTab, WMWidgetView(vb2), 2, NULL); - } - - - // left part - { - WMTableColumn *col; - WMTableColumnDelegate *colDeleg; - - vbox = WMCreateBox(hsplit); - WMSetBoxHorizontal(vbox, False); - WMAddSplitViewSubview(hsplit, WMWidgetView(vbox)); - - _panelSwitched = false; - - _cmdPanel = WMCreateTabView(vbox); - WMMapWidget(_cmdPanel); - WMSetTabViewType(_cmdPanel, WTNoTabsNoBorder); - WMAddBoxSubview(vbox, WMWidgetView(_cmdPanel), False, True, 20, 0, 5); - - // filter stuff - hbox = WMCreateBox(_cmdPanel); - WMMapWidget(hbox); - WMSetBoxHorizontal(hbox, True); - WMAddTabViewItemWithView(_cmdPanel, WMWidgetView(hbox), 0, NULL); - - - button = makeButton(hbox, NULL, find_xpm, font); - WMAddBoxSubview(hbox, WMWidgetView(button), False, True, 20, 0, 5); - WMSetBalloonTextForView(_("Switch to package search panel"), - WMWidgetView(button)); - WMSetButtonAction(button, switchCommandPanel, this); - - _filtersB = button = WMCreateCommandButton(hbox); - WMSetButtonText(button, _("Filters...")); - WMSetButtonAction(button, showFilterManagerWindow, this); - WMSetBalloonTextForView(_("Open package filter editor"), - WMWidgetView(button)); - WMAddBoxSubview(hbox, WMWidgetView(button), False, True, 80, 0, 5); - - _popup = WMCreatePopUpButton(hbox); - WMSetBalloonTextForView(_("Select package filter"), - WMWidgetView(_popup)); - WMAddPopUpButtonItem(_popup, _("All Packages")); - - WMAddBoxSubview(hbox, WMWidgetView(_popup), True, True, 80, 0, 5); - WMSetPopUpButtonAction(_popup, changedFilter, this); - - - _editFilterB = button = WMCreateCommandButton(hbox); - WMSetButtonText(button, _("Edit Filter...")); - WMSetButtonAction(button, showFilterWindow, this); - WMSetBalloonTextForView(_("Edit selected filter"), - WMWidgetView(button)); - WMAddBoxSubview(hbox, WMWidgetView(button), False, True, 100, 0, 0); - - WMMapSubwidgets(hbox); - - // search stuff - - hbox = WMCreateBox(vbox); - WMSetBoxHorizontal(hbox, True); - WMAddTabViewItemWithView(_cmdPanel, WMWidgetView(hbox), 1, NULL); - - button = makeButton(hbox, NULL, filter_xpm, font); - WMAddBoxSubview(hbox, WMWidgetView(button), False, True, 20, 0, 5); - WMSetBalloonTextForView(_("Switch to package filter panel"), - WMWidgetView(button)); - - - WMSetButtonAction(button, switchCommandPanel, this); - - WMLabel *label = WMCreateLabel(hbox); - WMSetLabelText(label, _("Find Package")); - WMSetLabelTextAlignment(label, WARight); - WMAddBoxSubview(hbox, WMWidgetView(label), False, True, 110, 0, 0); - - _findText = WMCreateTextField(hbox); - WMAddBoxSubview(hbox, WMWidgetView(_findText), True, True, 40, 0, 5); - WMAddNotificationObserver(findPackageObserver, this, - WMTextDidChangeNotification, _findText); - WMAddNotificationObserver(findPackageObserver, this, - WMTextDidEndEditingNotification, _findText); - WMSetViewNextResponder(WMWidgetView(_findText), WMWidgetView(_win)); - - _findNextB = WMCreateCommandButton(hbox); - WMSetButtonText(_findNextB, _("Next")); - WMSetBalloonTextForView(_("Find next package matching pattern"), - WMWidgetView(_findNextB)); - WMSetButtonAction(_findNextB, findNextAction, this); - WMAddBoxSubview(hbox, WMWidgetView(_findNextB), False, True, 70, 0, 5); - - button = WMCreateCommandButton(hbox); - WMSetButtonText(button, _("To Filter")); - WMSetBalloonTextForView(_("Make a filter in 'Search Filter' showing all packages matching the pattern"), - WMWidgetView(button)); - WMSetButtonAction(button, makeFinderFilterAction, this); - WMAddBoxSubview(hbox, WMWidgetView(button), False, True, 80, 0, 0); - - WMMapSubwidgets(hbox); - - // table - _table = WMCreateTableView(vbox); - WMMapWidget(_table); - WMSetTableViewDataSource(_table, this); - WMSetTableViewBackgroundColor(_table, WMWhiteColor(scr)); - WMSetTableViewHeaderHeight(_table, 20); - WMSetTableViewDelegate(_table, &delegate); - WMAddBoxSubview(vbox, WMWidgetView(_table), True, True, 200, 0, 5); - - WMSetTableViewAction(_table, clickedRow, this); -/* - // special action buttons - hbox = WMCreateBox(vbox); - WMSetBoxHorizontal(hbox, True); - WMAddBoxSubview(vbox, WMWidgetView(hbox), False, False, 22, 0, 0); - - button = WMCreateCommandButton(hbox); - WMSetButtonText(button, _("Unselect All")); - WMAddBoxSubview(hbox, WMWidgetView(button), False, True, 100, 0, 10); - - WMPopUpButton *advCmd = WMCreatePopUpButton(hbox); - WMSetPopUpButtonPullsDown(advCmd, True); - WMSetPopUpButtonText(advCmd, _("Advanced Dynamic Turbo Filters")); - WMAddBoxSubview(hbox, WMWidgetView(advCmd), True, True, 40, 0, 0); - - WMMapSubwidgets(hbox); - WMMapWidget(hbox); -*/ - WMMapWidget(vbox); - - colDeleg = WTCreatePixmapDelegate(_table); - - col = WMCreateTableColumn(""); - WMAddTableViewColumn(_table, col); - WMSetTableColumnWidth(col, 20); - WMSetTableColumnConstraints(col, 20, 20); - WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)CStatus); - - colDeleg = WTCreateStringDelegate(_table); - - col = WMCreateTableColumn(_("Package")); - WMSetTableColumnWidth(col, 140); - WMSetTableColumnConstraints(col, 2, 0); - WMAddTableViewColumn(_table, col); - WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)CName); - /* - col = WMCreateTableColumn(_("Section")); - WMSetTableColumnWidth(col, 80); - WMAddTableViewColumn(_table, col); - WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)CSection); - */ - col = WMCreateTableColumn(_("Installed")); - WMSetTableColumnWidth(col, 80); - WMSetTableColumnConstraints(col, 2, 0); - WMAddTableViewColumn(_table, col); - WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)CInstalled); - - col = WMCreateTableColumn(_("Available")); - WMSetTableColumnWidth(col, 80); - WMSetTableColumnConstraints(col, 2, 0); - WMAddTableViewColumn(_table, col); - WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)CNewest); - - colDeleg = WTCreatePixmapStringDelegate(_table); - - col = WMCreateTableColumn(_("Summary")); - WMSetTableColumnWidth(col, 400); - WMAddTableViewColumn(_table, col); - WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)CSummary); - } - - - - WMAdjustSplitViewSubviews(hsplit); - - WMMapWidget(_nameL); - WMMapWidget(_summL); - WMMapWidget(_tabview); - WMMapWidget(vbox); - - - WMBox *boxy; - boxy = WMCreateBox(_topBox); - WMMapWidget(boxy); - WMSetBoxHorizontal(boxy, True); - WMAddBoxSubview(_topBox, WMWidgetView(boxy), False, True, 20, 0, 0); - - // status bar - _statusL = WMCreateLabel(boxy); - WMSetLabelRelief(_statusL, WRSunken); - WMMapWidget(_statusL); - WMAddBoxSubview(boxy, WMWidgetView(_statusL), True, True, 80, 0, 0); - - _cacheProgress = new RWCacheProgress(boxy, _statusL); - - WMMapWidget(_statusL); - - WMMapWidget(_topBox); - - WMRealizeWidget(_win); -} - - -void RWMainWindow::setStatusText(char *text) -{ - - int listed, installed, broken; - int toinstall, toreinstall, toremove; - double size; - - _lister->getStats(installed, broken, toinstall, toreinstall, toremove, size); - - if (text) { - WMSetLabelText(_statusL, text); - } else { - char buffer[256]; - - listed = _lister->packagesSize(); - snprintf(buffer, sizeof(buffer), - _("%i packages listed, %i installed, %i broken. %i to install/upgrade, %i to remove; %sB will be %s"), - listed, installed, broken, toinstall, toremove, - SizeToStr(fabs(size)).c_str(), - size < 0 ? _("freed") : _("used")); - - WMSetLabelText(_statusL, buffer); - } - - WMSetButtonEnabled(_proceedB, (toinstall + toremove) != 0); - _unsavedChanges = (toinstall + toremove) != 0; - - XFlush(WMScreenDisplay(WMWidgetScreen(_win))); -} - - -void RWMainWindow::refreshFilterMenu() -{ - vector filters; - filters = _lister->getFilterNames(); - - int count = WMGetPopUpButtonNumberOfItems(_popup); - for (int i = 1; i < count; i++) - WMRemovePopUpButtonItem(_popup, 1); - - for (vector::const_iterator iter = filters.begin(); - iter != filters.end(); - iter++) { - WMAddPopUpButtonItem(_popup, (char*)(*iter).c_str()); - } -} - - -void RWMainWindow::saveState() -{ - _lister->storeFilters(); -} - - -bool RWMainWindow::restoreState() -{ - _lister->restoreFilters(); - - refreshFilterMenu(); - - WMSetPopUpButtonSelectedItem(_popup, 0); - changedFilter(_popup, this); - setStatusText(); - - return false; -} - - -void RWMainWindow::close() -{ - if (_interfaceLocked > 0) - return; - - if (_unsavedChanges == false || - WMRunAlertPanel(WMWidgetScreen(_win), _win, _("Warning"), - _("There are unsaved changes, are you sure\n" - "you want to quit Synaptic?"), - _("Quit"), _("Cancel"), NULL) == WAPRDefault) { - - _error->Discard(); - - saveState(); - - showErrors(); - - exit(0); - } -} - - - -void RWMainWindow::setInterfaceLocked(bool flag) -{ - WMScreen *scr = WMWidgetScreen(_win); - Display *dpy = WMScreenDisplay(scr); - - if (flag) { - //WMRect rect; - - _interfaceLocked++; - if (_interfaceLocked > 1) - return; - - if (_lockWindow == None) { - _lockWindow = XCreateWindow(dpy, WMWidgetXID(_win), - 0, 0, 16000, 16000, 0, - CopyFromParent, - InputOnly, CopyFromParent, - 0, NULL); - XSelectInput(dpy, _lockWindow, ButtonPressMask); - XDefineCursor(dpy, _lockWindow, _busyCursor); - } - XMapRaised(dpy, _lockWindow); - } else { - assert(_interfaceLocked > 0); - - _interfaceLocked--; - if (_interfaceLocked > 0) - return; - - XUnmapWindow(dpy, _lockWindow); - } - - XFlush(dpy); -} diff --git a/wings/rwmainwindow.h b/wings/rwmainwindow.h deleted file mode 100644 index a1c404378..000000000 --- a/wings/rwmainwindow.h +++ /dev/null @@ -1,203 +0,0 @@ -/* rwmainwindow.h - main window of application - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef _RWMAINWINDOW_H_ -#define _RWMAINWINDOW_H_ - - -#include "rpackagelister.h" - -#include -#include -#include - -#include "rwwindow.h" - - -class RWSourcesWindow; -class RWConfigWindow; -class RWFilterManagerWindow; -class RWFilterWindow; -class RWAboutPanel; - - -class RWUserDialog; -class RWCacheProgress; - -class RWMainWindow : public RWWindow, public RPackageObserver -{ - RPackageLister *_lister; - - bool _showUpdateInfo; - - bool _unsavedChanges; - - bool _tempKluge; // yet another permanent temporary kluge.. - - int _interfaceLocked; - Window _lockWindow; - Cursor _busyCursor; - - WMTableView *_table; - - WMLabel *_statusL; - - WMButton *_currentB; // ptr to one of below - WMButton *_actionB[3]; - WMButton *_holdB; - - WMButton *_proceedB; - - // filter/find panel - bool _panelSwitched; - WMTabView *_cmdPanel; - - WMTextField *_findText; - WMButton *_findNextB; - - WMButton *_editFilterB; - WMButton *_filtersB; - WMPopUpButton *_popup; - - // package info tabs - WMTabView *_tabview; - - WMLabel *_nameL; - WMLabel *_summL; - WMLabel *_stateL; - - WMPixmap *_alertPix; - - WMLabel *_importL; - WMLabel *_infoL; - - - WMText *_text; - - WMPopUpButton *_depP; - - WMTabView *_depTab; - - WMButton *_removeDepsB; - - WMList *_rdepList; - WMList *_depList; - WMList *_recList; - WMLabel *_depInfoL; - - RWFilterManagerWindow *_fmanagerWin; - RWSourcesWindow *_sourcesWin; - RWConfigWindow *_configWin; - RWFilterWindow *_filterWin; - RWAboutPanel *_aboutPanel; - - RWCacheProgress *_cacheProgress; - RWUserDialog *_userDialog; - - - void buildInterface(WMScreen *scr); - - void refreshFilterMenu(); - - void updatePackageInfo(RPackage *pkg); - - void updatePackageStatus(RPackage *pkg); - void updateDynPackageInfo(RPackage *pkg); - - RPackage *selectedPackage(); - void refreshTable(RPackage *selectedPkg); - - void navigateTable(char direction); - - virtual void close(); - - static void dependListDraw(WMList *lPtr, int index, Drawable d, char *text, - int state, WMRect *rect); - - static int numberOfRows(WMTableViewDelegate *self, WMTableView *table); - static void *valueForCell(WMTableViewDelegate *self, - WMTableColumn *column, int row); - - static void showSearchPanel(WMWidget *self, void *data); - static void showAboutPanel(WMWidget *self, void *data); - static void showFilterWindow(WMWidget *self, void *data); - static void showFilterManagerWindow(WMWidget *self, void *data); - static void showSourcesWindow(WMWidget *self, void *data); - static void showConfigWindow(WMWidget *self, void *data); - - static void findPackageObserver(void *self, WMNotification *notif); - - static void makeFinderFilterAction(WMWidget *self, void *data); - static void findNextAction(WMWidget *self, void *data); - - static void switchCommandPanel(WMWidget *self, void *data); - - static void clickedRow(WMWidget *self, void *data); - static void changedFilter(WMWidget *self, void *data); - - static void changedDepView(WMWidget *self, void *data); - - static void clickedDepList(WMWidget *self, void *data); - - static void updateClicked(WMWidget *self, void *data); - static void fixBrokenClicked(WMWidget *self, void *data); - static void upgradeClicked(WMWidget *self, void *data); - static void distUpgradeClicked(WMWidget *self, void *data); - static void proceedClicked(WMWidget *self, void *data); - - static void actionClicked(WMWidget *self, void *data); - static void holdClicked(WMWidget *self, void *data); - - static void removeDepsClicked(WMWidget *self, void *data); - - static void actionVisibleClicked(WMWidget *self, void *data); - - static void saveFilterAction(void *self, RWFilterWindow *rwin); - static void closeFilterAction(void *self, RWFilterWindow *rwin); - - static void closeFilterManagerAction(void *self, RWFilterManagerWindow *win); - - static void keyPressHandler(XEvent *event, void *data); - - // RPackageObserver - virtual void notifyChange(RPackage *pkg); - virtual void notifyPreFilteredChange() {}; - virtual void notifyPostFilteredChange() {}; - -public: - RWMainWindow(WMScreen *scr, RPackageLister *packLister); - virtual ~RWMainWindow() {}; - - void setInterfaceLocked(bool flag); - - void setStatusText(char *text = NULL); - - void saveState(); - bool restoreState(); - - bool showErrors(); -}; - - -#endif - diff --git a/wings/rwsourceswindow.cc b/wings/rwsourceswindow.cc deleted file mode 100644 index 8d3f77ac5..000000000 --- a/wings/rwsourceswindow.cc +++ /dev/null @@ -1,168 +0,0 @@ -/* rwsourceswindow.cc - * - * Copyright (c) 2000-2003 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "config.h" -#include "i18n.h" - -#include "rwsourceswindow.h" - -#include - -#include "up.xpm" -#include "down.xpm" - - -static int numberOfRows(WMTableViewDelegate *self, WMTableView *table) -{ - return 0; -} - - -static void *valueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row) -{ - - return (void*)"A"; -} - - - - -static WMButton *makeButton(WMWidget *parent, char **image) -{ - WMButton *button; - WMPixmap *pix; - - button = WMCreateCommandButton(parent); - - pix = WMCreatePixmapFromXPMData(WMWidgetScreen(parent), image); - WMSetButtonImagePosition(button, WIPImageOnly); - WMSetButtonImage(button, pix); - WMReleasePixmap(pix); - - return button; -} - - -RWSourcesWindow::RWSourcesWindow(RWWindow *parent) - : RWWindow(parent, "sources") -{ - WMBox *hbox; - WMButton *btn; - WMTableView *table; - WMScreen *scr = WMWidgetScreen(_win); - static WMTableViewDelegate delegate = { - NULL, - numberOfRows, - valueForCell, - NULL - }; - - WMResizeWidget(_win, 600, 200); - - WMSetBoxHorizontal(_topBox, False); - - - table = WMCreateTableView(_topBox); - WMSetTableViewDataSource(table, this); - WMSetTableViewBackgroundColor(table, WMWhiteColor(scr)); - WMSetTableViewGridColor(table, WMGrayColor(scr)); - WMSetTableViewHeaderHeight(table, 18); - WMSetTableViewDelegate(table, &delegate); - WMAddBoxSubview(_topBox, WMWidgetView(table), True, True, 200, 0, 5); - - { - WMTableColumn *col; - - col = WMCreateTableColumn(""); - WMAddTableViewColumn(table, col); - WMSetTableColumnWidth(col, 20); -// WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)0); - - col = WMCreateTableColumn(_("Type")); - WMSetTableColumnWidth(col, 50); - WMAddTableViewColumn(table, col); -// WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)1); - - col = WMCreateTableColumn(_("Vendor")); - WMSetTableColumnWidth(col, 54); - WMAddTableViewColumn(table, col); -// WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)2); - - col = WMCreateTableColumn(_("URI")); - WMSetTableColumnWidth(col, 250); - WMAddTableViewColumn(table, col); -// WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)4); - - col = WMCreateTableColumn(_("Distribution")); - WMSetTableColumnWidth(col, 80); - WMAddTableViewColumn(table, col); -// WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)3); - - col = WMCreateTableColumn(_("Components")); - WMSetTableColumnWidth(col, 100); - WMAddTableViewColumn(table, col); -// WMSetTableColumnDelegate(col, colDeleg); - WMSetTableColumnId(col, (void*)4); - } - - - hbox = WMCreateBox(_topBox); - WMSetBoxHorizontal(hbox, True); - WMAddBoxSubview(_topBox, WMWidgetView(hbox), False, True, 24, 0, 0); - - btn = makeButton(hbox, up_xpm); - WMAddBoxSubview(hbox, WMWidgetView(btn), False, True, 24, 0, 3); - - btn = makeButton(hbox, down_xpm); - WMAddBoxSubview(hbox, WMWidgetView(btn), False, True, 24, 0, 10); - - - - btn = WMCreateCommandButton(hbox); - WMSetButtonText(btn, _("Add Repository")); - WMAddBoxSubview(hbox, WMWidgetView(btn), False, True, 120, 0, 5); - - btn = WMCreateCommandButton(hbox); - WMSetButtonText(btn, _("Add CD-ROM")); - WMAddBoxSubview(hbox, WMWidgetView(btn), False, True, 120, 0, 5); - - btn = WMCreateCommandButton(hbox); - WMSetButtonText(btn, _("Remove")); - WMAddBoxSubview(hbox, WMWidgetView(btn), False, True, 100, 0, 5); - - btn = WMCreateCommandButton(hbox); - WMSetButtonText(btn, _("Close")); - WMAddBoxSubviewAtEnd(hbox, WMWidgetView(btn), False, True, 100, 0, 0); - - WMMapSubwidgets(_topBox); - WMMapSubwidgets(_win); - - setTitle(_("Setup Package Repositories (still not working!)")); - - WMRealizeWidget(_win); -} - diff --git a/wings/rwsourceswindow.h b/wings/rwsourceswindow.h deleted file mode 100644 index 06b1bc060..000000000 --- a/wings/rwsourceswindow.h +++ /dev/null @@ -1,35 +0,0 @@ -/* rwsourceswindow.h - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef _RWSOURCESWINDOW_H_ -#define _RWSOURCESWINDOW_H_ - -#include "rwwindow.h" - -class RWSourcesWindow : public RWWindow { - -public: - RWSourcesWindow(RWWindow *parent); - virtual ~RWSourcesWindow() {}; -}; - -#endif diff --git a/wings/rwsummarywindow.cc b/wings/rwsummarywindow.cc deleted file mode 100644 index 0b2c3b0d8..000000000 --- a/wings/rwsummarywindow.cc +++ /dev/null @@ -1,332 +0,0 @@ -/* rwsummarywindow.cc - * - * Copyright (c) 2000-2003 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "config.h" -#include "i18n.h" - -#include - -#include -#include - -#include "rpackagelister.h" - -#include -#include -#include "rwsummarywindow.h" - - - -void RWSummaryWindow::handleKeyPress(XEvent *event, void *clientData) -{ - RWSummaryWindow *me = (RWSummaryWindow*)clientData; - KeySym ksym; - - XLookupString(&event->xkey, NULL, 0, &ksym, NULL); - - if (ksym == XK_Return) { - WMPerformButtonClick(me->_defBtn); - } -} - - -void RWSummaryWindow::clickedOk(WMWidget *self, void *data) -{ - RWSummaryWindow *me = (RWSummaryWindow*)data; - - me->_confirmed = true; - WMBreakModalLoop(WMWidgetScreen(self)); -} - - -void RWSummaryWindow::clickedCancel(WMWidget *self, void *data) -{ - RWSummaryWindow *me = (RWSummaryWindow*)data; - - me->_confirmed = false; - WMBreakModalLoop(WMWidgetScreen(self)); -} - - -void RWSummaryWindow::clickedDetails(WMWidget *self, void *data) -{ - RWSummaryWindow *me = (RWSummaryWindow*)data; - RPackageLister *lister = me->_lister; - WMScrollView *view; - WMLabel *info; - int lines; - - WMSetButtonEnabled((WMButton*)self, False); - - WMDestroyWidget(me->_summaryL); - - WMResizeWidget(me->_win, 360, 400); - - WMSetFrameRelief(me->_topF, WRSunken); - view = WMCreateScrollView(me->_topF); - WMSetViewExpandsToParent(WMWidgetView(view), 1, 1, 2, 2); - WMMapWidget(view); - WMSetScrollViewHasVerticalScroller(view, True); - - info = WMCreateLabel(view); - WMMapWidget(info); - WMSetScrollViewContentView(view, WMWidgetView(info)); - - - lines = 1; - - string text; - - vector held; - vector kept; - vector essential; - vector toInstall; - vector toReInstall; - vector toUpgrade; - vector toRemove; - vector toDowngrade; - double sizeChange; - - - lister->getDetailedSummary(held, - kept, - essential, - toInstall, - toReInstall, - toUpgrade, - toRemove, - toDowngrade, - sizeChange); - - for (vector::const_iterator p = essential.begin(); - p != essential.end(); p++) { - text += string((*p)->name()) + _(": (ESSENTIAL) will be Removed\n"); - lines++; - } - - for (vector::const_iterator p = toDowngrade.begin(); - p != toDowngrade.end(); p++) { - text += string((*p)->name()) + _(": will be Downgraded\n"); - lines++; - } - - for (vector::const_iterator p = toRemove.begin(); - p != toRemove.end(); p++) { - text += string((*p)->name()) + _(": will be Removed\n"); - lines++; - } - - for (vector::const_iterator p = toUpgrade.begin(); - p != toUpgrade.end(); p++) { - text += string((*p)->name()) + " " +(*p)->installedVersion() - + _(": will be Upgraded to ")+(*p)->availableVersion()+"\n"; - lines++; - } - - for (vector::const_iterator p = toInstall.begin(); - p != toInstall.end(); p++) { - text += string((*p)->name()) + " " + (*p)->availableVersion() + _(": will be Installed\n"); - lines++; - } - - for (vector::const_iterator p = toReInstall.begin(); - p != toReInstall.end(); p++) { - text += string((*p)->name()) + " " + (*p)->availableVersion() + _(": will be re-installed\n"); - lines++; - } - - WMResizeWidget(info, 500, lines*14); - - WMSetLabelText(info, (char*)text.c_str()); - - WMRealizeWidget(view); -} - - -RWSummaryWindow::RWSummaryWindow(RWWindow *wwin, RPackageLister *lister) - : RWWindow(wwin, "summary", true, false) -{ - WMBox *hbox; - WMButton *button; - int lines = 0; - - _potentialBreak = false; - - _lister = lister; - - setTitle(_("Operation Summary")); - - WMResizeWidget(_win, 360, 150); - - WMSetBoxHorizontal(_topBox, False); - WMSetBoxBorderWidth(_topBox, 10); - - WMCreateEventHandler(WMWidgetView(_win), KeyPressMask, - handleKeyPress, this); - - _topF = WMCreateFrame(_topBox); - WMMapWidget(_topF); - WMAddBoxSubview(_topBox, WMWidgetView(_topF), True, True, 10, 0, 5); - - _summaryL = WMCreateLabel(_topF); - WMMapWidget(_summaryL); - WMSetViewExpandsToParent(WMWidgetView(_summaryL), 5, 5, 5, 5); - - _dlonlyB = WMCreateSwitchButton(_topBox); - WMSetButtonText(_dlonlyB, _("Perform package download only.")); - WMMapWidget(_dlonlyB); - WMAddBoxSubview(_topBox, WMWidgetView(_dlonlyB), False, True, 20, 0, 10); - - - hbox = WMCreateBox(_topBox); - WMSetBoxHorizontal(hbox, True); - WMAddBoxSubviewAtEnd(_topBox, WMWidgetView(hbox), False, True, 24, 0, 0); - - button = WMCreateCommandButton(hbox); - WMSetButtonText(button, _("Show Details")); - WMSetButtonAction(button, clickedDetails, this); - WMAddBoxSubview(hbox, WMWidgetView(button), True, True, 80, 0, 20); - - _defBtn = button = WMCreateCommandButton(hbox); - WMSetButtonText(button, _("Proceed")); - WMSetButtonAction(button, clickedOk, this); - WMSetButtonImagePosition(button, WIPRight); - WMSetButtonImage(button, WMGetSystemPixmap(WMWidgetScreen(button), - WSIReturnArrow)); - WMSetButtonAltImage(button, WMGetSystemPixmap(WMWidgetScreen(button), - WSIHighlightedReturnArrow)); - - WMAddBoxSubviewAtEnd(hbox, WMWidgetView(button), False, True, 100, 0, 0); - - button = WMCreateCommandButton(hbox); - WMSetButtonText(button, _("Cancel")); - WMSetButtonAction(button, clickedCancel, this); - WMAddBoxSubviewAtEnd(hbox, WMWidgetView(button), False, True, 80, 0, 5); - - WMMapSubwidgets(hbox); - WMMapWidget(hbox); - - WMMapWidget(_topBox); - - - { - char buffer[1024]; - int left = sizeof(buffer); - int used = 0; - int toInstall, toReInstall, toRemove, toUpgrade; - int held, kept, essential, toDowngrade; - double sizeChange, dlSize; - int dlCount; - - lister->getSummary(held, kept, essential, - toInstall, toReInstall, toUpgrade, toRemove, toDowngrade, - sizeChange); - - lister->getDownloadSummary(dlCount, dlSize); - -#define APPEND_TXT(descr, number)\ - used += snprintf(buffer+used, left, descr, number, \ - number > 1 ? _("packages") : _("package")),\ - left -= used, lines++ - - if (held) - APPEND_TXT(_("%d %s were held;\n"), held); - - if (kept) - APPEND_TXT(_("%d %s were kept back and not upgraded;\n"), kept); - - if (toInstall) - APPEND_TXT(_("%d new %s will be installed;\n"), toInstall); - - if (toUpgrade) - APPEND_TXT(_("%d %s will be upgraded;\n"), toUpgrade); - - if (toRemove) - APPEND_TXT(_("%d %s will be removed;\n"), toRemove); - - if (essential) { - APPEND_TXT(_("WARNING: %d essential %s will be removed!\n"), - essential); - _potentialBreak = true; - } - - char *templ = NULL; - if (sizeChange > 0) { - templ = _("\n%s B will be used after finished.\n"); - } else if (sizeChange < 0) { - templ = _("\n%s B will be freed after finished.\n"); - sizeChange = -sizeChange; - } - - if (templ) { - used += snprintf(buffer+used, left, templ, - SizeToStr(sizeChange).c_str()); - left -= used; - lines++; - } - - if (dlSize > 0) { - used += snprintf(buffer+used, left, - _("\n%s B need to be downloaded."), - SizeToStr(dlSize).c_str()); - left -= used; - lines++; - } - if (left <= 0) { - cout << _("BUFFER OVERFLOW DETECTED, ABORTING") << endl; - abort(); - } - -#undef APPEND_TXT - - WMSetLabelText(_summaryL, buffer); - } - - WMResizeWidget(_win, 360, lines * 12 + 10 + 100 + 20); - - - WMRealizeWidget(_win); -} - - - -bool RWSummaryWindow::showAndConfirm() -{ - WMSetButtonSelected(_dlonlyB, - _config->FindB("Synaptic::Download-Only", false)); - - show(); - WMRunModalLoop(WMWidgetScreen(_win), WMWidgetView(_win)); - - if (_confirmed && _potentialBreak - && WMRunAlertPanel(WMWidgetScreen(_win), _win, _("WARNING!!!"), - _("Essential packages will be removed.\n" - "That can render your system unusable!!!\n"), - _("Cancel"), _("Proceed System Breakage"), NULL) == WAPRDefault) - return false; - - _config->Set("Synaptic::Download-Only", - WMGetButtonSelected(_dlonlyB) ? "true" : "false"); - - return _confirmed; -} - diff --git a/wings/rwsummarywindow.h b/wings/rwsummarywindow.h deleted file mode 100644 index de41c4a1c..000000000 --- a/wings/rwsummarywindow.h +++ /dev/null @@ -1,58 +0,0 @@ -/* rwsummarywindow.h - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#ifndef _RWSUMMARYWINDOW_H_ -#define _RWSUMMARYWINDOW_H_ - -#include "rwwindow.h" - - -class RPackageLister; - - -class RWSummaryWindow : public RWWindow { - WMFrame *_topF; - WMLabel *_summaryL; - - bool _confirmed; - bool _potentialBreak; - - - RPackageLister *_lister; - - WMButton *_dlonlyB; - WMButton *_defBtn; - - static void clickedOk(WMWidget *self, void *data); - static void clickedCancel(WMWidget *self, void *data); - static void clickedDetails(WMWidget *self, void *data); - - static void handleKeyPress(XEvent *event, void *clientData); -public: - RWSummaryWindow(RWWindow *win, RPackageLister *lister); - virtual ~RWSummaryWindow() {}; - - bool showAndConfirm(); -}; - -#endif diff --git a/wings/rwuserdialog.cc b/wings/rwuserdialog.cc deleted file mode 100644 index 1440df659..000000000 --- a/wings/rwuserdialog.cc +++ /dev/null @@ -1,88 +0,0 @@ -/* rwuserdialog.cc - * - * Copyright (c) 2000-2003 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include "config.h" -#include "i18n.h" -#include "rwuserdialog.h" - - -bool RWUserDialog::message(const char *msg, - RUserDialog::DialogType dialog, - RUserDialog::ButtonsType buttons, - bool defres) -{ - char *button1 = NULL; - char *button2 = NULL; - char *tmpbutton; - char *title; - int res; - - switch(dialog) { - case DialogInfo: - title = _("Info"); - button1 = _("Ok"); - break; - case DialogWarning: - title = _("Warning"); - button1 = _("Ok"); - break; - case DialogError: - title = _("Error"); - button1 = _("Ok"); - break; - case DialogQuestion: - title = _("Question"); - button1 = _("Yes"); - button2 = _("No"); - break; - } - - switch(buttons) { - case ButtonsDefault: - break; - case ButtonsOk: - button1 = _("Ok"); - button2 = NULL; - break; - case ButtonsOkCancel: - button1 = _("Ok"); - button2 = _("Cancel"); - break; - case ButtonsYesNo: - button1 = _("Yes"); - button2 = _("No"); - break; - } - - if (defres == false) { - tmpbutton = button1; - button1 = button2; - button2 = button1; - } - - res = WMRunAlertPanel(_scr, _parentWindow, - title, (char*) msg, button1, button2, NULL); - return (defres && res == WAPRDefault) || - (!defres && res != WAPRDefault); -} - -// vim:sts=4:sw=4 diff --git a/wings/rwuserdialog.h b/wings/rwuserdialog.h deleted file mode 100644 index 037c8d759..000000000 --- a/wings/rwuserdialog.h +++ /dev/null @@ -1,51 +0,0 @@ -/* rwuserdialog.h - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef RWUSERDIALOG_H -#define RWUSERDIALOG_H - -#include - -#include "ruserdialog.h" -#include "rwwindow.h" - -class RWUserDialog : public RUserDialog -{ - -protected: - - WMScreen *_scr; - WMWindow *_parentWindow; - -public: - - RWUserDialog(WMScreen *scr) : _scr(scr), _parentWindow(0) {}; - - virtual bool message(const char *msg, - RUserDialog::DialogType dialog=RUserDialog::DialogInfo, - RUserDialog::ButtonsType buttons=RUserDialog::ButtonsOk, - bool defres=true); -}; - -#endif - -// vim:sts=4:sw=4 diff --git a/wings/rwwindow.cc b/wings/rwwindow.cc deleted file mode 100644 index f062ab7fb..000000000 --- a/wings/rwwindow.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* rwwindow.cc - * - * Copyright (c) 2000, 2001 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - - -#include "config.h" - -#include "i18n.h" - -#include "rwwindow.h" - - - -void RWWindow::windowCloseAction(WMWidget *win, void *data) -{ - RWWindow *rwin = (RWWindow*)data; - - rwin->close(); -} - - -RWWindow::RWWindow(WMScreen *scr, string name, bool makeBox) -{ - _win = WMCreateWindow(scr, (char*)name.c_str()); - - WMSetWindowCloseAction(_win, windowCloseAction, this); - - if (makeBox) { - _topBox = WMCreateBox(_win); - WMMapWidget(_topBox); - WMSetBoxBorderWidth(_topBox, 5); - WMSetViewExpandsToParent(WMWidgetView(_topBox), 0, 0, 0, 0); - } else { - _topBox = NULL; - } -} - - -RWWindow::RWWindow(RWWindow *parent, string name, bool makeBox, bool closable) -{ - int style = WMTitledWindowMask | WMResizableWindowMask; - - if (closable) - style |= WMClosableWindowMask; - - _win = WMCreatePanelWithStyleForWindow(parent->window(), - (char*)name.c_str(), - style); - - WMSetWindowCloseAction(_win, windowCloseAction, this); - - if (makeBox) { - _topBox = WMCreateBox(_win); - WMMapWidget(_topBox); - WMSetBoxBorderWidth(_topBox, 5); - WMSetViewExpandsToParent(WMWidgetView(_topBox), 0, 0, 0, 0); - } else { - _topBox = NULL; - } -} - - -RWWindow::~RWWindow() -{ -// cout << "Desotry wind"< - * - * Author: Alfredo K. Kojima - * Michael Vogt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef _RWWINDOW_H_ -#define _RWWINDOW_H_ - - -#include - -#include - -using namespace std; - -class RWWindow { -protected: - WMWindow *_win; - WMBox *_topBox; - - static void windowCloseAction(WMWidget *win, void *data); - virtual void close(); - -public: - inline virtual WMWindow *window() { return _win; }; - - virtual void setTitle(string title); - - inline virtual void hide() { WMCloseWindow(_win); }; - inline virtual void show() { WMMapWidget(_win); }; - - RWWindow(WMScreen *scr, string name, bool makeBox = true); - RWWindow(RWWindow *parent, string name, bool makeBox = true, - bool closable = true); - virtual ~RWWindow(); -}; - -#endif - diff --git a/wings/synaptic.cc b/wings/synaptic.cc deleted file mode 100644 index 3a84ed2e8..000000000 --- a/wings/synaptic.cc +++ /dev/null @@ -1,125 +0,0 @@ -/* synaptic.cc - main() - * - * Copyright (c) 2000-2003 Conectiva S/A - * - * Author: Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include - -#include "config.h" - -#include "i18n.h" - -#include "rconfiguration.h" -#include "rpackagelister.h" - -#include -#include - - -#include - -#include "rwmainwindow.h" - -#include - - -static Display *dpy; -static WMScreen *scr; - - - -void RWFlushInterface() -{ - XSync(dpy, False); - while (XPending(dpy)) { - XEvent ev; - - WMNextEvent(dpy, &ev); - WMHandleEvent(&ev); - } -} - - -int main(int argc, char **argv) -{ - setlocale(LC_ALL, ""); - -// bindtextdomain(PACKAGE, "/usr/local/share/locale"); - textdomain(PACKAGE); - - WMInitializeApplication("synaptic", &argc, argv); - - dpy = XOpenDisplay(""); - if (!dpy) { - cout << argv[0] << _(":could not open display") <DumpErrors(); - exit(1); - } - - - - RPackageLister *packageLister = new RPackageLister(); - - - RWMainWindow *mainWindow = new RWMainWindow(scr, packageLister); - -#ifndef HAVE_RPM - mainWindow->setTitle(PACKAGE" for Debian "VERSION); -#else - mainWindow->setTitle(_config->Find("Synaptic::MyName", PACKAGE)+" "VERSION); -#endif - - mainWindow->show(); - - RWFlushInterface(); - - mainWindow->setInterfaceLocked(true); - - if (!packageLister->openCache(false)) { - mainWindow->showErrors(); - exit(1); - } - - mainWindow->restoreState(); - - mainWindow->setInterfaceLocked(false); - - mainWindow->showErrors(); - - WMScreenMainLoop(scr); - - return 0; -} -