Hello all,
this patch does at least these changes when package apt-xapian-index is not 
installed:

 * Only disable quick filter and show a tooltip pointing to configuration dialog
 * Add configuration option to switch it off even when package is installed.
 * Add button besides configuration option to mark package for installation.

It still adds no question on first run - do we really want to add this?
But if we do not add it I am unsure what the default setting should be?

Kind regards,
Bernhard
From 855539098c1256636a54de866a00b6a986365aad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernhard=20=C3=9Cbelacker?= <bernha...@vr-web.de>
Date: Wed, 17 Sep 2014 00:29:40 +0200
Subject: Avoid hiding quick filter when package apt-xapian-index is not
 installed.

 * Only disable quick filter and show a tooltip pointing to configuration dialog
 * Add configuration option to switch it off even when package is installed.
 * Add button besides configuration option to mark package for installation.
---
 gtk/gtkbuilder/window_preferences.ui | 47 +++++++++++++++++++++++++++++++++++-
 gtk/rgmainwindow.cc                  | 11 ++++++---
 gtk/rgpreferenceswindow.cc           | 33 +++++++++++++++++++++++++
 gtk/rgpreferenceswindow.h            |  2 ++
 4 files changed, 89 insertions(+), 4 deletions(-)

diff --git a/gtk/gtkbuilder/window_preferences.ui b/gtk/gtkbuilder/window_preferences.ui
index f291750..0e904a6 100644
--- a/gtk/gtkbuilder/window_preferences.ui
+++ b/gtk/gtkbuilder/window_preferences.ui
@@ -254,6 +254,51 @@
                               </packing>
                             </child>
                             <child>
+                              <object class="GtkHBox" id="hbox2">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="border_width">2</property>
+                                <property name="spacing">6</property>
+                                <child>
+                                  <object class="GtkCheckButton" id="check_use_xapian">
+                                    <property name="label" translatable="yes">Enable quick search box (requires package 'apt-xapian-index', not recommended for slow machines)</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="border_width">2</property>
+                                    <property name="use_underline">True</property>
+                                    <property name="xalign">0.5</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkButton" id="button_mark_xapian_for_installation">
+                                    <property name="label" translatable="yes">Mark package 'apt-xapian-index' for installation</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="use_underline">True</property>
+                                    <signal name="clicked" handler="on_button_mark_xapian_for_installation" swapped="no"/>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">3</property>
+                              </packing>
+                            </child>
+                            <child>
                               <object class="GtkTable" id="table7">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
@@ -398,7 +443,7 @@
                               <packing>
                                 <property name="expand">True</property>
                                 <property name="fill">True</property>
-                                <property name="position">3</property>
+                                <property name="position">4</property>
                               </packing>
                             </child>
                           </object>
diff --git a/gtk/rgmainwindow.cc b/gtk/rgmainwindow.cc
index cf54ae5..19e3421 100644
--- a/gtk/rgmainwindow.cc
+++ b/gtk/rgmainwindow.cc
@@ -1601,9 +1601,14 @@ void RGMainWindow::buildInterface()
    // only enable fast search if its usable
 #ifdef WITH_EPT
    if(!_lister->xapiandatabase() ||
-      !FileExists("/usr/sbin/update-apt-xapian-index")) {
-      gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object
-                                 (_builder, "vbox_fast_search")));
+      !FileExists("/usr/sbin/update-apt-xapian-index") ||
+      _config->FindB("Synaptic::useXapian", true) != true)
+   {
+      GtkWidget *fast_search = GTK_WIDGET(gtk_builder_get_object
+                                          (_builder, "entry_fast_search"));
+      gtk_widget_set_sensitive(fast_search, FALSE);
+      gtk_widget_set_tooltip_text(fast_search,
+            _("To use the quick filter please check the configuration options."));
    }
 #else
    gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object
diff --git a/gtk/rgpreferenceswindow.cc b/gtk/rgpreferenceswindow.cc
index a0e47d0..f703677 100644
--- a/gtk/rgpreferenceswindow.cc
+++ b/gtk/rgpreferenceswindow.cc
@@ -226,6 +226,10 @@ void RGPreferencesWindow::saveGeneral()
    newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_optionOneClick));
    _config->Set("Synaptic::OneClickOnStatusActions", newval ? "true" : "false");
 
+   // Enable quick search box (requires package 'apt-xapian-index', not recommended for slow machines)
+   newval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_optionUseXapian));
+   _config->Set("Synaptic::useXapian", newval ? "true" : "false");
+
    // Removal of packages: 
    int delAction = gtk_combo_box_get_active(GTK_COMBO_BOX(_comboRemovalAction));
    // ugly :( but we need this +2 because RGPkgAction starts with 
@@ -501,6 +505,11 @@ void RGPreferencesWindow::readGeneral()
                                 _config->FindB("Synaptic::OneClickOnStatusActions",
                                                false));
 
+   // Enable quick search box (requires package 'apt-xapian-index', not recommended for slow machines)
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_optionUseXapian),
+                                _config->FindB("Synaptic::useXapian",
+                                               true));
+
    // Removal of packages: 
    int delAction = _config->FindI("Synaptic::delAction", PKG_DELETE);
    // now set the combobox
@@ -836,6 +845,24 @@ void RGPreferencesWindow::readTreeViewValues()
 
 }
 
+void RGPreferencesWindow::cbMarkXapianForInstallation(GtkWidget *self, void *data)
+{
+   RGPreferencesWindow *me = (RGPreferencesWindow *) data;
+   RPackage *pkg = (RPackage *) me->_lister->getPackage("apt-xapian-index");
+   int flags = pkg->getFlags();
+
+   if(!(flags & RPackage::FInstalled) || (flags & RPackage::FOutdated)) {
+      if (pkg->availableVersion() != NULL)
+         pkg->setInstall();
+
+      // check whether something broke
+      if (!me->_lister->check())
+         me->_lister->fixBroken();
+
+      pkg->setNotify(true);
+   }
+}
+
 void RGPreferencesWindow::cbMoveColumnUp(GtkWidget *self, void *data)
 {
    //cout << "void RGPReferencesWindow::cbMoveColumnUp()" << endl;
@@ -998,6 +1025,8 @@ RGPreferencesWindow::RGPreferencesWindow(RGWindow *win,
       GTK_WIDGET(gtk_builder_get_object(_builder, "check_ask_quit"));
    _optionOneClick =
       GTK_WIDGET(gtk_builder_get_object(_builder, "check_oneclick"));
+   _optionUseXapian =
+      GTK_WIDGET(gtk_builder_get_object(_builder, "check_use_xapian"));
 
    // cache
    _cacheLeave = GTK_WIDGET(gtk_builder_get_object(_builder,
@@ -1143,6 +1172,10 @@ RGPreferencesWindow::RGPreferencesWindow(RGWindow *win,
 
 
    // lots of signals :)
+   g_signal_connect(gtk_builder_get_object(_builder, "button_mark_xapian_for_installation"),
+                    "clicked",
+                    G_CALLBACK(cbMarkXapianForInstallation), this);
+
    g_signal_connect(gtk_builder_get_object(_builder, "button_column_up"),
                     "clicked",
                     G_CALLBACK(cbMoveColumnUp), this);
diff --git a/gtk/rgpreferenceswindow.h b/gtk/rgpreferenceswindow.h
index 579fdb1..de272a5 100644
--- a/gtk/rgpreferenceswindow.h
+++ b/gtk/rgpreferenceswindow.h
@@ -55,6 +55,7 @@ class RGPreferencesWindow:public RGGtkBuilderWindow {
    GtkWidget *_optionCheckRecom;
    GtkWidget *_optionAskQuit;
    GtkWidget *_optionOneClick;
+   GtkWidget *_optionUseXapian;
 
    // cache settings
    GtkWidget *_cacheLeave;
@@ -92,6 +93,7 @@ class RGPreferencesWindow:public RGGtkBuilderWindow {
    void readTreeViewValues();
    GtkListStore *_listColumns;
    GtkWidget *_treeView;
+   static void cbMarkXapianForInstallation(GtkWidget *self, void *data);
    static void cbMoveColumnUp(GtkWidget *self, void *data);
    static void cbMoveColumnDown(GtkWidget *self, void *data);
    static void cbToggleColumn(GtkWidget *self, char *path, void *data);
-- 
2.1.0

Reply via email to