Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icon: deprecate icon_size #4

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/sugar3/graphics/icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from gi.repository import Rsvg
import cairo

from sugar3.graphics import style
from sugar3.graphics.xocolor import XoColor
from sugar3.util import LRU

Expand Down Expand Up @@ -344,6 +345,25 @@ def __init__(self, **kwargs):
self._alpha = 1.0
self._scale = 1.0

if 'pixel_size' not in kwargs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

icon_size and pixel_size are gtk.Image properties, so they can also set with icon.props.icon_size =. What about handling this in _sync_image_properties? It seems like we are already calculating width/height from the properties there, and only there.

If we want a default_pixel size, I suspect the best way is to pass it to the GObject __init__ so that it's handled like a normal gobject property.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @dnarvaez,

good point. Here is another PR:
#5

kwargs['pixel_size'] = style.STANDARD_ICON_SIZE
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also be done with a default argument value. Reviewer choose :)


#FIXME: deprecate icon_size
if 'icon_size' in kwargs:
logging.warning("icon_size is deprecated. Use pixel_size instead.")
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we add a wiki page for deprecations, then the URL should be mentioned in this warning. "See http..."

logging.debug(kwargs['icon_size'])
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left this debug line accidentally. Please remove before pushing.


menu_sizes = (Gtk.IconSize.MENU, Gtk.IconSize.DND,
Gtk.IconSize.SMALL_TOOLBAR, Gtk.IconSize.BUTTON)

if kwargs['icon_size'] in menu_sizes:
kwargs['pixel_size'] = style.MENU_ICON_SIZE

elif kwargs['icon_size'] == Gtk.IconSize.LARGE_TOOLBAR:
kwargs['pixel_size'] = style.STANDARD_ICON_SIZE

kwargs.pop('icon_size')

GObject.GObject.__init__(self, **kwargs)

def get_file(self):
Expand Down
1 change: 1 addition & 0 deletions src/sugar3/graphics/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def zoom(units):
MEDIUM_ICON_SIZE = zoom(55 * 1.5)
LARGE_ICON_SIZE = zoom(55 * 2.0)
XLARGE_ICON_SIZE = zoom(55 * 2.75)
MENU_ICON_SIZE = zoom(33)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gtk.IconSize.MENU seems to be used in palettes, but PaletteMenuItem is using SMALL_ICON_SIZE. Maybe there is a difference that I'm missing, just wanted to point that out.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. We can look at that later.

The current change is needed to keep the sizes the same. In artwork for the theme at 100% we have icon sizes of 33px, and there is no 33px size in style.py .

gtk-icon-sizes = gtk-menu=33,33:gtk-dnd=33,33:gtk-small-toolbar=33,33:gtk-button=33,33:gtk-large-toolbar=55,55


settings = Gio.Settings('org.sugarlabs.font')
FONT_SIZE = settings.get_double('default-size')
Expand Down