Bindings to set activity_id and bundle_id hints
This commit is contained in:
+2
-1
@@ -8,7 +8,8 @@ sugar_PYTHON = \
|
||||
logger.py \
|
||||
ltihooks.py \
|
||||
profile.py \
|
||||
util.py
|
||||
util.py \
|
||||
x11.py
|
||||
|
||||
INCLUDES = \
|
||||
$(LIB_CFLAGS) \
|
||||
|
||||
+62
-5
@@ -9,23 +9,26 @@
|
||||
|
||||
#include "pygobject.h"
|
||||
#include "sugar-address-entry.h"
|
||||
#include "sugar-x11-util.h"
|
||||
#include "xdgmime.h"
|
||||
|
||||
#include <pygtk/pygtk.h>
|
||||
#include <glib.h>
|
||||
|
||||
#line 18 "_sugarext.c"
|
||||
#line 19 "_sugarext.c"
|
||||
|
||||
|
||||
/* ---------- types from other modules ---------- */
|
||||
static PyTypeObject *_PyGtkEntry_Type;
|
||||
#define PyGtkEntry_Type (*_PyGtkEntry_Type)
|
||||
static PyTypeObject *_PyGdkWindow_Type;
|
||||
#define PyGdkWindow_Type (*_PyGdkWindow_Type)
|
||||
|
||||
|
||||
/* ---------- forward type declarations ---------- */
|
||||
PyTypeObject G_GNUC_INTERNAL PySugarAddressEntry_Type;
|
||||
|
||||
#line 29 "_sugarext.c"
|
||||
#line 32 "_sugarext.c"
|
||||
|
||||
|
||||
|
||||
@@ -98,7 +101,7 @@ _wrap_sugar_mime_get_mime_type_from_file_name(PyObject *self, PyObject *args, Py
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
#line 23 "_sugarext.override"
|
||||
#line 25 "_sugarext.override"
|
||||
static PyObject *
|
||||
_wrap_sugar_mime_get_mime_type_for_file(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
@@ -116,14 +119,56 @@ _wrap_sugar_mime_get_mime_type_for_file(PyObject *self, PyObject *args, PyObject
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
#line 120 "_sugarext.c"
|
||||
#line 123 "_sugarext.c"
|
||||
|
||||
|
||||
static PyObject *
|
||||
_wrap_sugar_x11_util_set_string_property(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "window", "property", "value", NULL };
|
||||
PyGObject *window;
|
||||
char *property, *value;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!ss:x11_set_string_property", kwlist, &PyGdkWindow_Type, &window, &property, &value))
|
||||
return NULL;
|
||||
|
||||
sugar_x11_util_set_string_property(GDK_WINDOW(window->obj), property, value);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wrap_sugar_x11_util_get_string_property(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "window", "property", NULL };
|
||||
PyGObject *window;
|
||||
char *property;
|
||||
gchar *ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!s:x11_get_string_property", kwlist, &PyGdkWindow_Type, &window, &property))
|
||||
return NULL;
|
||||
|
||||
ret = sugar_x11_util_get_string_property(GDK_WINDOW(window->obj), property);
|
||||
|
||||
if (ret) {
|
||||
PyObject *py_ret = PyString_FromString(ret);
|
||||
g_free(ret);
|
||||
return py_ret;
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
const PyMethodDef py_sugarext_functions[] = {
|
||||
{ "get_mime_type_from_file_name", (PyCFunction)_wrap_sugar_mime_get_mime_type_from_file_name, METH_VARARGS|METH_KEYWORDS,
|
||||
NULL },
|
||||
{ "get_mime_type_for_file", (PyCFunction)_wrap_sugar_mime_get_mime_type_for_file, METH_VARARGS|METH_KEYWORDS,
|
||||
NULL },
|
||||
{ "x11_set_string_property", (PyCFunction)_wrap_sugar_x11_util_set_string_property, METH_VARARGS|METH_KEYWORDS,
|
||||
NULL },
|
||||
{ "x11_get_string_property", (PyCFunction)_wrap_sugar_x11_util_get_string_property, METH_VARARGS|METH_KEYWORDS,
|
||||
NULL },
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
@@ -145,8 +190,20 @@ py_sugarext_register_classes(PyObject *d)
|
||||
"could not import gtk");
|
||||
return ;
|
||||
}
|
||||
if ((module = PyImport_ImportModule("gtk.gdk")) != NULL) {
|
||||
_PyGdkWindow_Type = (PyTypeObject *)PyObject_GetAttrString(module, "Window");
|
||||
if (_PyGdkWindow_Type == NULL) {
|
||||
PyErr_SetString(PyExc_ImportError,
|
||||
"cannot import name Window from gtk.gdk");
|
||||
return ;
|
||||
}
|
||||
} else {
|
||||
PyErr_SetString(PyExc_ImportError,
|
||||
"could not import gtk.gdk");
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
#line 151 "_sugarext.c"
|
||||
#line 208 "_sugarext.c"
|
||||
pygobject_register_class(d, "SugarAddressEntry", SUGAR_TYPE_ADDRESS_ENTRY, &PySugarAddressEntry_Type, Py_BuildValue("(O)", &PyGtkEntry_Type));
|
||||
}
|
||||
|
||||
@@ -25,3 +25,21 @@
|
||||
'("const-char*" "filename")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function x11_set_string_property
|
||||
(c-name "sugar_x11_util_set_string_property")
|
||||
(parameters
|
||||
'("GdkWindow*" "window")
|
||||
'("const-char*" "property")
|
||||
'("const-char*" "value")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function x11_get_string_property
|
||||
(c-name "sugar_x11_util_get_string_property")
|
||||
(return-type "char*")
|
||||
(parameters
|
||||
'("GdkWindow*" "window")
|
||||
'("const-char*" "property")
|
||||
)
|
||||
)
|
||||
|
||||
@@ -5,6 +5,7 @@ headers
|
||||
|
||||
#include "pygobject.h"
|
||||
#include "sugar-address-entry.h"
|
||||
#include "sugar-x11-util.h"
|
||||
#include "xdgmime.h"
|
||||
|
||||
#include <pygtk/pygtk.h>
|
||||
@@ -14,6 +15,7 @@ headers
|
||||
modulename _sugarext
|
||||
%%
|
||||
import gtk.Entry as PyGtkEntry_Type
|
||||
import gtk.gdk.Window as PyGdkWindow_Type
|
||||
%%
|
||||
ignore-glob
|
||||
*_get_type
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
# Copyright (C) 2007, Red Hat, Inc.
|
||||
#
|
||||
# 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
|
||||
|
||||
import _sugarext
|
||||
|
||||
def get_activity_id(wnck_window)
|
||||
window = gtk.gdk.window_foreign_new(window.get_xid())
|
||||
return _sugarext.x11_get_string_property(
|
||||
window, '_SUGAR_ACTIVITY_ID')
|
||||
|
||||
def get_bundle_id(wnck_window, prop):
|
||||
window = gtk.gdk.window_foreign_new(window.get_xid())
|
||||
return _sugarext.x11_get_string_property(
|
||||
window, '_SUGAR_BUNDLE_ID')
|
||||
|
||||
def set_activity_id(window, activity_id):
|
||||
_sugarext.x11_set_string_property(
|
||||
window, '_SUGAR_ACTIVITY_ID', activity_id)
|
||||
|
||||
def set_bundle_id(window, bundle_id):
|
||||
_sugarext.x11_set_string_property(
|
||||
window, '_SUGAR_BUNDLE_ID', activity_id)
|
||||
Reference in New Issue
Block a user