put some methods toward proper wrapper
[simple-launcher] / applet-wrapper.cc
1 // This file is a part of Simple Launcher
2 //
3 // Copyright (C) 2006, 2007, Mikhail Sobolev
4 //
5 // Simple Launcher is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License version 2 as published by
7 // the Free Software Foundation.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT
10 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12 // more details.
13 //
14 // You should have received a copy of the GNU General Public License along with
15 // this program; if not, write to the Free Software Foundation, Inc., 51
16 // Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 #include <cairo/cairo.h>
19
20 #include <libhildondesktop/libhildondesktop.h>
21
22 #include "applet-wrapper.h"
23
24 #include "simple-launcher.h"
25
26   static void sla_wrapper_init(SLAWrapper *applet);
27   static void sla_wrapper_class_init(SLAWrapperClass *klass);
28   static void sla_wrapper_finalize(GObject *object);
29   static gboolean sla_wrapper_expose(GtkWidget *widget, GdkEventExpose *event);
30   static void sla_wrapper_size_allocate(GtkWidget *widget, GtkAllocation *alloc);
31   static void sla_wrapper_size_request(GtkWidget *widget, GtkRequisition *requisition);
32
33 struct _SLAWrapperPrivate {
34   void *applet;
35 };
36
37 HD_DEFINE_PLUGIN(SLAWrapper, sla_wrapper, HILDON_DESKTOP_TYPE_HOME_ITEM)
38
39 static void sla_wrapper_init(SLAWrapper *applet) {
40   GdkColormap *colormap = NULL;
41
42   if ((colormap = gdk_screen_get_rgba_colormap(gdk_screen_get_default())) != NULL) {
43     gtk_widget_set_colormap(GTK_WIDGET(applet), colormap);
44   }
45 }
46
47 static void sla_wrapper_class_init(SLAWrapperClass *klass) {
48   GtkWidgetClass *widget_class;
49   GObjectClass *object_class;
50
51   widget_class = GTK_WIDGET_CLASS(klass);
52   object_class = G_OBJECT_CLASS(klass);
53
54   object_class->finalize = sla_wrapper_finalize;
55
56   widget_class->expose_event = sla_wrapper_expose;
57   widget_class->size_allocate = sla_wrapper_size_allocate;
58   widget_class->size_request = sla_wrapper_size_request;
59
60   g_type_class_add_private(klass, sizeof (SLAWrapperPrivate)); // Do I need this?
61 }
62
63 static void sla_wrapper_finalize(GObject *object) {
64 #if 0
65   _SLAWrapperPrivate *priv = SLA_WRAPPER(object)->priv;
66
67   if (priv->background_pixmap != NULL) {
68     g_object_unref(priv->background_pixmap);
69     priv->background_pixmap = NULL;
70   }
71 #endif
72 }
73
74 static gboolean sla_wrapper_expose(GtkWidget *widget, GdkEventExpose *event) {
75   if (GTK_WIDGET_DRAWABLE(widget)) {
76     return GTK_WIDGET_CLASS(sla_wrapper_parent_class)->expose_event(widget, event);
77   } else {
78     return FALSE;
79   }
80 }
81
82 static void sla_wrapper_size_allocate(GtkWidget *widget, GtkAllocation *alloc) {
83   GTK_WIDGET_CLASS(sla_wrapper_parent_class)->size_allocate(widget, alloc);
84 }
85
86 static void sla_wrapper_size_request(GtkWidget *widget, GtkRequisition *requisition) {
87 #if 0
88   requisition->width = our_desired_width;
89   requisition->height = our_desired_height;
90 #endif
91 }
92
93 // vim:ts=2:sw=2:et