Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2007-08-20 11:03:17 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2007-08-20 11:03:17 (GMT)
commit00b7013de12e0bfadb8183c50fa246a092ef8eb6 (patch)
treee03e36bcc5b3ccd6623142a200a2b27226d0d554 /sugar
parentdb4e502de5a0d37c54bc74d3d1d0d69a0d157e54 (diff)
Added an entry that can have icons inside: IconEntry. From libsexy.
Diffstat (limited to 'sugar')
-rw-r--r--sugar/_sugaruiext.defs75
-rw-r--r--sugar/_sugaruiext.override2
-rw-r--r--sugar/_sugaruiextmodule.c2
-rw-r--r--sugar/graphics/Makefile.am2
-rw-r--r--sugar/graphics/iconentry.py45
5 files changed, 125 insertions, 1 deletions
diff --git a/sugar/_sugaruiext.defs b/sugar/_sugaruiext.defs
index 3c011e1..6a9129d 100644
--- a/sugar/_sugaruiext.defs
+++ b/sugar/_sugaruiext.defs
@@ -22,8 +22,25 @@
(gtype-id "SUGAR_TYPE_MENU")
)
+(define-object IconEntry
+ (in-module "Sexy")
+ (parent "GtkEntry")
+ (c-name "SexyIconEntry")
+ (gtype-id "SEXY_TYPE_ICON_ENTRY")
+)
+
;; Enumerations and flags ...
+(define-enum IconEntryPosition
+ (in-module "Sexy")
+ (c-name "SexyIconEntryPosition")
+ (gtype-id "SEXY_TYPE_ICON_ENTRY_POSITION")
+ (values
+ '("primary" "SEXY_ICON_ENTRY_PRIMARY")
+ '("secondary" "SEXY_ICON_ENTRY_SECONDARY")
+ )
+)
+
;; From sugar-menu.h
(define-method set_active
@@ -94,3 +111,61 @@
'("const-char*" "property")
)
)
+
+;; From sexy-icon-entry.h
+
+(define-function sexy_icon_entry_get_type
+ (c-name "sexy_icon_entry_get_type")
+ (return-type "GType")
+)
+
+(define-function sexy_icon_entry_new
+ (c-name "sexy_icon_entry_new")
+ (is-constructor-of "SexyIconEntry")
+ (return-type "GtkWidget*")
+)
+
+(define-method set_icon
+ (of-object "SexyIconEntry")
+ (c-name "sexy_icon_entry_set_icon")
+ (return-type "none")
+ (parameters
+ '("SexyIconEntryPosition" "position")
+ '("GtkImage*" "icon")
+ )
+)
+
+(define-method set_icon_highlight
+ (of-object "SexyIconEntry")
+ (c-name "sexy_icon_entry_set_icon_highlight")
+ (return-type "none")
+ (parameters
+ '("SexyIconEntryPosition" "position")
+ '("gboolean" "highlight")
+ )
+)
+
+(define-method get_icon
+ (of-object "SexyIconEntry")
+ (c-name "sexy_icon_entry_get_icon")
+ (return-type "GtkImage*")
+ (parameters
+ '("SexyIconEntryPosition" "position")
+ )
+)
+
+(define-method get_icon_highlight
+ (of-object "SexyIconEntry")
+ (c-name "sexy_icon_entry_get_icon_highlight")
+ (return-type "gboolean")
+ (parameters
+ '("SexyIconEntryPosition" "position")
+ )
+)
+
+(define-method add_clear_button
+ (of-object "SexyIconEntry")
+ (c-name "sexy_icon_entry_add_clear_button")
+ (return-type "none")
+)
+
diff --git a/sugar/_sugaruiext.override b/sugar/_sugaruiext.override
index 6daafc3..beeaad0 100644
--- a/sugar/_sugaruiext.override
+++ b/sugar/_sugaruiext.override
@@ -8,6 +8,7 @@ headers
#include "sugar-key-grabber.h"
#include "sugar-menu.h"
#include "sugar-x11-util.h"
+#include "sexy-icon-entry.h"
#include <pygtk/pygtk.h>
#include <glib.h>
@@ -20,6 +21,7 @@ import gtk.Entry as PyGtkEntry_Type
import gtk.Menu as PyGtkMenu_Type
import gtk.Container as PyGtkContainer_Type
import gtk.gdk.Window as PyGdkWindow_Type
+import gtk.Image as PyGtkImage_Type
%%
ignore-glob
*_get_type
diff --git a/sugar/_sugaruiextmodule.c b/sugar/_sugaruiextmodule.c
index 8c74010..719b153 100644
--- a/sugar/_sugaruiextmodule.c
+++ b/sugar/_sugaruiextmodule.c
@@ -27,6 +27,7 @@
extern PyMethodDef py_sugaruiext_functions[];
void py_sugaruiext_register_classes (PyObject *d);
+void py_sugaruiext_add_constants (PyObject *module, const gchar *strip_prefix);
DL_EXPORT(void)
init_sugaruiext(void)
@@ -39,6 +40,7 @@ init_sugaruiext(void)
d = PyModule_GetDict (m);
py_sugaruiext_register_classes (d);
+ py_sugaruiext_add_constants(m, "SEXY_");
if (PyErr_Occurred ()) {
Py_FatalError ("can't initialise module _sugaruiext");
diff --git a/sugar/graphics/Makefile.am b/sugar/graphics/Makefile.am
index af66cfb..2d0dc17 100644
--- a/sugar/graphics/Makefile.am
+++ b/sugar/graphics/Makefile.am
@@ -9,7 +9,7 @@ sugar_PYTHON = \
combobox.py \
icon.py \
iconbutton.py \
- menuitem.py \
+ iconentry.py \
notebook.py \
objectchooser.py \
radiotoolbutton.py \
diff --git a/sugar/graphics/iconentry.py b/sugar/graphics/iconentry.py
new file mode 100644
index 0000000..2f7584f
--- /dev/null
+++ b/sugar/graphics/iconentry.py
@@ -0,0 +1,45 @@
+# Copyright (C) 2007, One Laptop Per Child
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+import gtk
+
+from sugar import _sugaruiext
+
+ICON_ENTRY_PRIMARY = _sugaruiext.ICON_ENTRY_PRIMARY
+ICON_ENTRY_SECONDARY = _sugaruiext.ICON_ENTRY_SECONDARY
+
+class IconEntry(_sugaruiext.IconEntry):
+ def set_icon_from_name(self, position, name):
+ icon_theme = gtk.icon_theme_get_default()
+ icon_info = icon_theme.lookup_icon(name,
+ gtk.ICON_SIZE_SMALL_TOOLBAR,
+ 0)
+
+ pixbuf = gtk.gdk.pixbuf_new_from_file(icon_info.get_filename())
+
+ image = gtk.Image()
+ image.set_from_pixbuf(pixbuf)
+ image.show()
+
+ self.set_icon(position, image)
+
+ def set_icon(self, position, image):
+ if image.get_storage_type() not in [gtk.IMAGE_PIXBUF, gtk.IMAGE_STOCK]:
+ raise ValueError('Image must have a storage type of pixbuf or ' +
+ 'stock, not %r.' % image.get_storage_type())
+ _sugaruiext.IconEntry.set_icon(self, position, image)
+