Merge branch 'master' of ssh+git://dev.laptop.org/git/sugar-toolkit
This commit is contained in:
commit
783ec6734c
@ -200,7 +200,7 @@
|
|||||||
(c-name "sugar_preview_take_screenshot")
|
(c-name "sugar_preview_take_screenshot")
|
||||||
(return-type "none")
|
(return-type "none")
|
||||||
(parameters
|
(parameters
|
||||||
'("GdkDrawable" "drawable")
|
'("GtkWidget" "widget")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,11 +22,11 @@ headers
|
|||||||
modulename sugar._sugarext
|
modulename sugar._sugarext
|
||||||
%%
|
%%
|
||||||
import gobject.GObject as PyGObject_Type
|
import gobject.GObject as PyGObject_Type
|
||||||
|
import gtk.Widget as PyGtkWidget_Type
|
||||||
import gtk.Entry as PyGtkEntry_Type
|
import gtk.Entry as PyGtkEntry_Type
|
||||||
import gtk.Menu as PyGtkMenu_Type
|
import gtk.Menu as PyGtkMenu_Type
|
||||||
import gtk.Container as PyGtkContainer_Type
|
import gtk.Container as PyGtkContainer_Type
|
||||||
import gtk.gdk.Window as PyGdkWindow_Type
|
import gtk.gdk.Window as PyGdkWindow_Type
|
||||||
import gtk.gdk.Drawable as PyGdkDrawable_Type
|
|
||||||
import gtk.Image as PyGtkImage_Type
|
import gtk.Image as PyGtkImage_Type
|
||||||
%%
|
%%
|
||||||
ignore-glob
|
ignore-glob
|
||||||
|
@ -754,8 +754,8 @@ class Activity(Window, gtk.Container):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
def take_screenshot(self):
|
def take_screenshot(self):
|
||||||
if self.canvas and self.canvas.window:
|
if self.canvas:
|
||||||
self._preview.take_screenshot(self.canvas.window)
|
self._preview.take_screenshot(self.canvas)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
"""Request that the activity is saved to the Journal.
|
"""Request that the activity is saved to the Journal.
|
||||||
|
@ -396,6 +396,7 @@ class ActivityBundle(Bundle):
|
|||||||
if mime_types is not None:
|
if mime_types is not None:
|
||||||
installed_icons_dir = os.path.join(xdg_data_home,
|
installed_icons_dir = os.path.join(xdg_data_home,
|
||||||
'icons/sugar/scalable/mimetypes')
|
'icons/sugar/scalable/mimetypes')
|
||||||
|
if os.path.isdir(installed_icons_dir):
|
||||||
for f in os.listdir(installed_icons_dir):
|
for f in os.listdir(installed_icons_dir):
|
||||||
path = os.path.join(installed_icons_dir, f)
|
path = os.path.join(installed_icons_dir, f)
|
||||||
if os.path.islink(path) and \
|
if os.path.islink(path) and \
|
||||||
|
@ -69,16 +69,38 @@ sugar_preview_clear(SugarPreview *preview)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static gboolean
|
||||||
sugar_preview_take_screenshot(SugarPreview *preview, GdkDrawable *drawable)
|
widget_is_off_screen(GtkWidget *widget)
|
||||||
{
|
{
|
||||||
|
GdkScreen *screen;
|
||||||
|
gint x, y, width, height;
|
||||||
|
|
||||||
|
screen = gtk_widget_get_screen(widget);
|
||||||
|
|
||||||
|
gdk_window_get_geometry(widget->window, &x, &y, &width, &height, NULL);
|
||||||
|
|
||||||
|
return (x < 0 || y < 0 ||
|
||||||
|
x + width > gdk_screen_get_width(screen) ||
|
||||||
|
y + height > gdk_screen_get_height(screen));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sugar_preview_take_screenshot(SugarPreview *preview, GtkWidget *widget)
|
||||||
|
{
|
||||||
|
GdkDrawable *drawable;
|
||||||
GdkScreen *screen;
|
GdkScreen *screen;
|
||||||
GdkVisual *visual;
|
GdkVisual *visual;
|
||||||
GdkColormap *colormap;
|
GdkColormap *colormap;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
|
||||||
|
if (widget->window == NULL || widget_is_off_screen(widget)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sugar_preview_clear(preview);
|
sugar_preview_clear(preview);
|
||||||
|
|
||||||
|
drawable = GDK_DRAWABLE(widget->window);
|
||||||
|
|
||||||
gdk_drawable_get_size(drawable, &width, &height);
|
gdk_drawable_get_size(drawable, &width, &height);
|
||||||
|
|
||||||
screen = gdk_drawable_get_screen(drawable);
|
screen = gdk_drawable_get_screen(drawable);
|
||||||
|
@ -50,7 +50,7 @@ struct _SugarPreviewClass {
|
|||||||
|
|
||||||
GType sugar_preview_get_type (void);
|
GType sugar_preview_get_type (void);
|
||||||
void sugar_preview_take_screenshot (SugarPreview *preview,
|
void sugar_preview_take_screenshot (SugarPreview *preview,
|
||||||
GdkDrawable *drawable);
|
GtkWidget *widget);
|
||||||
void sugar_preview_set_size (SugarPreview *preview,
|
void sugar_preview_set_size (SugarPreview *preview,
|
||||||
int width,
|
int width,
|
||||||
int height);
|
int height);
|
||||||
|
Loading…
Reference in New Issue
Block a user