Difference between revisions of "Tooltips"

From GnuCash
Jump to: navigation, search
(Tooltips / Statusbar tips in menus: remove unnecessary text)
(use {{BugURL}})
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Tooltips in GnuCash ==
 
== Tooltips in GnuCash ==
  
In the 1.8-branch of gnucash, all menu items and all multichoice-option values were having a corresponding tooltip that was displayed when the mouse hovers of the items. In the gnome2 version SVN-HEAD, these are no longer there due to missing features in gtk2. This page collects the information about feasible re-implementations of that feature.
+
In the 1.8-branch of [[GnuCash]], all menu items and all multichoice-option values were having a corresponding tooltip that was displayed when the mouse hovers of the items. In the gnome2 version SVN-HEAD, these are no longer there due to missing features in gtk2. This page collects the information about feasible re-implementations of that feature.
  
 
* https://lists.gnucash.org/pipermail/gnucash-devel/2005-December/015139.html Discussion on gnucash-devel
 
* https://lists.gnucash.org/pipermail/gnucash-devel/2005-December/015139.html Discussion on gnucash-devel
 +
 +
The tooltips/statusbar tips in menus have been implemented in [http://svn.gnucash.org/trac/changeset/12295 r12295]. --[[User:Cstim|Cstim]] 09:01, 8 January 2006 (EST)
  
 
== Tooltips in Multichoice/Combobox widgets ==
 
== Tooltips in Multichoice/Combobox widgets ==
Line 9: Line 11:
  
 
The 1.8-Widget for the multichoice-options was a [http://developer.gnome.org/doc/API/gtk/gtkoptionmenu.html GtkOptionMenu] widget. It contains a [http://developer.gnome.org/doc/API/gtk/gtkmenu.html GtkMenu] where [http://developer.gnome.org/doc/API/gtk/gtkmenuitem.html GtkMenuItem]s are inserted, which are created by  gtk_menu_item_new_with_label. This was all used in gnc_build_option_menu() in src/gnome-utils/dialog-utils.c. The tooltip was directly set on any new GtkMenuItem by calling gtk_tooltips_set_tip() on the GtkMenuItem.
 
The 1.8-Widget for the multichoice-options was a [http://developer.gnome.org/doc/API/gtk/gtkoptionmenu.html GtkOptionMenu] widget. It contains a [http://developer.gnome.org/doc/API/gtk/gtkmenu.html GtkMenu] where [http://developer.gnome.org/doc/API/gtk/gtkmenuitem.html GtkMenuItem]s are inserted, which are created by  gtk_menu_item_new_with_label. This was all used in gnc_build_option_menu() in src/gnome-utils/dialog-utils.c. The tooltip was directly set on any new GtkMenuItem by calling gtk_tooltips_set_tip() on the GtkMenuItem.
 +
 +
To view the usefulness of these tooltips: Start gnucash-1.8. Open the "Report"→"Assets&Liabilities"→"Asset piechart". Click "Options". On the tab "General", there is the option "price source". Take a look at the available choices. You will notice that the short item names are not very obvious (because that whole option is quite non-trivial), but with the tooltip explanation it is fine again.
  
 
=== New GtkComboBox in gtk2 ===
 
=== New GtkComboBox in gtk2 ===
  
The old GtkOptionMenu is now deprecated since gtk2.4. Instead, the [http://developer.gnome.org/doc/API/2.0/gtk/GtkComboBox.html GtkComboBox] has to be used. However, this widget either requires using a Model-View programming, or alternatively it will only allow to set entries by gtk_combo_box_append_text() which is what we currently do in src/gnome-utils/dialog-options.c. The function gtk_combo_box_append_text() will only allow to add one text entry per item, but it does not give access to the actual item widget, so it is impossible to set gtk_tooltips_set_tip() on the item widget.  
+
The old GtkOptionMenu is now deprecated since gtk2.4. Instead, the [http://developer.gnome.org/doc/API/2.0/gtk/GtkComboBox.html GtkComboBox] has to be used, which still doesn't offer tooltips per items, see [{{BugURL}}/show_bug.cgi?id=303717 bug#303717]. However, this widget either requires using a Model-View programming ourselves, or alternatively it will only allow to set entries by gtk_combo_box_append_text() which is what we currently do in src/gnome-utils/dialog-options.c. The function gtk_combo_box_append_text() will only allow to add one text entry per item, which it will insert into the internally used GtkTreeModel of the combo box. This means there is no longer one widget per item, so it is impossible to set gtk_tooltips_set_tip() on anything like the item widget.
 +
 
 +
The implementation of that in gtk_combo_box_new_text()  of [http://cvs.gnome.org/viewcvs/gtk%2B/gtk/gtkcombobox.c?rev=1.166&view=markup gtk/gtkcombobox.c] confirms that the new GtkComboBox doesn't create widgets for the items anymore. Instead, the items are rendered by a GtkCellRendererText. If that were able to view a tooltip, it would basically mean that any GtkTreeView would be able to display a tooltip on any listview cell. HOWEVER, that kind of gtk feature request is [{{BugURL}}/show_bug.cgi?id=80980 bug#80980 in bugzilla] since 2001 and NOTHING has been done in that direction. Aaarg.  
  
The implementation of that in gtk_combo_box_new_text() of [http://cvs.gnome.org/viewcvs/gtk%2B/gtk/gtkcombobox.c?rev=1.166&view=markup gtk/gtkcombobox.c] confirms that the new GtkComboBox doesn't create widgets for the items anymore. Instead, the items are rendered by a GtkCellRendererText. If they were able to view a tooltip, it would basically mean that any ListView would be able to display a tooltip on any listview cell. HOWEVER, that kind of gtk feature request is [http://bugzilla.gnome.org/show_bug.cgi?id=80980 in bugzilla] since 2001 and NOTHING has been done in that direction. Aaarg. A different application has coded its own workaround [http://bugzilla.gnome.org/show_bug.cgi?id=130983 here] -- maybe we can copy from there.
+
As confirmed by a not-so-helpful IRC "discussion" with mclasen, the current GtkComboBox offers no way for us to add per-item-tooltips. There are three options for gnucash:
 +
# Copy the code of gtk/gtkcombobox.c into gnucash and create our own ComboBox widget. If we do this, then we have access to the GtkTreeView widget that is used internally in the combobox. We can use the "motion-notify" signal of that widget to update a displayed tooltip depending on the location of the mouse pointer. This approach was tried by a different application as a workaround, see [{{BugURL}}/show_bug.cgi?id=130983 bug#130983]. Alternatively, [http://mail.gnome.org/archives/gtk-app-devel-list/2003-October/msg00241.html this message] proposes to use the "show-help" signal in the very same way. Although they reported that the positioning of the tooltip was not optimum, I think this would at least enable us again to show these tooltips.
 +
# Revert the change of GtkOptionMenu to GtkComboBox and continue to use the old GtkOptionMenu, until gtk is able to deliver a combo box which has per-item-tooltips again.  
 +
# Ignore the per-item-tooltips until gtk implements that function. The implementation of that feature necessarily requires that [{{BugURL}}/show_bug.cgi?id=80980 bug#80980] is implemented and closed, which won't happen in the near future.
  
== Tooltips / Statusbar tips in menus ==
+
I propose to go back to the deprecated GtkOptionMenu, which is the most gain with the least effort for us. --[[User:Cstim|Cstim]] 08:12, 21 January 2006 (EST)
Has been fixed in r12295. --[[User:Cstim|Cstim]] 09:01, 8 January 2006 (EST)
 

Latest revision as of 21:22, 29 June 2018

Tooltips in GnuCash

In the 1.8-branch of GnuCash, all menu items and all multichoice-option values were having a corresponding tooltip that was displayed when the mouse hovers of the items. In the gnome2 version SVN-HEAD, these are no longer there due to missing features in gtk2. This page collects the information about feasible re-implementations of that feature.

The tooltips/statusbar tips in menus have been implemented in r12295. --Cstim 09:01, 8 January 2006 (EST)

Tooltips in Multichoice/Combobox widgets

Old implementation in 1.8

The 1.8-Widget for the multichoice-options was a GtkOptionMenu widget. It contains a GtkMenu where GtkMenuItems are inserted, which are created by gtk_menu_item_new_with_label. This was all used in gnc_build_option_menu() in src/gnome-utils/dialog-utils.c. The tooltip was directly set on any new GtkMenuItem by calling gtk_tooltips_set_tip() on the GtkMenuItem.

To view the usefulness of these tooltips: Start gnucash-1.8. Open the "Report"→"Assets&Liabilities"→"Asset piechart". Click "Options". On the tab "General", there is the option "price source". Take a look at the available choices. You will notice that the short item names are not very obvious (because that whole option is quite non-trivial), but with the tooltip explanation it is fine again.

New GtkComboBox in gtk2

The old GtkOptionMenu is now deprecated since gtk2.4. Instead, the GtkComboBox has to be used, which still doesn't offer tooltips per items, see bug#303717. However, this widget either requires using a Model-View programming ourselves, or alternatively it will only allow to set entries by gtk_combo_box_append_text() which is what we currently do in src/gnome-utils/dialog-options.c. The function gtk_combo_box_append_text() will only allow to add one text entry per item, which it will insert into the internally used GtkTreeModel of the combo box. This means there is no longer one widget per item, so it is impossible to set gtk_tooltips_set_tip() on anything like the item widget.

The implementation of that in gtk_combo_box_new_text() of gtk/gtkcombobox.c confirms that the new GtkComboBox doesn't create widgets for the items anymore. Instead, the items are rendered by a GtkCellRendererText. If that were able to view a tooltip, it would basically mean that any GtkTreeView would be able to display a tooltip on any listview cell. HOWEVER, that kind of gtk feature request is bug#80980 in bugzilla since 2001 and NOTHING has been done in that direction. Aaarg.

As confirmed by a not-so-helpful IRC "discussion" with mclasen, the current GtkComboBox offers no way for us to add per-item-tooltips. There are three options for gnucash:

  1. Copy the code of gtk/gtkcombobox.c into gnucash and create our own ComboBox widget. If we do this, then we have access to the GtkTreeView widget that is used internally in the combobox. We can use the "motion-notify" signal of that widget to update a displayed tooltip depending on the location of the mouse pointer. This approach was tried by a different application as a workaround, see bug#130983. Alternatively, this message proposes to use the "show-help" signal in the very same way. Although they reported that the positioning of the tooltip was not optimum, I think this would at least enable us again to show these tooltips.
  2. Revert the change of GtkOptionMenu to GtkComboBox and continue to use the old GtkOptionMenu, until gtk is able to deliver a combo box which has per-item-tooltips again.
  3. Ignore the per-item-tooltips until gtk implements that function. The implementation of that feature necessarily requires that bug#80980 is implemented and closed, which won't happen in the near future.

I propose to go back to the deprecated GtkOptionMenu, which is the most gain with the least effort for us. --Cstim 08:12, 21 January 2006 (EST)