Mailinglist Archive: yast-commit (1914 mails)

< Previous Next >
[yast-commit] r58553 - in /trunk/gtk: ./ src/
  • From: rpmcruz@xxxxxxxxxxxxxxxx
  • Date: Sun, 06 Sep 2009 16:25:16 -0000
  • Message-id: <E1MkKYH-0005UO-06@xxxxxxxxxxxxxxxx>
Author: rpmcruz
Date: Sun Sep 6 18:25:16 2009
New Revision: 58553

URL: http://svn.opensuse.org/viewcvs/yast?rev=58553&view=rev
Log:
* src/ygtktooltip.h/c: re-added tooltip window.

* src/ygtknotebook.h/c: sub-notebook that allows a widget to be
installed at the empty top-right corner.

* src/YGPackageSelector.cc: replaced find pane by a find entry
at the tab-book corner.

* src/yzyppwrapper.h/cc: bug fix: highlight broken for sub-queries:
now pass Package to highlight() instead of index.

* src/yzyppwrapper.h/cc: replaced explicit PkgList::refreshProps()
for an implicit call when a package in the list is modified.

Added:
trunk/gtk/src/ygtknotebook.c
trunk/gtk/src/ygtknotebook.h
trunk/gtk/src/ygtktooltip.c
trunk/gtk/src/ygtktooltip.h
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/Makefile.am
trunk/gtk/src/YGPackageSelector.cc
trunk/gtk/src/YGUI.cc
trunk/gtk/src/ygtkfindentry.c
trunk/gtk/src/ygtkrichtext.c
trunk/gtk/src/ygtkzyppview.cc
trunk/gtk/src/yzyppwrapper.cc
trunk/gtk/src/yzyppwrapper.h

Modified: trunk/gtk/ChangeLog
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=58553&r1=58552&r2=58553&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Sun Sep 6 18:25:16 2009
@@ -1,3 +1,19 @@
+2009-09-06 Ricardo Cruz <rpmcruz@xxxxxxxxxxxxxxxxxxx>
+
+ * src/ygtktooltip.h/c: re-added tooltip window.
+
+ * src/ygtknotebook.h/c: sub-notebook that allows a widget to be
+ installed at the empty top-right corner.
+
+ * src/YGPackageSelector.cc: replaced find pane by a find entry
+ at the tab-book corner.
+
+ * src/yzyppwrapper.h/cc: bug fix: highlight broken for sub-queries:
+ now pass Package to highlight() instead of index.
+
+ * src/yzyppwrapper.h/cc: replaced explicit PkgList::refreshProps()
+ for an implicit call when a package in the list is modified.
+
2009-09-04 Ricardo Cruz <rpmcruz@xxxxxxxxxxxxxxxxxxx>

* src/YGPackageSelector.cc: fixes for online_update.

Modified: trunk/gtk/src/Makefile.am
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/Makefile.am?rev=58553&r1=58552&r2=58553&view=diff
==============================================================================
--- trunk/gtk/src/Makefile.am (original)
+++ trunk/gtk/src/Makefile.am Sun Sep 6 18:25:16 2009
@@ -66,6 +66,8 @@
ygtklinklabel.c \
ygtktextview.c \
ygtkrichtext.c \
+ ygtknotebook.c \
+ ygtktooltip.c \
ygtktreemodel.cc \
ygtkzyppview.cc \
yzyppwrapper.cc \

Modified: trunk/gtk/src/YGPackageSelector.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=58553&r1=58552&r2=58553&view=diff
==============================================================================
--- trunk/gtk/src/YGPackageSelector.cc (original)
+++ trunk/gtk/src/YGPackageSelector.cc Sun Sep 6 18:25:16 2009
@@ -21,8 +21,212 @@
#include "ygtktreeview.h"
#include "ygtkzyppview.h"

+// experimentations:
+//#define SHOW_FIND_PANE
+
+#ifndef SHOW_FIND_PANE
+#include "ygtktooltip.h"
+#endif
+
//** UI components -- split up for re-usability, but mostly for readability

+class FlexPane
+{
+GtkWidget *m_bin, *m_child1, *m_child2;
+bool m_isVertical, m_resize1, m_resize2, m_shrink1, m_shrink2;
+int m_vpos, m_hpos;
+
+public:
+ GtkWidget *getWidget() { return m_bin; }
+
+ FlexPane() : m_child1 (NULL), m_isVertical (true), m_vpos (0), m_hpos
(0)
+ {
+ m_bin = gtk_event_box_new();
+ gtk_widget_show (m_bin);
+ g_signal_connect_after (G_OBJECT (m_bin), "size-allocate",
+ G_CALLBACK (size_allocate_cb), this);
+ }
+
+ ~FlexPane()
+ {
+ g_object_unref (G_OBJECT (m_child1));
+ g_object_unref (G_OBJECT (m_child2));
+ }
+
+ void pack (GtkWidget *child, bool resize, bool shrink)
+ {
+ g_object_ref_sink (G_OBJECT (child));
+ if (m_child1) {
+ m_child2 = child; m_resize2 = resize; m_shrink2 =
shrink;
+ }
+ else {
+ m_child1 = child; m_resize1 = resize; m_shrink1 =
shrink;
+ }
+ }
+
+ void setPosition (int vpos, int hpos)
+ { m_vpos = vpos; m_hpos = hpos; }
+
+private:
+ static bool isVertical (int width)
+ { return width < 1000; } // heuristic
+
+ void setup()
+ {
+ bool isVer = isVertical (m_bin->allocation.width);
+ GtkWidget *oldPane = GTK_BIN (m_bin)->child;
+ if (!oldPane || (m_isVertical != isVer)) {
+ m_isVertical = isVer;
+ if (oldPane) {
+ gtk_container_remove (GTK_CONTAINER (oldPane),
m_child1);
+ gtk_container_remove (GTK_CONTAINER (oldPane),
m_child2);
+ gtk_container_remove (GTK_CONTAINER (m_bin),
oldPane);
+ }
+
+ GtkWidget *pane = isVer ? gtk_vpaned_new() :
gtk_hpaned_new();
+ gtk_paned_pack1 (GTK_PANED (pane), m_child1, m_resize1,
m_shrink1);
+ gtk_paned_pack2 (GTK_PANED (pane), m_child2, m_resize2,
m_shrink2);
+ if (m_hpos) {
+ int size = isVer ? m_bin->allocation.height :
m_bin->allocation.width;
+ int pos = isVer ? m_vpos : m_hpos;
+ pos = pos < 0 ? size + pos : pos;
+ gtk_paned_set_position (GTK_PANED (pane), pos);
+ }
+
+ gtk_container_add (GTK_CONTAINER (m_bin), pane);
+ gtk_widget_show (pane);
+ }
+ }
+
+ static void size_allocate_cb (GtkWidget *bin, GtkAllocation *alloc,
FlexPane *pThis)
+ { pThis->setup(); }
+};
+
+class UndoView
+{
+GtkWidget *m_vbox;
+Ypp::PkgList m_changes;
+
+public:
+ GtkWidget *getWidget() { return m_vbox; }
+
+ UndoView (YGtkPackageView::Listener *listener)
+ {
+ Ypp::PkgQuery::Query *query = new Ypp::PkgQuery::Query();
+ query->setToModify (true);
+ m_changes = Ypp::PkgQuery (Ypp::Package::PACKAGE_TYPE, query);
+
+ GtkWidget *view = createView (m_changes, listener);
+
+ GtkWidget *uncouple_button = gtk_button_new_with_label
(_("Uncouple"));
+ GtkWidget *icon = gtk_image_new_from_stock
(GTK_STOCK_DISCONNECT, GTK_ICON_SIZE_BUTTON);
+ gtk_button_set_image (GTK_BUTTON (uncouple_button), icon);
+ GtkWidget *uncouple_align = gtk_alignment_new (1, .5, 0, 1);
+ gtk_container_add (GTK_CONTAINER (uncouple_align),
uncouple_button);
+ gtk_widget_set_tooltip_text (uncouple_button, _("Open in new
window"));
+ g_signal_connect (G_OBJECT (uncouple_button), "clicked",
+ G_CALLBACK (uncouple_clicked_cb), this);
+
+ m_vbox = gtk_vbox_new (FALSE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (m_vbox), 6);
+ gtk_box_pack_start (GTK_BOX (m_vbox), view, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (m_vbox), uncouple_align, FALSE,
TRUE, 0);
+ gtk_widget_show_all (m_vbox);
+ g_object_ref_sink (m_vbox);
+ }
+
+ ~UndoView()
+ { g_object_unref (m_vbox); }
+
+private:
+ static GtkWidget *createView (const Ypp::PkgList changes,
YGtkPackageView::Listener *listener)
+ {
+ GtkWidget *hbox = gtk_hbox_new (TRUE, 6);
+ for (int i = 0; i < 3; i++) {
+ const char *str = 0, *stock = 0;
+ Ypp::PkgQuery::Query *query = new
Ypp::PkgQuery::Query();
+ int checkCol = 0;
+ switch (i) {
+ case 0:
+ str = _("To install:");
+ stock = GTK_STOCK_ADD;
+ query->setToInstall (true);
+ query->setIsInstalled (false);
+ checkCol = ZyppModel::TO_INSTALL_COLUMN;
+ break;
+ case 1:
+ str = _("To upgrade:");
+ stock = GTK_STOCK_GO_UP;
+ query->setToInstall (true);
+ query->setIsInstalled (true);
+ checkCol = ZyppModel::TO_UPGRADE_COLUMN;
+ break;
+ case 2:
+ str = _("To remove:");
+ stock = GTK_STOCK_REMOVE;
+ query->setToRemove (true);
+ checkCol = ZyppModel::TO_REMOVE_COLUMN;
+ break;
+ default: break;
+ }
+ Ypp::PkgQuery list (changes, query);
+
+ GtkWidget *label_box, *icon, *label;
+ label = gtk_label_new (str);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, .5);
+ icon = gtk_image_new_from_stock (stock,
GTK_ICON_SIZE_MENU);
+ label_box = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (label_box), icon, FALSE,
TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (label_box), label, TRUE,
TRUE, 0);
+ YGtkPackageView *view = ygtk_package_view_new (FALSE);
+ view->appendCheckColumn (checkCol);
+ view->appendTextColumn (NULL, ZyppModel::NAME_COLUMN);
+ view->setList (list, NULL);
+ view->setListener (listener);
+ gtk_scrolled_window_set_shadow_type (
+ GTK_SCROLLED_WINDOW (view), GTK_SHADOW_IN);
+
+ GtkWidget *box = gtk_vbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (box), label_box, FALSE,
TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (view),
TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), box, TRUE, TRUE, 0);
+ }
+ return hbox;
+ }
+
+ static void uncouple_clicked_cb (GtkButton *button, UndoView *pThis)
+ {
+ gtk_widget_hide (pThis->m_vbox);
+ GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Undo
History"),
+ YGDialog::currentWindow(),
GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
GTK_RESPONSE_CLOSE);
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 450);
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
+ g_signal_connect (G_OBJECT (dialog), "delete-event",
+ G_CALLBACK (uncouple_delete_event_cb), pThis);
+ g_signal_connect (G_OBJECT (dialog), "response",
+ G_CALLBACK (close_response_cb), pThis);
+
+ GtkWidget *view = createView (pThis->m_changes, NULL);
+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area
(GTK_DIALOG (dialog))), view);
+ gtk_widget_show_all (dialog);
+ }
+
+ static gboolean uncouple_delete_event_cb (
+ GtkWidget *widget, GdkEvent *event, UndoView *pThis)
+ {
+ gtk_widget_show (pThis->m_vbox);
+ return FALSE;
+ }
+
+ static void close_response_cb (GtkDialog *dialog, gint response,
UndoView *pThis)
+ {
+ gtk_widget_show (pThis->m_vbox);
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ }
+};
+
struct QueryListener {
virtual void queryNotify() = 0;
virtual void queryNotifyDelay() = 0;
@@ -441,79 +645,33 @@
{ pThis->doAll (false); }
};

-#if 0
-class FindEntry
+static const char *find_entry_tooltip =
+ _("<b>Package search:</b> Use spaces to separate your keywords. They "
+ "will be matched against RPM <i>name</i> and <i>summary</i> attributes.
"
+ "Other criteria attributes are available by pressing the search icon.\n"
+ "(usage example: \"yast dhcp\" will return yast's dhcpd tool)");
+static const char *find_entry_novelty_tooltip =
+ _("Number of days since the package was built by the repository.");
+static const char *find_entry_file_tooltip =
+ _("Note: Only applicable to installed packages.");
+static std::string findPatternTooltip (const std::string &name)
{
- m_name = ygtk_find_entry_new();
- gtk_widget_set_tooltip_markup (m_name,
- _("<b>Package search:</b> Use spaces to separate your
keywords. They "
- "will be matched against RPM <i>name</i> and
<i>summary</i> attributes. "
- "Other criteria attributes are available by pressing
the search icon.\n"
- "(usage example: \"yast dhcp\" will return yast's dhcpd
tool)"));
- ygtk_find_entry_insert_item (YGTK_FIND_ENTRY (m_name),
_("Filter by name & summary"),
- GTK_STOCK_FIND, NULL);
- ygtk_find_entry_insert_item (YGTK_FIND_ENTRY (m_name),
_("Filter by description"),
- GTK_STOCK_EDIT, NULL);
- ygtk_find_entry_insert_item (YGTK_FIND_ENTRY (m_name),
_("Filter by file"),
- GTK_STOCK_OPEN, NULL);
- ygtk_find_entry_insert_item (YGTK_FIND_ENTRY (m_name),
_("Filter by author"),
- GTK_STOCK_ABOUT, NULL);
- ygtk_find_entry_insert_item (YGTK_FIND_ENTRY (m_name),
_("Filter by novelty (in days)"),
- GTK_STOCK_NEW, _("Number of days since the package was
built by the repository."));
- g_signal_connect (G_OBJECT (m_name), "changed",
- G_CALLBACK (name_changed_cb), this);
- g_signal_connect (G_OBJECT (m_name), "menu-item-selected",
- G_CALLBACK (name_item_changed_cb), this);
-
-
-
- void clearNameEntry()
- {
- g_signal_handlers_block_by_func (m_name, (gpointer)
name_changed_cb, this);
- g_signal_handlers_block_by_func (m_name, (gpointer)
name_item_changed_cb, this);
- gtk_entry_set_text (GTK_ENTRY (m_name), "");
- ygtk_find_entry_select_item (YGTK_FIND_ENTRY (m_name), 0);
- g_signal_handlers_unblock_by_func (m_name, (gpointer)
name_changed_cb, this);
- g_signal_handlers_unblock_by_func (m_name, (gpointer)
name_item_changed_cb, this);
- }
-
-
- static void name_changed_cb (YGtkFindEntry *entry, Filters *pThis)
- {
- gint nb = ygtk_find_entry_get_selected_item (entry);
- if (nb == 4) { // novelty only allows numbers
- const gchar *text = gtk_entry_get_text (GTK_ENTRY
(entry));
- gboolean correct = TRUE;
- for (const gchar *i = text; *i; i++)
- if (!g_ascii_isdigit (*i)) {
- correct = FALSE;
- break;
- }
- ygtk_find_entry_set_state (entry, correct);
- }
- pThis->signalChangedDelay();
- }
- static void name_item_changed_cb (YGtkFindEntry *entry, gint nb,
Filters *pThis)
- {
- const gchar *text = "";
- if (nb == 4) text = "7"; // novelty is weird; show usage case
- g_signal_handlers_block_by_func (entry, (gpointer)
name_changed_cb, pThis);
- gtk_entry_set_text (GTK_ENTRY (entry), text);
- g_signal_handlers_unblock_by_func (entry, (gpointer)
name_changed_cb, pThis);
- gtk_editable_set_position (GTK_EDITABLE (entry), -1);
- ygtk_find_entry_set_state (entry, TRUE);
-
- pThis->signalChanged();
+ Ypp::PkgQuery::Query *query = new Ypp::PkgQuery::Query();
+ query->addNames (name, ' ', true, false, false, false, false, true);
+ query->setIsInstalled (false);
+ Ypp::PkgQuery pool (Ypp::Package::PATTERN_TYPE, query);
+ if (pool.size() > 0) {
+ std::string _name = pool.get (0)->name();
+ std::string text = _("Patterns are available that can "
+ "assist you in the installment of");
+ text += " <i>" + _name + "</i>.";
+ return text;
}
- static void field_changed_cb (gpointer widget, Filters *pThis)
- { pThis->signalChangedDelay(); }
-
-
-
-};
-#endif
+ return "";
+}

-class FindBox : public QueryWidget
+#ifdef SHOW_FIND_PANE
+class FindPane : public QueryWidget
{
GtkWidget *m_box, *m_name, *m_radio[5], *m_info_box, *m_info_label;
bool m_onlineUpdate;
@@ -521,16 +679,12 @@
public:
virtual GtkWidget *getWidget() { return m_box; }

- FindBox (bool onlineUpdate)
+ FindPane (bool onlineUpdate)
: m_onlineUpdate (onlineUpdate)
{
GtkWidget *name_box = gtk_hbox_new (FALSE, 6), *button;
m_name = ygtk_find_entry_new();
- gtk_widget_set_tooltip_markup (m_name,
- _("<b>Package search:</b> Use spaces to separate your
keywords. They "
- "will be matched against RPM <i>name</i> and
<i>summary</i> attributes. "
- "Other criteria attributes are available by pressing
the search icon.\n"
- "(usage example: \"yast dhcp\" will return yast's dhcpd
tool)"));
+ gtk_widget_set_tooltip_markup (m_name, find_entry_tooltip);
g_signal_connect (G_OBJECT (m_name), "changed",
G_CALLBACK (name_changed_cb), this);
button = gtk_button_new_with_label ("");
@@ -546,16 +700,14 @@
GtkRadioButton *radiob = GTK_RADIO_BUTTON (m_radio[0]);
m_radio[1] = gtk_radio_button_new_with_label_from_widget
(radiob, _("Description"));
m_radio[2] = gtk_radio_button_new_with_label_from_widget
(radiob, _("File name"));
- gtk_widget_set_tooltip_text (m_radio[2],
- _("Only applicable to installed packages."));
+ gtk_widget_set_tooltip_text (m_radio[2],
find_entry_file_tooltip);
if (m_onlineUpdate)
m_radio[3] = NULL;
else
m_radio[3] =
gtk_radio_button_new_with_label_from_widget (radiob, _("Author"));
m_radio[4] = gtk_radio_button_new_with_label_from_widget
(radiob, _("Novelty (in days)"));
g_signal_connect (G_OBJECT (m_radio[4]), "toggled", G_CALLBACK
(novelty_toggled_cb), this);
- gtk_widget_set_tooltip_markup (m_radio[4],
- _("Number of days since the package was built by the
repository."));
+ gtk_widget_set_tooltip_markup (m_radio[4],
find_entry_novelty_tooltip);
for (int i = 0; i < 5; i++)
if (m_radio [i])
gtk_box_pack_start (GTK_BOX (radio_box),
m_radio[i], FALSE, TRUE, 0);
@@ -632,25 +784,16 @@
query->addNames (name, ' ', use_name,
use_summary, use_description,
use_filelist, use_authors);
}
- if (item == 0) { // tip: the user may be unaware of
the patterns
- if (!m_onlineUpdate) {
- Ypp::PkgQuery::Query *query = new
Ypp::PkgQuery::Query();
- query->addNames (name, ' ', true,
false, false, false, false, true);
- query->setIsInstalled (false);
- Ypp::PkgQuery pool
(Ypp::Package::PATTERN_TYPE, query);
- if (pool.size() > 0) {
- std::string _name = pool.get
(0)->name();
- std::string text = _("Patterns
are available that can "
- "assist you in the
installment of");
- text += " <i>" + _name +
"</i>.";
- gtk_label_set_markup (GTK_LABEL
(m_info_label), text.c_str());
-
- int width;
- gtk_icon_size_lookup
(GTK_ICON_SIZE_MENU, &width, NULL);
- width =
getWidget()->allocation.width - width - 6;
- gtk_widget_set_size_request
(m_info_label, width, -1);
- gtk_widget_show_all
(m_info_box);
- }
+ if (item == 0 && !m_onlineUpdate) { // tip: user may
be unaware of the patterns
+ std::string text = findPatternTooltip (name);
+ if (!text.empty()) {
+ gtk_label_set_markup (GTK_LABEL
(m_info_label), text.c_str());
+ // wrapping must be performed manually
in GTK
+ int width;
+ gtk_icon_size_lookup
(GTK_ICON_SIZE_MENU, &width, NULL);
+ width = getWidget()->allocation.width -
width - 6;
+ gtk_widget_set_size_request
(m_info_label, width, -1);
+ gtk_widget_show_all (m_info_box);
}
}
}
@@ -669,7 +812,7 @@
}

private:
- static void novelty_toggled_cb (GtkToggleButton *button, FindBox *pThis)
+ static void novelty_toggled_cb (GtkToggleButton *button, FindPane
*pThis)
{
// novelty is weird; so show usage case
const gchar *text = "";
@@ -682,7 +825,7 @@
ygtk_find_entry_set_state (YGTK_FIND_ENTRY (pThis->m_name),
TRUE);
}

- static void name_changed_cb (YGtkFindEntry *entry, FindBox *pThis)
+ static void name_changed_cb (YGtkFindEntry *entry, FindPane *pThis)
{
const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry));
// novelty allows only numbers
@@ -701,36 +844,168 @@
pThis->notify();
}

- static void button_clicked_cb (GtkWidget *widget, FindBox *pThis)
+ static void button_clicked_cb (GtkWidget *widget, FindPane *pThis)
{ pThis->notify(); }
};

-class FilterCombo : public QueryWidget
+#else
+class FindEntry : public QueryWidget
{
-GtkWidget *m_box, *m_combo, *m_bin;
-bool m_onlineUpdate, m_repoMgrEnabled;
-QueryWidget *m_queryWidget;
+GtkWidget *m_name;
+bool m_onlineUpdate;
+GtkWidget *m_combo;
+
+public:
+ GtkWidget *getWidget() { return m_name; }
+
+ FindEntry (bool onlineUpdate, GtkWidget *combo) : QueryWidget()
+ , m_onlineUpdate (onlineUpdate), m_combo (combo)
+ {
+ m_name = ygtk_find_entry_new();
+ gtk_widget_set_size_request (m_name, 140, -1);
+ gtk_widget_set_tooltip_markup (m_name, find_entry_tooltip);
+ ygtk_find_entry_insert_item (YGTK_FIND_ENTRY (m_name),
+ _("Filter by name & summary"), GTK_STOCK_FIND, NULL);
+ ygtk_find_entry_insert_item (YGTK_FIND_ENTRY (m_name),
+ _("Filter by description"), GTK_STOCK_EDIT, NULL);
+ ygtk_find_entry_insert_item (YGTK_FIND_ENTRY (m_name),
+ _("Filter by file"), GTK_STOCK_OPEN,
find_entry_file_tooltip);
+ ygtk_find_entry_insert_item (YGTK_FIND_ENTRY (m_name),
+ _("Filter by author"), GTK_STOCK_ABOUT, NULL);
+ ygtk_find_entry_insert_item (YGTK_FIND_ENTRY (m_name),
_("Filter by novelty (in days)"),
+ GTK_STOCK_NEW, find_entry_novelty_tooltip);
+ g_signal_connect (G_OBJECT (m_name), "changed",
+ G_CALLBACK (name_changed_cb), this);
+ g_signal_connect (G_OBJECT (m_name), "menu-item-selected",
+ G_CALLBACK (name_item_changed_cb), this);
+ gtk_widget_show (m_name);
+ }
+
+ void clear()
+ {
+ g_signal_handlers_block_by_func (m_name, (gpointer)
name_changed_cb, this);
+ g_signal_handlers_block_by_func (m_name, (gpointer)
name_item_changed_cb, this);
+ gtk_entry_set_text (GTK_ENTRY (m_name), "");
+ ygtk_find_entry_select_item (YGTK_FIND_ENTRY (m_name), 0);
+ g_signal_handlers_unblock_by_func (m_name, (gpointer)
name_changed_cb, this);
+ g_signal_handlers_unblock_by_func (m_name, (gpointer)
name_item_changed_cb, this);
+ }
+
+ const char *searchName()
+ {
+ YGtkFindEntry *entry = YGTK_FIND_ENTRY (m_name);
+ if (ygtk_find_entry_get_selected_item (entry) == 0) {
+ const char *name = gtk_entry_get_text (GTK_ENTRY
(m_name));
+ return *name ? name : NULL;
+ }
+ return NULL;
+ }
+
+ virtual void writeQuery (Ypp::PkgQuery::Query *query)
+ {
+ const char *name = gtk_entry_get_text (GTK_ENTRY (m_name));
+ if (*name) {
+ int item = ygtk_find_entry_get_selected_item
(YGTK_FIND_ENTRY (m_name));
+ if (item >= 5) ;
+ else if (item == 4) { // novelty
+ int days = atoi (name);
+ query->setBuildAge (days);
+ }
+ else {
+ bool use_name, use_summary, use_description,
use_filelist, use_authors;
+ use_name = use_summary = use_description =
use_filelist = use_authors = false;
+ switch (item) {
+ case 0: // name & summary
+ default:
+ use_name = use_summary = true;
+ break;
+ case 1: // description
+ use_name = use_summary =
use_description = true;
+ break;
+ case 2: // file
+ use_filelist = true;
+ break;
+ case 3: // author
+ use_authors = true;
+ break;
+ }
+ query->addNames (name, ' ', use_name,
use_summary, use_description,
+ use_filelist, use_authors);
+ }
+
+ if (item == 0 && !m_onlineUpdate) { // tip: user may
be unaware of the patterns
+ std::string text = findPatternTooltip (name);
+ if (!text.empty())
+ ygtk_tooltip_show_at_widget (m_combo,
YGTK_POINTER_UP_LEFT,
+ text.c_str(),
GTK_STOCK_DIALOG_INFO);
+ }
+ }
+ }
+
+ virtual bool installedPackagesOnly()
+ { return ygtk_find_entry_get_selected_item (YGTK_FIND_ENTRY (m_name))
== 2; }
+
+private:
+ static void name_changed_cb (YGtkFindEntry *entry, FindEntry *pThis)
+ {
+ gint nb = ygtk_find_entry_get_selected_item (entry);
+ if (nb == 4) { // novelty only allows numbers
+ const gchar *text = gtk_entry_get_text (GTK_ENTRY
(entry));
+ gboolean correct = TRUE;
+ for (const gchar *i = text; *i; i++)
+ if (!g_ascii_isdigit (*i)) {
+ correct = FALSE;
+ break;
+ }
+ ygtk_find_entry_set_state (entry, correct);
+ }
+ pThis->notifyDelay();
+ }
+
+ static void name_item_changed_cb (YGtkFindEntry *entry, gint nb,
FindEntry *pThis)
+ {
+ const gchar *text = "";
+ if (nb == 4) text = "7"; // novelty is weird; show usage case
+ g_signal_handlers_block_by_func (entry, (gpointer)
name_changed_cb, pThis);
+ gtk_entry_set_text (GTK_ENTRY (entry), text);
+ g_signal_handlers_unblock_by_func (entry, (gpointer)
name_changed_cb, pThis);
+ gtk_editable_set_position (GTK_EDITABLE (entry), -1);
+ ygtk_find_entry_set_state (entry, TRUE);
+ pThis->notify();
+ }
+};
+#endif
+
+class FilterCombo : public QueryWidget
+{
+GtkWidget *m_box, *m_combo, *m_bin;
+bool m_onlineUpdate, m_repoMgrEnabled;
+QueryWidget *m_queryWidget;

public:
virtual GtkWidget *getWidget() { return m_box; }
+ GtkWidget *getComboBox() { return m_combo; }

- FilterCombo (QueryListener *listener, bool onlineUpdate, bool
repoMgrEnabled)
+ FilterCombo (bool onlineUpdate, bool repoMgrEnabled)
: QueryWidget(), m_onlineUpdate (onlineUpdate), m_repoMgrEnabled
(repoMgrEnabled),
m_queryWidget (NULL)
{
- setListener (listener);
m_combo = gtk_combo_box_new_text();
if (onlineUpdate)
gtk_combo_box_append_text (GTK_COMBO_BOX (m_combo),
_("Severity"));
else {
+ #ifdef SHOW_FIND_PANE
gtk_combo_box_append_text (GTK_COMBO_BOX (m_combo),
_("Search"));
+ #endif
gtk_combo_box_append_text (GTK_COMBO_BOX (m_combo),
_("Groups"));
gtk_combo_box_append_text (GTK_COMBO_BOX (m_combo),
_("Patterns"));
gtk_combo_box_append_text (GTK_COMBO_BOX (m_combo),
_("Languages"));
gtk_widget_set_tooltip_markup (m_combo,
_("Packages can be organized in:\n"
+ #ifdef SHOW_FIND_PANE
"<b>Search:</b> find a given package by name,
summary or some "
"other attribute.\n"
+ #endif
"<b>Groups:</b> simple categorization of
packages by purpose.\n"
"<b>Patterns:</b> assists in installing all
packages necessary "
"for several working environments.\n"
@@ -761,21 +1036,14 @@
virtual bool installedPackagesOnly()
{ return m_queryWidget->installedPackagesOnly(); }

+ #ifdef SHOW_FIND_PANE
const char *searchName()
{
if (gtk_combo_box_get_active (GTK_COMBO_BOX (m_combo)) == 0)
- return ((FindBox *) m_queryWidget)->searchName();
+ return ((FindPane *) m_queryWidget)->searchName();
return NULL;
}
-
-private:
- void set (GtkWidget *widget)
- {
- if (GTK_BIN (m_bin)->child)
- gtk_container_remove (GTK_CONTAINER (m_bin), GTK_BIN
(m_bin)->child);
- gtk_container_add (GTK_CONTAINER (m_bin), widget);
- gtk_widget_show_all (m_bin);
- }
+ #endif

void select (int nb)
{
@@ -788,8 +1056,12 @@
}
}
else {
+ #ifdef SHOW_FIND_PANE
switch (nb) {
- case 0: m_queryWidget = new FindBox
(m_onlineUpdate); break;
+ case 0: m_queryWidget = new FindPane
(m_onlineUpdate); break;
+ #else
+ switch (nb+1) {
+ #endif
case 1: m_queryWidget = new Categories
(m_onlineUpdate); break;
case 2: m_queryWidget = new Collection
(Ypp::Package::PATTERN_TYPE); break;
case 3: m_queryWidget = new Collection
(Ypp::Package::LANGUAGE_TYPE); break;
@@ -798,213 +1070,27 @@
}
}
m_queryWidget->setListener (m_listener);
- set (m_queryWidget->getWidget());
+ setChild (m_queryWidget->getWidget());
}

- static void combo_changed_cb (GtkComboBox *combo, FilterCombo *pThis)
- {
- pThis->select (gtk_combo_box_get_active (combo));
- pThis->notify();
- }
-};
-
-class FlexPane
-{
-GtkWidget *m_bin, *m_child1, *m_child2;
-bool m_isVertical, m_resize1, m_resize2, m_shrink1, m_shrink2;
-int m_vpos, m_hpos;
-
-public:
- GtkWidget *getWidget() { return m_bin; }
-
- FlexPane() : m_child1 (NULL), m_isVertical (true), m_vpos (0), m_hpos
(0)
- {
- m_bin = gtk_event_box_new();
- gtk_widget_show (m_bin);
- g_signal_connect_after (G_OBJECT (m_bin), "size-allocate",
- G_CALLBACK (size_allocate_cb), this);
- }
-
- ~FlexPane()
- {
- g_object_unref (G_OBJECT (m_child1));
- g_object_unref (G_OBJECT (m_child2));
- }
-
- void pack (GtkWidget *child, bool resize, bool shrink)
- {
- g_object_ref_sink (G_OBJECT (child));
- if (m_child1) {
- m_child2 = child; m_resize2 = resize; m_shrink2 =
shrink;
- }
- else {
- m_child1 = child; m_resize1 = resize; m_shrink1 =
shrink;
- }
- }
-
- void setPosition (int vpos, int hpos)
- { m_vpos = vpos; m_hpos = hpos; }
-
private:
- static bool isVertical (int width)
- { return width < 1000; } // heuristic
-
- void setup()
- {
- bool isVer = isVertical (m_bin->allocation.width);
- GtkWidget *oldPane = GTK_BIN (m_bin)->child;
- if (!oldPane || (m_isVertical != isVer)) {
- m_isVertical = isVer;
- if (oldPane) {
- gtk_container_remove (GTK_CONTAINER (oldPane),
m_child1);
- gtk_container_remove (GTK_CONTAINER (oldPane),
m_child2);
- gtk_container_remove (GTK_CONTAINER (m_bin),
oldPane);
- }
-
- GtkWidget *pane = isVer ? gtk_vpaned_new() :
gtk_hpaned_new();
- gtk_paned_pack1 (GTK_PANED (pane), m_child1, m_resize1,
m_shrink1);
- gtk_paned_pack2 (GTK_PANED (pane), m_child2, m_resize2,
m_shrink2);
- if (m_hpos) {
- int size = isVer ? m_bin->allocation.height :
m_bin->allocation.width;
- int pos = isVer ? m_vpos : m_hpos;
- pos = pos < 0 ? size + pos : pos;
- gtk_paned_set_position (GTK_PANED (pane), pos);
- }
-
- gtk_container_add (GTK_CONTAINER (m_bin), pane);
- gtk_widget_show (pane);
- }
- }
-
- static void size_allocate_cb (GtkWidget *bin, GtkAllocation *alloc,
FlexPane *pThis)
- { pThis->setup(); }
-};
-
-class UndoView
-{
-GtkWidget *m_vbox;
-Ypp::PkgList m_changes;
-
-public:
- GtkWidget *getWidget() { return m_vbox; }
-
- UndoView (YGtkPackageView::Listener *listener)
- {
- Ypp::PkgQuery::Query *query = new Ypp::PkgQuery::Query();
- query->setToModify (true);
- m_changes = Ypp::PkgQuery (Ypp::Package::PACKAGE_TYPE, query);
-
- GtkWidget *view = createView (m_changes, listener);
-
- GtkWidget *uncouple_button = gtk_button_new_with_label
(_("Uncouple"));
- GtkWidget *icon = gtk_image_new_from_stock
(GTK_STOCK_DISCONNECT, GTK_ICON_SIZE_BUTTON);
- gtk_button_set_image (GTK_BUTTON (uncouple_button), icon);
- GtkWidget *uncouple_align = gtk_alignment_new (1, .5, 0, 1);
- gtk_container_add (GTK_CONTAINER (uncouple_align),
uncouple_button);
- gtk_widget_set_tooltip_text (uncouple_button, _("Open in new
window"));
- g_signal_connect (G_OBJECT (uncouple_button), "clicked",
- G_CALLBACK (uncouple_clicked_cb), this);
-
- m_vbox = gtk_vbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (m_vbox), 6);
- gtk_box_pack_start (GTK_BOX (m_vbox), view, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (m_vbox), uncouple_align, FALSE,
TRUE, 0);
- gtk_widget_show_all (m_vbox);
- g_object_ref_sink (m_vbox);
- }
-
- ~UndoView()
- { g_object_unref (m_vbox); }
-
-private:
- static GtkWidget *createView (const Ypp::PkgList changes,
YGtkPackageView::Listener *listener)
+ void setChild (GtkWidget *widget)
{
- GtkWidget *hbox = gtk_hbox_new (TRUE, 6);
- for (int i = 0; i < 3; i++) {
- const char *str = 0, *stock = 0;
- Ypp::PkgQuery::Query *query = new
Ypp::PkgQuery::Query();
- int checkCol = 0;
- switch (i) {
- case 0:
- str = _("To install:");
- stock = GTK_STOCK_ADD;
- query->setToInstall (true);
- query->setIsInstalled (false);
- checkCol = ZyppModel::TO_INSTALL_COLUMN;
- break;
- case 1:
- str = _("To upgrade:");
- stock = GTK_STOCK_GO_UP;
- query->setToInstall (true);
- query->setIsInstalled (true);
- checkCol = ZyppModel::TO_UPGRADE_COLUMN;
- break;
- case 2:
- str = _("To remove:");
- stock = GTK_STOCK_REMOVE;
- query->setToRemove (true);
- checkCol = ZyppModel::TO_REMOVE_COLUMN;
- break;
- default: break;
- }
- Ypp::PkgQuery list (changes, query);
-
- GtkWidget *label_box, *icon, *label;
- label = gtk_label_new (str);
- gtk_misc_set_alignment (GTK_MISC (label), 0, .5);
- icon = gtk_image_new_from_stock (stock,
GTK_ICON_SIZE_MENU);
- label_box = gtk_hbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (label_box), icon, FALSE,
TRUE, 0);
- gtk_box_pack_start (GTK_BOX (label_box), label, TRUE,
TRUE, 0);
- YGtkPackageView *view = ygtk_package_view_new (FALSE);
- view->appendCheckColumn (checkCol);
- view->appendTextColumn (NULL, ZyppModel::NAME_COLUMN);
- view->setList (list, NULL);
- view->setListener (listener);
- gtk_scrolled_window_set_shadow_type (
- GTK_SCROLLED_WINDOW (view), GTK_SHADOW_IN);
-
- GtkWidget *box = gtk_vbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (box), label_box, FALSE,
TRUE, 0);
- gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (view),
TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), box, TRUE, TRUE, 0);
- }
- return hbox;
- }
-
- static void uncouple_clicked_cb (GtkButton *button, UndoView *pThis)
- {
- gtk_widget_hide (pThis->m_vbox);
- GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Undo
History"),
- YGDialog::currentWindow(),
GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
GTK_RESPONSE_CLOSE);
- gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 450);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
- g_signal_connect (G_OBJECT (dialog), "delete-event",
- G_CALLBACK (uncouple_delete_event_cb), pThis);
- g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (close_response_cb), pThis);
-
- GtkWidget *view = createView (pThis->m_changes, NULL);
- gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area
(GTK_DIALOG (dialog))), view);
- gtk_widget_show_all (dialog);
- }
-
- static gboolean uncouple_delete_event_cb (
- GtkWidget *widget, GdkEvent *event, UndoView *pThis)
- {
- gtk_widget_show (pThis->m_vbox);
- return FALSE;
+ if (GTK_BIN (m_bin)->child)
+ gtk_container_remove (GTK_CONTAINER (m_bin), GTK_BIN
(m_bin)->child);
+ gtk_container_add (GTK_CONTAINER (m_bin), widget);
+ gtk_widget_show_all (m_bin);
}

- static void close_response_cb (GtkDialog *dialog, gint response,
UndoView *pThis)
+ static void combo_changed_cb (GtkComboBox *combo, FilterCombo *pThis)
{
- gtk_widget_show (pThis->m_vbox);
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ pThis->select (gtk_combo_box_get_active (combo));
+ pThis->notify();
}
};

+#include "ygtknotebook.h"
+
class QueryNotebook : public QueryListener, YGtkPackageView::Listener
{
GtkWidget *m_widget, *m_notebook;
@@ -1017,6 +1103,9 @@
bool m_disabledTab, m_highlightTab;
UndoView *m_undoView;
Ypp::PkgList m_packages, m_pool;
+#ifndef SHOW_FIND_PANE
+FindEntry *m_find;
+#endif

public:
GtkWidget *getWidget() { return m_widget; }
@@ -1025,27 +1114,14 @@
: m_onlineUpdate (onlineUpdate), m_timeout_id (0), m_disabledTab
(true), m_highlightTab (false),
m_undoView (NULL)
{
- m_notebook = gtk_notebook_new();
+ m_notebook = ygtk_notebook_new();
+ gtk_widget_show (m_notebook);
appendPage (0, _("_Install"), GTK_STOCK_ADD);
if (!onlineUpdate)
appendPage (1, _("_Upgrade"), GTK_STOCK_GO_UP);
appendPage (2, _("_Remove"), GTK_STOCK_REMOVE);
if (!onlineUpdate)
appendPage (3, _("_Undo"), GTK_STOCK_UNDO);
- gtk_widget_show (m_notebook);
- g_signal_connect (G_OBJECT (m_notebook), "switch-page",
- G_CALLBACK (switch_page_cb), this);
-
-#if 0 // test: put search entry as a new tab (since we can't make use of the
empty space...)
- GtkWidget *entry = ygtk_find_entry_new();
- gtk_widget_show (entry);
- GtkWidget *page = gtk_event_box_new();
- gtk_widget_show (page);
- gtk_notebook_append_page (GTK_NOTEBOOK (m_notebook), page,
entry);
- gtk_notebook_set_tab_label_packing (
- GTK_NOTEBOOK (m_notebook), page, TRUE, TRUE,
GTK_PACK_START);
- g_object_set (G_OBJECT (m_notebook), "tab-vborder", 0, NULL);
-#endif

m_details = YGTK_DETAIL_VIEW (ygtk_detail_view_new
(onlineUpdate));
m_pane = new FlexPane();
@@ -1053,16 +1129,24 @@
m_pane->pack (GTK_WIDGET (m_details), false, false);
m_pane->setPosition (-175, -500);

- m_combo = new FilterCombo (this, onlineUpdate, repoMgrEnabled);
+ m_combo = new FilterCombo (onlineUpdate, repoMgrEnabled);
+ m_combo->setListener (this);
+ m_combo->select (0);
GtkWidget *hpane = gtk_hpaned_new();
gtk_paned_pack1 (GTK_PANED (hpane), m_combo->getWidget(),
FALSE, TRUE);
gtk_paned_pack2 (GTK_PANED (hpane), m_pane->getWidget(), TRUE,
FALSE);
- gtk_paned_set_position (GTK_PANED (hpane), 180);
+ gtk_paned_set_position (GTK_PANED (hpane), 160);

m_widget = hpane;
gtk_widget_show_all (m_widget);
gtk_widget_hide (GTK_WIDGET (m_details));

+ #ifndef SHOW_FIND_PANE
+ m_find = new FindEntry (onlineUpdate, m_combo->getComboBox());
+ ygtk_notebook_set_corner_widget (YGTK_NOTEBOOK (m_notebook),
m_find->getWidget());
+ m_find->setListener (this);
+ #endif
+
Ypp::Package::Type type = Ypp::Package::PACKAGE_TYPE;
if (m_onlineUpdate)
type = Ypp::Package::PATCH_TYPE;
@@ -1077,6 +1161,9 @@
delete m_undoView;
delete m_combo;
delete m_pane;
+ #ifndef SHOW_FIND_PANE
+ delete m_find;
+ #endif
}

void setUndoPage()
@@ -1086,57 +1173,6 @@
}

private:
- void appendPage (int nb, const char *text, const char *stock)
- {
- GtkWidget *hbox = gtk_hbox_new (FALSE, 6), *label, *icon;
- if (stock) {
- icon = gtk_image_new_from_stock (stock,
GTK_ICON_SIZE_MENU);
- gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, TRUE,
0);
- }
- label = gtk_label_new (text);
- gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
- g_object_set_data (G_OBJECT (hbox), "label", label);
- gtk_widget_show_all (hbox);
-
- GtkWidget *page;
- if (nb < 3) {
- int col;
- switch (nb) {
- default:
- case 0: col = ZyppModel::TO_INSTALL_COLUMN;
break;
- case 1: col = ZyppModel::TO_UPGRADE_COLUMN;
break;
- case 2: col = ZyppModel::TO_REMOVE_COLUMN;
break;
- }
- YGtkPackageView *view = ygtk_package_view_new (FALSE);
- view->appendCheckColumn (col);
- int nameSize = (col == ZyppModel::TO_UPGRADE_COLUMN) ?
-1 : 150;
- view->appendTextColumn (_("Name"),
ZyppModel::NAME_COLUMN, nameSize);
- if (col == ZyppModel::TO_UPGRADE_COLUMN) {
- view->appendTextColumn (_("Installed"),
ZyppModel::INSTALLED_VERSION_COLUMN, 150);
- view->appendTextColumn (_("Available"),
ZyppModel::AVAILABLE_VERSION_COLUMN, 150);
- }
- else
- view->appendTextColumn (_("Summary"),
ZyppModel::SUMMARY_COLUMN);
- view->setListener (this);
- page = GTK_WIDGET (view);
- }
- else {
- m_undoView = new UndoView (this);
- page = m_undoView->getWidget();
- }
- gtk_notebook_append_page (GTK_NOTEBOOK (m_notebook), page,
hbox);
- }
-
- void setTabLabelWeight (int page, PangoWeight weight)
- {
- GtkNotebook *notebook = GTK_NOTEBOOK (m_notebook);
- GtkWidget *label = gtk_notebook_get_tab_label (notebook,
- gtk_notebook_get_nth_page (notebook, page));
- label = (GtkWidget *) g_object_get_data (G_OBJECT (label),
"label");
- YGUtils::setWidgetFont (label, PANGO_STYLE_NORMAL, weight,
PANGO_SCALE_MEDIUM);
- }
-
const char *getTooltip (int page)
{
if (m_onlineUpdate && page > 0)
@@ -1151,42 +1187,23 @@
return NULL;
}

- void setEnabled (int page_nb, bool enabled, int new_page_nb = -1)
- {
- GtkNotebook *notebook = GTK_NOTEBOOK (m_notebook);
- GtkWidget *page = gtk_notebook_get_nth_page (notebook, page_nb);
- if (page) {
- GtkWidget *label = gtk_notebook_get_tab_label
(notebook, page);
- gtk_widget_set_sensitive (label, enabled);
- const char *tooltip = getTooltip (page_nb);
- if (!enabled)
- tooltip = _("Query only applicable to available
packages.");
- gtk_widget_set_tooltip_text (label, tooltip);
- if (!enabled && new_page_nb >= 0) {
- GtkWidget *selected = gtk_notebook_get_nth_page
(notebook,
- gtk_notebook_get_current_page
(notebook));
- if (selected == page)
- gtk_notebook_set_current_page
(notebook, new_page_nb);
- }
- }
- }
-
+ // callbacks
virtual void queryNotify()
{
if (m_disabledTab) { // limit users to the tabs whose query is
applicable
m_disabledTab = false;
for (int i = 0; i < 4; i++)
- setEnabled (i, true);
+ enablePage (i, true);
}
if (m_combo->availablePackagesOnly()) {
- setEnabled (1, false);
+ enablePage (1, false);
if (!m_onlineUpdate)
- setEnabled (2, false, 0);
+ enablePage (2, false, 0);
m_disabledTab = true;
}
else if (m_combo->installedPackagesOnly()) {
int new_page = m_onlineUpdate ? 1 : 2;
- setEnabled (0, false, new_page);
+ enablePage (0, false, new_page);
m_disabledTab = true;
}

@@ -1197,6 +1214,9 @@
}

Ypp::PkgQuery::Query *query = new Ypp::PkgQuery::Query();
+ #ifndef SHOW_FIND_PANE
+ m_find->writeQuery (query);
+ #endif
m_combo->writeQuery (query);
m_pool = Ypp::PkgQuery (m_packages, query);

@@ -1235,10 +1255,14 @@
// set tab label bold if there's a package there with
the name
if (m_highlightTab) {
for (int i = 0; i < 3; i++)
- setTabLabelWeight (i,
PANGO_WEIGHT_NORMAL);
+ highlightPage (i, false);
m_highlightTab = false;
}
+ #ifdef SHOW_FIND_PANE
const char *name = m_combo->searchName();
+ #else
+ const char *name = m_find->searchName();
+ #endif
if (name) {
Ypp::PkgQuery::Query *query = new
Ypp::PkgQuery::Query();
query->addNames (name, 0, true, false, false,
false, false, true, true);
@@ -1247,11 +1271,11 @@
m_highlightTab = true;
Ypp::Package *pkg = list.get (0);
if (!pkg->isInstalled())
- setTabLabelWeight (0,
PANGO_WEIGHT_BOLD);
+ highlightPage (0, true);
else {
- setTabLabelWeight (2,
PANGO_WEIGHT_BOLD);
+ highlightPage (2, true);
if (pkg->hasUpgrade())
- setTabLabelWeight (1,
PANGO_WEIGHT_BOLD);
+ highlightPage (1, true);
}
}
}
@@ -1280,25 +1304,77 @@
gtk_widget_show (GTK_WIDGET (m_details));
}

- static void switch_page_cb (GtkNotebook *notebook, GtkNotebookPage *,
- gint page_nb, QueryNotebook *pThis)
- { // don't let user selected insensitive tab
+ // utilities
+ void appendPage (int nb, const char *text, const char *stock)
+ {
+ GtkWidget *hbox = gtk_hbox_new (FALSE, 6), *label, *icon;
+ if (stock) {
+ icon = gtk_image_new_from_stock (stock,
GTK_ICON_SIZE_MENU);
+ gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, TRUE,
0);
+ }
+ label = gtk_label_new (text);
+ gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
+ g_object_set_data (G_OBJECT (hbox), "label", label);
+ gtk_widget_show_all (hbox);
+
+ GtkWidget *page;
+ if (nb < 3) {
+ int col;
+ switch (nb) {
+ default:
+ case 0: col = ZyppModel::TO_INSTALL_COLUMN;
break;
+ case 1: col = ZyppModel::TO_UPGRADE_COLUMN;
break;
+ case 2: col = ZyppModel::TO_REMOVE_COLUMN;
break;
+ }
+ YGtkPackageView *view = ygtk_package_view_new (FALSE);
+ view->appendCheckColumn (col);
+ int nameSize = (col == ZyppModel::TO_UPGRADE_COLUMN) ?
-1 : 150;
+ view->appendTextColumn (_("Name"),
ZyppModel::NAME_COLUMN, nameSize);
+ if (col == ZyppModel::TO_UPGRADE_COLUMN) {
+ view->appendTextColumn (_("Installed"),
ZyppModel::INSTALLED_VERSION_COLUMN, 150);
+ view->appendTextColumn (_("Available"),
ZyppModel::AVAILABLE_VERSION_COLUMN, 150);
+ }
+ else
+ view->appendTextColumn (_("Summary"),
ZyppModel::SUMMARY_COLUMN);
+ view->setListener (this);
+ page = GTK_WIDGET (view);
+ }
+ else {
+ m_undoView = new UndoView (this);
+ page = m_undoView->getWidget();
+ }
+ gtk_notebook_append_page (GTK_NOTEBOOK (m_notebook), page,
hbox);
+ }
+
+ void enablePage (int page_nb, bool enabled, int new_page_nb = -1)
+ {
+ GtkNotebook *notebook = GTK_NOTEBOOK (m_notebook);
GtkWidget *page = gtk_notebook_get_nth_page (notebook, page_nb);
- GtkWidget *label = gtk_notebook_get_tab_label (notebook, page);
- if (!GTK_WIDGET_IS_SENSITIVE (label)) { // change back to
current page
- int page_nb = gtk_notebook_get_current_page (notebook);
- // seems like GTK doesn't like changing current page
here
- g_object_set_data (G_OBJECT (notebook), "to-page",
GINT_TO_POINTER (page_nb));
- g_idle_add_full (G_PRIORITY_HIGH_IDLE,
change_page_idle_cb, notebook, NULL);
+ if (page) {
+ GtkWidget *label = gtk_notebook_get_tab_label
(notebook, page);
+ gtk_widget_set_sensitive (label, enabled);
+ const char *tooltip = getTooltip (page_nb);
+ if (!enabled)
+ tooltip = _("Query only applicable to available
packages.");
+ gtk_widget_set_tooltip_text (label, tooltip);
+ if (!enabled && new_page_nb >= 0) {
+ GtkWidget *selected = gtk_notebook_get_nth_page
(notebook,
+ gtk_notebook_get_current_page
(notebook));
+ if (selected == page)
+ gtk_notebook_set_current_page
(notebook, new_page_nb);
+ }
}
}

- static gboolean change_page_idle_cb (gpointer data)
+ void highlightPage (int page_nb, bool highlight)
{
- GtkNotebook *notebook = (GtkNotebook *) data;
- int page_nb = GPOINTER_TO_INT (g_object_get_data (G_OBJECT
(notebook), "to-page"));
- gtk_notebook_set_current_page (notebook, page_nb);
- return FALSE;
+ GtkNotebook *notebook = GTK_NOTEBOOK (m_notebook);
+ GtkWidget *label = gtk_notebook_get_tab_label (notebook,
+ gtk_notebook_get_nth_page (notebook, page_nb));
+ label = (GtkWidget *) g_object_get_data (G_OBJECT (label),
"label");
+ YGUtils::setWidgetFont (label, PANGO_STYLE_NORMAL,
+ highlight ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
PANGO_SCALE_MEDIUM);
}
};


Modified: trunk/gtk/src/YGUI.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGUI.cc?rev=58553&r1=58552&r2=58553&view=diff
==============================================================================
--- trunk/gtk/src/YGUI.cc (original)
+++ trunk/gtk/src/YGUI.cc Sun Sep 6 18:25:16 2009
@@ -84,7 +84,12 @@
// intern the domain - that can be allocated (or belong to a transient
// plugin's address space).
const char *component = domain ? g_intern_string (domain) : "yast2-gtk";
- YUILog::instance()->log (ylevel, component, "yast2-gtk", 0, "") <<
message;
+ YUILog::instance()->log (ylevel, component, "yast2-gtk", 0, "") <<
message << std::endl;
+#if 0 // uncomment to put a stop to gdb
+ static int bugStop = 0;
+ if (bugStop-- <= 0)
+ abort();
+#endif
}

void YGUI::checkInit()

Modified: trunk/gtk/src/ygtkfindentry.c
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkfindentry.c?rev=58553&r1=58552&r2=58553&view=diff
==============================================================================
--- trunk/gtk/src/ygtkfindentry.c (original)
+++ trunk/gtk/src/ygtkfindentry.c Sun Sep 6 18:25:16 2009
@@ -301,7 +301,7 @@
if (entry->find_icon) {
left_border = gdk_pixbuf_get_width (entry->find_icon) + 2;
if (entry->context_menu)
- left_border += ARROW_SIZE - 1;
+ left_border += ARROW_SIZE;
}
if (entry->clear_icon)
right_border = gdk_pixbuf_get_width (entry->clear_icon) + 2;
@@ -365,17 +365,22 @@
GdkWindow *hover_window = gdk_display_get_window_at_pointer (
gtk_widget_get_display (widget), NULL, NULL);

- if (event->window == eentry->left_window ||
- event->window == eentry->right_window) {
+ if (event->window == eentry->left_window || event->window ==
eentry->right_window) {
gboolean hover = hover_window == event->window;
+ int win_width, win_height;
+ gdk_drawable_get_size (event->window, &win_width, &win_height);
+
+/* if (fentry->context_menu && event->window ==
eentry->left_window)
+ gtk_paint_box (widget->style, event->window,
GTK_STATE_NORMAL,
+ GTK_SHADOW_OUT, &event->area, widget,
"combobox",
+ 0, 0, win_width, win_height);*/
+
GdkPixbuf *pixbuf;
if (event->window == eentry->left_window)
pixbuf = hover ? fentry->find_hover_icon :
fentry->find_icon;
else
pixbuf = hover ? fentry->clear_hover_icon :
fentry->clear_icon;
-
- int pix_height = gdk_pixbuf_get_height (pixbuf), win_width,
win_height, y;
- gdk_drawable_get_size (event->window, &win_width, &win_height);
+ int pix_height = gdk_pixbuf_get_height (pixbuf), y;
y = (win_height - pix_height) / 2;

gdk_draw_pixbuf (event->window, widget->style->fg_gc[0], pixbuf,
@@ -383,10 +388,8 @@

if (fentry->context_menu && event->window ==
eentry->left_window)
gtk_paint_arrow (widget->style, event->window,
GTK_STATE_NORMAL,
- GTK_SHADOW_NONE, &event->area, widget,
NULL,
- GTK_ARROW_DOWN, FALSE,
- win_width - ARROW_SIZE - 1, win_height
- ARROW_SIZE,
- ARROW_SIZE, ARROW_SIZE);
+ GTK_SHADOW_NONE, &event->area, widget, NULL,
GTK_ARROW_DOWN, FALSE,
+ win_width - ARROW_SIZE-1, win_height -
ARROW_SIZE, ARROW_SIZE, ARROW_SIZE);
}
else
GTK_WIDGET_CLASS (ygtk_find_entry_parent_class)->expose_event
(widget, event);

Added: trunk/gtk/src/ygtknotebook.c
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtknotebook.c?rev=58553&view=auto
==============================================================================
--- trunk/gtk/src/ygtknotebook.c (added)
+++ trunk/gtk/src/ygtknotebook.c Sun Sep 6 18:25:16 2009
@@ -0,0 +1,116 @@
+/********************************************************************
+ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK *
+ ********************************************************************/
+
+/* YGtkNotebook widget */
+// check the header file for information about this widget
+
+#include <config.h>
+#include "ygtknotebook.h"
+#include <gtk/gtk.h>
+
+extern void ygutils_setWidgetFont (GtkWidget *widget, PangoStyle style,
+ PangoWeight weight, double scale);
+
+G_DEFINE_TYPE (YGtkNotebook, ygtk_notebook, GTK_TYPE_NOTEBOOK)
+
+static void ygtk_notebook_init (YGtkNotebook *view)
+{
+}
+
+static void ygtk_notebook_size_request (GtkWidget *widget, GtkRequisition
*requisition)
+{
+ GTK_WIDGET_CLASS (ygtk_notebook_parent_class)->size_request (widget,
requisition);
+ YGtkNotebook *notebook = YGTK_NOTEBOOK (widget);
+ if (notebook->corner_widget) {
+ GtkRequisition child_req; // many widgets like size_request
asked
+ gtk_widget_size_request (notebook->corner_widget, &child_req);
+ }
+}
+
+static void ygtk_notebook_size_allocate (GtkWidget *widget, GtkAllocation
*allocation)
+{
+ GTK_WIDGET_CLASS (ygtk_notebook_parent_class)->size_allocate (widget,
allocation);
+ YGtkNotebook *ynotebook = YGTK_NOTEBOOK (widget);
+ if (ynotebook->corner_widget) {
+ GtkRequisition child_req;
+ gtk_widget_get_child_requisition (ynotebook->corner_widget,
&child_req);
+
+ GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+ int npages = gtk_notebook_get_n_pages (notebook);
+ GtkWidget *last_label = gtk_notebook_get_nth_page (notebook,
npages-1);
+ if (last_label)
+ last_label = gtk_notebook_get_tab_label (notebook,
last_label);
+ int tabs_width = 0;
+ if (last_label)
+ tabs_width = last_label->allocation.x +
last_label->allocation.width + 8;
+
+ GtkAllocation child_alloc;
+ child_alloc.width = MIN (allocation->width - tabs_width,
child_req.width);
+ child_alloc.height = child_req.height;
+ child_alloc.x = allocation->x + (allocation->width -
child_alloc.width);
+ child_alloc.y = allocation->y + 3;
+
+ gtk_widget_size_allocate (ynotebook->corner_widget,
&child_alloc);
+ }
+}
+
+static void ygtk_notebook_forall (GtkContainer *container, gboolean
include_internals,
+ GtkCallback callback, gpointer callback_data)
+{
+ g_return_if_fail (callback != NULL);
+ if (include_internals) {
+ YGtkNotebook *notebook = YGTK_NOTEBOOK (container);
+ if (notebook->corner_widget)
+ (* callback) (notebook->corner_widget, callback_data);
+ }
+ GTK_CONTAINER_CLASS (ygtk_notebook_parent_class)->forall (
+ container, include_internals, callback, callback_data);
+}
+
+static void ygtk_notebook_map (GtkWidget *widget)
+{
+ GTK_WIDGET_CLASS (ygtk_notebook_parent_class)->map (widget);
+ YGtkNotebook *notebook = YGTK_NOTEBOOK (widget);
+ if (notebook->corner_widget) {
+ GtkWidget *corner = notebook->corner_widget;
+ if (corner && GTK_WIDGET_VISIBLE (corner) && !GTK_WIDGET_MAPPED
(corner))
+ gtk_widget_map (corner);
+ }
+}
+
+static void ygtk_notebook_switch_page (
+ GtkNotebook *notebook, GtkNotebookPage *_page, guint page_nb)
+{ // don't let user select insensitive tab
+ GtkWidget *page = gtk_notebook_get_nth_page (notebook, page_nb);
+ GtkWidget *label = gtk_notebook_get_tab_label (notebook, page);
+ if (label && !GTK_WIDGET_IS_SENSITIVE (label))
+ ; // insensitive; don't call parent
+ else
+ GTK_NOTEBOOK_CLASS (ygtk_notebook_parent_class)->switch_page (
+ notebook, _page, page_nb);
+}
+
+void ygtk_notebook_set_corner_widget (YGtkNotebook *ynotebook, GtkWidget
*child)
+{
+ ynotebook->corner_widget = child;
+ gtk_widget_set_parent (child, GTK_WIDGET (ynotebook));
+}
+
+GtkWidget *ygtk_notebook_new (void)
+{ return g_object_new (YGTK_TYPE_NOTEBOOK, NULL); }
+
+static void ygtk_notebook_class_init (YGtkNotebookClass *klass)
+{
+ GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS (klass);
+ gtkwidget_class->size_request = ygtk_notebook_size_request;
+ gtkwidget_class->size_allocate = ygtk_notebook_size_allocate;
+ gtkwidget_class->map = ygtk_notebook_map;
+
+ GtkContainerClass *gtkcontainer_class = GTK_CONTAINER_CLASS (klass);
+ gtkcontainer_class->forall = ygtk_notebook_forall;
+
+ GtkNotebookClass *gtknotebook_class = GTK_NOTEBOOK_CLASS (klass);
+ gtknotebook_class->switch_page = ygtk_notebook_switch_page;
+}
+

Added: trunk/gtk/src/ygtknotebook.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtknotebook.h?rev=58553&view=auto
==============================================================================
--- trunk/gtk/src/ygtknotebook.h (added)
+++ trunk/gtk/src/ygtknotebook.h Sun Sep 6 18:25:16 2009
@@ -0,0 +1,46 @@
+/********************************************************************
+ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK *
+ ********************************************************************/
+
+/* Makes GtkNotebook's top-corner available for a widget.
+ Also makes pages, whose tab labels are insentitive, unaccesible.
+*/
+
+#ifndef YGTK_NOTEBOOK_H
+#define YGTK_NOTEBOOK_H
+
+#include <gtk/gtknotebook.h>
+G_BEGIN_DECLS
+
+#define YGTK_TYPE_NOTEBOOK (ygtk_notebook_get_type ())
+#define YGTK_NOTEBOOK(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), YGTK_TYPE_NOTEBOOK, YGtkNotebook))
+#define YGTK_NOTEBOOK_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), YGTK_TYPE_NOTEBOOK,
YGtkNotebookClass))
+#define YGTK_IS_NOTEBOOK(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), YGTK_TYPE_NOTEBOOK))
+#define YGTK_IS_NOTEBOOK_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), YGTK_TYPE_NOTEBOOK))
+#define YGTK_NOTEBOOK_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), YGTK_TYPE_NOTEBOOK,
YGtkNotebookClass))
+
+typedef struct _YGtkNotebook
+{
+ GtkNotebook parent;
+ // private:
+ GtkWidget *corner_widget;
+} YGtkNotebook;
+
+typedef struct _YGtkNotebookClass
+{
+ GtkNotebookClass parent_class;
+} YGtkNotebookClass;
+
+GtkWidget* ygtk_notebook_new (void);
+GType ygtk_notebook_get_type (void) G_GNUC_CONST;
+
+void ygtk_notebook_set_corner_widget (YGtkNotebook *notebook, GtkWidget
*child);
+
+G_END_DECLS
+#endif /*YGTK_NOTEBOOK_H*/
+

Modified: trunk/gtk/src/ygtkrichtext.c
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkrichtext.c?rev=58553&r1=58552&r2=58553&view=diff
==============================================================================
--- trunk/gtk/src/ygtkrichtext.c (original)
+++ trunk/gtk/src/ygtkrichtext.c Sun Sep 6 18:25:16 2009
@@ -382,8 +382,8 @@

// for tags like <br/>, GMarkup will pass them through the end
// tag callback too, so we'll deal with them there
- else if (!g_ascii_strcasecmp (element_name, "br"))
- ;
+ else if (!g_ascii_strcasecmp (element_name, "br")) ;
+ else if (!g_ascii_strcasecmp (element_name, "hr")) ;

else
{

Added: trunk/gtk/src/ygtktooltip.c
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtktooltip.c?rev=58553&view=auto
==============================================================================
--- trunk/gtk/src/ygtktooltip.c (added)
+++ trunk/gtk/src/ygtktooltip.c Sun Sep 6 18:25:16 2009
@@ -0,0 +1,265 @@
+/********************************************************************
+ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK *
+ ********************************************************************/
+
+/* YGtkTooltip widget */
+// check the header file for information about this widget
+
+#include <config.h>
+#include "ygtktooltip.h"
+#include <gtk/gtk.h>
+
+#define TOOLTIP_TIMEOUT 10000
+#define POINTER_LENGTH 10
+
+// header
+
+#define YGTK_TYPE_TOOLTIP (ygtk_tooltip_get_type ())
+#define YGTK_TOOLTIP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ YGTK_TYPE_TOOLTIP, YGtkTooltip))
+#define YGTK_TOOLTIP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ YGTK_TYPE_TOOLTIP, YGtkTooltipClass))
+#define YGTK_IS_TOOLTIP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ YGTK_TYPE_TOOLTIP))
+#define YGTK_IS_TOOLTIP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ YGTK_TYPE_TOOLTIP))
+#define YGTK_TOOLTIP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ YGTK_TYPE_TOOLTIP, YGtkTooltipClass))
+
+typedef struct YGtkTooltip
+{
+ GtkWindow parent;
+ // private:
+ YGtkPointerType pointer;
+ guint timeout_id;
+} YGtkTooltip;
+
+typedef struct YGtkTooltipClass
+{
+ GtkWindowClass parent_class;
+} YGtkTooltipClass;
+
+GtkWidget *ygtk_tooltip_new (void);
+GType ygtk_tooltip_get_type (void) G_GNUC_CONST;
+
+// implementation
+
+G_DEFINE_TYPE (YGtkTooltip, ygtk_tooltip, GTK_TYPE_WINDOW)
+
+static void ygtk_tooltip_init (YGtkTooltip *tooltip)
+{
+ GtkWidget *widget = GTK_WIDGET (tooltip);
+ GtkWindow *window = GTK_WINDOW (tooltip);
+ // we may need to do this if _new() not used
+ //g_object_set (G_OBJECT (tooltip), "type", GTK_WINDOW_POPUP, NULL);
+ gtk_window_set_type_hint (window, GDK_WINDOW_TYPE_HINT_TOOLTIP);
+ gtk_widget_set_app_paintable (widget, TRUE);
+ gtk_window_set_resizable (window, FALSE);
+ gtk_widget_set_name (widget, "gtk-tooltip");
+}
+
+static void ygtk_tooltip_finalize (GObject *object)
+{
+ YGtkTooltip *tooltip = YGTK_TOOLTIP (object);
+ if (tooltip->timeout_id) {
+ g_source_remove (tooltip->timeout_id);
+ tooltip->timeout_id = 0;
+ }
+ G_OBJECT_CLASS (ygtk_tooltip_parent_class)->finalize (object);
+}
+
+static void get_border (YGtkTooltip *tooltip, gint *left_border, gint
*right_border,
+ gint *up_border, gint *down_border)
+{
+ GtkWidget *widget = GTK_WIDGET (tooltip);
+ *left_border = *right_border = widget->style->xthickness;
+ *up_border = *down_border = widget->style->ythickness;
+ int len = POINTER_LENGTH + 2;
+ switch (tooltip->pointer) {
+ case YGTK_POINTER_NONE: break;
+ case YGTK_POINTER_UP_LEFT:
+ *left_border += len;
+ break;
+ case YGTK_POINTER_UP_RIGHT:
+ *right_border += len;
+ break;
+ case YGTK_POINTER_DOWN_LEFT:
+ case YGTK_POINTER_DOWN_RIGHT:
+ *down_border += len;
+ break;
+ }
+}
+
+static void ygtk_tooltip_size_request (GtkWidget *widget, GtkRequisition
*requisition)
+{
+ GTK_WIDGET_CLASS (ygtk_tooltip_parent_class)->size_request (widget,
requisition);
+ gint left_border, right_border, up_border, down_border;
+ get_border (YGTK_TOOLTIP (widget), &left_border, &right_border,
+ &up_border, &down_border);
+ requisition->width += left_border + right_border;
+ requisition->height += up_border + down_border;
+}
+
+static void ygtk_tooltip_size_allocate (GtkWidget *widget, GtkAllocation
*alloc)
+{
+ GTK_WIDGET_CLASS (ygtk_tooltip_parent_class)->size_allocate (widget,
alloc);
+ gint left_border, right_border, up_border, down_border;
+ get_border (YGTK_TOOLTIP (widget), &left_border, &right_border,
+ &up_border, &down_border);
+ GtkAllocation child_alloc = {
+ alloc->x + left_border, alloc->y + up_border,
+ alloc->width - (left_border+right_border),
+ alloc->height - (up_border+down_border)
+ };
+ gtk_widget_size_allocate (GTK_BIN (widget)->child, &child_alloc);
+}
+
+static gboolean ygtk_tooltip_expose_event (GtkWidget *widget, GdkEventExpose
*event)
+{
+ gtk_paint_flat_box (widget->style, widget->window, GTK_STATE_NORMAL,
+ GTK_SHADOW_OUT, NULL, widget, "tooltip", 0, 0,
widget->allocation.width,
+ widget->allocation.height);
+ YGtkPointerType pointer = YGTK_TOOLTIP (widget)->pointer;
+ if (pointer) {
+ gint x = 0, y = 0, len_x = 0, len_y = 0;
+ switch (pointer) {
+ case YGTK_POINTER_NONE: break;
+ case YGTK_POINTER_UP_LEFT:
+ case YGTK_POINTER_DOWN_LEFT:
+ x = 2;
+ len_x = POINTER_LENGTH;
+ break;
+ case YGTK_POINTER_UP_RIGHT:
+ case YGTK_POINTER_DOWN_RIGHT:
+ x = widget->allocation.width - 2;
+ len_x = -POINTER_LENGTH;
+ break;
+ }
+ switch (pointer) {
+ case YGTK_POINTER_NONE: break;
+ case YGTK_POINTER_UP_LEFT:
+ case YGTK_POINTER_UP_RIGHT:
+ y = 2;
+ len_y = POINTER_LENGTH;
+ break;
+ case YGTK_POINTER_DOWN_LEFT:
+ case YGTK_POINTER_DOWN_RIGHT:
+ y = widget->allocation.height - 2;
+ len_y = -POINTER_LENGTH;
+ break;
+ }
+
+ GdkPoint points[3] = {
+ { x, y }, { x + len_x, y }, { x, y + len_y } };
+ gdk_draw_polygon (widget->window, *widget->style->dark_gc,
TRUE, points, 3);
+ }
+ GTK_WIDGET_CLASS (ygtk_tooltip_parent_class)->expose_event (widget,
event);
+ return FALSE;
+}
+
+static gboolean tooltip_timeout_cb (void *pdata)
+{
+ YGtkTooltip *tooltip = (YGtkTooltip *) pdata;
+ tooltip->timeout_id = 0;
+ gtk_widget_destroy (GTK_WIDGET (tooltip));
+ return FALSE;
+}
+
+static YGtkTooltip *ygtk_tooltip_create (const gchar *text, const gchar *stock)
+{
+ GtkWidget *tooltip, *box, *label, *image = 0;
+ tooltip = ygtk_tooltip_new();
+ label = gtk_label_new (text);
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_widget_set_size_request (label, 200, -1);
+ box = gtk_hbox_new (FALSE, 6);
+ if (stock) {
+ image = gtk_image_new_from_stock (stock, GTK_ICON_SIZE_BUTTON);
+ gtk_box_pack_start (GTK_BOX (box), image, FALSE, TRUE, 0);
+ }
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
+ gtk_widget_show_all (box);
+ gtk_container_add (GTK_CONTAINER (tooltip), box);
+ return YGTK_TOOLTIP (tooltip);
+}
+
+static YGtkTooltip *singleton = 0;
+
+static void ygtk_tooltip_show (YGtkTooltip *tooltip, gint x, gint y)
+{
+ gtk_window_move (GTK_WINDOW (tooltip), x, y);
+ gtk_widget_show (GTK_WIDGET (tooltip));
+ if (singleton)
+ gtk_widget_destroy (GTK_WIDGET (singleton));
+ singleton = tooltip;
+ tooltip->timeout_id = g_timeout_add (TOOLTIP_TIMEOUT,
tooltip_timeout_cb, tooltip);
+}
+
+void ygtk_tooltip_show_at (gint x, gint y, YGtkPointerType pointer,
+ const gchar *label, const gchar *stock)
+{
+ YGtkTooltip *tooltip = ygtk_tooltip_create (label, stock);
+ tooltip->pointer = pointer;
+ ygtk_tooltip_show (tooltip, x, y);
+}
+
+#define XMARGIN 8
+#define YMARGIN 2
+
+void ygtk_tooltip_show_at_widget (GtkWidget *widget, YGtkPointerType pointer,
+ const gchar *label, const gchar *stock)
+{
+ YGtkTooltip *tooltip = ygtk_tooltip_create (label, stock);
+ tooltip->pointer = pointer;
+ gint x, y;
+ gdk_window_get_origin (widget->window, &x, &y);
+ if (GTK_WIDGET_NO_WINDOW (widget)) {
+ x += widget->allocation.x;
+ y += widget->allocation.y;
+ }
+ GtkRequisition tooltip_req;
+ gtk_widget_size_request (GTK_WIDGET (tooltip), &tooltip_req);
+ switch (pointer) {
+ case YGTK_POINTER_NONE: break;
+ case YGTK_POINTER_UP_RIGHT:
+ case YGTK_POINTER_DOWN_RIGHT:
+ x -= (tooltip_req.width - widget->allocation.width) +
XMARGIN;
+ break;
+ case YGTK_POINTER_UP_LEFT:
+ case YGTK_POINTER_DOWN_LEFT:
+ x += XMARGIN;
+ break;
+ }
+ switch (pointer) {
+ case YGTK_POINTER_NONE: break;
+ case YGTK_POINTER_UP_RIGHT:
+ case YGTK_POINTER_UP_LEFT:
+ y += widget->allocation.height + YMARGIN;
+ break;
+ case YGTK_POINTER_DOWN_RIGHT:
+ case YGTK_POINTER_DOWN_LEFT:
+ y -= tooltip_req.height + YMARGIN;
+ break;
+ }
+ ygtk_tooltip_show (tooltip, x, y);
+}
+
+GtkWidget *ygtk_tooltip_new (void)
+{
+ return g_object_new (YGTK_TYPE_TOOLTIP, "type", GTK_WINDOW_POPUP, NULL);
+}
+
+static void ygtk_tooltip_class_init (YGtkTooltipClass *klass)
+{
+ ygtk_tooltip_parent_class = g_type_class_peek_parent (klass);
+
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = ygtk_tooltip_finalize;
+
+ GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class->size_request = ygtk_tooltip_size_request;
+ widget_class->size_allocate = ygtk_tooltip_size_allocate;
+ widget_class->expose_event = ygtk_tooltip_expose_event;
+}
+

Added: trunk/gtk/src/ygtktooltip.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtktooltip.h?rev=58553&view=auto
==============================================================================
--- trunk/gtk/src/ygtktooltip.h (added)
+++ trunk/gtk/src/ygtktooltip.h Sun Sep 6 18:25:16 2009
@@ -0,0 +1,27 @@
+/********************************************************************
+ * YaST2-GTK - http://en.opensuse.org/YaST2-GTK *
+ ********************************************************************/
+
+/* YGtkTooltip, unlike GtkTooltip, can be used independently of a widget.
+ Also displays an arrow since it's meant to descript some element.
+*/
+
+#ifndef YGTK_TOOLTIP_H
+#define YGTK_TOOLTIP_H
+
+#include <gtk/gtkwidget.h>
+G_BEGIN_DECLS
+
+typedef enum { YGTK_POINTER_NONE, YGTK_POINTER_UP_LEFT, YGTK_POINTER_UP_RIGHT,
+ YGTK_POINTER_DOWN_LEFT, YGTK_POINTER_DOWN_RIGHT }
YGtkPointerType;
+
+// will display the tooltip and destroy it after a few seconds
+// note: no need to free the thing yourself
+void ygtk_tooltip_show_at (gint x, gint y, YGtkPointerType pointer,
+ const gchar *label, const gchar *stock_id);
+void ygtk_tooltip_show_at_widget (GtkWidget *widget, YGtkPointerType pointer,
+ const gchar *label, const gchar *stock_id);
+
+G_END_DECLS
+#endif /*YGTK_TOOLTIP_H*/
+

Modified: trunk/gtk/src/ygtkzyppview.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkzyppview.cc?rev=58553&r1=58552&r2=58553&view=diff
==============================================================================
--- trunk/gtk/src/ygtkzyppview.cc (original)
+++ trunk/gtk/src/ygtkzyppview.cc Sun Sep 6 18:25:16 2009
@@ -348,6 +348,14 @@
case ZyppModel::FOREGROUND_COLUMN:
g_value_set_string (value, g_strdup
("black"));
break;
+ case ZyppModel::TO_INSTALL_COLUMN:
+ case ZyppModel::TO_UPGRADE_COLUMN:
+ case ZyppModel::TO_REMOVE_COLUMN:
+ case ZyppModel::TO_MODIFY_COLUMN: {
+ bool modified =
segment->list.modified();
+ g_value_set_boolean (value, modified);
+ break;
+ }
default:
_getValueDefault (col, value);
break;
@@ -490,7 +498,7 @@
break;
}
case ZyppModel::WEIGHT_COLUMN: {
- bool highlight = segment->list.highlight
(index);
+ bool highlight = segment->list.highlight
(package);
int weight = highlight ? PANGO_WEIGHT_BOLD :
PANGO_WEIGHT_NORMAL;
g_value_set_int (value, weight);
break;
@@ -1095,7 +1103,6 @@
{
m_packages.removeListener (this);
m_packages = packages;
- m_packages.refreshProps();
m_packages.addListener (this);

GList *children = gtk_container_get_children
(GTK_CONTAINER (m_versions_box));
@@ -1376,7 +1383,7 @@
appendExpander (vbox, _("Changelog"), m_changelog);
appendExpander (vbox, _("Authors"), m_authors);
appendExpander (vbox, _("Dependencies"),
dependencies_box);
- appendExpander (vbox, _(""), m_support);
+ appendExpander (vbox, "", m_support);
m_contents = NULL;
if (CAN_OPEN_URIS())
g_signal_connect (G_OBJECT (m_filelist),
"link-clicked",

Modified: trunk/gtk/src/yzyppwrapper.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzyppwrapper.cc?rev=58553&r1=58552&r2=58553&view=diff
==============================================================================
--- trunk/gtk/src/yzyppwrapper.cc (original)
+++ trunk/gtk/src/yzyppwrapper.cc Sun Sep 6 18:25:16 2009
@@ -1398,7 +1398,6 @@
continue;
}

-fprintf (stderr, "patch '%s' category: %s - %d\n", patch->name().c_str(),
patch->category().c_str(), patch->categoryEnum());
std::string str;
#if 0 // Zypp patch->categoryEnum() seems broken: always returns the same
value (opensuse 11.1)
switch (patch->categoryEnum()) {
@@ -1524,10 +1523,9 @@
if (!pkg->hasUpgrade())
_allUpgradable = false;
}
- if (pkg->toModify()) {
+ if (pkg->toModify())
// if modified, can't be locked or
unlocked
_allLocked = _allUnlocked = false;
- }
else
_allModified = false;
if (pkg->isLocked())
@@ -1547,6 +1545,7 @@

void signalChanged (int index, Package *package)
{
+ inited = false;
PkgList list (this); refcount++;
for (std::list <PkgList::Listener *>::iterator it =
listeners.begin();
it != listeners.end(); it++)
@@ -1555,6 +1554,7 @@

void signalInserted (int index, Package *package)
{
+ inited = false;
PkgList list (this); refcount++;
for (std::list <PkgList::Listener *>::iterator it =
listeners.begin();
it != listeners.end(); it++)
@@ -1563,6 +1563,7 @@

void signalDeleted (int index, Package *package)
{
+ inited = false;
PkgList list (this); refcount++;
for (std::list <PkgList::Listener *>::iterator it =
listeners.begin();
it != listeners.end(); it++)
@@ -1608,7 +1609,7 @@
// for sub-classes to implement live lists
virtual bool liveList() const { return false; }
virtual bool match (Package *pkg) const { return true; }
- virtual bool highlight (int index) const { return false; }
+ virtual bool highlight (Package *pkg) const { return false; }
};

Ypp::PkgList::PkgList()
@@ -1637,8 +1638,8 @@
Ypp::Package *Ypp::PkgList::get (int i) const
{ return i >= (signed) impl->pool.size() ? NULL : impl->pool.at (i); }

-bool Ypp::PkgList::highlight (int i) const
-{ return impl->highlight (i); }
+bool Ypp::PkgList::highlight (Ypp::Package *pkg) const
+{ return impl->highlight (pkg); }

int Ypp::PkgList::size() const
{ return impl->pool.size(); }
@@ -1729,9 +1730,6 @@
bool Ypp::PkgList::canRemove() const
{ impl->buildProps(); return impl->_allCanRemove; }

-void Ypp::PkgList::refreshProps()
-{ impl->inited = 0; }
-
void Ypp::PkgList::install()
{
Ypp::get()->startTransactions();
@@ -1829,11 +1827,8 @@
bool clear;
Ypp::Package *highlight;

- Impl()
- {
- highlight = NULL;
- clear = false;
- }
+ Impl() : clear (false), highlight (NULL)
+ {}

bool match (Package *package) const
{
@@ -2054,8 +2049,12 @@
virtual bool match (Package *pkg) const
{ return query ? query->impl->match (pkg) : true; }

- virtual bool highlight (int index) const
- { return query ? query->impl->highlight == pool [index] : false; }
+ virtual bool highlight (Package *pkg) const
+ {
+ if (query && query->impl->highlight == pkg)
+ return true;
+ return parent->highlight (pkg); // this might be a sub-query
+ }
};

Ypp::PkgQuery::PkgQuery (const Ypp::PkgList list, Ypp::PkgQuery::Query *query)

Modified: trunk/gtk/src/yzyppwrapper.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/yzyppwrapper.h?rev=58553&r1=58552&r2=58553&view=diff
==============================================================================
--- trunk/gtk/src/yzyppwrapper.h (original)
+++ trunk/gtk/src/yzyppwrapper.h Sun Sep 6 18:25:16 2009
@@ -116,7 +116,7 @@
// this class and all proper subclassed are refcounted
struct PkgList { // NOTE: this is actually implemented as a vector
Package *get (int index) const;
- bool highlight (int index) const; // applicable to some
subclasses only
+ bool highlight (Ypp::Package *pkg) const; // applicable to
some subclasses only
int size() const;

void reserve (int size);
@@ -142,7 +142,6 @@
bool unlocked() const;
bool canRemove() const;
bool canLock() const;
- void refreshProps();

// actions
// NOTE: can take time (depending on size); show busy cursor

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages