Logo Search packages:      
Sourcecode: unity version File versions  Download package

panel-menu-manager.c

/* panel-menu-manager.c generated by valac, the Vala compiler
 * generated from panel-menu-manager.vala, do not modify */

/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
/*
 * Copyright (C) 2010 Canonical Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by canonical.com
 *
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>


#define TYPE_MENU_MANAGER (menu_manager_get_type ())
#define MENU_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MENU_MANAGER, MenuManager))
#define MENU_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MENU_MANAGER, MenuManagerClass))
#define IS_MENU_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MENU_MANAGER))
#define IS_MENU_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MENU_MANAGER))
#define MENU_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MENU_MANAGER, MenuManagerClass))

typedef struct _MenuManager MenuManager;
typedef struct _MenuManagerClass MenuManagerClass;
typedef struct _MenuManagerPrivate MenuManagerPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _MenuManager {
      GObject parent_instance;
      MenuManagerPrivate * priv;
};

struct _MenuManagerClass {
      GObjectClass parent_class;
};

struct _MenuManagerPrivate {
      GtkMenu* current_menu;
};


static MenuManager* menu_manager__menu_manager_global;
static MenuManager* menu_manager__menu_manager_global = NULL;
static gpointer menu_manager_parent_class = NULL;

GType menu_manager_get_type (void);
#define MENU_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MENU_MANAGER, MenuManagerPrivate))
enum  {
      MENU_MANAGER_DUMMY_PROPERTY
};
MenuManager* menu_manager_new (void);
MenuManager* menu_manager_construct (GType object_type);
MenuManager* menu_manager_get_default (void);
void menu_manager_register_visible_menu (MenuManager* self, GtkMenu* menu);
gboolean menu_manager_menu_is_open (MenuManager* self);
static void menu_manager_finalize (GObject* obj);



static gpointer _g_object_ref0 (gpointer self) {
      return self ? g_object_ref (self) : NULL;
}


MenuManager* menu_manager_get_default (void) {
      MenuManager* result = NULL;
      if (menu_manager__menu_manager_global == NULL) {
            MenuManager* _tmp0_;
            menu_manager__menu_manager_global = (_tmp0_ = menu_manager_new (), _g_object_unref0 (menu_manager__menu_manager_global), _tmp0_);
      }
      result = _g_object_ref0 (menu_manager__menu_manager_global);
      return result;
}


void menu_manager_register_visible_menu (MenuManager* self, GtkMenu* menu) {
      gboolean _tmp0_ = FALSE;
      gboolean _tmp1_ = FALSE;
      GtkMenu* _tmp2_;
      g_return_if_fail (self != NULL);
      g_return_if_fail (menu != NULL);
      if (GTK_IS_MENU (self->priv->current_menu)) {
            _tmp1_ = gtk_widget_get_visible ((GtkWidget*) self->priv->current_menu) == TRUE;
      } else {
            _tmp1_ = FALSE;
      }
      if (_tmp1_) {
            _tmp0_ = self->priv->current_menu != menu;
      } else {
            _tmp0_ = FALSE;
      }
      if (_tmp0_) {
            gtk_menu_popdown (self->priv->current_menu);
      }
      self->priv->current_menu = (_tmp2_ = _g_object_ref0 (menu), _g_object_unref0 (self->priv->current_menu), _tmp2_);
}


gboolean menu_manager_menu_is_open (MenuManager* self) {
      gboolean result = FALSE;
      gboolean _tmp0_ = FALSE;
      g_return_val_if_fail (self != NULL, FALSE);
      if (GTK_IS_MENU (self->priv->current_menu)) {
            _tmp0_ = gtk_widget_get_visible ((GtkWidget*) self->priv->current_menu) == TRUE;
      } else {
            _tmp0_ = FALSE;
      }
      if (_tmp0_) {
            result = TRUE;
            return result;
      }
      result = FALSE;
      return result;
}


MenuManager* menu_manager_construct (GType object_type) {
      MenuManager * self;
      self = (MenuManager*) g_object_new (object_type, NULL);
      return self;
}


MenuManager* menu_manager_new (void) {
      return menu_manager_construct (TYPE_MENU_MANAGER);
}


static void menu_manager_class_init (MenuManagerClass * klass) {
      menu_manager_parent_class = g_type_class_peek_parent (klass);
      g_type_class_add_private (klass, sizeof (MenuManagerPrivate));
      G_OBJECT_CLASS (klass)->finalize = menu_manager_finalize;
}


static void menu_manager_instance_init (MenuManager * self) {
      self->priv = MENU_MANAGER_GET_PRIVATE (self);
}


static void menu_manager_finalize (GObject* obj) {
      MenuManager * self;
      self = MENU_MANAGER (obj);
      _g_object_unref0 (self->priv->current_menu);
      G_OBJECT_CLASS (menu_manager_parent_class)->finalize (obj);
}


GType menu_manager_get_type (void) {
      static volatile gsize menu_manager_type_id__volatile = 0;
      if (g_once_init_enter (&menu_manager_type_id__volatile)) {
            static const GTypeInfo g_define_type_info = { sizeof (MenuManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) menu_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MenuManager), 0, (GInstanceInitFunc) menu_manager_instance_init, NULL };
            GType menu_manager_type_id;
            menu_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "MenuManager", &g_define_type_info, 0);
            g_once_init_leave (&menu_manager_type_id__volatile, menu_manager_type_id);
      }
      return menu_manager_type_id__volatile;
}





Generated by  Doxygen 1.6.0   Back to index