r3806 - in software/ui: . src
Miriam Ruiz
baby-guest at alioth.debian.org
Fri Aug 24 12:59:12 UTC 2007
Author: baby-guest
Date: 2007-08-24 12:59:12 +0000 (Fri, 24 Aug 2007)
New Revision: 3806
Added:
software/ui/src/goplay.cpp
Removed:
software/ui/src/games.cpp
Modified:
software/ui/Makefile.am
software/ui/configure.ac
software/ui/src/Makefile.am
software/ui/src/manpage.cpp
Log:
Renamed program to goplay
Modified: software/ui/Makefile.am
===================================================================
--- software/ui/Makefile.am 2007-08-24 11:56:20 UTC (rev 3805)
+++ software/ui/Makefile.am 2007-08-24 12:59:12 UTC (rev 3806)
@@ -2,9 +2,9 @@
SUBDIRS = src .
-man_MANS = games.1
+man_MANS = goplay.1
-games.1: src/manpage
- src/manpage games > $@ || rm $@
+goplay.1: src/manpage
+ src/manpage goplay > $@ || rm $@
EXTRA_DIST = $(man_MANS)
Modified: software/ui/configure.ac
===================================================================
--- software/ui/configure.ac 2007-08-24 11:56:20 UTC (rev 3805)
+++ software/ui/configure.ac 2007-08-24 12:59:12 UTC (rev 3806)
@@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
-AC_INIT(games, 0.1, [Miriam Ruiz <little_miry at yahoo.es>, Enrico Zini <enrico at debian.org>])
+AC_INIT(goplay, 0.1, [Miriam Ruiz <little_miry at yahoo.es>, Enrico Zini <enrico at debian.org>])
AC_CONFIG_SRCDIR([configure.ac])
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE([foreign])
Modified: software/ui/src/Makefile.am
===================================================================
--- software/ui/src/Makefile.am 2007-08-24 11:56:20 UTC (rev 3805)
+++ software/ui/src/Makefile.am 2007-08-24 12:59:12 UTC (rev 3806)
@@ -1,9 +1,9 @@
## Process this file with automake to produce Makefile.in
-bin_PROGRAMS = games
+bin_PROGRAMS = goplay
noinst_PROGRAMS = manpage
-games_SOURCES = \
+goplay_SOURCES = \
Environment.cpp \
Engine.cpp \
ui.cpp \
@@ -12,8 +12,8 @@
taghandler.cpp \
windows.cpp \
aux.cpp \
- games.cpp
-games_LDFLAGS = $(LIBEPT_LIBS) `fltk-config --ldflags --use-images`
+ goplay.cpp
+goplay_LDFLAGS = $(LIBEPT_LIBS) `fltk-config --ldflags --use-images`
manpage_SOURCES = manpage.cpp
manpage_LDADD = $(LIBEPT_LIBS)
Deleted: software/ui/src/games.cpp
===================================================================
--- software/ui/src/games.cpp 2007-08-24 11:56:20 UTC (rev 3805)
+++ software/ui/src/games.cpp 2007-08-24 12:59:12 UTC (rev 3806)
@@ -1,418 +0,0 @@
-/*
- * debtags - Implement package tags support for Debian
- *
- * Copyright (C) 2007 Enrico Zini <enrico at debian.org>
- * Copyright (C) 2007 Miriam Ruiz <little_miry at yahoo.es>
- *
- * 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
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#define APPNAME PACKAGE_NAME
-#else
-#warning No config.h found: using fallback values
-#define APPNAME __FILE__
-#define PACKAGE_VERSION "unknown"
-#endif
-
-#include "common.h"
-#include "ui.h"
-#include "filter.h"
-
-#include "Environment.h"
-#include "GamesOptions.h"
-#include "Engine.h"
-
-#include <ept/apt/packagerecord.h>
-
-#include <iostream>
-#include <cmath>
-
-#ifdef USE_GETTEXT
-#include <libintl.h>
-#include <locale.h>
-#endif
-
-#include <FL/Fl.H>
-#include <FL/Fl_PNG_Image.H>
-
-namespace std {
-
-template<typename TAG, typename _Traits>
-basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& out, const std::set<TAG>& tags)
-{
- for (typename std::set<TAG>::const_iterator i = tags.begin();
- i != tags.end(); i++)
- if (i == tags.begin())
- out << i->fullname();
- else
- out << ", " << i->fullname();
- return out;
-}
-
-template<typename TAG, typename _Traits>
-basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& out, const wibble::Singleton<TAG>& tags)
-{
- out << *tags.begin();
- return out;
-}
-
-template<typename TAG, typename _Traits>
-basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& out, const wibble::Empty<TAG>&)
-{
- return out;
-}
-
-}
-
-using namespace std;
-using namespace ept;
-using namespace ept::debtags;
-using namespace ept::apt;
-using namespace ept::textsearch;
-
-char* tagString(const Tag& tag)
-{
- static map<string, char*> table;
- map<string, char*>::iterator i = table.find(tag.fullname());
- if (i == table.end())
- {
- pair< map<string, char*>::iterator, bool > tmp =
- table.insert(make_pair(tag.fullname(), strdup(tag.fullname().c_str())));
- i = tmp.first;
- }
- return i->second;
-}
-char* pkgString(const std::string& name)
-{
- static map<string, char*> table;
- map<string, char*>::iterator i = table.find(name);
- if (i == table.end())
- {
- pair< map<string, char*>::iterator, bool > tmp =
- table.insert(make_pair(name, strdup(name.c_str())));
- i = tmp.first;
- }
- return i->second;
-}
-
-void printResults(Engine& engine)
-{
- const vector<Result>& packages = engine.results();
- for (vector<Result>::const_iterator i = packages.begin();
- i != packages.end(); ++i)
- {
- PackageRecord pkg = engine.apt().rawRecord(i->name);
- cerr << "PKG " << pkg.package() << " - " << pkg.shortDescription() << endl;
- }
-
- const set<Tag>& ttags = engine.types();
- for (set<Tag>::const_iterator i = ttags.begin();
- i != ttags.end(); ++i)
- {
- cerr << "TTAG " << i->fullname() << endl;
- }
-
- const set<Tag>& ftags = engine.interfaces();
- for (set<Tag>::const_iterator i = ftags.begin();
- i != ftags.end(); ++i)
- {
- cerr << "ITAG " << i->fullname() << endl;
- }
-}
-
-const char* ReadFlChoice(Fl_Choice& c)
-{
- const Fl_Menu_Item* cur = c.mvalue();
- if (cur->user_data_)
- return (const char*)cur->user_data_;
- else
- return "";
-}
-
-static char *VoidString = "";
-
-static void UpdateUILists(GamesUI& ui)
-{
- Engine& engine = *ui.engine;
- const char* oldType = ReadFlChoice(*ui.TypeSelection);
- const char* oldIface = ReadFlChoice(*ui.InterfaceSelection);
- ui.TypeSelection->clear();
- ui.TypeSelection->add(_("Any type"), 0, NULL, VoidString, FL_NORMAL_LABEL);
- ui.InterfaceSelection->clear();
- ui.InterfaceSelection->add(_("Any interface"), 0, NULL, VoidString, FL_NORMAL_LABEL);
-
- static int widths_with_popcon[] = { 100, 300, 0 }; // widths for each column
- static int widths_without_popcon[] = { 100, 0 };
- ui.ResultsBrowser->clear();
- if (engine.popcon().hasData())
- {
- ui.ResultsBrowser->column_widths(widths_with_popcon);
- // tab delimited columns with colors
- ui.ResultsBrowser->add(_("@B12 at C7@b at .PACKAGE\t at B12@C7 at b@.DESCRIPTION\t at B12@C7 at b@.POPCON"));
- }
- else
- {
- ui.ResultsBrowser->column_widths(widths_without_popcon);
- // tab delimited columns with colors
- ui.ResultsBrowser->add(_("@B12 at C7@b at .PACKAGE\t at B12@C7 at b@.DESCRIPTION"));
- }
-
- // FIXME: there are better ways to remember the previous item
-
- const set<Tag> types = engine.types();
- int newIdx = 0;
- for (set<Tag>::const_iterator i = types.begin();
- i != types.end(); ++i)
- {
- int idx = ui.TypeSelection->add(gettext(i->shortDescription().c_str()),
- 0, NULL, tagString(*i), FL_NORMAL_LABEL);
- if (i->fullname() == oldType)
- newIdx = idx;
- }
- ui.TypeSelection->value(newIdx);
-
- const set<Tag> ifaces = engine.interfaces();
- newIdx = 0;
- for (set<Tag>::const_iterator i = ifaces.begin();
- i != ifaces.end(); ++i)
- {
- int idx = ui.InterfaceSelection->add(gettext(i->shortDescription().c_str()),
- 0, NULL, tagString(*i), FL_NORMAL_LABEL);
- if (i->fullname() == oldIface)
- newIdx = idx;
- }
- ui.InterfaceSelection->value(newIdx);
-
- PackageFilter filter;
-
- const std::vector<Result> res = engine.results();
- for (vector<Result>::const_iterator i = res.begin();
- i != res.end(); ++i)
- {
- PackageRecord rec(engine.apt().rawRecord(i->name));
- char* userData = pkgString(rec.package());
-
- // Available Colors: FL_BLACK, FL_BLUE, FL_CYAN, FL_DARK_BLUE,
- // FL_DARK_CYAN, FL_DARK_GREEN FL_DARK_MAGENTA, FL_DARK_RED,
- // FL_DARK_YELLOW, FL_GREEN, FL_MAGENTA, FL_RED, FL_WHITE, FL_YELLOW
-
- Fl_Color bk(FL_WHITE);
- Fl_Color fr(FL_BLACK);
- set<Tag> tags = ui.engine->debtags().getTagsOfItem((const char *)rec.package().c_str());
- switch (filter.TagsValue(tags))
- {
- case PackageFilter::Green:
- fr = FL_BLACK; bk = FL_GREEN; break;
- case PackageFilter::Yellow:
- fr = FL_BLACK; bk = FL_YELLOW; break;
- case PackageFilter::Red:
- fr = FL_WHITE; bk = FL_RED; break;
- case PackageFilter::Black:
- fr = FL_WHITE; bk = FL_BLACK; break;
- default:
- fr = FL_BLACK; bk = FL_WHITE; break;
- }
-
- char fmtstr[16];
- snprintf(fmtstr, sizeof(fmtstr), "@B%d at C%d at .", bk, fr);
-
- string desc = string(fmtstr) + rec.package() + "\t" +
- string(fmtstr) + rec.shortDescription();
- if (engine.popcon().hasData())
- {
- desc += "\t" + string(fmtstr);
- char stars[16];
- snprintf(stars, sizeof(stars), "%%%d/8/1;",
- (int)rintf(log(i->popcon) * 100 / log(engine.popconLocalMax())));
- desc += stars;
- printf ("%s (%s): POPCON=%f\n", rec.package().c_str(), rec.shortDescription().c_str(), i->popcon);
- }
- ui.ResultsBrowser->add(desc.c_str(), userData);
-
- // Relevance is 0 to 100
- // Popcon is a weird floating point number (to be improved)
- //FIXMEaddToResults(rec.package() + " - " + rec.shortDescription(), i->relevance, i->popcon);
- }
-}
-
-static void CallBackTypeSelection(Fl_Choice* choice, void *data)
-{
- printf("CallBackTypeSelection\n");
- fflush(stdout);
- GamesUI& ui = *static_cast<GamesUI*>(data);
- Tag tag = ui.engine->voc().tagByName(ReadFlChoice(*choice));
- ui.engine->setTypeFilter(tag);
- UpdateUILists(ui);
-}
-
-static void CallBackInterfaceSelection(Fl_Choice* choice, void *data)
-{
- printf("CallBackInterfaceSelection\n");
- fflush(stdout);
- GamesUI& ui = *static_cast<GamesUI*>(data);
- Tag tag = ui.engine->voc().tagByName(ReadFlChoice(*choice));
- ui.engine->setInterfaceFilter(tag);
- UpdateUILists(ui);
-}
-
-static void CallBackSearchInput(Fl_Input* input, void *data)
-{
- printf("CallBackSearchInput\n"); fflush(stdout);
- GamesUI& ui = *static_cast<GamesUI*>(data);
- ui.engine->setKeywordFilter(input->value());
- UpdateUILists(ui);
-}
-
-static void CallBackAlreadyInstalled(Fl_Round_Button*, void *data)
-{
- printf("CallBackInstalled\n"); fflush(stdout);
- GamesUI& ui = *static_cast<GamesUI*>(data);
- ui.AlreadyInstalled->value(1); ui.AlreadyInstalled->redraw();
- ui.ToBeInstalled->value(0); ui.ToBeInstalled->redraw();
- ui.InstalledOrNot->value(0); ui.InstalledOrNot->redraw();
- ui.engine->setInstalledFilter(Engine::INSTALLED);
- UpdateUILists(ui);
-}
-
-static void CallBackToBeInstalled(Fl_Round_Button*, void *data)
-{
- printf("CallBackToBeInstalled\n"); fflush(stdout);
- GamesUI& ui = *static_cast<GamesUI*>(data);
- ui.AlreadyInstalled->value(0); ui.AlreadyInstalled->redraw();
- ui.ToBeInstalled->value(1); ui.ToBeInstalled->redraw();
- ui.InstalledOrNot->value(0); ui.InstalledOrNot->redraw();
- ui.engine->setInstalledFilter(Engine::NOTINSTALLED);
- UpdateUILists(ui);
-}
-
-static void CallBackInstalledOrNot(Fl_Round_Button*, void *data)
-{
- printf("CallBackToBeInstalled\n"); fflush(stdout);
- GamesUI& ui = *static_cast<GamesUI*>(data);
- ui.AlreadyInstalled->value(0); ui.AlreadyInstalled->redraw();
- ui.ToBeInstalled->value(0); ui.ToBeInstalled->redraw();
- ui.InstalledOrNot->value(1); ui.InstalledOrNot->redraw();
- ui.engine->setInstalledFilter(Engine::ANY);
- UpdateUILists(ui);
-}
-
-static void OnResultsBrowserClick(Fl_Browser*, void *data)
-{
- printf("OnResultsBrowserClick\n"); fflush(stdout);
-// GamesUI& ui = *static_cast<GamesUI*>(data);
-}
-
-int main(int argc, const char* argv[])
-{
-#ifdef USE_GETTEXT
- setlocale (LC_MESSAGES, "");
- setlocale (LC_CTYPE, "");
- setlocale (LC_COLLATE, "");
- textdomain ("gamesui");
- bindtextdomain ("gamesui", NULL);
-#endif
-
- wibble::commandline::GamesOptions opts;
-
- try {
- // Install the handler for unexpected exceptions
- wibble::exception::InstallUnexpected installUnexpected;
-
- if (opts.parse(argc, argv))
- return 0;
-
- if (opts.out_verbose->boolValue())
- ::Environment::get().verbose(true);
-
- if (opts.out_debug->boolValue())
- ::Environment::get().debug(true);
-
- Engine engine;
-
- /*
- cerr << " *** Initial:" << endl;
- printResults(engine);
-
- engine.setTypeFilter(engine.voc().tagByName("game::arcade"));
- cerr << " *** Arcades:" << endl;
- printResults(engine);
-
- engine.setInterfaceFilter(engine.voc().tagByName("interface::x11"));
- cerr << " *** X11 Arcades:" << endl;
- printResults(engine);
-
- engine.setInstalledFilter(Engine::INSTALLED);
- cerr << " *** Installed X11 Arcades:" << endl;
- printResults(engine);
- */
-
- GamesUI mainui;
- mainui.engine = &engine;
- Fl_Double_Window *window = mainui.CreateWindows();
- mainui.TypeSelection->callback((Fl_Callback*)CallBackTypeSelection, &mainui);
- mainui.TypeSelection->when(FL_WHEN_CHANGED);
- mainui.InterfaceSelection->callback((Fl_Callback*)CallBackInterfaceSelection, &mainui);
- mainui.InterfaceSelection->when(FL_WHEN_CHANGED);
- mainui.SearchInput->callback((Fl_Callback*)CallBackSearchInput, &mainui);
- mainui.SearchInput->when(FL_WHEN_CHANGED);
- mainui.AlreadyInstalled->callback((Fl_Callback*)CallBackAlreadyInstalled, &mainui);
- mainui.AlreadyInstalled->when(FL_WHEN_CHANGED);
- mainui.ToBeInstalled->callback((Fl_Callback*)CallBackToBeInstalled, &mainui);
- mainui.ToBeInstalled->when(FL_WHEN_CHANGED);
- mainui.InstalledOrNot->callback((Fl_Callback*)CallBackInstalledOrNot, &mainui);
- mainui.InstalledOrNot->when(FL_WHEN_CHANGED);
-
- mainui.AlreadyInstalled->value(0); mainui.AlreadyInstalled->redraw();
- mainui.ToBeInstalled->value(0); mainui.ToBeInstalled->redraw();
- mainui.InstalledOrNot->value(1); mainui.InstalledOrNot->redraw();
- mainui.engine->setInstalledFilter(Engine::ANY);
-
- mainui.Screenshot(new Fl_PNG_Image(FILE_NO_SCREENSHOT));
- mainui.AboutView->load(HTMLDIR "/about.en.html");
-
- UpdateUILists(mainui);
-
- window->show(argc, (char**)argv);
- while (Fl::wait());
- return 0;
- } catch (wibble::exception::BadOption& e) {
- cerr << e.desc() << endl;
- opts.outputHelp(cerr);
- return 1;
- } catch (std::exception& e) {
- cerr << e.what() << endl;
- return 1;
- } catch (Xapian::DatabaseVersionError& e) {
- cerr << "Xapian " << e.get_type() << ": " << e.get_msg();
- if (!e.get_context().empty())
- cerr << ". Context: " << e.get_context();
- cerr << endl;
- cerr << endl;
- cerr << "Please recreate the database by removing /var/lib/apt-xapian and running ept-cache reindex as root." << endl;
- } catch (Xapian::Error& e) {
- cerr << "Xapian " << e.get_type() << ": " << e.get_msg();
- if (!e.get_context().empty())
- cerr << ". Context: " << e.get_context();
- cerr << endl;
- return 1;
- }
-
-}
-
-#include <ept/debtags/debtags.tcc>
-
-// vim:set ts=4 sw=4:
Copied: software/ui/src/goplay.cpp (from rev 3803, software/ui/src/games.cpp)
===================================================================
--- software/ui/src/goplay.cpp (rev 0)
+++ software/ui/src/goplay.cpp 2007-08-24 12:59:12 UTC (rev 3806)
@@ -0,0 +1,418 @@
+/*
+ * debtags - Implement package tags support for Debian
+ *
+ * Copyright (C) 2007 Enrico Zini <enrico at debian.org>
+ * Copyright (C) 2007 Miriam Ruiz <little_miry at yahoo.es>
+ *
+ * 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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#define APPNAME PACKAGE_NAME
+#else
+#warning No config.h found: using fallback values
+#define APPNAME __FILE__
+#define PACKAGE_VERSION "unknown"
+#endif
+
+#include "common.h"
+#include "ui.h"
+#include "filter.h"
+
+#include "Environment.h"
+#include "GamesOptions.h"
+#include "Engine.h"
+
+#include <ept/apt/packagerecord.h>
+
+#include <iostream>
+#include <cmath>
+
+#ifdef USE_GETTEXT
+#include <libintl.h>
+#include <locale.h>
+#endif
+
+#include <FL/Fl.H>
+#include <FL/Fl_PNG_Image.H>
+
+namespace std {
+
+template<typename TAG, typename _Traits>
+basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& out, const std::set<TAG>& tags)
+{
+ for (typename std::set<TAG>::const_iterator i = tags.begin();
+ i != tags.end(); i++)
+ if (i == tags.begin())
+ out << i->fullname();
+ else
+ out << ", " << i->fullname();
+ return out;
+}
+
+template<typename TAG, typename _Traits>
+basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& out, const wibble::Singleton<TAG>& tags)
+{
+ out << *tags.begin();
+ return out;
+}
+
+template<typename TAG, typename _Traits>
+basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& out, const wibble::Empty<TAG>&)
+{
+ return out;
+}
+
+}
+
+using namespace std;
+using namespace ept;
+using namespace ept::debtags;
+using namespace ept::apt;
+using namespace ept::textsearch;
+
+char* tagString(const Tag& tag)
+{
+ static map<string, char*> table;
+ map<string, char*>::iterator i = table.find(tag.fullname());
+ if (i == table.end())
+ {
+ pair< map<string, char*>::iterator, bool > tmp =
+ table.insert(make_pair(tag.fullname(), strdup(tag.fullname().c_str())));
+ i = tmp.first;
+ }
+ return i->second;
+}
+char* pkgString(const std::string& name)
+{
+ static map<string, char*> table;
+ map<string, char*>::iterator i = table.find(name);
+ if (i == table.end())
+ {
+ pair< map<string, char*>::iterator, bool > tmp =
+ table.insert(make_pair(name, strdup(name.c_str())));
+ i = tmp.first;
+ }
+ return i->second;
+}
+
+void printResults(Engine& engine)
+{
+ const vector<Result>& packages = engine.results();
+ for (vector<Result>::const_iterator i = packages.begin();
+ i != packages.end(); ++i)
+ {
+ PackageRecord pkg = engine.apt().rawRecord(i->name);
+ cerr << "PKG " << pkg.package() << " - " << pkg.shortDescription() << endl;
+ }
+
+ const set<Tag>& ttags = engine.types();
+ for (set<Tag>::const_iterator i = ttags.begin();
+ i != ttags.end(); ++i)
+ {
+ cerr << "TTAG " << i->fullname() << endl;
+ }
+
+ const set<Tag>& ftags = engine.interfaces();
+ for (set<Tag>::const_iterator i = ftags.begin();
+ i != ftags.end(); ++i)
+ {
+ cerr << "ITAG " << i->fullname() << endl;
+ }
+}
+
+const char* ReadFlChoice(Fl_Choice& c)
+{
+ const Fl_Menu_Item* cur = c.mvalue();
+ if (cur->user_data_)
+ return (const char*)cur->user_data_;
+ else
+ return "";
+}
+
+static char *VoidString = "";
+
+static void UpdateUILists(GamesUI& ui)
+{
+ Engine& engine = *ui.engine;
+ const char* oldType = ReadFlChoice(*ui.TypeSelection);
+ const char* oldIface = ReadFlChoice(*ui.InterfaceSelection);
+ ui.TypeSelection->clear();
+ ui.TypeSelection->add(_("Any type"), 0, NULL, VoidString, FL_NORMAL_LABEL);
+ ui.InterfaceSelection->clear();
+ ui.InterfaceSelection->add(_("Any interface"), 0, NULL, VoidString, FL_NORMAL_LABEL);
+
+ static int widths_with_popcon[] = { 100, 300, 0 }; // widths for each column
+ static int widths_without_popcon[] = { 100, 0 };
+ ui.ResultsBrowser->clear();
+ if (engine.popcon().hasData())
+ {
+ ui.ResultsBrowser->column_widths(widths_with_popcon);
+ // tab delimited columns with colors
+ ui.ResultsBrowser->add(_("@B12 at C7@b at .PACKAGE\t at B12@C7 at b@.DESCRIPTION\t at B12@C7 at b@.POPCON"));
+ }
+ else
+ {
+ ui.ResultsBrowser->column_widths(widths_without_popcon);
+ // tab delimited columns with colors
+ ui.ResultsBrowser->add(_("@B12 at C7@b at .PACKAGE\t at B12@C7 at b@.DESCRIPTION"));
+ }
+
+ // FIXME: there are better ways to remember the previous item
+
+ const set<Tag> types = engine.types();
+ int newIdx = 0;
+ for (set<Tag>::const_iterator i = types.begin();
+ i != types.end(); ++i)
+ {
+ int idx = ui.TypeSelection->add(gettext(i->shortDescription().c_str()),
+ 0, NULL, tagString(*i), FL_NORMAL_LABEL);
+ if (i->fullname() == oldType)
+ newIdx = idx;
+ }
+ ui.TypeSelection->value(newIdx);
+
+ const set<Tag> ifaces = engine.interfaces();
+ newIdx = 0;
+ for (set<Tag>::const_iterator i = ifaces.begin();
+ i != ifaces.end(); ++i)
+ {
+ int idx = ui.InterfaceSelection->add(gettext(i->shortDescription().c_str()),
+ 0, NULL, tagString(*i), FL_NORMAL_LABEL);
+ if (i->fullname() == oldIface)
+ newIdx = idx;
+ }
+ ui.InterfaceSelection->value(newIdx);
+
+ PackageFilter filter;
+
+ const std::vector<Result> res = engine.results();
+ for (vector<Result>::const_iterator i = res.begin();
+ i != res.end(); ++i)
+ {
+ PackageRecord rec(engine.apt().rawRecord(i->name));
+ char* userData = pkgString(rec.package());
+
+ // Available Colors: FL_BLACK, FL_BLUE, FL_CYAN, FL_DARK_BLUE,
+ // FL_DARK_CYAN, FL_DARK_GREEN FL_DARK_MAGENTA, FL_DARK_RED,
+ // FL_DARK_YELLOW, FL_GREEN, FL_MAGENTA, FL_RED, FL_WHITE, FL_YELLOW
+
+ Fl_Color bk(FL_WHITE);
+ Fl_Color fr(FL_BLACK);
+ set<Tag> tags = ui.engine->debtags().getTagsOfItem((const char *)rec.package().c_str());
+ switch (filter.TagsValue(tags))
+ {
+ case PackageFilter::Green:
+ fr = FL_BLACK; bk = FL_GREEN; break;
+ case PackageFilter::Yellow:
+ fr = FL_BLACK; bk = FL_YELLOW; break;
+ case PackageFilter::Red:
+ fr = FL_WHITE; bk = FL_RED; break;
+ case PackageFilter::Black:
+ fr = FL_WHITE; bk = FL_BLACK; break;
+ default:
+ fr = FL_BLACK; bk = FL_WHITE; break;
+ }
+
+ char fmtstr[16];
+ snprintf(fmtstr, sizeof(fmtstr), "@B%d at C%d at .", bk, fr);
+
+ string desc = string(fmtstr) + rec.package() + "\t" +
+ string(fmtstr) + rec.shortDescription();
+ if (engine.popcon().hasData())
+ {
+ desc += "\t" + string(fmtstr);
+ char stars[16];
+ snprintf(stars, sizeof(stars), "%%%d/8/1;",
+ (int)rintf(log(i->popcon) * 100 / log(engine.popconLocalMax())));
+ desc += stars;
+ printf ("%s (%s): POPCON=%f\n", rec.package().c_str(), rec.shortDescription().c_str(), i->popcon);
+ }
+ ui.ResultsBrowser->add(desc.c_str(), userData);
+
+ // Relevance is 0 to 100
+ // Popcon is a weird floating point number (to be improved)
+ //FIXMEaddToResults(rec.package() + " - " + rec.shortDescription(), i->relevance, i->popcon);
+ }
+}
+
+static void CallBackTypeSelection(Fl_Choice* choice, void *data)
+{
+ printf("CallBackTypeSelection\n");
+ fflush(stdout);
+ GamesUI& ui = *static_cast<GamesUI*>(data);
+ Tag tag = ui.engine->voc().tagByName(ReadFlChoice(*choice));
+ ui.engine->setTypeFilter(tag);
+ UpdateUILists(ui);
+}
+
+static void CallBackInterfaceSelection(Fl_Choice* choice, void *data)
+{
+ printf("CallBackInterfaceSelection\n");
+ fflush(stdout);
+ GamesUI& ui = *static_cast<GamesUI*>(data);
+ Tag tag = ui.engine->voc().tagByName(ReadFlChoice(*choice));
+ ui.engine->setInterfaceFilter(tag);
+ UpdateUILists(ui);
+}
+
+static void CallBackSearchInput(Fl_Input* input, void *data)
+{
+ printf("CallBackSearchInput\n"); fflush(stdout);
+ GamesUI& ui = *static_cast<GamesUI*>(data);
+ ui.engine->setKeywordFilter(input->value());
+ UpdateUILists(ui);
+}
+
+static void CallBackAlreadyInstalled(Fl_Round_Button*, void *data)
+{
+ printf("CallBackInstalled\n"); fflush(stdout);
+ GamesUI& ui = *static_cast<GamesUI*>(data);
+ ui.AlreadyInstalled->value(1); ui.AlreadyInstalled->redraw();
+ ui.ToBeInstalled->value(0); ui.ToBeInstalled->redraw();
+ ui.InstalledOrNot->value(0); ui.InstalledOrNot->redraw();
+ ui.engine->setInstalledFilter(Engine::INSTALLED);
+ UpdateUILists(ui);
+}
+
+static void CallBackToBeInstalled(Fl_Round_Button*, void *data)
+{
+ printf("CallBackToBeInstalled\n"); fflush(stdout);
+ GamesUI& ui = *static_cast<GamesUI*>(data);
+ ui.AlreadyInstalled->value(0); ui.AlreadyInstalled->redraw();
+ ui.ToBeInstalled->value(1); ui.ToBeInstalled->redraw();
+ ui.InstalledOrNot->value(0); ui.InstalledOrNot->redraw();
+ ui.engine->setInstalledFilter(Engine::NOTINSTALLED);
+ UpdateUILists(ui);
+}
+
+static void CallBackInstalledOrNot(Fl_Round_Button*, void *data)
+{
+ printf("CallBackToBeInstalled\n"); fflush(stdout);
+ GamesUI& ui = *static_cast<GamesUI*>(data);
+ ui.AlreadyInstalled->value(0); ui.AlreadyInstalled->redraw();
+ ui.ToBeInstalled->value(0); ui.ToBeInstalled->redraw();
+ ui.InstalledOrNot->value(1); ui.InstalledOrNot->redraw();
+ ui.engine->setInstalledFilter(Engine::ANY);
+ UpdateUILists(ui);
+}
+
+static void OnResultsBrowserClick(Fl_Browser*, void *data)
+{
+ printf("OnResultsBrowserClick\n"); fflush(stdout);
+// GamesUI& ui = *static_cast<GamesUI*>(data);
+}
+
+int main(int argc, const char* argv[])
+{
+#ifdef USE_GETTEXT
+ setlocale (LC_MESSAGES, "");
+ setlocale (LC_CTYPE, "");
+ setlocale (LC_COLLATE, "");
+ textdomain ("gamesui");
+ bindtextdomain ("gamesui", NULL);
+#endif
+
+ wibble::commandline::GamesOptions opts;
+
+ try {
+ // Install the handler for unexpected exceptions
+ wibble::exception::InstallUnexpected installUnexpected;
+
+ if (opts.parse(argc, argv))
+ return 0;
+
+ if (opts.out_verbose->boolValue())
+ ::Environment::get().verbose(true);
+
+ if (opts.out_debug->boolValue())
+ ::Environment::get().debug(true);
+
+ Engine engine;
+
+ /*
+ cerr << " *** Initial:" << endl;
+ printResults(engine);
+
+ engine.setTypeFilter(engine.voc().tagByName("game::arcade"));
+ cerr << " *** Arcades:" << endl;
+ printResults(engine);
+
+ engine.setInterfaceFilter(engine.voc().tagByName("interface::x11"));
+ cerr << " *** X11 Arcades:" << endl;
+ printResults(engine);
+
+ engine.setInstalledFilter(Engine::INSTALLED);
+ cerr << " *** Installed X11 Arcades:" << endl;
+ printResults(engine);
+ */
+
+ GamesUI mainui;
+ mainui.engine = &engine;
+ Fl_Double_Window *window = mainui.CreateWindows();
+ mainui.TypeSelection->callback((Fl_Callback*)CallBackTypeSelection, &mainui);
+ mainui.TypeSelection->when(FL_WHEN_CHANGED);
+ mainui.InterfaceSelection->callback((Fl_Callback*)CallBackInterfaceSelection, &mainui);
+ mainui.InterfaceSelection->when(FL_WHEN_CHANGED);
+ mainui.SearchInput->callback((Fl_Callback*)CallBackSearchInput, &mainui);
+ mainui.SearchInput->when(FL_WHEN_CHANGED);
+ mainui.AlreadyInstalled->callback((Fl_Callback*)CallBackAlreadyInstalled, &mainui);
+ mainui.AlreadyInstalled->when(FL_WHEN_CHANGED);
+ mainui.ToBeInstalled->callback((Fl_Callback*)CallBackToBeInstalled, &mainui);
+ mainui.ToBeInstalled->when(FL_WHEN_CHANGED);
+ mainui.InstalledOrNot->callback((Fl_Callback*)CallBackInstalledOrNot, &mainui);
+ mainui.InstalledOrNot->when(FL_WHEN_CHANGED);
+
+ mainui.AlreadyInstalled->value(0); mainui.AlreadyInstalled->redraw();
+ mainui.ToBeInstalled->value(0); mainui.ToBeInstalled->redraw();
+ mainui.InstalledOrNot->value(1); mainui.InstalledOrNot->redraw();
+ mainui.engine->setInstalledFilter(Engine::ANY);
+
+ mainui.Screenshot(new Fl_PNG_Image(FILE_NO_SCREENSHOT));
+ mainui.AboutView->load(HTMLDIR "/about.en.html");
+
+ UpdateUILists(mainui);
+
+ window->show(argc, (char**)argv);
+ while (Fl::wait());
+ return 0;
+ } catch (wibble::exception::BadOption& e) {
+ cerr << e.desc() << endl;
+ opts.outputHelp(cerr);
+ return 1;
+ } catch (std::exception& e) {
+ cerr << e.what() << endl;
+ return 1;
+ } catch (Xapian::DatabaseVersionError& e) {
+ cerr << "Xapian " << e.get_type() << ": " << e.get_msg();
+ if (!e.get_context().empty())
+ cerr << ". Context: " << e.get_context();
+ cerr << endl;
+ cerr << endl;
+ cerr << "Please recreate the database by removing /var/lib/apt-xapian and running ept-cache reindex as root." << endl;
+ } catch (Xapian::Error& e) {
+ cerr << "Xapian " << e.get_type() << ": " << e.get_msg();
+ if (!e.get_context().empty())
+ cerr << ". Context: " << e.get_context();
+ cerr << endl;
+ return 1;
+ }
+
+}
+
+#include <ept/debtags/debtags.tcc>
+
+// vim:set ts=4 sw=4:
Modified: software/ui/src/manpage.cpp
===================================================================
--- software/ui/src/manpage.cpp 2007-08-24 11:56:20 UTC (rev 3805)
+++ software/ui/src/manpage.cpp 2007-08-24 12:59:12 UTC (rev 3806)
@@ -34,10 +34,10 @@
string cmd(argv[1]);
string hooks(argc > 2 ? argv[2] : "");
- if (cmd == "games")
+ if (cmd == "goplay")
{
wibble::commandline::GamesOptions opts;
- wibble::commandline::Manpage help("games", VERSION, 1, "enrico at enricozini.org,little_miry at yahoo.es");
+ wibble::commandline::Manpage help("goplay", VERSION, 1, "enrico at enricozini.org,little_miry at yahoo.es");
if (!hooks.empty())
help.readHooks(hooks);
help.output(cout, opts);
@@ -49,7 +49,7 @@
} catch (wibble::exception::BadOption& e) {
cerr << e.desc() << endl << endl;
cerr << "Usage: manpage <command>" << endl << endl;
- cerr << "Supported commands are: games" << endl;
+ cerr << "Supported commands are: goplay" << endl;
return 1;
} catch (std::exception& e) {
cerr << e.what() << endl;
More information about the Pkg-games-commits
mailing list