[maemo-commits] [maemo-commits] r9857 - in projects/haf/trunk/libosso-help: . debian helptest src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Wed Feb 14 14:51:17 EET 2007
Author: schulhof
Date: 2007-02-14 14:51:15 +0200 (Wed, 14 Feb 2007)
New Revision: 9857

Modified:
   projects/haf/trunk/libosso-help/ChangeLog
   projects/haf/trunk/libosso-help/configure.ac
   projects/haf/trunk/libosso-help/debian/changelog
   projects/haf/trunk/libosso-help/debian/control
   projects/haf/trunk/libosso-help/helptest/helptest.c
   projects/haf/trunk/libosso-help/src/osso-helplib.c
Log:
libosso-help-2.1.0-1:
Migrated to hildon-1


Modified: projects/haf/trunk/libosso-help/ChangeLog
===================================================================
--- projects/haf/trunk/libosso-help/ChangeLog	2007-02-14 12:46:51 UTC (rev 9856)
+++ projects/haf/trunk/libosso-help/ChangeLog	2007-02-14 12:51:15 UTC (rev 9857)
@@ -1,3 +1,8 @@
+2007-02-14  Gabriel Schulhof <gabriel.schulhof at nokia.com>
+
+	* Version 2.1.0
+	* Migrated to libhildon-1
+
 2007-01-04  Gabriel Schulhof <gabriel.schulhof at nokia.com>
 	
 	* Version 2.0.9

Modified: projects/haf/trunk/libosso-help/configure.ac
===================================================================
--- projects/haf/trunk/libosso-help/configure.ac	2007-02-14 12:46:51 UTC (rev 9856)
+++ projects/haf/trunk/libosso-help/configure.ac	2007-02-14 12:51:15 UTC (rev 9857)
@@ -35,8 +35,7 @@
     libxml-2.0 >= 2.6.7
     gtk+-2.0 >= 2.6
     glib-2.0 >= 2.6
-    hildon-libs >= 0.9.4
-    hildon-lgpl >= 0.9.4
+    hildon-1 >= 1.0.0
     libosso >= 1.0.0
     libpng
     libgtkhtml-3.8

Modified: projects/haf/trunk/libosso-help/debian/changelog
===================================================================
--- projects/haf/trunk/libosso-help/debian/changelog	2007-02-14 12:46:51 UTC (rev 9856)
+++ projects/haf/trunk/libosso-help/debian/changelog	2007-02-14 12:51:15 UTC (rev 9857)
@@ -1,3 +1,9 @@
+libosso-help (2.1.0-1) unstable; urgency=low
+
+  * Migrated to libhildon-1
+
+ -- Gabriel Schulhof <gabriel.schulhof at nokia.com>  Wed, 14 Feb 2007 14:47:52 +0200
+
 libosso-help (2.0.9-1) unstable; urgency=low
 
   * When translation unavailable, fall back to en_GB

Modified: projects/haf/trunk/libosso-help/debian/control
===================================================================
--- projects/haf/trunk/libosso-help/debian/control	2007-02-14 12:46:51 UTC (rev 9856)
+++ projects/haf/trunk/libosso-help/debian/control	2007-02-14 12:51:15 UTC (rev 9857)
@@ -2,13 +2,13 @@
 Section: misc
 Priority: optional
 Maintainer: Jakub Pavelek <jakub.pavelek at nokia.com>
-Build-Depends: debhelper (>= 4.0.0), libgtk2.0-dev (>= 2.6.0-1), pkg-config, libosso-dev, hildon-lgpl-dev (>= 0.12.1-3), hildon-libs-dev (>= 0.12.1-1), intltool (>= 0.21), autoconf, automake1.7, libtool, gtkhtml-dev (>= 3.9.1), libart-2.0-dev, libpng12-dev, libjpeg62-dev, libxml2-dev
+Build-Depends: debhelper (>= 4.0.0), libgtk2.0-dev (>= 2.6.0-1), pkg-config, libosso-dev, libhildon1-dev (>= 0.9.9-3), intltool (>= 0.21), autoconf, automake1.7, libtool, gtkhtml-dev (>= 3.9.1), libart-2.0-dev, libpng12-dev, libjpeg62-dev, libxml2-dev
 Standards-Version: 3.6.1
 
 Package: libosso-help-dev
 Section: libdevel
 Architecture: all
-Depends: ${shlibs:Depends}, ${misc:Depends}, libosso-help0 (= ${Source-Version}), hildon-libs-dev, libart-2.0-dev, gtkhtml-dev
+Depends: ${shlibs:Depends}, ${misc:Depends}, libosso-help0 (= ${Source-Version}), libhildon1-dev, libart-2.0-dev, gtkhtml-dev
 Description: OSSO HelpLib for application developers
  Development files for HelpLib; access and controlling
  OSSO Help from other applications.

Modified: projects/haf/trunk/libosso-help/helptest/helptest.c
===================================================================
--- projects/haf/trunk/libosso-help/helptest/helptest.c	2007-02-14 12:46:51 UTC (rev 9856)
+++ projects/haf/trunk/libosso-help/helptest/helptest.c	2007-02-14 12:51:15 UTC (rev 9857)
@@ -37,8 +37,8 @@
 #include <gtk/gtk.h>
 #include <libosso.h>
 
-#include <hildon-widgets/hildon-app.h>
-#include <hildon-widgets/hildon-appview.h>
+#include <hildon/hildon.h>
+#include <hildon/hildon.h>
 
 #include <locale.h>
 #include <libintl.h>
@@ -162,23 +162,23 @@
     g_assert( osso );
 
     if (!style) {   /* Button UI */
-        HildonApp *app;
-        HildonAppView *appview;
+        HildonProgram *hildon_program ;
+        HildonWindow *hildon_window ;
         GtkWidget *main_vbox;
         GtkWidget *button;
 
-        app= HILDON_APP (hildon_app_new());
-        g_assert(app);
+        hildon_program = hildon_program_get_instance () ;
+        g_assert (hildon_program) ;
 
-        hildon_app_set_title( app, "Help Dialog Test" );
+        hildon_window = HILDON_WINDOW (hildon_window_new ()) ;
+        g_assert (hildon_window) ;
 
-        appview= HILDON_APPVIEW (hildon_appview_new(""));
-        g_assert(appview);
+        hildon_program_add_window (hildon_program, hildon_window) ;
 
-        hildon_app_set_appview( HILDON_APP (app), appview );
+        g_set_application_name ( "Help Dialog Test" );
 
         main_vbox= gtk_vbox_new( FALSE, 0 );
-        gtk_container_add( GTK_CONTAINER (appview), GTK_WIDGET (main_vbox) );
+        gtk_container_add( GTK_CONTAINER (hildon_window), GTK_WIDGET (main_vbox) );
     
         button= gtk_button_new_with_label( "Help!" );
         gtk_box_pack_start( GTK_BOX (main_vbox), 
@@ -189,7 +189,7 @@
     
         gtk_widget_show_all( GTK_WIDGET (main_vbox) );
 
-        gtk_widget_show( GTK_WIDGET (app) );
+        gtk_widget_show( GTK_WIDGET (hildon_window) );
     } else {
         GtkWidget *dialog;
         GtkWidget *vbox;

Modified: projects/haf/trunk/libosso-help/src/osso-helplib.c
===================================================================
--- projects/haf/trunk/libosso-help/src/osso-helplib.c	2007-02-14 12:46:51 UTC (rev 9856)
+++ projects/haf/trunk/libosso-help/src/osso-helplib.c	2007-02-14 12:51:15 UTC (rev 9857)
@@ -26,7 +26,7 @@
 
 #include <libosso.h>
 #include <osso-log.h>
-#include <hildon-widgets/hildon-dialoghelp.h>
+#include <hildon/hildon.h>
 
 #include <unistd.h>
 #include <string.h>
@@ -43,6 +43,155 @@
 
 /*---=== Generic helpers (private interface) ===---*/
 
+static guint help_signal = 0 ;
+
+static GdkFilterReturn
+handle_xevent(GdkXEvent * xevent, GdkEvent * event, gpointer dialog)
+{
+    XAnyEvent *eventti = xevent;
+
+    if (eventti->type == ClientMessage) {
+        Atom help_atom, wm_atom;
+        Display *disp;
+        XClientMessageEvent *cm;
+
+        disp = GDK_DISPLAY();
+        cm = xevent;
+
+        help_atom = XInternAtom(disp, "_NET_WM_CONTEXT_HELP", True);
+        wm_atom = XInternAtom(disp, "WM_PROTOCOLS", True);
+
+        if (cm->message_type == wm_atom && cm->data.l[0] == help_atom) {
+            /* XClientMessageEvent *cm = xevent; */
+            g_signal_emit(G_OBJECT(dialog), help_signal, 0);
+        }
+
+        return GDK_FILTER_REMOVE;       /* Event handled, don't process
+                                           further */
+    }
+
+    return GDK_FILTER_CONTINUE; /* Event not handled */
+}
+
+/**
+ * gtk_dialog_help_enable:
+ * @dialog: The dialog for which help is to be enabled.
+ *
+ * Enables context help button for a given dialog. The signal "help" can be
+ * connected to handler by normal GTK methods. Note that this function
+ * has to be called before the dialog is shown.
+ *
+ * The "help" signal itself has no other parameters than the dialog where
+ * it is connected to, ie.:
+ * void user_function(GtkDialog *dialog, gpointer user_data);
+ */
+static void gtk_dialog_help_enable(GtkDialog * dialog)
+{
+    GdkWindow *window;
+    GdkDisplay *display;
+    Atom *protocols;
+    Atom *list;
+    Atom helpatom;
+    int amount = 0;
+    int n = 0;
+    int i = 0;
+    int help_enabled = 0;
+   
+    /* Create help signal if it didn't exist */  
+    if (help_signal == 0) {
+        help_signal = g_signal_new("help", GTK_TYPE_DIALOG,
+                                   G_SIGNAL_ACTION, (guint) - 1, NULL,
+                                   NULL, g_cclosure_marshal_VOID__VOID,
+                                   G_TYPE_NONE, 0);
+    }
+
+    g_return_if_fail(GTK_IS_DIALOG(dialog));
+
+    gtk_widget_realize(GTK_WIDGET(dialog));
+    window = GTK_WIDGET(dialog)->window;
+    display = gdk_drawable_get_display (window);
+
+    /* Create a list of atoms stored in GdkWindow */
+    XGetWMProtocols(GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
+                    &list, &amount);
+   
+    protocols = (Atom *) malloc ((amount+1) * sizeof (Atom));
+    helpatom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_CONTEXT_HELP");
+
+    /* Enable the dialoghelp if help_atom is in the atoms' list */
+    for (i=0; i<amount; i++)
+    {
+            protocols[n++] = list[i];
+            if (list[i] == helpatom)
+            {
+                    help_enabled = 1;
+            }
+    }
+    XFree (list);
+
+    /* Add the help_atom to the atoms' list if it was not in it */
+    if (!help_enabled)
+    {
+            protocols[n++] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_CONTEXT_HELP");
+    }
+   
+    /* Replace the protocol property of the GdkWindow with the new atoms' list */
+    XSetWMProtocols (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), protocols, n);
+    free (protocols);
+   
+    /* Add a callback function as event filter */
+    gdk_window_add_filter(window, handle_xevent, dialog);
+}
+
+
+/**
+ * gtk_dialog_help_disable:
+ * @dialog: The dialog for which help is to be disabled.
+ *
+ * Disables context help button for the given dialog.
+ **/
+static void gtk_dialog_help_disable(GtkDialog * dialog)
+{
+    GdkWindow *window=NULL;
+    GdkDisplay *display;
+    Atom *protocols;
+    Atom *list;
+    Atom helpatom;
+    int amount = 0;
+    int n = 0;
+    int i = 0;
+   
+    g_return_if_fail(GTK_IS_DIALOG(dialog));
+
+    gtk_widget_realize(GTK_WIDGET(dialog));
+    window = GTK_WIDGET(dialog)->window;
+    display = gdk_drawable_get_display (window);
+
+    /* Create a list of atoms stored in GdkWindow */
+    XGetWMProtocols(GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
+                    &list, &amount);
+   
+    helpatom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_CONTEXT_HELP");
+    protocols = (Atom *) malloc (amount * sizeof (Atom));
+
+    /* Remove the help_atom if it is in the atoms' list */
+    for (i=0; i<amount; i++)
+    {
+            if (list[i] != helpatom)
+            {
+                    protocols[n++] = list[i];
+            }
+    }
+    XFree (list);
+   
+    /* Replace the protocol property of the GdkWindow with the new atoms' list */
+    XSetWMProtocols (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), protocols, n);
+    free (protocols);
+
+    /* Remove the event filter */
+    gdk_window_remove_filter(window, handle_xevent, dialog);
+}
+
 static gboolean ossohelp_file2_private( const char *basename, int basename_len,
                          char *fn_buf, size_t fn_buflen, char *language ) ;
 /**


More information about the maemo-commits mailing list