Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

GTK 3 porting

  • Loading branch information...
commit 0e66fbfb39c6c614d0debc33f1be44f5c47e0929 1 parent 3391b3a
@smokku smokku authored
View
33 examples/home/example-label-home-applet.c
@@ -48,39 +48,30 @@ example_label_home_applet_class_finalize (ExampleLabelHomeAppletClass *klass)
static void
example_label_home_applet_realize (GtkWidget *widget)
{
- GdkScreen *screen;
+ GdkScreen *screen = gtk_widget_get_screen (widget);
+ GdkVisual *visual = gdk_screen_get_rgba_visual (screen);
- screen = gtk_widget_get_screen (widget);
- gtk_widget_set_colormap (widget,
- gdk_screen_get_rgba_colormap (screen));
+ if (visual == NULL)
+ visual = gdk_screen_get_system_visual (screen);
- gtk_widget_set_app_paintable (widget,
- TRUE);
+ gtk_widget_set_visual (widget, visual);
+
+ gtk_widget_set_app_paintable (widget, TRUE);
GTK_WIDGET_CLASS (example_label_home_applet_parent_class)->realize (widget);
}
static gboolean
-example_label_home_applet_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
+example_label_home_applet_draw (GtkWidget *widget,
+ cairo_t *cr)
{
- cairo_t *cr;
-
- /* Create cairo context */
- cr = gdk_cairo_create (GDK_DRAWABLE (widget->window));
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
-
/* Draw alpha background */
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.0);
cairo_paint (cr);
- /* Free context */
- cairo_destroy (cr);
-
- return GTK_WIDGET_CLASS (example_label_home_applet_parent_class)->expose_event (widget,
- event);
+ return GTK_WIDGET_CLASS (example_label_home_applet_parent_class)->draw (widget,
+ cr);
}
static void
@@ -89,7 +80,7 @@ example_label_home_applet_class_init (ExampleLabelHomeAppletClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
widget_class->realize = example_label_home_applet_realize;
- widget_class->expose_event = example_label_home_applet_expose_event;
+ widget_class->draw = example_label_home_applet_draw;
g_type_class_add_private (klass, sizeof (ExampleLabelHomeAppletPrivate));
}
View
123 libhildondesktop/hd-home-plugin-item.c
@@ -147,6 +147,8 @@ enum
static guint signals[LAST_SIGNAL] = { 0, };
+static GdkAtom show_settings_atom = GDK_NONE;
+
struct _HDHomePluginItemPrivate
{
gchar *plugin_id;
@@ -183,26 +185,20 @@ hd_home_plugin_item_init_plugin_item (HDPluginItemIface *iface)
return;
}
-static gboolean
-hd_home_plugin_item_client_event (GtkWidget *widget,
- GdkEventClient *event)
+static GdkFilterReturn
+hd_home_plugin_item_event_filter (GdkXEvent *xevent,
+ GdkEvent *event,
+ gpointer data)
{
- static GdkAtom show_settings_atom = GDK_NONE;
-
- if (show_settings_atom == GDK_NONE)
- show_settings_atom = gdk_atom_intern_static_string ("_HILDON_APPLET_SHOW_SETTINGS");
-
- if (event->message_type == show_settings_atom)
+ if (((XClientMessageEvent*)xevent)->type == ClientMessage &&
+ ((XClientMessageEvent*)xevent)->message_type == gdk_x11_atom_to_xatom (show_settings_atom))
{
- g_signal_emit (widget, signals[SHOW_SETTINGS], 0);
+ g_signal_emit (GTK_WIDGET (data), signals[SHOW_SETTINGS], 0);
- return TRUE;
+ return GDK_FILTER_REMOVE;
}
- if (GTK_WIDGET_CLASS (hd_home_plugin_item_parent_class)->client_event)
- return GTK_WIDGET_CLASS (hd_home_plugin_item_parent_class)->client_event (widget, event);
-
- return FALSE;
+ return GDK_FILTER_CONTINUE;
}
static gboolean
@@ -243,29 +239,31 @@ hd_home_plugin_item_realize (GtkWidget *widget)
GdkDisplay *display;
Atom atom, wm_type;
gchar *applet_id;
- GdkPixmap *pixmap;
- cairo_t *cr;
+ GdkRGBA transparent = {0.0, 0.0, 0.0, 0.0};
+ GdkWindow *window;
GTK_WIDGET_CLASS (hd_home_plugin_item_parent_class)->realize (widget);
+ window = gtk_widget_get_window (widget);
+
/* No border as decoration */
- gdk_window_set_decorations (widget->window, 0);
+ gdk_window_set_decorations (window, 0);
/* Set the _NET_WM_WINDOW_TYPE property to _HILDON_WM_WINDOW_TYPE_HOME_APPLET */
- display = gdk_drawable_get_display (widget->window);
+ display = gdk_window_get_display (window);
atom = gdk_x11_get_xatom_by_name_for_display (display,
"_NET_WM_WINDOW_TYPE");
wm_type = gdk_x11_get_xatom_by_name_for_display (display,
"_HILDON_WM_WINDOW_TYPE_HOME_APPLET");
- XChangeProperty (GDK_WINDOW_XDISPLAY (widget->window),
- GDK_WINDOW_XID (widget->window),
+ XChangeProperty (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XID (window),
atom, XA_ATOM, 32, PropModeReplace,
(unsigned char *)&wm_type, 1);
applet_id = hd_home_plugin_item_get_applet_id (HD_HOME_PLUGIN_ITEM (widget));
- XChangeProperty (GDK_WINDOW_XDISPLAY (widget->window),
- GDK_WINDOW_XID (widget->window),
+ XChangeProperty (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (display,
"_HILDON_APPLET_ID"),
gdk_x11_get_xatom_by_name_for_display (display,
@@ -276,41 +274,51 @@ hd_home_plugin_item_realize (GtkWidget *widget)
/* Set or remove settings property */
if (priv->settings)
- XChangeProperty (GDK_WINDOW_XDISPLAY (widget->window),
- GDK_WINDOW_XID (widget->window),
+ XChangeProperty (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (display,
"_HILDON_APPLET_SETTINGS"),
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &(priv->settings), 1);
else
- XDeleteProperty (GDK_WINDOW_XDISPLAY (widget->window),
- GDK_WINDOW_XID (widget->window),
+ XDeleteProperty (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (display,
"_HILDON_APPLET_SETTINGS"));
/* Set display on all views property */
if (priv->display_on_all_views)
- XChangeProperty (GDK_WINDOW_XDISPLAY (widget->window),
- GDK_WINDOW_XID (widget->window),
+ XChangeProperty (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (display,
"_HILDON_APPLET_DISPLAY_ON_ALL_VIEWS"),
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &(priv->display_on_all_views), 1);
else
- XDeleteProperty (GDK_WINDOW_XDISPLAY (widget->window),
- GDK_WINDOW_XID (widget->window),
+ XDeleteProperty (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (display,
"_HILDON_APPLET_DISPLAY_ON_ALL_VIEWS"));
- /* Set background to transparent pixmap */
- pixmap = gdk_pixmap_new (GDK_DRAWABLE (widget->window), 1, 1, -1);
- cr = gdk_cairo_create (GDK_DRAWABLE (pixmap));
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.0);
- cairo_paint (cr);
- cairo_destroy (cr);
- gdk_window_set_back_pixmap (widget->window, pixmap, FALSE);
+ /* Install client message filter */
+ if (show_settings_atom == GDK_NONE)
+ show_settings_atom = gdk_atom_intern_static_string ("_HILDON_APPLET_SHOW_SETTINGS");
+
+ gdk_window_add_filter (window,
+ hd_home_plugin_item_event_filter, widget);
+
+ /* Set background to transparent */
+ gdk_window_set_background_rgba (window, &transparent);
+}
+
+static void
+hd_home_plugin_item_unrealize (GtkWidget *widget)
+{
+ gdk_window_remove_filter (gtk_widget_get_window (widget),
+ hd_home_plugin_item_event_filter, widget);
+
+ GTK_WIDGET_CLASS (hd_home_plugin_item_parent_class)->unrealize (widget);
}
static void
@@ -324,9 +332,9 @@ hd_home_plugin_item_constructed (GObject *object)
static void
hd_home_plugin_item_dispose (GObject *object)
{
- HDHomePluginItemPrivate *priv;
+//HDHomePluginItemPrivate *priv;
- priv = HD_HOME_PLUGIN_ITEM (object)->priv;
+//priv = HD_HOME_PLUGIN_ITEM (object)->priv;
G_OBJECT_CLASS (hd_home_plugin_item_parent_class)->dispose (object);
}
@@ -423,9 +431,9 @@ hd_home_plugin_item_class_init (HDHomePluginItemClass *klass)
klass->get_applet_id = hd_home_plugin_item_get_applet_id_real;
- widget_class->client_event = hd_home_plugin_item_client_event;
widget_class->property_notify_event = hd_home_plugin_item_property_notify_event;
widget_class->realize = hd_home_plugin_item_realize;
+ widget_class->unrealize = hd_home_plugin_item_unrealize;
object_class->constructed = hd_home_plugin_item_constructed;
object_class->dispose = hd_home_plugin_item_dispose;
@@ -525,13 +533,10 @@ hd_home_plugin_item_get_dbus_connection (HDHomePluginItem *item,
DBusBusType type,
DBusError *error)
{
- HDHomePluginItemPrivate *priv;
DBusConnection *connection;
g_return_val_if_fail (HD_IS_HOME_PLUGIN_ITEM (item), NULL);
- priv = item->priv;
-
/* Create a private connection */
connection = dbus_bus_get_private (type, error);
@@ -566,15 +571,12 @@ hd_home_plugin_item_get_dbus_g_connection (HDHomePluginItem *item,
DBusBusType type,
GError **error)
{
- HDHomePluginItemPrivate *priv;
DBusGConnection *g_connection;
DBusConnection *connection;
GError *tmp_error = NULL;
g_return_val_if_fail (HD_IS_HOME_PLUGIN_ITEM (item), NULL);
- priv = item->priv;
-
/* Create a DBusGConnection (not private yet) */
g_connection = dbus_g_bus_get (type, &tmp_error);
@@ -688,32 +690,29 @@ void
hd_home_plugin_item_set_settings (HDHomePluginItem *item,
gboolean settings)
{
- HDHomePluginItemPrivate *priv;
-
g_return_if_fail (HD_IS_HOME_PLUGIN_ITEM (item));
- priv = item->priv;
-
- priv->settings = settings;
+ item->priv->settings = settings;
- if (GTK_WIDGET_REALIZED (item))
+ if (gtk_widget_get_realized (GTK_WIDGET (item)))
{
- GtkWidget *widget = GTK_WIDGET (item);
+ GdkWindow *window;
GdkDisplay *display;
- display = gdk_drawable_get_display (widget->window);
+ window = gtk_widget_get_window (GTK_WIDGET (item));
+ display = gdk_window_get_display (window);
/* Set or remove settings property from the window */
- if (priv->settings)
- XChangeProperty (GDK_WINDOW_XDISPLAY (widget->window),
- GDK_WINDOW_XID (widget->window),
+ if (item->priv->settings)
+ XChangeProperty (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (display,
"_HILDON_APPLET_SETTINGS"),
XA_CARDINAL, 32, PropModeReplace,
- (unsigned char *) &(priv->settings), 1);
+ (unsigned char *) &(item->priv->settings), 1);
else
- XDeleteProperty (GDK_WINDOW_XDISPLAY (widget->window),
- GDK_WINDOW_XID (widget->window),
+ XDeleteProperty (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (display,
"_HILDON_APPLET_SETTINGS"));
}
View
3  libhildondesktop/hd-plugin-loader.h
@@ -25,8 +25,7 @@
#ifndef __HD_PLUGIN_LOADER_H__
#define __HD_PLUGIN_LOADER_H__
-#include <glib-object.h>
-#include <glib/gkeyfile.h>
+#include <glib.h>
#include <libhildondesktop/hd-plugin-item.h>
View
35 libhildondesktop/hd-status-plugin-item.c
@@ -97,7 +97,7 @@ hd_status_plugin_item_size_allocate (GtkWidget *widget,
GTK_WIDGET_CLASS (hd_status_plugin_item_parent_class)->size_allocate (widget,
allocation);
- child = GTK_BIN (widget)->child;
+ child = gtk_bin_get_child (GTK_BIN (widget));
if (child)
{
@@ -116,19 +116,29 @@ hd_status_plugin_item_size_allocate (GtkWidget *widget,
}
static void
-hd_status_plugin_item_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+hd_status_plugin_item_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
{
GtkWidget *child;
- GtkRequisition child_requisition = {0, 0};
- child = GTK_BIN (widget)->child;
+ child = gtk_bin_get_child (GTK_BIN (widget));
if (child)
- gtk_widget_size_request (child, &child_requisition);
+ gtk_widget_get_preferred_width (child, minimal_width, natural_width);
+}
- requisition->width = child_requisition.width;
- requisition->height = child_requisition.height;
+static void
+hd_status_plugin_item_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
+{
+ GtkWidget *child;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+
+ if (child)
+ gtk_widget_get_preferred_height (child, minimal_height, natural_height);
}
static void
@@ -237,7 +247,8 @@ hd_status_plugin_item_class_init (HDStatusPluginItemClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
widget_class->size_allocate = hd_status_plugin_item_size_allocate;
- widget_class->size_request = hd_status_plugin_item_size_request;
+ widget_class->get_preferred_width = hd_status_plugin_item_get_preferred_width;
+ widget_class->get_preferred_height = hd_status_plugin_item_get_preferred_height;
object_class->dispose = hd_status_plugin_item_dispose;
object_class->finalize = hd_status_plugin_item_finalize;
@@ -382,13 +393,10 @@ hd_status_plugin_item_get_dbus_connection (HDStatusPluginItem *item,
DBusBusType type,
DBusError *error)
{
- HDStatusPluginItemPrivate *priv;
DBusConnection *connection;
g_return_val_if_fail (HD_IS_STATUS_PLUGIN_ITEM (item), NULL);
- priv = item->priv;
-
/* Create a private connection */
connection = dbus_bus_get_private (type, error);
@@ -423,15 +431,12 @@ hd_status_plugin_item_get_dbus_g_connection (HDStatusPluginItem *item,
DBusBusType type,
GError **error)
{
- HDStatusPluginItemPrivate *priv;
DBusGConnection *g_connection;
DBusConnection *connection;
GError *tmp_error = NULL;
g_return_val_if_fail (HD_IS_STATUS_PLUGIN_ITEM (item), NULL);
- priv = item->priv;
-
/* Create a DBusGConnection (not private yet) */
g_connection = dbus_g_bus_get (type, &tmp_error);
Please sign in to comment.
Something went wrong with that request. Please try again.