[maemo-commits] [maemo-commits] r15098 - in projects/haf/trunk/hail: . debian hail/hail-hildon-desktop

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu Jan 17 17:19:53 EET 2008
Author: atdomoko
Date: 2008-01-17 17:19:52 +0200 (Thu, 17 Jan 2008)
New Revision: 15098

Modified:
   projects/haf/trunk/hail/ChangeLog
   projects/haf/trunk/hail/debian/changelog
   projects/haf/trunk/hail/hail/hail-hildon-desktop/hailmenuitem.c
Log:
* hail/hail-hildon-desktop/hailmenuitem.c
  AtkSelection interface implementation
* Fixes: NB#79011



Modified: projects/haf/trunk/hail/ChangeLog
===================================================================
--- projects/haf/trunk/hail/ChangeLog	2008-01-17 15:09:40 UTC (rev 15097)
+++ projects/haf/trunk/hail/ChangeLog	2008-01-17 15:19:52 UTC (rev 15098)
@@ -1,3 +1,9 @@
+2008-01-17 Attila Domokos <attila.domokos at nokia.com>
+
+	* hail/hail-hildon-desktop/hailmenuitem.c
+	  AtkSelection interface implementation
+	* Fixes: NB#79011
+
 2008-01-10 Attila Domokos <attila.domokos at nokia.com>
 
 	* hail/hail-hildon-libs/hailnumbereditor.c

Modified: projects/haf/trunk/hail/debian/changelog
===================================================================
--- projects/haf/trunk/hail/debian/changelog	2008-01-17 15:09:40 UTC (rev 15097)
+++ projects/haf/trunk/hail/debian/changelog	2008-01-17 15:19:52 UTC (rev 15098)
@@ -1,3 +1,11 @@
+hail (2.0.0-2) unstable; urgency=low
+
+  * hail/hail-hildon-desktop/hailmenuitem.c
+    AtkSelection interface implementation
+  * Fixes: NB#79011
+
+ -- Attila Domokos <attila.domokos at nokia.com>  Thu, 17 Jan 2008 17:11:39 +0200
+
 hail (2.0.0-1) unstable; urgency=low
 
   * hail/hail-hildon-libs/hailnumbereditor.c

Modified: projects/haf/trunk/hail/hail/hail-hildon-desktop/hailmenuitem.c
===================================================================
--- projects/haf/trunk/hail/hail/hail-hildon-desktop/hailmenuitem.c	2008-01-17 15:09:40 UTC (rev 15097)
+++ projects/haf/trunk/hail/hail/hail-hildon-desktop/hailmenuitem.c	2008-01-17 15:19:52 UTC (rev 15098)
@@ -41,6 +41,20 @@
 
 static void                  hail_menu_item_real_initialize  (AtkObject *obj,
 							      gpointer data);
+/* AtkSelection interface */
+static void                  atk_selection_interface_init    (AtkSelectionIface  *iface);
+static gboolean              hail_menu_item_add_selection    (AtkSelection   *selection,
+                                                              gint           i);
+static gboolean              hail_menu_item_clear_selection  (AtkSelection   *selection);
+static AtkObject*            hail_menu_item_ref_selection    (AtkSelection   *selection,
+                                                              gint           i);
+static gint                  hail_menu_item_get_selection_count
+                                                             (AtkSelection   *selection);
+static gboolean              hail_menu_item_is_child_selected
+                                                             (AtkSelection   *selection,
+                                                              gint           i);
+static gboolean              hail_menu_item_remove_selection (AtkSelection   *selection,
+                                                              gint           i);
 
 static GType parent_type;
 static GtkAccessibleClass *parent_class = NULL;
@@ -89,11 +103,21 @@
         NULL
       };
 
+      static const GInterfaceInfo atk_selection_info =
+        {
+          (GInterfaceInitFunc) atk_selection_interface_init,
+          (GInterfaceFinalizeFunc) NULL,
+          NULL
+        };
+
       type = g_type_register_static (parent_type,
                                      "HailMenuItem", &tinfo, 0);
 
       g_type_add_interface_static (type, ATK_TYPE_ACTION,
                                    &atk_action_info);
+
+      g_type_add_interface_static (type, ATK_TYPE_SELECTION,
+                                   &atk_selection_info);
     }
 
   return type;
@@ -217,6 +241,8 @@
     {
       return FALSE;
     }
+
+  return FALSE;
 }
 
 /*
@@ -232,7 +258,7 @@
   /* define properly roleName if it is a submenu */
   widget = GTK_ACCESSIBLE(obj)->widget;
 
-  if (GTK_IS_MENU_ITEM(widget)) 
+  if (GTK_IS_MENU_ITEM(widget))
     {
       if (gtk_menu_item_get_submenu(GTK_MENU_ITEM (widget)))
       {
@@ -240,3 +266,207 @@
       }
     }
 }
+/******************************************************************************/
+/****************** atkselection.h implementation *****************************/
+/******* This in implemented on gailsubmenuitem, but we *can't* access to *****/
+/******* that, as it obscured on GAIL package, and we can't use the ***********/
+/******** "Anonymous (run-time) Inheritance from GAIL here"  ******************/
+/******************************************************************************/
+
+static void
+atk_selection_interface_init (AtkSelectionIface *iface)
+{
+  g_return_if_fail (iface != NULL);
+
+  iface->add_selection = hail_menu_item_add_selection;
+  iface->clear_selection = hail_menu_item_clear_selection;
+  iface->ref_selection = hail_menu_item_ref_selection;
+  iface->get_selection_count = hail_menu_item_get_selection_count;
+  iface->is_child_selected = hail_menu_item_is_child_selected;
+  iface->remove_selection = hail_menu_item_remove_selection;
+  /*
+   * select_all_selection does not make sense for a submenu of a menu item
+   * so no implementation is provided.
+   */
+}
+
+static gboolean
+hail_menu_item_add_selection (AtkSelection *selection,
+                                  gint          i)
+{
+  GtkMenuShell *shell;
+  GList *item;
+  guint length;
+  GtkWidget *widget;
+  GtkWidget *submenu;
+
+  widget =  GTK_ACCESSIBLE (selection)->widget;
+  if (widget == NULL)
+    /* State is defunct */
+    return FALSE;
+
+  submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
+  if (submenu == NULL) {
+    return FALSE;
+  }
+
+  shell = GTK_MENU_SHELL (submenu);
+  length = g_list_length (shell->children);
+  if (i < 0 || i > length)
+    return FALSE;
+
+  item = g_list_nth (shell->children, i);
+  g_return_val_if_fail (item != NULL, FALSE);
+  g_return_val_if_fail (GTK_IS_MENU_ITEM(item->data), FALSE);
+   
+  gtk_menu_shell_select_item (shell, GTK_WIDGET (item->data));
+  return TRUE;
+}
+
+static gboolean
+hail_menu_item_clear_selection (AtkSelection   *selection)
+{
+  GtkMenuShell *shell;
+  GtkWidget *widget;
+  GtkWidget *submenu;
+
+  widget =  GTK_ACCESSIBLE (selection)->widget;
+  if (widget == NULL)
+    /* State is defunct */
+    return FALSE;
+
+  submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
+  if (submenu == NULL) {
+    return FALSE;
+  }
+
+  shell = GTK_MENU_SHELL (submenu);
+
+  gtk_menu_shell_deselect (shell);
+  return TRUE;
+}
+
+static AtkObject*
+hail_menu_item_ref_selection (AtkSelection   *selection,
+                                  gint           i)
+{
+  GtkMenuShell *shell;
+  AtkObject *obj;
+  GtkWidget *widget;
+  GtkWidget *submenu;
+
+  if (i != 0)
+    return NULL;
+
+  widget =  GTK_ACCESSIBLE (selection)->widget;
+  if (widget == NULL)
+    /* State is defunct */
+    return NULL;
+
+  submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
+  if (submenu == NULL) {
+    return NULL;
+  }
+
+  shell = GTK_MENU_SHELL (submenu);
+  
+  if (shell->active_menu_item != NULL)
+    {
+      obj = gtk_widget_get_accessible (shell->active_menu_item);
+      g_object_ref (obj);
+      return obj;
+    }
+  else
+    {
+      return NULL;
+    }
+}
+
+static gint
+hail_menu_item_get_selection_count (AtkSelection   *selection)
+{
+  GtkMenuShell *shell;
+  GtkWidget *widget;
+  GtkWidget *submenu;
+
+  widget =  GTK_ACCESSIBLE (selection)->widget;
+  if (widget == NULL)
+    /* State is defunct */
+    return 0;
+
+  submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
+  if (submenu == NULL) {
+    return 0;
+  }
+
+  shell = GTK_MENU_SHELL (submenu);
+
+  /*
+   * Identifies the currently selected menu item
+   */
+  if (shell->active_menu_item == NULL)
+    return 0;
+  else
+    return 1;
+}
+
+static gboolean
+hail_menu_item_is_child_selected (AtkSelection   *selection,
+                                       gint           i)
+{
+  GtkMenuShell *shell;
+  gint j;
+  GtkWidget *widget;
+  GtkWidget *submenu;
+
+  widget =  GTK_ACCESSIBLE (selection)->widget;
+  if (widget == NULL)
+    /* State is defunct */
+    return FALSE;
+
+  submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
+  g_return_val_if_fail (GTK_IS_MENU_SHELL (submenu), FALSE);
+  shell = GTK_MENU_SHELL (submenu);
+
+  if (shell->active_menu_item == NULL)
+    return FALSE;
+  
+  j = g_list_index (shell->children, shell->active_menu_item);
+
+  return (j==i);   
+}
+
+static gboolean
+hail_menu_item_remove_selection (AtkSelection   *selection,
+                                 gint           i)
+{
+  GtkMenuShell *shell;
+  GtkWidget *widget;
+  GtkWidget *submenu;
+
+  if (i != 0)
+    return FALSE;
+
+  widget =  GTK_ACCESSIBLE (selection)->widget;
+  if (widget == NULL)
+    /* State is defunct */
+    return FALSE;
+
+  submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
+  if (submenu == NULL) {
+    return FALSE;
+  }
+
+  shell = GTK_MENU_SHELL (submenu);
+
+  if (shell->active_menu_item && 
+      GTK_MENU_ITEM (shell->active_menu_item)->submenu)
+    {
+    /*
+     * Menu item contains a menu and it is the selected menu item
+     * so deselect it.
+     */
+      gtk_menu_shell_deselect (shell);
+    }
+  return TRUE;
+}


More information about the maemo-commits mailing list