libyui-gtk-pkg  2.43.2
 All Classes
ygtkpkgquerywidget.h
1 /********************************************************************
2  * YaST2-GTK - http://en.opensuse.org/YaST2-GTK *
3  ********************************************************************/
4 
5 /* Abstract for widgets that support query.
6 */
7 
8 #ifndef YGTK_PKG_QUERY_WIDGET_H
9 #define YGTK_PKG_QUERY_WIDGET_H
10 
11 #include <gtk/gtk.h>
12 #include "yzyppwrapper.h"
13 
15 {
16  virtual ~YGtkPkgQueryWidget() {}
17  virtual GtkWidget *getWidget() = 0;
18 
19  // if begsUpdate is true, the current List without this filter applied
20  // will be passed to updateList() so you can e.g. avoid presenting
21  // entries for which there is no match.
22  virtual bool begsUpdate() = 0;
23  virtual void updateList (Ypp::List list) = 0;
24 
25  virtual void clearSelection() = 0;
26  virtual bool writeQuery (Ypp::PoolQuery &query) = 0;
27 
28  virtual GtkWidget *createToolbox() { return NULL; }
29 
30  struct Listener {
31  virtual void refreshQuery() = 0;
32  };
33 
34  virtual void setListener (Listener *listener) { this->listener = listener; }
35  Listener *listener;
36 
37  bool modified; // flag for internal use
38 
39  //protected:
40  void notify() { if (listener) listener->refreshQuery(); }
41 
42  void notifyDelay (int delay)
43  {
44  static guint timeout_id = 0;
45  struct inner {
46  static gboolean timeout_cb (gpointer data)
47  {
48  YGtkPkgQueryWidget *pThis = (YGtkPkgQueryWidget *) data;
49  timeout_id = 0;
50  pThis->notify();
51  return FALSE;
52  }
53  };
54  if (timeout_id) g_source_remove (timeout_id);
55  timeout_id = g_timeout_add_full (
56  G_PRIORITY_LOW, delay, inner::timeout_cb, this, NULL);
57  }
58 
59 protected:
60  YGtkPkgQueryWidget() : listener (NULL) {}
61 };
62 
63 #endif
64