69 Commits (aa8a5e70c415e6c2acf4ff373d9b366ac4692bb1)

Author SHA1 Message Date
Pro-Panda aa8a5e70c4 Port from Python 2 to six
Signed-off-by: James Cameron <quozl@laptop.org>
5 years ago
Rahul Bothra 13a2282e5e Port from GObject to GLib 6 years ago
James Cameron 58224cb15d Fix traceback when an icon name matches a GNOME theme icon
When an icon file name matches a GNOME theme icon;

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/sugar3/graphics/icon.py", line 214, in _get_attach_points
    cp.readfp(config_file)
  File "/usr/lib/python2.7/ConfigParser.py", line 324, in readfp
    self._read(fp, filename)
  File "/usr/lib/python2.7/ConfigParser.py", line 512, in _read
    raise MissingSectionHeaderError(fpname, lineno, line)
MissingSectionHeaderError: File contains no section headers.

Caused by reading a .png file as if it were config file, in turn
because the icon was expected by the toolkit to be .svg file type.

Regression introduced by f796638.

Fixes https://github.com/sugarlabs/activity-abacus/issues/16
6 years ago
James Cameron aaea86066d Icon - increase LRU cache sizes
Some activities suffer from performance penalties once the number of
icons backed by SVGs exceeds 50.

Double the cache sizes.

Tested on OLPC XO-1, the weakest known system on which Sugar is used.
6 years ago
James Cameron 04a1ff181f Fix Python GI API version warning in Wikipedia
The Wikipedia activity imports from sugar3.graphics.icon without any
other use of GTK+, causing a version warning.
7 years ago
James Cameron ae62708a7f Documentation - small typos 7 years ago
Sam Parkinson 4009e2a476
Merge branch 'long-press-eventicons' of https://github.com/samdroid-apps/sugar-toolkit-gtk3 8 years ago
Sam Parkinson 74d3a4d0c8
Revert "Don't activate EventIcons after touch long press"
This commit was never reviewed or intended for the master branch.

This reverts commit ed5e50239b.
8 years ago
Sam Parkinson 4a9b35a38a
Merge branch 'icon-docs' of https://github.com/samdroid-apps/sugar-toolkit-gtk3 8 years ago
Sam Parkinson 0f4309a324
Don't activate EventIcons after touch long press
Steps to reproduce:

1.  Long press activity icon on homeview
Expcected:  Palette invokes, icon not activated
Actual:     Palette invokes, icon also activated, activity launched

This was because the "activate" signal was emitted before the
palette invoker got it's signal, meaning the palette invoker couldn't
scilence the event.
8 years ago
Sam Parkinson ed5e50239b
Don't activate EventIcons after touch long press
Steps to reproduce:

1.  Long press activity icon on homeview
Expcected:  Palette invokes, icon not activated
Actual:     Palette invokes, icon also activated, activity launched

This was because the "activate" signal was emitted before the
palette invoker got it's signal, meaning the palette invoker couldn't
scilence the event.
8 years ago
Sam Parkinson 3f4a5e904d
First pass sugar3.graphics.icon docs 8 years ago
Sam Parkinson 9c0f7df739 Merge branch 'gi-require-version' of https://github.com/samdroid-apps/sugar-toolkit-gtk3 8 years ago
Sam Parkinson 8d0cc98e43 Set css name for widgets
In Gtk+ 3.20, you need to use the css name to select elements,
rather than the gtype name.  Therefore, these must be added.

The css name must be set before the class instances are created, as
it effects the class rather than the instance.  This is why it must
be places after the class definition.
8 years ago
Sam Parkinson aea65408f0 Specify library version prior to import, fixes #4900
Gi has been emitting warnings into the log to do this for some
time now. Not doing this has also caused bugs, such as #4900.
9 years ago
Gonzalo Odiard 88213f6408 EventIcon: only trigger 'activate' signal on principal button click
With the introduction of 'activate' signal on [1], and the use of that
signal in Sugar Home, we introduced a bug, now, pressing the secondary button
starts the activity instead of open the palette.
This patch solves the issue checking the putton pressed before send the signal.

[1] a19cf9ed27
9 years ago
Sam Parkinson 16107a3985 Show proper state indication for CanvasIcons
Commit a19cf9e changed the logic for handling CanvasIcon clicks.  Therefore,
the visual state indicators must be updated to fit the new logic.

Test Case:  Hold the mouse down on a home view icon.  Move the mouse
in and out of the icon.  See that the states correspond with what
happens if you release the mouse.
9 years ago
Gonzalo Odiard a19cf9ed27 Do not trigger events on EventIcons when button release is outside - #4863
The industry convention for mouse driven menu options is for them
to be activated when two conditions are met:
* a button down event occurs with the pointer inside the option, and;
* a button up event occurs with the pointer inside the option.

This issue was already solved on the PaletteMenuItem,
but the EventIcon have the same problem. This change add a 'activate' event,
that control that the two conditions are meet.
The code in Sugar need use this event instead of button-release-event.
9 years ago
Gonzalo Odiard 7a9510a187 Remove CellRendererInvoker
This invoker is not used anymore, now is replaced by TreeViewInvoker.
9 years ago
Gonzalo Odiard 49365e132c New invoker, TreeViewInvoker
This new invoker is able to handle all the palettes on a treeview,
removing the need of one invoker per cell renderer (CellRendererInvoker).
This simplifies the code and makes it more efficient.
Also removes the logic from the CellRendererIcon, which
should only care about drawing itself. [1]

Is important to note than in Gtk3 a CellRenderer is not a GtkWidget
then can't know when the mouse is over it or have the usual events
used by other invokers, making the implementation CellRendererInvoker
very complicate.

This commit also removes the invoker of CellRendererIcon.

The ScrollingDetector logic is simplified too,
because now there are only one invoker instead of one by renderer
and the example code updated.

[1] https://developer.gnome.org/gtk3/stable/GtkCellRenderer.html
9 years ago
Gonzalo Odiard 5626a6c182 Detect scrolling in treviews and optimize drawing
Detecting if the treeview is scrolling we can improve the performance of
the CellRendererIcon by avoiding unneeded calculations.

The example scrollingdetector.py shows how this can be used.  The
changes are backward compatible.

Signed-off-by: Manuel Quiñones <manuel.por.aca@gmail.com>
Signed-off-by: Gonzalo Odiard <godiard@sugarlabs.org>
9 years ago
Gonzalo Odiard d9e6fa6813 CellRendererIcon: cache offsets
Instead of calculating them on each render.  The cache is removed when
the size is changed.

Signed-off-by: Manuel Quiñones <manuel.por.aca@gmail.com>
9 years ago
Gonzalo Odiard f08757d75f CellRendererIcon: remove unused frame
The white frame is not visible over the white background.

Signed-off-by: Manuel Quiñones <manuel.por.aca@gmail.com>
9 years ago
Gonzalo Odiard 3a6427cdc6 CellRendererIcon: improve calculation in do_render
Use a more efficient method to check if the pointer is inside the cell,
because we have the cell_area in the do_render method.

Signed-off-by: Manuel Quiñones <manuel.por.aca@gmail.com>
Signed-off-by: Gonzalo Odiard <godiard@sugarlabs.org>
9 years ago
Gonzalo Odiard f7966382b8 Read icon attach points when is not possible get the info from gtk
Gtk has deprecated gtk-icon-get-attach-points on version 3.14
We need that information to place pur badges,
this fix read the information from the .icon file

[1] https://developer.gnome.org/gtk3/stable/GtkIconTheme.html#gtk-icon-info-get-attach-points
9 years ago
Martin Abente Lahaye 72994bd73c Add Icon.get_badge_size
Add get_badge_size method to Icon class, so it can be accessed
by other Icon sub-classes.

ie., jarabe.frame.notification.NotificationPulsingIcon.

Signed-off-by: Martin Abente Lahaye <tch@sugarlabs.org>
10 years ago
Daniel Narvaez 01ed63ee4b Fixes for pep8 1.5 10 years ago
Daniel Narvaez f92f0efe06 Fix pep8 10 years ago
Sebastian Silva 2a7d4da38a Implementation of pixbufs for use with X11 window icons. 10 years ago
Manuel Quiñones 5802d67ee1 Icon: deprecate icon_size
pixel_size should be always used now.

Change SMALL_ICON_SIZE to cover the other sizes at settings.ini.

Adds a transformation to keep backwards compatibility for some
time. This will be removed in the future.
10 years ago
Walter Bender ec5f064c10 Ensure entity value is type str
There are times when the entity value passed in for substitution
is of type unicode. This causes Rsvg to fail when processing the
SVG. This patch checks for unicode and converts it to utf-8.

Fixes #4621
11 years ago
Daniel Drake 670fc44b1a Icon: handle image loading errors
If the icon can't be found, fall back on showing a generic icon.

Useful when activity/content bundles specify a bad icon, which is
unfortunately true for most content bundles in current existance
(because the icon field was previously unused).
11 years ago
William Orr edbc8f53b3 pep8'd sugar3.graphics 11 years ago
Daniel Narvaez db448c4eea Remove a lot of unused imports
Signed-off-by: Daniel Narvaez <dwnarvaez@gmail.com>
11 years ago
Manuel Quiñones a3cda7c49f Revert "icon.py: move all imports to the top"
We have circular imports if we do this.

This reverts commit 355ca09a8c.
11 years ago
Manuel Quiñones 355ca09a8c icon.py: move all imports to the top
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
11 years ago
Manuel Quiñones e456cf1c9e Fixup for previous commit - SL #4224
The palette can be None.

Signed-off-by: Manuel Quiñones <manuq@laptop.org>
12 years ago
Manuel Kaufmann 1497ebc006 CanvasIcon: do not keep it ACTIVE when right-click twice SL #4224
When a CanvasIcon is right-clicked __button_press_event_cb and
__palette_popup_cb are called but not __button_release_event_cb. So,
ACTIVE flag is set but immediately removed by __palette_popup_cb and
PRELIGHT is set.

Now, if the user right-click it again while the palette is popped up,
__button_press_event_cb is called and it sets ACTIVE flag but
__palette_popup_cb is not called again because the palette is already
shown and that makes the icon to keep in ACTIVE state.

This patch checks if the palette is popped up when
__button_press_event_cb is called and if the palette is not popped up
the ACTIVE flag is set.

Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
Acked-by: Manuel Quiñones <manuq@laptop.org>
12 years ago
Manuel Quiñones 2a76b10ce0 CellRendererIcon: add active state - SL #3989
For press feedback.  Do this connecting to the treeview press and
release signals, as the palette invoker does.  After this, the active
state can be styled in the artwork.

Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
12 years ago
Manuel Quiñones f5b96e1fbd CellRendererIcon: add prelight state and render background - SL #3989
This is to provide feedback on mouse over.  The styling needs to be
done in the artwork component.

Because cell renderers don't inherit GtkWidget anymore, the styling
can't be done using the __gtype_name__ .  Instead, it has to be done
adding a css class [1] to the style context, and rendering the background
in the reimplementation of the do_render method.

For reference, see how GtkCellRendererToggle implements render [2] and
how Baobab app does it [3].

[1] http://developer.gnome.org/gtk3/3.2/GtkStyleContext.html#gtk-style-context-add-class
[2] http://git.gnome.org/browse/gtk+/tree/gtk/gtkcellrenderertoggle.c#n338
[3] http://git.gnome.org/browse/baobab/tree/src/baobab-cellrenderers.vala#n125

Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
12 years ago
Simon Schampijer 590785f7d1 EventIcon: make sure we are able to dismiss the Palette
Without this patch when tapping on an EventIcon
we do get a GDK_CROSSING_UNGRAB leave event when
the Palette is raised. Because of this the Invoker
does not know how to popdown the Palette when
you tap outside or when clicking on actions in the
Palette itself.

Signed-off-by: Simon Schampijer <simon@laptop.org>
Acked-by: Manuel Quiñones <manuq@laptop.org>
12 years ago
Manuel Quiñones e4e1881662 CanvasIcon: use set_state_flags and unset_state_flags instead of deprecated set_state - SL #3989
set_state is deprecated [1] and using flags improves the code and
makes it less error prone, because there is no need to handle the
prelight state in a variable _in_prelight_state .

[1] http://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-set-state

Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
12 years ago
Manuel Quiñones e591d9aa80 CanvasIcon: check if we have a palette in the button release callback
The buddy icon in the home view has the mouse pointer inside at boot,
moving the pointer outside provokes an error because the icon doesn't
have a palette attached yet.

Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
12 years ago
Manuel Quiñones 845371f2bc Icon: add new class CanvasIcon - SL #3989
Move code from shell ActivityIcon to new class CanvasIcon, that will
allow to reuse it in other icons.  This class inherits EventIcon and
adds state and drawing handling.  The right-click callback for the
palette invoker is not needed.

Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
12 years ago
Simon Schampijer c6c2220f0d CellRendererIcon: clipping rectangle not applied, SL #3872
We do not apply the clipping rectangle in do_render, we
need to call clip on the cairo_t as well. This solves the
issue in the Journal and in the Activity List View where
the icons do only appear on hovering over them.

See gtk_cell_renderer_render [1] for background information.

[1] http://git.gnome.org/browse/gtk+/tree/gtk/gtkcellrenderer.c#n731

Signed-off-by: Simon Schampijer <simon@laptop.org>
Acked-by: Manuel Quiñones <manuq@laptop.org>
12 years ago
Manuel Quiñones c0756f48d4 Fix the badge position at the icon attach point - SL #3835
The convert script pygi-convert.sh commented out the call to
info.get_attach_points() in commit 820efa56

Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
12 years ago
Simon Schampijer 1ed4eb8ad5 Icon: Gdk.CairoContext does not exist
First of all 'Gdk.CairoContext' does not exist, this has been
made up by the conversion script in 820efa56b9

We do not need the previous gtk.gdk.CairoContext here anymore, we
do only want to set the background of the context here. See the
toolkit-gtk2 commit where this has been simplified [1].

[1] 6ce463585c

Signed-off-by: Simon Schampijer <simon@laptop.org>
Acked-by: Manuel Quiñones <manuq@laptop.org>
12 years ago
Manuel Quiñones a14574c666 Finish the port of the CellRendererIcon
In pygtk custom cellrenderers were done inheriting
gtk.GenericCellRenderer, and overriding the on_* methods.  Now we
inherit Gtk.CellRenderer and the methods to override changed to do_* .

The destroy signal was moved to Gtk.Widget [1] so the Gtk.CellRenderer
doesn't have it anymore.  Now we do the cleanup in the python
destructor method.  A testcase tests/graphics/customdestroy.py shows
how is done.

tests/graphics/cellrenderericon.py tests the usage.

Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>

[1] http://developer.gnome.org/gtk3/stable/ch24s02.html#id1459754
12 years ago
Manuel Quiñones cd590b552b Fix the Handle Rsvg get_width() -> props.width, get_height() -> props.height
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
12 years ago
Simon Schampijer 6438c89dea EventIcon: update to the latest implementation used in the shell port
The icon consists of an GtkEventBox and an IconBuffer. The
GtkEventBox is a subclass of GtkBin which has its own window and
therefor is used to catch events for our IconBuffer which does
not have it's own window. The window of the EventBox is
made invisible.

The EventIcon does not emit the 'activated' signal when clicked
anymore, you can listen to 'button-release-event' to know
when the icon has been clicked. The EventIcon uses the
CursorInvoker to invoke a palette the same way as the
CanvasIcon did.

We keep the same API as with the CanvasIcon, only the 'size'
property is changed to be called 'pixel_size' in order to
make clearer which values it expects to be passed. We don't
expect a GtkIconSize to be passed here.

Another option would have been to put a SugarIcon inside a
a GtkEventBox and make the properties available through an
icon property but the API would have not been as nice and
logically it seems to make more sense to have the IconBuffer
being the base for both the SugarIcon and the SugarEventIcon.

This patch has ben developed based on the one that is
used in the shell port.

Signed-off-by: Simon Schampijer <simon@laptop.org>
Reviewd-by: Benjamin Berg <benzea@sugarlabs.org>
12 years ago