After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 553765 - Add orientation API to GtkRange
Add orientation API to GtkRange
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 541009
 
 
Reported: 2008-09-25 11:12 UTC by Michael Natterer
Modified: 2010-07-10 03:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch implementing the above (46.67 KB, patch)
2008-09-25 11:32 UTC, Michael Natterer
needs-work Details | Review
Updated patch (41.33 KB, patch)
2008-11-11 16:24 UTC, Michael Natterer
committed Details | Review

Description Michael Natterer 2008-09-25 11:12:04 UTC
See bug #541009.

Here are the patches for GtkRange and all its subclasses.
Comment 1 Michael Natterer 2008-09-25 11:32:41 UTC
Created attachment 119362 [details] [review]
Patch implementing the above

This one is a bit more complex:

- GtkRange: add orientation API, add some evil code that makes
  sure we keep using the right drawing details instead of always
  the ones from GtkRangeClass.

- GtkScale: swallow all code from GtkHScale and GtkVScale, set the drawing
  detail in GtkRangeClass in a way that triggers above magic in GtkRange.
  Make sure the range is set to flippable when the orientation is horizontal,
  but not when it's vertical.

- GtkScrollbar: set the drawing detail so range's magic is triggered.
Comment 2 Matthias Clasen 2008-09-27 03:06:10 UTC
One think I don't like about the evil details business is that this makes the detail string per instance, rather than per class. How about using static strings instead of duping the string for each instance ?
Comment 3 Tim Janik 2008-10-09 15:02:44 UTC
(In reply to comment #2)
> One think I don't like about the evil details business is that this makes the
> detail string per instance, rather than per class. How about using static
> strings instead of duping the string for each instance ?

The problem with using static strings is that the detail string is partly determined by sub classes ("scale", "scrollbar") and partly from orientation state ("h"/"v"). However since only a limited set of strings make sense here and are very likely to be reused over the program lifetime, i agree with Matthias that wasting strdup-ed space for these strings per instance should be fixed. I suggest changing _get_*_detail() so that it does:
  gchar *s = g_strdup_printf ("createdynamicstring...");
  GQuark q = g_quark_from_string (s);
  g_free (s);
  return g_quark_to_string (q);
Comment 4 Michael Natterer 2008-11-11 16:24:28 UTC
Created attachment 122428 [details] [review]
Updated patch

- caches the detail strings in quarks
- implements the GtkOrientable interface
Comment 5 Matthias Clasen 2008-11-11 16:55:20 UTC
+ * gtk_scale_new:
+ * @orientation: the scale's orientation.
+ * @adjustment: the #GtkAdjustment which sets the range of the scale.

Should add ", or %NULL to create a new adjustement" for the adjustment, 
since that is what the code does.


+  if (!layout)

I prefer to reserve ! for actual booleans nowadays, and use != NULL for pointers, but no big deal...


Other than that, looks good to me.
Comment 6 Michael Natterer 2008-11-11 17:49:51 UTC
Committed including above mentioned doc fix. Leaving the bug open since
deprecation needs to be discussed. Also, GtkScrollbar and GtkScale
are not abstract any longer so we can change their defaults. Needs
discussion too.

2008-11-11  Michael Natterer  <mitch@imendio.com>

	Bug 553765 – Add orientation API to GtkRange

	* gtk/gtkrange.[ch]: implement the GtkOrientable interface. Add
	evil code that makes sure that the stepper_detail and slider_detail
	set in GtkRangeClass continue to work with the hacked subclasses
	below.

	* gtk/gtkscale.[ch]: swallow all code from GtkHScale and GtkVScale
	and add gtk_scale_new() and gtk_scale_new_with_range() which take
	a GtkOrientation argument. Set slider_detail to "Xscale" so above
	evil code works.

	* gtk/gtkscrollbar.[ch]: add gtk_scrollbar_new() which takes a
	GtkOrientation argument. Set stepper_detail to "Xscrollbar" so
	above evil code works.

	* gtk/gtkhscale.c
	* gtk/gtkvscale.c
	* gtk/gtkhscrollbar.c
	* gtk/gtkvscrollbar.c: remove all code except the constructor and
	call gtk_orientable_set_orientation() in init().

	* gtk/gtk.symbols: changed accordingly.