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

search-field.c

/* search-field.c generated by valac, the Vala compiler
 * generated from search-field.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 Jay Taoko <jay.taoko@canonical.com>
 *
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <clutk/clutk.h>
#include <clutter/clutter.h>
#include <float.h>
#include <math.h>
#include <unity.h>


#define UNITY_PLACES_SEARCH_FIELD_TYPE_VIEW (unity_places_search_field_view_get_type ())
#define UNITY_PLACES_SEARCH_FIELD_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PLACES_SEARCH_FIELD_TYPE_VIEW, UnityPlacesSearchFieldView))
#define UNITY_PLACES_SEARCH_FIELD_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PLACES_SEARCH_FIELD_TYPE_VIEW, UnityPlacesSearchFieldViewClass))
#define UNITY_PLACES_SEARCH_FIELD_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PLACES_SEARCH_FIELD_TYPE_VIEW))
#define UNITY_PLACES_SEARCH_FIELD_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PLACES_SEARCH_FIELD_TYPE_VIEW))
#define UNITY_PLACES_SEARCH_FIELD_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PLACES_SEARCH_FIELD_TYPE_VIEW, UnityPlacesSearchFieldViewClass))

typedef struct _UnityPlacesSearchFieldView UnityPlacesSearchFieldView;
typedef struct _UnityPlacesSearchFieldViewClass UnityPlacesSearchFieldViewClass;
typedef struct _UnityPlacesSearchFieldViewPrivate UnityPlacesSearchFieldViewPrivate;

#define UNITY_PLACES_CAIRO_DRAWING_TYPE_RECTANGLE_BOX (unity_places_cairo_drawing_rectangle_box_get_type ())
#define UNITY_PLACES_CAIRO_DRAWING_RECTANGLE_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_PLACES_CAIRO_DRAWING_TYPE_RECTANGLE_BOX, UnityPlacesCairoDrawingRectangleBox))
#define UNITY_PLACES_CAIRO_DRAWING_RECTANGLE_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_PLACES_CAIRO_DRAWING_TYPE_RECTANGLE_BOX, UnityPlacesCairoDrawingRectangleBoxClass))
#define UNITY_PLACES_CAIRO_DRAWING_IS_RECTANGLE_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_PLACES_CAIRO_DRAWING_TYPE_RECTANGLE_BOX))
#define UNITY_PLACES_CAIRO_DRAWING_IS_RECTANGLE_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_PLACES_CAIRO_DRAWING_TYPE_RECTANGLE_BOX))
#define UNITY_PLACES_CAIRO_DRAWING_RECTANGLE_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_PLACES_CAIRO_DRAWING_TYPE_RECTANGLE_BOX, UnityPlacesCairoDrawingRectangleBoxClass))

typedef struct _UnityPlacesCairoDrawingRectangleBox UnityPlacesCairoDrawingRectangleBox;
typedef struct _UnityPlacesCairoDrawingRectangleBoxClass UnityPlacesCairoDrawingRectangleBoxClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _UnityPlacesCairoDrawingRectangleBoxPrivate UnityPlacesCairoDrawingRectangleBoxPrivate;

struct _UnityPlacesSearchFieldView {
      CtkBox parent_instance;
      UnityPlacesSearchFieldViewPrivate * priv;
};

struct _UnityPlacesSearchFieldViewClass {
      CtkBoxClass parent_class;
};

struct _UnityPlacesSearchFieldViewPrivate {
      CtkImage* search_icon;
      CtkText* text_field;
      UnityPlacesCairoDrawingRectangleBox* rect_box;
};

struct _UnityPlacesCairoDrawingRectangleBox {
      CtkBin parent_instance;
      UnityPlacesCairoDrawingRectangleBoxPrivate * priv;
      gint Width;
      gint Height;
      ClutterCairoTexture* cairotxt;
};

struct _UnityPlacesCairoDrawingRectangleBoxClass {
      CtkBinClass parent_class;
};


static gpointer unity_places_search_field_view_parent_class = NULL;

#define UNITY_PLACES_SEARCH_FIELD_SEARCH_ICON PKGDATADIR "/search_icon.png"
GType unity_places_search_field_view_get_type (void);
GType unity_places_cairo_drawing_rectangle_box_get_type (void);
#define UNITY_PLACES_SEARCH_FIELD_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_PLACES_SEARCH_FIELD_TYPE_VIEW, UnityPlacesSearchFieldViewPrivate))
enum  {
      UNITY_PLACES_SEARCH_FIELD_VIEW_DUMMY_PROPERTY
};
void unity_places_cairo_drawing_rectangle_box_CreateRectangleBox (UnityPlacesCairoDrawingRectangleBox* self, gint W, gint H);
static void unity_places_search_field_view_real_allocate (ClutterActor* base, const ClutterActorBox* box, ClutterAllocationFlags flags);
UnityPlacesCairoDrawingRectangleBox* unity_places_cairo_drawing_rectangle_box_new (void);
UnityPlacesCairoDrawingRectangleBox* unity_places_cairo_drawing_rectangle_box_construct (GType object_type);
static gboolean _lambda8_ (ClutterEvent* e, UnityPlacesSearchFieldView* self);
static gboolean __lambda8__clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self);
UnityPlacesSearchFieldView* unity_places_search_field_view_new (void);
UnityPlacesSearchFieldView* unity_places_search_field_view_construct (GType object_type);
static void unity_places_search_field_view_real_map (ClutterActor* base);
static void unity_places_search_field_view_real_unmap (ClutterActor* base);
static void unity_places_search_field_view_real_paint (ClutterActor* base);
static GObject * unity_places_search_field_view_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void unity_places_search_field_view_finalize (GObject* obj);



static void unity_places_search_field_view_real_allocate (ClutterActor* base, const ClutterActorBox* box, ClutterAllocationFlags flags) {
      UnityPlacesSearchFieldView * self;
      ClutterActorBox _tmp0_ = {0};
      ClutterActorBox child_box;
      float width;
      self = (UnityPlacesSearchFieldView*) base;
      child_box = (_tmp0_.x1 = 0.0f, _tmp0_.y1 = 0.0f, _tmp0_.x2 = 0.0f, _tmp0_.y2 = 0.0f, _tmp0_);
      width = (*box).x2 - (*box).x1;
      CLUTTER_ACTOR_CLASS (unity_places_search_field_view_parent_class)->allocate ((ClutterActor*) CTK_BOX (self), box, flags);
      if (self->priv->rect_box->Width != 200) {
            unity_places_cairo_drawing_rectangle_box_CreateRectangleBox (self->priv->rect_box, 200, 22);
      }
      child_box.x1 = (float) 0;
      child_box.x2 = (float) 200;
      child_box.y1 = (float) 0;
      child_box.y2 = (float) 22;
      clutter_actor_allocate ((ClutterActor*) self->priv->rect_box, &child_box, flags);
      child_box.x1 = (float) 0;
      child_box.x2 = (float) 22;
      child_box.y1 = (float) 0;
      child_box.y2 = (float) 22;
      clutter_actor_allocate ((ClutterActor*) self->priv->search_icon, &child_box, flags);
      child_box.x1 = child_box.x2 + 3;
      child_box.x2 = (child_box.x1 + width) - 22;
      child_box.y1 = (float) 4;
      child_box.y2 = (float) 22;
      clutter_actor_allocate ((ClutterActor*) self->priv->text_field, &child_box, flags);
}


static gboolean _lambda8_ (ClutterEvent* e, UnityPlacesSearchFieldView* self) {
      gboolean result = FALSE;
      unity_shell_grab_keyboard (unity_global_shell, TRUE, (*e).button.time);
      result = FALSE;
      return result;
}


static gboolean __lambda8__clutter_actor_button_press_event (ClutterActor* _sender, ClutterEvent* event, gpointer self) {
      gboolean result;
      result = _lambda8_ (event, self);
      return result;
}


UnityPlacesSearchFieldView* unity_places_search_field_view_construct (GType object_type) {
      UnityPlacesSearchFieldView * self;
      CtkImage* _tmp0_;
      CtkText* _tmp1_;
      UnityPlacesCairoDrawingRectangleBox* _tmp2_;
      self = g_object_newv (object_type, 0, NULL);
      self->priv->search_icon = (_tmp0_ = g_object_ref_sink ((CtkImage*) ctk_image_new_from_filename ((guint) 22, UNITY_PLACES_SEARCH_FIELD_SEARCH_ICON)), _g_object_unref0 (self->priv->search_icon), _tmp0_);
      self->priv->text_field = (_tmp1_ = (CtkText*) g_object_ref_sink (unity_entry_new ("Search")), _g_object_unref0 (self->priv->text_field), _tmp1_);
      self->priv->rect_box = (_tmp2_ = g_object_ref_sink (unity_places_cairo_drawing_rectangle_box_new ()), _g_object_unref0 (self->priv->rect_box), _tmp2_);
      clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->priv->rect_box);
      clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->priv->search_icon);
      clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->priv->text_field);
      clutter_actor_show_all ((ClutterActor*) self);
      g_signal_connect_object ((ClutterActor*) self->priv->text_field, "button-press-event", (GCallback) __lambda8__clutter_actor_button_press_event, self, 0);
      return self;
}


UnityPlacesSearchFieldView* unity_places_search_field_view_new (void) {
      return unity_places_search_field_view_construct (UNITY_PLACES_SEARCH_FIELD_TYPE_VIEW);
}


static void unity_places_search_field_view_real_map (ClutterActor* base) {
      UnityPlacesSearchFieldView * self;
      self = (UnityPlacesSearchFieldView*) base;
      CLUTTER_ACTOR_CLASS (unity_places_search_field_view_parent_class)->map ((ClutterActor*) CTK_BOX (self));
}


static void unity_places_search_field_view_real_unmap (ClutterActor* base) {
      UnityPlacesSearchFieldView * self;
      self = (UnityPlacesSearchFieldView*) base;
      CLUTTER_ACTOR_CLASS (unity_places_search_field_view_parent_class)->unmap ((ClutterActor*) CTK_BOX (self));
}


static void unity_places_search_field_view_real_paint (ClutterActor* base) {
      UnityPlacesSearchFieldView * self;
      self = (UnityPlacesSearchFieldView*) base;
      CLUTTER_ACTOR_CLASS (unity_places_search_field_view_parent_class)->paint ((ClutterActor*) CTK_BOX (self));
}


static GObject * unity_places_search_field_view_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
      GObject * obj;
      GObjectClass * parent_class;
      UnityPlacesSearchFieldView * self;
      parent_class = G_OBJECT_CLASS (unity_places_search_field_view_parent_class);
      obj = parent_class->constructor (type, n_construct_properties, construct_properties);
      self = UNITY_PLACES_SEARCH_FIELD_VIEW (obj);
      {
      }
      return obj;
}


static void unity_places_search_field_view_class_init (UnityPlacesSearchFieldViewClass * klass) {
      unity_places_search_field_view_parent_class = g_type_class_peek_parent (klass);
      g_type_class_add_private (klass, sizeof (UnityPlacesSearchFieldViewPrivate));
      CLUTTER_ACTOR_CLASS (klass)->allocate = unity_places_search_field_view_real_allocate;
      CLUTTER_ACTOR_CLASS (klass)->map = unity_places_search_field_view_real_map;
      CLUTTER_ACTOR_CLASS (klass)->unmap = unity_places_search_field_view_real_unmap;
      CLUTTER_ACTOR_CLASS (klass)->paint = unity_places_search_field_view_real_paint;
      G_OBJECT_CLASS (klass)->constructor = unity_places_search_field_view_constructor;
      G_OBJECT_CLASS (klass)->finalize = unity_places_search_field_view_finalize;
}


static void unity_places_search_field_view_instance_init (UnityPlacesSearchFieldView * self) {
      self->priv = UNITY_PLACES_SEARCH_FIELD_VIEW_GET_PRIVATE (self);
}


static void unity_places_search_field_view_finalize (GObject* obj) {
      UnityPlacesSearchFieldView * self;
      self = UNITY_PLACES_SEARCH_FIELD_VIEW (obj);
      _g_object_unref0 (self->priv->search_icon);
      _g_object_unref0 (self->priv->text_field);
      _g_object_unref0 (self->priv->rect_box);
      G_OBJECT_CLASS (unity_places_search_field_view_parent_class)->finalize (obj);
}


GType unity_places_search_field_view_get_type (void) {
      static volatile gsize unity_places_search_field_view_type_id__volatile = 0;
      if (g_once_init_enter (&unity_places_search_field_view_type_id__volatile)) {
            static const GTypeInfo g_define_type_info = { sizeof (UnityPlacesSearchFieldViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_places_search_field_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityPlacesSearchFieldView), 0, (GInstanceInitFunc) unity_places_search_field_view_instance_init, NULL };
            GType unity_places_search_field_view_type_id;
            unity_places_search_field_view_type_id = g_type_register_static (CTK_TYPE_BOX, "UnityPlacesSearchFieldView", &g_define_type_info, 0);
            g_once_init_leave (&unity_places_search_field_view_type_id__volatile, unity_places_search_field_view_type_id);
      }
      return unity_places_search_field_view_type_id__volatile;
}





Generated by  Doxygen 1.6.0   Back to index