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

panel-indicator-bar.c

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

/*
 * 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: Neil Jagdish Patel <neil.patel@canonical.com>
 *              Jay Taoko <jay.taoko@canonical.com>
 *
 */

#include <glib.h>
#include <glib-object.h>
#include <clutk/clutk.h>
#include <gee.h>
#include <clutter/clutter.h>
#include <gtk/gtk.h>
#include <libindicator/indicator-object.h>
#include <stdlib.h>
#include <string.h>


#define UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR (unity_panel_indicators_indicator_bar_get_type ())
#define UNITY_PANEL_INDICATORS_INDICATOR_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR, UnityPanelIndicatorsIndicatorBar))
#define UNITY_PANEL_INDICATORS_INDICATOR_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR, UnityPanelIndicatorsIndicatorBarClass))
#define UNITY_PANEL_INDICATORS_IS_INDICATOR_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR))
#define UNITY_PANEL_INDICATORS_IS_INDICATOR_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR))
#define UNITY_PANEL_INDICATORS_INDICATOR_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR, UnityPanelIndicatorsIndicatorBarClass))

typedef struct _UnityPanelIndicatorsIndicatorBar UnityPanelIndicatorsIndicatorBar;
typedef struct _UnityPanelIndicatorsIndicatorBarClass UnityPanelIndicatorsIndicatorBarClass;
typedef struct _UnityPanelIndicatorsIndicatorBarPrivate UnityPanelIndicatorsIndicatorBarPrivate;

#define UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW (unity_panel_indicators_indicator_object_view_get_type ())
#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectView))
#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectViewClass))
#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW))
#define UNITY_PANEL_INDICATORS_IS_INDICATOR_OBJECT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW))
#define UNITY_PANEL_INDICATORS_INDICATOR_OBJECT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, UnityPanelIndicatorsIndicatorObjectViewClass))

typedef struct _UnityPanelIndicatorsIndicatorObjectView UnityPanelIndicatorsIndicatorObjectView;
typedef struct _UnityPanelIndicatorsIndicatorObjectViewClass UnityPanelIndicatorsIndicatorObjectViewClass;

#define UNITY_PANEL_TYPE_INDICATOR_BACKGROUND (unity_panel_indicator_background_get_type ())
#define UNITY_PANEL_INDICATOR_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_TYPE_INDICATOR_BACKGROUND, UnityPanelIndicatorBackground))
#define UNITY_PANEL_INDICATOR_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_TYPE_INDICATOR_BACKGROUND, UnityPanelIndicatorBackgroundClass))
#define UNITY_PANEL_IS_INDICATOR_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_TYPE_INDICATOR_BACKGROUND))
#define UNITY_PANEL_IS_INDICATOR_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_TYPE_INDICATOR_BACKGROUND))
#define UNITY_PANEL_INDICATOR_BACKGROUND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_TYPE_INDICATOR_BACKGROUND, UnityPanelIndicatorBackgroundClass))

typedef struct _UnityPanelIndicatorBackground UnityPanelIndicatorBackground;
typedef struct _UnityPanelIndicatorBackgroundClass UnityPanelIndicatorBackgroundClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define UNITY_TESTING_TYPE_OBJECT_REGISTRY (unity_testing_object_registry_get_type ())
#define UNITY_TESTING_OBJECT_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_TESTING_TYPE_OBJECT_REGISTRY, UnityTestingObjectRegistry))
#define UNITY_TESTING_OBJECT_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_TESTING_TYPE_OBJECT_REGISTRY, UnityTestingObjectRegistryClass))
#define UNITY_TESTING_IS_OBJECT_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_TESTING_TYPE_OBJECT_REGISTRY))
#define UNITY_TESTING_IS_OBJECT_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_TESTING_TYPE_OBJECT_REGISTRY))
#define UNITY_TESTING_OBJECT_REGISTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_TESTING_TYPE_OBJECT_REGISTRY, UnityTestingObjectRegistryClass))

typedef struct _UnityTestingObjectRegistry UnityTestingObjectRegistry;
typedef struct _UnityTestingObjectRegistryClass UnityTestingObjectRegistryClass;
#define _unity_testing_object_registry_unref0(var) ((var == NULL) ? NULL : (var = (unity_testing_object_registry_unref (var), NULL)))

#define UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL (unity_panel_indicators_indicators_model_get_type ())
#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModel))
#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModelClass))
#define UNITY_PANEL_INDICATORS_IS_INDICATORS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL))
#define UNITY_PANEL_INDICATORS_IS_INDICATORS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL))
#define UNITY_PANEL_INDICATORS_INDICATORS_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PANEL_INDICATORS_TYPE_INDICATORS_MODEL, UnityPanelIndicatorsIndicatorsModelClass))

typedef struct _UnityPanelIndicatorsIndicatorsModel UnityPanelIndicatorsIndicatorsModel;
typedef struct _UnityPanelIndicatorsIndicatorsModelClass UnityPanelIndicatorsIndicatorsModelClass;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _UnityPanelIndicatorsIndicatorBar {
      CtkBox parent_instance;
      UnityPanelIndicatorsIndicatorBarPrivate * priv;
};

struct _UnityPanelIndicatorsIndicatorBarClass {
      CtkBoxClass parent_class;
};

struct _UnityPanelIndicatorsIndicatorBarPrivate {
      GeeArrayList* indicator_array;
      UnityPanelIndicatorBackground* indicator_bground;
};


static gpointer unity_panel_indicators_indicator_bar_parent_class = NULL;

GType unity_panel_indicators_indicator_bar_get_type (void);
GType unity_panel_indicators_indicator_object_view_get_type (void);
GType unity_panel_indicator_background_get_type (void);
#define UNITY_PANEL_INDICATORS_INDICATOR_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR, UnityPanelIndicatorsIndicatorBarPrivate))
enum  {
      UNITY_PANEL_INDICATORS_INDICATOR_BAR_DUMMY_PROPERTY
};
UnityPanelIndicatorsIndicatorBar* unity_panel_indicators_indicator_bar_new (void);
UnityPanelIndicatorsIndicatorBar* unity_panel_indicators_indicator_bar_construct (GType object_type);
void unity_panel_indicators_indicator_object_view_open_last_menu_entry (UnityPanelIndicatorsIndicatorObjectView* self);
void unity_panel_indicators_indicator_object_view_open_first_menu_entry (UnityPanelIndicatorsIndicatorObjectView* self);
static void unity_panel_indicators_indicator_bar_on_menu_moved (UnityPanelIndicatorsIndicatorBar* self, UnityPanelIndicatorsIndicatorObjectView* object_view, GtkMenuDirectionType type);
IndicatorObject* unity_panel_indicators_indicator_object_view_get_indicator_object (UnityPanelIndicatorsIndicatorObjectView* self);
UnityPanelIndicatorsIndicatorObjectView* unity_panel_indicators_indicator_bar_get_indicator_view_matching (UnityPanelIndicatorsIndicatorBar* self, IndicatorObject* o);
void unity_panel_indicators_indicator_bar_set_indicator_mode (UnityPanelIndicatorsIndicatorBar* self, gboolean mode);
gpointer unity_testing_object_registry_ref (gpointer instance);
void unity_testing_object_registry_unref (gpointer instance);
GParamSpec* unity_testing_param_spec_object_registry (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void unity_testing_value_set_object_registry (GValue* value, gpointer v_object);
void unity_testing_value_take_object_registry (GValue* value, gpointer v_object);
gpointer unity_testing_value_get_object_registry (const GValue* value);
GType unity_testing_object_registry_get_type (void);
UnityTestingObjectRegistry* unity_testing_object_registry_get_default (void);
void unity_testing_object_registry_register (UnityTestingObjectRegistry* self, const char* name, GObject* object);
UnityPanelIndicatorBackground* unity_panel_indicator_background_new (void);
UnityPanelIndicatorBackground* unity_panel_indicator_background_construct (GType object_type);
GType unity_panel_indicators_indicators_model_get_type (void);
UnityPanelIndicatorsIndicatorsModel* unity_panel_indicators_indicators_model_get_default (void);
GeeArrayList* unity_panel_indicators_indicators_model_get_indicators (UnityPanelIndicatorsIndicatorsModel* self);
char* unity_panel_indicators_indicators_model_get_indicator_name (UnityPanelIndicatorsIndicatorsModel* self, IndicatorObject* o);
UnityPanelIndicatorsIndicatorObjectView* unity_panel_indicators_indicator_object_view_new (IndicatorObject* _object);
UnityPanelIndicatorsIndicatorObjectView* unity_panel_indicators_indicator_object_view_construct (GType object_type, IndicatorObject* _object);
static void _unity_panel_indicators_indicator_bar_on_menu_moved_unity_panel_indicators_indicator_object_view_menu_moved (UnityPanelIndicatorsIndicatorObjectView* _sender, GtkMenuDirectionType type, gpointer self);
static GObject * unity_panel_indicators_indicator_bar_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void unity_panel_indicators_indicator_bar_finalize (GObject* obj);
static int _vala_strcmp0 (const char * str1, const char * str2);



UnityPanelIndicatorsIndicatorBar* unity_panel_indicators_indicator_bar_construct (GType object_type) {
      UnityPanelIndicatorsIndicatorBar * self;
      self = (UnityPanelIndicatorsIndicatorBar*) g_object_new (object_type, "orientation", CTK_ORIENTATION_HORIZONTAL, "spacing", 0, "homogeneous", FALSE, NULL);
      return self;
}


UnityPanelIndicatorsIndicatorBar* unity_panel_indicators_indicator_bar_new (void) {
      return unity_panel_indicators_indicator_bar_construct (UNITY_PANEL_INDICATORS_TYPE_INDICATOR_BAR);
}


static void unity_panel_indicators_indicator_bar_on_menu_moved (UnityPanelIndicatorsIndicatorBar* self, UnityPanelIndicatorsIndicatorObjectView* object_view, GtkMenuDirectionType type) {
      gint pos;
      UnityPanelIndicatorsIndicatorObjectView* next_object_view;
      g_return_if_fail (self != NULL);
      g_return_if_fail (object_view != NULL);
      pos = gee_abstract_list_index_of ((GeeAbstractList*) self->priv->indicator_array, object_view);
      if (pos == (-1)) {
            return;
      }
      if (type == GTK_MENU_DIR_PARENT) {
            if (pos == 0) {
                  pos = gee_collection_get_size ((GeeCollection*) self->priv->indicator_array) - 1;
            } else {
                  pos = pos - 1;
            }
      } else {
            if (type == GTK_MENU_DIR_CHILD) {
                  if (pos == (gee_collection_get_size ((GeeCollection*) self->priv->indicator_array) - 1)) {
                        pos = 0;
                  } else {
                        pos = pos + 1;
                  }
            }
      }
      next_object_view = (UnityPanelIndicatorsIndicatorObjectView*) gee_abstract_list_get ((GeeAbstractList*) self->priv->indicator_array, pos);
      if (type == GTK_MENU_DIR_PARENT) {
            unity_panel_indicators_indicator_object_view_open_last_menu_entry (next_object_view);
      }
      if (type == GTK_MENU_DIR_CHILD) {
            unity_panel_indicators_indicator_object_view_open_first_menu_entry (next_object_view);
      }
      _g_object_unref0 (next_object_view);
}


UnityPanelIndicatorsIndicatorObjectView* unity_panel_indicators_indicator_bar_get_indicator_view_matching (UnityPanelIndicatorsIndicatorBar* self, IndicatorObject* o) {
      UnityPanelIndicatorsIndicatorObjectView* result = NULL;
      g_return_val_if_fail (self != NULL, NULL);
      g_return_val_if_fail (o != NULL, NULL);
      {
            GeeIterator* _i_it;
            _i_it = gee_abstract_collection_iterator ((GeeAbstractCollection*) self->priv->indicator_array);
            while (TRUE) {
                  UnityPanelIndicatorsIndicatorObjectView* i;
                  if (!gee_iterator_next (_i_it)) {
                        break;
                  }
                  i = (UnityPanelIndicatorsIndicatorObjectView*) gee_iterator_get (_i_it);
                  if (unity_panel_indicators_indicator_object_view_get_indicator_object (i) == o) {
                        result = i;
                        _g_object_unref0 (_i_it);
                        return result;
                  }
                  _g_object_unref0 (i);
            }
            _g_object_unref0 (_i_it);
      }
      result = NULL;
      return result;
}


void unity_panel_indicators_indicator_bar_set_indicator_mode (UnityPanelIndicatorsIndicatorBar* self, gboolean mode) {
      g_return_if_fail (self != NULL);
      if (mode) {
            clutter_actor_show ((ClutterActor*) self->priv->indicator_bground);
      } else {
            clutter_actor_hide ((ClutterActor*) self->priv->indicator_bground);
      }
}


static void _unity_panel_indicators_indicator_bar_on_menu_moved_unity_panel_indicators_indicator_object_view_menu_moved (UnityPanelIndicatorsIndicatorObjectView* _sender, GtkMenuDirectionType type, gpointer self) {
      unity_panel_indicators_indicator_bar_on_menu_moved (self, _sender, type);
}


static GObject * unity_panel_indicators_indicator_bar_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
      GObject * obj;
      GObjectClass * parent_class;
      UnityPanelIndicatorsIndicatorBar * self;
      parent_class = G_OBJECT_CLASS (unity_panel_indicators_indicator_bar_parent_class);
      obj = parent_class->constructor (type, n_construct_properties, construct_properties);
      self = UNITY_PANEL_INDICATORS_INDICATOR_BAR (obj);
      {
            UnityTestingObjectRegistry* _tmp0_;
            UnityPanelIndicatorBackground* _tmp1_;
            GeeArrayList* _tmp2_;
            UnityPanelIndicatorsIndicatorsModel* model;
            GeeArrayList* indicators_list;
            unity_testing_object_registry_register (_tmp0_ = unity_testing_object_registry_get_default (), "IndicatorBar", (GObject*) self);
            _unity_testing_object_registry_unref0 (_tmp0_);
            self->priv->indicator_bground = (_tmp1_ = g_object_ref_sink (unity_panel_indicator_background_new ()), _g_object_unref0 (self->priv->indicator_bground), _tmp1_);
            ctk_actor_set_background ((CtkActor*) self, (ClutterActor*) self->priv->indicator_bground);
            clutter_actor_hide ((ClutterActor*) self->priv->indicator_bground);
            self->priv->indicator_array = (_tmp2_ = gee_array_list_new (UNITY_PANEL_INDICATORS_TYPE_INDICATOR_OBJECT_VIEW, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL), _g_object_unref0 (self->priv->indicator_array), _tmp2_);
            model = unity_panel_indicators_indicators_model_get_default ();
            indicators_list = unity_panel_indicators_indicators_model_get_indicators (model);
            {
                  GeeIterator* _o_it;
                  _o_it = gee_abstract_collection_iterator ((GeeAbstractCollection*) indicators_list);
                  while (TRUE) {
                        IndicatorObject* o;
                        char* name;
                        if (!gee_iterator_next (_o_it)) {
                              break;
                        }
                        o = (IndicatorObject*) gee_iterator_get (_o_it);
                        name = unity_panel_indicators_indicators_model_get_indicator_name (model, o);
                        if (_vala_strcmp0 (name, "libappmenu.so") != 0) {
                              UnityPanelIndicatorsIndicatorObjectView* indicator_object_view;
                              indicator_object_view = g_object_ref_sink (unity_panel_indicators_indicator_object_view_new (o));
                              g_signal_connect_object (indicator_object_view, "menu-moved", (GCallback) _unity_panel_indicators_indicator_bar_on_menu_moved_unity_panel_indicators_indicator_object_view_menu_moved, self, 0);
                              gee_abstract_collection_add ((GeeAbstractCollection*) self->priv->indicator_array, indicator_object_view);
                              clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) indicator_object_view);
                              clutter_actor_show ((ClutterActor*) indicator_object_view);
                              _g_object_unref0 (indicator_object_view);
                        }
                        _g_object_unref0 (o);
                        _g_free0 (name);
                  }
                  _g_object_unref0 (_o_it);
            }
            _g_object_unref0 (model);
            _g_object_unref0 (indicators_list);
      }
      return obj;
}


static void unity_panel_indicators_indicator_bar_class_init (UnityPanelIndicatorsIndicatorBarClass * klass) {
      unity_panel_indicators_indicator_bar_parent_class = g_type_class_peek_parent (klass);
      g_type_class_add_private (klass, sizeof (UnityPanelIndicatorsIndicatorBarPrivate));
      G_OBJECT_CLASS (klass)->constructor = unity_panel_indicators_indicator_bar_constructor;
      G_OBJECT_CLASS (klass)->finalize = unity_panel_indicators_indicator_bar_finalize;
}


static void unity_panel_indicators_indicator_bar_instance_init (UnityPanelIndicatorsIndicatorBar * self) {
      self->priv = UNITY_PANEL_INDICATORS_INDICATOR_BAR_GET_PRIVATE (self);
}


static void unity_panel_indicators_indicator_bar_finalize (GObject* obj) {
      UnityPanelIndicatorsIndicatorBar * self;
      self = UNITY_PANEL_INDICATORS_INDICATOR_BAR (obj);
      _g_object_unref0 (self->priv->indicator_array);
      _g_object_unref0 (self->priv->indicator_bground);
      G_OBJECT_CLASS (unity_panel_indicators_indicator_bar_parent_class)->finalize (obj);
}


GType unity_panel_indicators_indicator_bar_get_type (void) {
      static volatile gsize unity_panel_indicators_indicator_bar_type_id__volatile = 0;
      if (g_once_init_enter (&unity_panel_indicators_indicator_bar_type_id__volatile)) {
            static const GTypeInfo g_define_type_info = { sizeof (UnityPanelIndicatorsIndicatorBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_panel_indicators_indicator_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityPanelIndicatorsIndicatorBar), 0, (GInstanceInitFunc) unity_panel_indicators_indicator_bar_instance_init, NULL };
            GType unity_panel_indicators_indicator_bar_type_id;
            unity_panel_indicators_indicator_bar_type_id = g_type_register_static (CTK_TYPE_BOX, "UnityPanelIndicatorsIndicatorBar", &g_define_type_info, 0);
            g_once_init_leave (&unity_panel_indicators_indicator_bar_type_id__volatile, unity_panel_indicators_indicator_bar_type_id);
      }
      return unity_panel_indicators_indicator_bar_type_id__volatile;
}


static int _vala_strcmp0 (const char * str1, const char * str2) {
      if (str1 == NULL) {
            return -(str1 != str2);
      }
      if (str2 == NULL) {
            return str1 != str2;
      }
      return strcmp (str1, str2);
}





Generated by  Doxygen 1.6.0   Back to index