r1486 - in trunk/src/target/OM-2007/applications/openmoko-today: . src
thomas at sita.openmoko.org
thomas at sita.openmoko.org
Thu Mar 22 16:40:11 CET 2007
Author: thomas
Date: 2007-03-22 16:40:10 +0100 (Thu, 22 Mar 2007)
New Revision: 1486
Added:
trunk/src/target/OM-2007/applications/openmoko-today/src/xutil.c
trunk/src/target/OM-2007/applications/openmoko-today/src/xutil.h
Modified:
trunk/src/target/OM-2007/applications/openmoko-today/ChangeLog
trunk/src/target/OM-2007/applications/openmoko-today/src/Makefile.am
trunk/src/target/OM-2007/applications/openmoko-today/src/today-main.c
Log:
* src/Makefile.am:
* src/today-main.c: (today_update_date), (today_setup_events_area),
(create_ui):
* src/xutil.c:
* src/xutil.h:
Add --enable-desktop option
Modified: trunk/src/target/OM-2007/applications/openmoko-today/ChangeLog
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-today/ChangeLog 2007-03-22 13:34:20 UTC (rev 1485)
+++ trunk/src/target/OM-2007/applications/openmoko-today/ChangeLog 2007-03-22 15:40:10 UTC (rev 1486)
@@ -1,3 +1,13 @@
+Thu, 22 Mar 2007 15:36:29 +0000 Thomas Wood
+
+ * src/Makefile.am:
+ * src/today-main.c: (today_update_date), (today_setup_events_area),
+ (create_ui):
+ * src/xutil.c:
+ * src/xutil.h:
+
+ Add --enable-desktop option
+
Thu, 22 Mar 2007 12:59:43 +0000 Thomas Wood
* src/today-main.c: (create_ui): Set window title to keep hrw happy
Modified: trunk/src/target/OM-2007/applications/openmoko-today/src/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-today/src/Makefile.am 2007-03-22 13:34:20 UTC (rev 1485)
+++ trunk/src/target/OM-2007/applications/openmoko-today/src/Makefile.am 2007-03-22 15:40:10 UTC (rev 1486)
@@ -10,7 +10,7 @@
today_SOURCES = today-main.c \
today-events-area.h today-events-area.c \
-today-utils.h today-utils.c
+today-utils.h today-utils.c xutil.c
today_LDADD = @TODAY_LIBS@
Modified: trunk/src/target/OM-2007/applications/openmoko-today/src/today-main.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-today/src/today-main.c 2007-03-22 13:34:20 UTC (rev 1485)
+++ trunk/src/target/OM-2007/applications/openmoko-today/src/today-main.c 2007-03-22 15:40:10 UTC (rev 1486)
@@ -30,6 +30,7 @@
#include <libmokoui/moko-pixmap-button.h>
#include "today-events-area.h"
#include "today-utils.h"
+#include "xutil.h"
#define LOG_ERROR \
g_warning ("Got error '%s', code '%d'", \
@@ -37,6 +38,22 @@
#define FREE_ERROR g_error_free (error) ; error = NULL ;
+/*** configuration options ***/
+/* default to false, although this might want to be reversed in the future */
+static gboolean enable_desktop = FALSE;
+
+static GOptionEntry option_entries[] =
+{
+ { "enable-desktop", 'd', 0, G_OPTION_ARG_NONE, &enable_desktop, "Set as desktop window", NULL},
+ { NULL }
+};
+
+
+/**
+ * today_update_date ()
+ *
+ * Update the specified GtkLabel with the current date
+ */
static void
today_update_date (GtkLabel * label)
{
@@ -59,6 +76,11 @@
}
+/**
+ * today_update_time ()
+ *
+ * Update the specified GtkLabel with the current time
+ */
static void
today_update_time (GtkLabel * label)
{
@@ -216,6 +238,18 @@
gtk_widget_set_name (window, "today-application-window");
gtk_window_set_title (GTK_WINDOW (window), "Today");
+ if (enable_desktop)
+ {
+ gint x, y, w, h;
+ gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DESKTOP);
+ gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window), TRUE);
+ if (x_get_workarea (&x, &y, &w, &h))
+ {
+ gtk_window_set_default_size (GTK_WINDOW (window), w, h);
+ gtk_window_move (GTK_WINDOW (window), x, y);
+ }
+ }
+
vbox = gtk_vbox_new (FALSE, 12);
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -293,8 +327,20 @@
int
main (int argc, char **argv)
{
+ GError *error = NULL;
+ GOptionContext *context;
+
gtk_init (&argc, &argv);
+
+ /* parse command line options */
+ context = g_option_context_new ("- OpenMoko Today Application");
+ g_option_context_add_main_entries (context, option_entries, NULL);
+ g_option_context_add_group (context, gtk_get_option_group (TRUE));
+ g_option_context_parse (context, &argc, &argv, &error);
+
+ /* create the UI and run */
create_ui ();
gtk_main ();
+
return 0;
}
Added: trunk/src/target/OM-2007/applications/openmoko-today/src/xutil.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-today/src/xutil.c 2007-03-22 13:34:20 UTC (rev 1485)
+++ trunk/src/target/OM-2007/applications/openmoko-today/src/xutil.c 2007-03-22 15:40:10 UTC (rev 1486)
@@ -0,0 +1,52 @@
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+
+char *
+x_strerror (int code)
+{
+#define BUFFER_SIZE 255
+ char *s;
+
+ s = g_malloc (BUFFER_SIZE);
+
+ XGetErrorText (GDK_DISPLAY (), code, s, BUFFER_SIZE);
+
+ return s;
+}
+
+
+gboolean
+x_get_workarea (int *x, int *y, int *w, int *h)
+{
+ Atom real_type;
+ int result, xres, real_format;
+ unsigned long items_read, items_left;
+ long *coords;
+
+ Atom workarea_atom = XInternAtom (GDK_DISPLAY (), "_NET_WORKAREA", False);
+
+ gdk_error_trap_push ();
+ result = XGetWindowProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (),
+ workarea_atom, 0L, 4L, False,
+ XA_CARDINAL, &real_type, &real_format,
+ &items_read, &items_left,
+ (unsigned char **) (void*)&coords);
+ if ((xres = gdk_error_trap_pop ()) != 0) {
+ char *s = x_strerror (xres);
+ g_warning ("Cannot get property: %s", s);
+ g_free (s);
+ return FALSE;
+ }
+
+ if (result == Success && items_read) {
+ *x = coords[0];
+ *y = coords[1];
+ *w = coords[2];
+ *h = coords[3];
+ XFree(coords);
+ return TRUE;
+ }
+ return FALSE;
+}
Added: trunk/src/target/OM-2007/applications/openmoko-today/src/xutil.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-today/src/xutil.h 2007-03-22 13:34:20 UTC (rev 1485)
+++ trunk/src/target/OM-2007/applications/openmoko-today/src/xutil.h 2007-03-22 15:40:10 UTC (rev 1486)
@@ -0,0 +1,3 @@
+char * x_strerror (int code);
+
+gboolean x_get_workarea (int *x, int *y, int *w, int *h);
More information about the commitlog
mailing list