/* candidatepanel.c generated by valac 0.40.8, the Vala compiler
* generated from candidatepanel.vala, do not modify */
/* vim:set et sts=4 sw=4:
*
* ibus - The Input Bus
*
* Copyright(c) 2011-2015 Peng Huang <shawn.p.huang@gmail.com>
* Copyright(c) 2015-2018 Takao Fujiwara <takao.fujiwara1@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <ibus.h>
#include <string.h>
#include <cairo.h>
#include <pango/pango.h>
#include <stdlib.h>
#define TYPE_CANDIDATE_PANEL (candidate_panel_get_type ())
#define CANDIDATE_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CANDIDATE_PANEL, CandidatePanel))
#define CANDIDATE_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CANDIDATE_PANEL, CandidatePanelClass))
#define IS_CANDIDATE_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CANDIDATE_PANEL))
#define IS_CANDIDATE_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CANDIDATE_PANEL))
#define CANDIDATE_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CANDIDATE_PANEL, CandidatePanelClass))
typedef struct _CandidatePanel CandidatePanel;
typedef struct _CandidatePanelClass CandidatePanelClass;
typedef struct _CandidatePanelPrivate CandidatePanelPrivate;
#define TYPE_CANDIDATE_AREA (candidate_area_get_type ())
#define CANDIDATE_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CANDIDATE_AREA, CandidateArea))
#define CANDIDATE_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CANDIDATE_AREA, CandidateAreaClass))
#define IS_CANDIDATE_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CANDIDATE_AREA))
#define IS_CANDIDATE_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CANDIDATE_AREA))
#define CANDIDATE_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CANDIDATE_AREA, CandidateAreaClass))
typedef struct _CandidateArea CandidateArea;
typedef struct _CandidateAreaClass CandidateAreaClass;
#define TYPE_HSEPARATOR (hseparator_get_type ())
#define HSEPARATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_HSEPARATOR, HSeparator))
#define HSEPARATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_HSEPARATOR, HSeparatorClass))
#define IS_HSEPARATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_HSEPARATOR))
#define IS_HSEPARATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_HSEPARATOR))
#define HSEPARATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_HSEPARATOR, HSeparatorClass))
typedef struct _HSeparator HSeparator;
typedef struct _HSeparatorClass HSeparatorClass;
enum {
CANDIDATE_PANEL_0_PROPERTY,
CANDIDATE_PANEL_NUM_PROPERTIES
};
static GParamSpec* candidate_panel_properties[CANDIDATE_PANEL_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define TYPE_HANDLE (handle_get_type ())
#define HANDLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_HANDLE, Handle))
#define HANDLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_HANDLE, HandleClass))
#define IS_HANDLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_HANDLE))
#define IS_HANDLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_HANDLE))
#define HANDLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_HANDLE, HandleClass))
typedef struct _Handle Handle;
typedef struct _HandleClass HandleClass;
#define _pango_attribute_destroy0(var) ((var == NULL) ? NULL : (var = (pango_attribute_destroy (var), NULL)))
#define _pango_attr_list_unref0(var) ((var == NULL) ? NULL : (var = (pango_attr_list_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
enum {
CANDIDATE_PANEL_CURSOR_UP_SIGNAL,
CANDIDATE_PANEL_CURSOR_DOWN_SIGNAL,
CANDIDATE_PANEL_PAGE_UP_SIGNAL,
CANDIDATE_PANEL_PAGE_DOWN_SIGNAL,
CANDIDATE_PANEL_CANDIDATE_CLICKED_SIGNAL,
CANDIDATE_PANEL_NUM_SIGNALS
};
static guint candidate_panel_signals[CANDIDATE_PANEL_NUM_SIGNALS] = {0};
struct _CandidatePanel {
GtkBox parent_instance;
CandidatePanelPrivate * priv;
};
struct _CandidatePanelClass {
GtkBoxClass parent_class;
};
struct _CandidatePanelPrivate {
gboolean m_vertical_panel_system;
gboolean m_vertical_writing;
GtkWindow* m_toplevel;
GtkBox* m_vbox;
GtkLabel* m_preedit_label;
GtkLabel* m_aux_label;
CandidateArea* m_candidate_area;
HSeparator* m_hseparator;
GdkRectangle m_cursor_location;
};
static gpointer candidate_panel_parent_class = NULL;
GType candidate_panel_get_type (void) G_GNUC_CONST;
GType candidate_area_get_type (void) G_GNUC_CONST;
GType hseparator_get_type (void) G_GNUC_CONST;
#define CANDIDATE_PANEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_CANDIDATE_PANEL, CandidatePanelPrivate))
CandidatePanel* candidate_panel_new (void);
CandidatePanel* candidate_panel_construct (GType object_type);
static gboolean __lambda13_ (CandidatePanel* self,
GtkWidget* w,
GdkEventButton* e);
void candidate_panel_set_vertical (CandidatePanel* self,
gboolean vertical);
static gboolean ___lambda13__gtk_widget_button_press_event (GtkWidget* _sender,
GdkEventButton* event,
gpointer self);
static void __lambda14_ (CandidatePanel* self,
GtkWidget* w,
GtkAllocation* a);
static void candidate_panel_adjust_window_position (CandidatePanel* self);
static void ___lambda14__gtk_widget_size_allocate (GtkWidget* _sender,
GtkAllocation* allocation,
gpointer self);
GType handle_get_type (void) G_GNUC_CONST;
Handle* handle_new (void);
Handle* handle_construct (GType object_type);
static void candidate_panel_create_ui (CandidatePanel* self);
void candidate_area_set_vertical (CandidateArea* self,
gboolean vertical,
gboolean force);
static void candidate_panel_set_orientation (CandidatePanel* self,
IBusOrientation orientation);
void candidate_panel_set_cursor_location (CandidatePanel* self,
gint x,
gint y,
gint width,
gint height);
static gboolean _cairo_rectangle_int_equal (const cairo_rectangle_int_t * s1,
const cairo_rectangle_int_t * s2);
static void candidate_panel_set_labels (CandidatePanel* self,
IBusText** labels,
int labels_length1);
void candidate_area_set_labels (CandidateArea* self,
IBusText** labels,
int labels_length1);
static void candidate_panel_set_attributes (CandidatePanel* self,
GtkLabel* label,
IBusText* text);
PangoAttrList* get_pango_attr_list_from_ibus_text (IBusText* text);
void candidate_panel_set_preedit_text (CandidatePanel* self,
IBusText* text,
guint cursor);
static void candidate_panel_update (CandidatePanel* self);
void candidate_panel_set_auxiliary_text (CandidatePanel* self,
IBusText* text);
void candidate_panel_set_lookup_table (CandidatePanel* self,
IBusLookupTable* table);
static void _vala_array_add8 (IBusText** * array,
int* length,
int* size,
IBusText* value);
static void _vala_array_add9 (IBusText** * array,
int* length,
int* size,
IBusText* value);
void candidate_area_set_candidates (CandidateArea* self,
IBusText** candidates,
int candidates_length1,
guint focus_candidate,
gboolean show_cursor);
void candidate_panel_set_content_type (CandidatePanel* self,
guint purpose,
guint hints);
CandidateArea* candidate_area_new (gboolean vertical);
CandidateArea* candidate_area_construct (GType object_type,
gboolean vertical);
static void __lambda15_ (CandidatePanel* self,
CandidateArea* w,
guint i,
guint b,
guint s);
static void ___lambda15__candidate_area_candidate_clicked (CandidateArea* _sender,
guint index,
guint button,
guint state,
gpointer self);
static void __lambda16_ (CandidatePanel* self,
CandidateArea* c);
static void ___lambda16__candidate_area_page_up (CandidateArea* _sender,
gpointer self);
static void __lambda17_ (CandidatePanel* self,
CandidateArea* c);
static void ___lambda17__candidate_area_page_down (CandidateArea* _sender,
gpointer self);
static void __lambda18_ (CandidatePanel* self,
CandidateArea* c);
static void ___lambda18__candidate_area_cursor_up (CandidateArea* _sender,
gpointer self);
static void __lambda19_ (CandidatePanel* self,
CandidateArea* c);
static void ___lambda19__candidate_area_cursor_down (CandidateArea* _sender,
gpointer self);
HSeparator* hseparator_new (void);
HSeparator* hseparator_construct (GType object_type);
static void candidate_panel_pack_all_widgets (CandidatePanel* self);
void candidate_panel_show (CandidatePanel* self);
void candidate_panel_hide (CandidatePanel* self);
static void candidate_panel_move (CandidatePanel* self,
gint x,
gint y);
static void candidate_panel_adjust_window_position_horizontal (CandidatePanel* self);
static void candidate_panel_adjust_window_position_vertical (CandidatePanel* self);
static void candidate_panel_get_monitor_geometry (CandidatePanel* self,
GdkRectangle* result);
gboolean candidate_area_get_vertical (CandidateArea* self);
static void g_cclosure_user_marshal_VOID__UINT_UINT_UINT (GClosure * closure,
GValue * return_value,
guint n_param_values,
const GValue * param_values,
gpointer invocation_hint,
gpointer marshal_data);
static void candidate_panel_finalize (GObject * obj);
static void _vala_array_destroy (gpointer array,
gint array_length,
GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
gint array_length,
GDestroyNotify destroy_func);
static gboolean
__lambda13_ (CandidatePanel* self,
GtkWidget* w,
GdkEventButton* e)
{
gboolean result = FALSE;
gboolean _tmp0_ = FALSE;
guint _tmp1_;
gboolean _tmp3_;
g_return_val_if_fail (w != NULL, FALSE);
g_return_val_if_fail (e != NULL, FALSE);
_tmp1_ = e->button;
if (_tmp1_ != ((guint) 1)) {
_tmp0_ = TRUE;
} else {
GdkModifierType _tmp2_;
_tmp2_ = e->state;
_tmp0_ = (_tmp2_ & GDK_CONTROL_MASK) == 0;
}
if (_tmp0_) {
result = FALSE;
return result;
}
_tmp3_ = self->priv->m_vertical_panel_system;
candidate_panel_set_vertical (self, !_tmp3_);
result = TRUE;
return result;
}
static gboolean
___lambda13__gtk_widget_button_press_event (GtkWidget* _sender,
GdkEventButton* event,
gpointer self)
{
gboolean result;
result = __lambda13_ ((CandidatePanel*) self, _sender, event);
return result;
}
static void
__lambda14_ (CandidatePanel* self,
GtkWidget* w,
GtkAllocation* a)
{
g_return_if_fail (w != NULL);
g_return_if_fail (a != NULL);
candidate_panel_adjust_window_position (self);
}
static void
___lambda14__gtk_widget_size_allocate (GtkWidget* _sender,
GtkAllocation* allocation,
gpointer self)
{
__lambda14_ ((CandidatePanel*) self, _sender, allocation);
}
CandidatePanel*
candidate_panel_construct (GType object_type)
{
CandidatePanel * self = NULL;
GtkWindow* _tmp0_;
GtkWindow* _tmp1_;
GtkWindow* _tmp2_;
GtkWindow* _tmp3_;
Handle* handle = NULL;
Handle* _tmp4_;
GtkBox* _tmp5_;
GtkBox* _tmp6_;
GtkBox* _tmp7_;
GtkWindow* _tmp8_;
self = (CandidatePanel*) g_object_new (object_type, "name", "IBusCandidate", "orientation", GTK_ORIENTATION_HORIZONTAL, "visible", TRUE, NULL);
_tmp0_ = (GtkWindow*) gtk_window_new (GTK_WINDOW_POPUP);
g_object_ref_sink (_tmp0_);
_g_object_unref0 (self->priv->m_toplevel);
self->priv->m_toplevel = _tmp0_;
_tmp1_ = self->priv->m_toplevel;
gtk_widget_add_events ((GtkWidget*) _tmp1_, (gint) GDK_BUTTON_PRESS_MASK);
_tmp2_ = self->priv->m_toplevel;
g_signal_connect_object ((GtkWidget*) _tmp2_, "button-press-event", (GCallback) ___lambda13__gtk_widget_button_press_event, self, 0);
_tmp3_ = self->priv->m_toplevel;
g_signal_connect_object ((GtkWidget*) _tmp3_, "size-allocate", (GCallback) ___lambda14__gtk_widget_size_allocate, self, 0);
_tmp4_ = handle_new ();
g_object_ref_sink (_tmp4_);
handle = _tmp4_;
gtk_widget_set_visible ((GtkWidget*) handle, TRUE);
gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) handle, FALSE, FALSE, (guint) 0);
_tmp5_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
g_object_ref_sink (_tmp5_);
_g_object_unref0 (self->priv->m_vbox);
self->priv->m_vbox = _tmp5_;
_tmp6_ = self->priv->m_vbox;
gtk_widget_set_visible ((GtkWidget*) _tmp6_, TRUE);
_tmp7_ = self->priv->m_vbox;
gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) _tmp7_, FALSE, FALSE, (guint) 0);
_tmp8_ = self->priv->m_toplevel;
gtk_container_add ((GtkContainer*) _tmp8_, (GtkWidget*) self);
candidate_panel_create_ui (self);
_g_object_unref0 (handle);
return self;
}
CandidatePanel*
candidate_panel_new (void)
{
return candidate_panel_construct (TYPE_CANDIDATE_PANEL);
}
void
candidate_panel_set_vertical (CandidatePanel* self,
gboolean vertical)
{
gboolean _tmp0_;
CandidateArea* _tmp1_;
g_return_if_fail (self != NULL);
_tmp0_ = self->priv->m_vertical_panel_system;
if (_tmp0_ == vertical) {
return;
}
self->priv->m_vertical_panel_system = vertical;
_tmp1_ = self->priv->m_candidate_area;
candidate_area_set_vertical (_tmp1_, vertical, FALSE);
}
static void
candidate_panel_set_orientation (CandidatePanel* self,
IBusOrientation orientation)
{
g_return_if_fail (self != NULL);
switch (orientation) {
case IBUS_ORIENTATION_VERTICAL:
{
CandidateArea* _tmp0_;
_tmp0_ = self->priv->m_candidate_area;
candidate_area_set_vertical (_tmp0_, TRUE, FALSE);
break;
}
case IBUS_ORIENTATION_HORIZONTAL:
{
CandidateArea* _tmp1_;
_tmp1_ = self->priv->m_candidate_area;
candidate_area_set_vertical (_tmp1_, FALSE, FALSE);
break;
}
case IBUS_ORIENTATION_SYSTEM:
{
CandidateArea* _tmp2_;
gboolean _tmp3_;
_tmp2_ = self->priv->m_candidate_area;
_tmp3_ = self->priv->m_vertical_panel_system;
candidate_area_set_vertical (_tmp2_, _tmp3_, FALSE);
break;
}
default:
break;
}
}
static gboolean
_cairo_rectangle_int_equal (const cairo_rectangle_int_t * s1,
const cairo_rectangle_int_t * s2)
{
if (s1 == s2) {
return TRUE;
}
if (s1 == NULL) {
return FALSE;
}
if (s2 == NULL) {
return FALSE;
}
if (s1->x != s2->x) {
return FALSE;
}
if (s1->y != s2->y) {
return FALSE;
}
if (s1->width != s2->width) {
return FALSE;
}
if (s1->height != s2->height) {
return FALSE;
}
return TRUE;
}
void
candidate_panel_set_cursor_location (CandidatePanel* self,
gint x,
gint y,
gint width,
gint height)
{
GdkRectangle location = {0};
GdkRectangle _tmp0_ = {0};
GdkRectangle _tmp1_;
GdkRectangle _tmp2_;
GdkRectangle _tmp3_;
g_return_if_fail (self != NULL);
memset (&_tmp0_, 0, sizeof (GdkRectangle));
_tmp0_.x = x;
_tmp0_.y = y;
_tmp0_.width = width;
_tmp0_.height = height;
location = _tmp0_;
_tmp1_ = self->priv->m_cursor_location;
_tmp2_ = location;
if (_cairo_rectangle_int_equal (&_tmp1_, &_tmp2_) == TRUE) {
return;
}
_tmp3_ = location;
self->priv->m_cursor_location = _tmp3_;
}
static void
candidate_panel_set_labels (CandidatePanel* self,
IBusText** labels,
int labels_length1)
{
CandidateArea* _tmp0_;
g_return_if_fail (self != NULL);
_tmp0_ = self->priv->m_candidate_area;
candidate_area_set_labels (_tmp0_, labels, labels_length1);
}
static gpointer
_g_object_ref0 (gpointer self)
{
return self ? g_object_ref (self) : NULL;
}
static void
candidate_panel_set_attributes (CandidatePanel* self,
GtkLabel* label,
IBusText* text)
{
PangoAttrList* attrs = NULL;
PangoAttrList* _tmp0_;
GtkStyleContext* context = NULL;
GtkStyleContext* _tmp1_;
GtkStyleContext* _tmp2_;
GdkRGBA color = {0};
GtkStyleContext* _tmp3_;
GdkRGBA _tmp4_ = {0};
gboolean _tmp5_;
PangoAttrList* _tmp20_;
g_return_if_fail (self != NULL);
g_return_if_fail (label != NULL);
g_return_if_fail (text != NULL);
_tmp0_ = get_pango_attr_list_from_ibus_text (text);
attrs = _tmp0_;
_tmp1_ = gtk_widget_get_style_context ((GtkWidget*) label);
_tmp2_ = _g_object_ref0 (_tmp1_);
context = _tmp2_;
_tmp3_ = context;
_tmp5_ = gtk_style_context_lookup_color (_tmp3_, "placeholder_text_color", &_tmp4_);
color = _tmp4_;
if (_tmp5_) {
PangoAttribute* pango_attr = NULL;
GdkRGBA _tmp6_;
gdouble _tmp7_;
GdkRGBA _tmp8_;
gdouble _tmp9_;
GdkRGBA _tmp10_;
gdouble _tmp11_;
PangoAttribute* _tmp12_;
PangoAttribute* _tmp13_;
PangoAttribute* _tmp14_;
const gchar* _tmp15_;
gint _tmp16_;
gint _tmp17_;
PangoAttrList* _tmp18_;
PangoAttribute* _tmp19_;
_tmp6_ = color;
_tmp7_ = _tmp6_.red;
_tmp8_ = color;
_tmp9_ = _tmp8_.green;
_tmp10_ = color;
_tmp11_ = _tmp10_.blue;
_tmp12_ = pango_attr_foreground_new ((guint16) (_tmp7_ * G_MAXUINT16), (guint16) (_tmp9_ * G_MAXUINT16), (guint16) (_tmp11_ * G_MAXUINT16));
pango_attr = _tmp12_;
_tmp13_ = pango_attr;
_tmp13_->start_index = (guint) 0;
_tmp14_ = pango_attr;
_tmp15_ = gtk_label_get_text (label);
_tmp16_ = strlen (_tmp15_);
_tmp17_ = _tmp16_;
_tmp14_->end_index = (guint) _tmp17_;
_tmp18_ = attrs;
_tmp19_ = pango_attr;
pango_attr = NULL;
pango_attr_list_insert (_tmp18_, _tmp19_);
_pango_attribute_destroy0 (pango_attr);
}
_tmp20_ = attrs;
gtk_label_set_attributes (label, _tmp20_);
_g_object_unref0 (context);
_pango_attr_list_unref0 (attrs);
}
void
candidate_panel_set_preedit_text (CandidatePanel* self,
IBusText* text,
guint cursor)
{
g_return_if_fail (self != NULL);
if (text != NULL) {
gchar* str = NULL;
const gchar* _tmp0_;
gchar* _tmp1_;
const gchar* _tmp2_;
gint _tmp3_;
gint _tmp4_;
_tmp0_ = ibus_text_get_text (text);
_tmp1_ = g_strdup (_tmp0_);
str = _tmp1_;
_tmp2_ = str;
_tmp3_ = strlen (_tmp2_);
_tmp4_ = _tmp3_;
if (_tmp4_ > 0) {
GtkLabel* _tmp5_;
const gchar* _tmp6_;
GtkLabel* _tmp7_;
GtkLabel* _tmp8_;
_tmp5_ = self->priv->m_preedit_label;
_tmp6_ = str;
gtk_label_set_text (_tmp5_, _tmp6_);
_tmp7_ = self->priv->m_preedit_label;
gtk_widget_show ((GtkWidget*) _tmp7_);
_tmp8_ = self->priv->m_preedit_label;
candidate_panel_set_attributes (self, _tmp8_, text);
} else {
GtkLabel* _tmp9_;
GtkLabel* _tmp10_;
_tmp9_ = self->priv->m_preedit_label;
gtk_label_set_text (_tmp9_, "");
_tmp10_ = self->priv->m_preedit_label;
gtk_widget_hide ((GtkWidget*) _tmp10_);
}
_g_free0 (str);
} else {
GtkLabel* _tmp11_;
GtkLabel* _tmp12_;
_tmp11_ = self->priv->m_preedit_label;
gtk_label_set_text (_tmp11_, "");
_tmp12_ = self->priv->m_preedit_label;
gtk_widget_hide ((GtkWidget*) _tmp12_);
}
candidate_panel_update (self);
}
void
candidate_panel_set_auxiliary_text (CandidatePanel* self,
IBusText* text)
{
g_return_if_fail (self != NULL);
if (text != NULL) {
GtkLabel* _tmp0_;
const gchar* _tmp1_;
PangoAttrList* attrs = NULL;
PangoAttrList* _tmp2_;
GtkLabel* _tmp3_;
PangoAttrList* _tmp4_;
GtkLabel* _tmp5_;
_tmp0_ = self->priv->m_aux_label;
_tmp1_ = ibus_text_get_text (text);
gtk_label_set_text (_tmp0_, _tmp1_);
_tmp2_ = get_pango_attr_list_from_ibus_text (text);
attrs = _tmp2_;
_tmp3_ = self->priv->m_aux_label;
_tmp4_ = attrs;
gtk_label_set_attributes (_tmp3_, _tmp4_);
_tmp5_ = self->priv->m_aux_label;
gtk_widget_show ((GtkWidget*) _tmp5_);
_pango_attr_list_unref0 (attrs);
} else {
GtkLabel* _tmp6_;
GtkLabel* _tmp7_;
_tmp6_ = self->priv->m_aux_label;
gtk_label_set_text (_tmp6_, "");
_tmp7_ = self->priv->m_aux_label;
gtk_widget_hide ((GtkWidget*) _tmp7_);
}
candidate_panel_update (self);
}
static void
_vala_array_add8 (IBusText** * array,
int* length,
int* size,
IBusText* value)
{
if ((*length) == (*size)) {
*size = (*size) ? (2 * (*size)) : 4;
*array = g_renew (IBusText*, *array, (*size) + 1);
}
(*array)[(*length)++] = value;
(*array)[*length] = NULL;
}
static void
_vala_array_add9 (IBusText** * array,
int* length,
int* size,
IBusText* value)
{
if ((*length) == (*size)) {
*size = (*size) ? (2 * (*size)) : 4;
*array = g_renew (IBusText*, *array, (*size) + 1);
}
(*array)[(*length)++] = value;
(*array)[*length] = NULL;
}
void
candidate_panel_set_lookup_table (CandidatePanel* self,
IBusLookupTable* table)
{
IBusText** candidates = NULL;
IBusText** _tmp0_;
gint candidates_length1;
gint _candidates_size_;
guint cursor_in_page = 0U;
gboolean show_cursor = FALSE;
IBusText** labels = NULL;
IBusText** _tmp1_;
gint labels_length1;
gint _labels_size_;
IBusOrientation orientation = 0;
CandidateArea* _tmp28_;
IBusText** _tmp29_;
gint _tmp29__length1;
guint _tmp30_;
gboolean _tmp31_;
IBusText** _tmp32_;
gint _tmp32__length1;
IBusText** _tmp34_;
gint _tmp34__length1;
g_return_if_fail (self != NULL);
_tmp0_ = g_new0 (IBusText*, 0 + 1);
candidates = _tmp0_;
candidates_length1 = 0;
_candidates_size_ = candidates_length1;
cursor_in_page = (guint) 0;
show_cursor = TRUE;
_tmp1_ = g_new0 (IBusText*, 0 + 1);
labels = _tmp1_;
labels_length1 = 0;
_labels_size_ = labels_length1;
orientation = IBUS_ORIENTATION_SYSTEM;
if (table != NULL) {
guint page_size = 0U;
guint ncandidates = 0U;
guint cursor = 0U;
guint page_start_pos = 0U;
guint _tmp2_;
guint _tmp3_;
guint _tmp4_;
guint page_end_pos = 0U;
guint _tmp5_;
guint _tmp6_;
guint _tmp7_;
page_size = ibus_lookup_table_get_page_size (table);
ncandidates = ibus_lookup_table_get_number_of_candidates (table);
cursor = ibus_lookup_table_get_cursor_pos (table);
cursor_in_page = ibus_lookup_table_get_cursor_in_page (table);
show_cursor = ibus_lookup_table_is_cursor_visible (table);
_tmp2_ = cursor;
_tmp3_ = page_size;
_tmp4_ = page_size;
page_start_pos = (_tmp2_ / _tmp3_) * _tmp4_;
_tmp5_ = page_start_pos;
_tmp6_ = page_size;
_tmp7_ = ncandidates;
page_end_pos = MIN (_tmp5_ + _tmp6_, _tmp7_);
{
guint i = 0U;
guint _tmp8_;
_tmp8_ = page_start_pos;
i = _tmp8_;
{
gboolean _tmp9_ = FALSE;
_tmp9_ = TRUE;
while (TRUE) {
guint _tmp11_;
guint _tmp12_;
IBusText** _tmp13_;
gint _tmp13__length1;
guint _tmp14_;
IBusText* _tmp15_;
IBusText* _tmp16_;
if (!_tmp9_) {
guint _tmp10_;
_tmp10_ = i;
i = _tmp10_ + 1;
}
_tmp9_ = FALSE;
_tmp11_ = i;
_tmp12_ = page_end_pos;
if (!(_tmp11_ < _tmp12_)) {
break;
}
_tmp13_ = candidates;
_tmp13__length1 = candidates_length1;
_tmp14_ = i;
_tmp15_ = ibus_lookup_table_get_candidate (table, _tmp14_);
_tmp16_ = _g_object_ref0 (_tmp15_);
_vala_array_add8 (&candidates, &candidates_length1, &_candidates_size_, _tmp16_);
}
}
}
{
guint i = 0U;
i = (guint) 0;
{
gboolean _tmp17_ = FALSE;
_tmp17_ = TRUE;
while (TRUE) {
guint _tmp19_;
guint _tmp20_;
IBusText* label = NULL;
guint _tmp21_;
IBusText* _tmp22_;
IBusText* _tmp23_;
IBusText* _tmp24_;
if (!_tmp17_) {
guint _tmp18_;
_tmp18_ = i;
i = _tmp18_ + 1;
}
_tmp17_ = FALSE;
_tmp19_ = i;
_tmp20_ = page_size;
if (!(_tmp19_ < _tmp20_)) {
break;
}
_tmp21_ = i;
_tmp22_ = ibus_lookup_table_get_label (table, _tmp21_);
_tmp23_ = _g_object_ref0 (_tmp22_);
label = _tmp23_;
_tmp24_ = label;
if (_tmp24_ != NULL) {
IBusText** _tmp25_;
gint _tmp25__length1;
IBusText* _tmp26_;
IBusText* _tmp27_;
_tmp25_ = labels;
_tmp25__length1 = labels_length1;
_tmp26_ = label;
_tmp27_ = _g_object_ref0 (_tmp26_);
_vala_array_add9 (&labels, &labels_length1, &_labels_size_, _tmp27_);
}
_g_object_unref0 (label);
}
}
}
orientation = (IBusOrientation) ibus_lookup_table_get_orientation (table);
}
_tmp28_ = self->priv->m_candidate_area;
_tmp29_ = candidates;
_tmp29__length1 = candidates_length1;
_tmp30_ = cursor_in_page;
_tmp31_ = show_cursor;
candidate_area_set_candidates (_tmp28_, _tmp29_, _tmp29__length1, _tmp30_, _tmp31_);
_tmp32_ = labels;
_tmp32__length1 = labels_length1;
candidate_panel_set_labels (self, _tmp32_, _tmp32__length1);
if (table != NULL) {
IBusOrientation _tmp33_;
_tmp33_ = orientation;
candidate_panel_set_orientation (self, _tmp33_);
}
_tmp34_ = candidates;
_tmp34__length1 = candidates_length1;
if (_tmp34__length1 != 0) {
CandidateArea* _tmp35_;
_tmp35_ = self->priv->m_candidate_area;
gtk_widget_show_all ((GtkWidget*) _tmp35_);
} else {
CandidateArea* _tmp36_;
_tmp36_ = self->priv->m_candidate_area;
gtk_widget_hide ((GtkWidget*) _tmp36_);
}
candidate_panel_update (self);
labels = (_vala_array_free (labels, labels_length1, (GDestroyNotify) g_object_unref), NULL);
candidates = (_vala_array_free (candidates, candidates_length1, (GDestroyNotify) g_object_unref), NULL);
}
void
candidate_panel_set_content_type (CandidatePanel* self,
guint purpose,
guint hints)
{
g_return_if_fail (self != NULL);
self->priv->m_vertical_writing = (hints & IBUS_INPUT_HINT_VERTICAL_WRITING) != ((guint) 0);
}
static void
candidate_panel_update (CandidatePanel* self)
{
GtkWindow* _tmp0_;
gboolean _tmp1_ = FALSE;
gboolean _tmp2_ = FALSE;
CandidateArea* _tmp3_;
gboolean _tmp8_ = FALSE;
GtkLabel* _tmp9_;
g_return_if_fail (self != NULL);
_tmp0_ = self->priv->m_toplevel;
gtk_window_resize (_tmp0_, 1, 1);
_tmp3_ = self->priv->m_candidate_area;
if (gtk_widget_get_visible ((GtkWidget*) _tmp3_)) {
_tmp2_ = TRUE;
} else {
GtkLabel* _tmp4_;
_tmp4_ = self->priv->m_preedit_label;
_tmp2_ = gtk_widget_get_visible ((GtkWidget*) _tmp4_);
}
if (_tmp2_) {
_tmp1_ = TRUE;
} else {
GtkLabel* _tmp5_;
_tmp5_ = self->priv->m_aux_label;
_tmp1_ = gtk_widget_get_visible ((GtkWidget*) _tmp5_);
}
if (_tmp1_) {
GtkWindow* _tmp6_;
_tmp6_ = self->priv->m_toplevel;
gtk_widget_show ((GtkWidget*) _tmp6_);
} else {
GtkWindow* _tmp7_;
_tmp7_ = self->priv->m_toplevel;
gtk_widget_hide ((GtkWidget*) _tmp7_);
}
_tmp9_ = self->priv->m_aux_label;
if (gtk_widget_get_visible ((GtkWidget*) _tmp9_)) {
gboolean _tmp10_ = FALSE;
CandidateArea* _tmp11_;
_tmp11_ = self->priv->m_candidate_area;
if (gtk_widget_get_visible ((GtkWidget*) _tmp11_)) {
_tmp10_ = TRUE;
} else {
GtkLabel* _tmp12_;
_tmp12_ = self->priv->m_preedit_label;
_tmp10_ = gtk_widget_get_visible ((GtkWidget*) _tmp12_);
}
_tmp8_ = _tmp10_;
} else {
_tmp8_ = FALSE;
}
if (_tmp8_) {
HSeparator* _tmp13_;
_tmp13_ = self->priv->m_hseparator;
gtk_widget_show ((GtkWidget*) _tmp13_);
} else {
HSeparator* _tmp14_;
_tmp14_ = self->priv->m_hseparator;
gtk_widget_hide ((GtkWidget*) _tmp14_);
}
}
static void
__lambda15_ (CandidatePanel* self,
CandidateArea* w,
guint i,
guint b,
guint s)
{
g_return_if_fail (w != NULL);
g_signal_emit (self, candidate_panel_signals[CANDIDATE_PANEL_CANDIDATE_CLICKED_SIGNAL], 0, i, b, s);
}
static void
___lambda15__candidate_area_candidate_clicked (CandidateArea* _sender,
guint index,
guint button,
guint state,
gpointer self)
{
__lambda15_ ((CandidatePanel*) self, _sender, index, button, state);
}
static void
__lambda16_ (CandidatePanel* self,
CandidateArea* c)
{
g_return_if_fail (c != NULL);
g_signal_emit (self, candidate_panel_signals[CANDIDATE_PANEL_PAGE_UP_SIGNAL], 0);
}
static void
___lambda16__candidate_area_page_up (CandidateArea* _sender,
gpointer self)
{
__lambda16_ ((CandidatePanel*) self, _sender);
}
static void
__lambda17_ (CandidatePanel* self,
CandidateArea* c)
{
g_return_if_fail (c != NULL);
g_signal_emit (self, candidate_panel_signals[CANDIDATE_PANEL_PAGE_DOWN_SIGNAL], 0);
}
static void
___lambda17__candidate_area_page_down (CandidateArea* _sender,
gpointer self)
{
__lambda17_ ((CandidatePanel*) self, _sender);
}
static void
__lambda18_ (CandidatePanel* self,
CandidateArea* c)
{
g_return_if_fail (c != NULL);
g_signal_emit (self, candidate_panel_signals[CANDIDATE_PANEL_CURSOR_UP_SIGNAL], 0);
}
static void
___lambda18__candidate_area_cursor_up (CandidateArea* _sender,
gpointer self)
{
__lambda18_ ((CandidatePanel*) self, _sender);
}
static void
__lambda19_ (CandidatePanel* self,
CandidateArea* c)
{
g_return_if_fail (c != NULL);
g_signal_emit (self, candidate_panel_signals[CANDIDATE_PANEL_CURSOR_DOWN_SIGNAL], 0);
}
static void
___lambda19__candidate_area_cursor_down (CandidateArea* _sender,
gpointer self)
{
__lambda19_ ((CandidatePanel*) self, _sender);
}
static void
candidate_panel_create_ui (CandidatePanel* self)
{
GtkLabel* _tmp0_;
GtkLabel* _tmp1_;
GtkLabel* _tmp2_;
GtkLabel* _tmp3_;
GtkLabel* _tmp4_;
GtkLabel* _tmp5_;
GtkLabel* _tmp6_;
GtkLabel* _tmp7_;
GtkLabel* _tmp8_;
GtkLabel* _tmp9_;
GtkLabel* _tmp10_;
GtkLabel* _tmp11_;
gboolean _tmp12_;
CandidateArea* _tmp13_;
CandidateArea* _tmp14_;
CandidateArea* _tmp15_;
CandidateArea* _tmp16_;
CandidateArea* _tmp17_;
CandidateArea* _tmp18_;
HSeparator* _tmp19_;
HSeparator* _tmp20_;
g_return_if_fail (self != NULL);
_tmp0_ = (GtkLabel*) gtk_label_new (NULL);
g_object_ref_sink (_tmp0_);
_g_object_unref0 (self->priv->m_preedit_label);
self->priv->m_preedit_label = _tmp0_;
_tmp1_ = self->priv->m_preedit_label;
gtk_widget_set_size_request ((GtkWidget*) _tmp1_, 20, -1);
_tmp2_ = self->priv->m_preedit_label;
gtk_widget_set_halign ((GtkWidget*) _tmp2_, GTK_ALIGN_START);
_tmp3_ = self->priv->m_preedit_label;
gtk_widget_set_valign ((GtkWidget*) _tmp3_, GTK_ALIGN_CENTER);
_tmp4_ = self->priv->m_preedit_label;
gtk_misc_set_padding ((GtkMisc*) _tmp4_, 8, 0);
_tmp5_ = self->priv->m_preedit_label;
gtk_widget_set_no_show_all ((GtkWidget*) _tmp5_, TRUE);
_tmp6_ = (GtkLabel*) gtk_label_new (NULL);
g_object_ref_sink (_tmp6_);
_g_object_unref0 (self->priv->m_aux_label);
self->priv->m_aux_label = _tmp6_;
_tmp7_ = self->priv->m_aux_label;
gtk_widget_set_size_request ((GtkWidget*) _tmp7_, 20, -1);
_tmp8_ = self->priv->m_aux_label;
gtk_widget_set_halign ((GtkWidget*) _tmp8_, GTK_ALIGN_START);
_tmp9_ = self->priv->m_aux_label;
gtk_widget_set_valign ((GtkWidget*) _tmp9_, GTK_ALIGN_CENTER);
_tmp10_ = self->priv->m_aux_label;
gtk_misc_set_padding ((GtkMisc*) _tmp10_, 8, 0);
_tmp11_ = self->priv->m_aux_label;
gtk_widget_set_no_show_all ((GtkWidget*) _tmp11_, TRUE);
_tmp12_ = self->priv->m_vertical_panel_system;
_tmp13_ = candidate_area_new (_tmp12_);
g_object_ref_sink (_tmp13_);
_g_object_unref0 (self->priv->m_candidate_area);
self->priv->m_candidate_area = _tmp13_;
_tmp14_ = self->priv->m_candidate_area;
g_signal_connect_object (_tmp14_, "candidate-clicked", (GCallback) ___lambda15__candidate_area_candidate_clicked, self, 0);
_tmp15_ = self->priv->m_candidate_area;
g_signal_connect_object (_tmp15_, "page-up", (GCallback) ___lambda16__candidate_area_page_up, self, 0);
_tmp16_ = self->priv->m_candidate_area;
g_signal_connect_object (_tmp16_, "page-down", (GCallback) ___lambda17__candidate_area_page_down, self, 0);
_tmp17_ = self->priv->m_candidate_area;
g_signal_connect_object (_tmp17_, "cursor-up", (GCallback) ___lambda18__candidate_area_cursor_up, self, 0);
_tmp18_ = self->priv->m_candidate_area;
g_signal_connect_object (_tmp18_, "cursor-down", (GCallback) ___lambda19__candidate_area_cursor_down, self, 0);
_tmp19_ = hseparator_new ();
g_object_ref_sink (_tmp19_);
_g_object_unref0 (self->priv->m_hseparator);
self->priv->m_hseparator = _tmp19_;
_tmp20_ = self->priv->m_hseparator;
gtk_widget_set_visible ((GtkWidget*) _tmp20_, TRUE);
candidate_panel_pack_all_widgets (self);
}
static void
candidate_panel_pack_all_widgets (CandidatePanel* self)
{
GtkBox* _tmp0_;
GtkLabel* _tmp1_;
GtkBox* _tmp2_;
GtkLabel* _tmp3_;
GtkBox* _tmp4_;
HSeparator* _tmp5_;
GtkBox* _tmp6_;
CandidateArea* _tmp7_;
g_return_if_fail (self != NULL);
_tmp0_ = self->priv->m_vbox;
_tmp1_ = self->priv->m_preedit_label;
gtk_box_pack_start (_tmp0_, (GtkWidget*) _tmp1_, FALSE, FALSE, (guint) 4);
_tmp2_ = self->priv->m_vbox;
_tmp3_ = self->priv->m_aux_label;
gtk_box_pack_start (_tmp2_, (GtkWidget*) _tmp3_, FALSE, FALSE, (guint) 4);
_tmp4_ = self->priv->m_vbox;
_tmp5_ = self->priv->m_hseparator;
gtk_box_pack_start (_tmp4_, (GtkWidget*) _tmp5_, FALSE, FALSE, (guint) 0);
_tmp6_ = self->priv->m_vbox;
_tmp7_ = self->priv->m_candidate_area;
gtk_box_pack_start (_tmp6_, (GtkWidget*) _tmp7_, FALSE, FALSE, (guint) 0);
}
void
candidate_panel_show (CandidatePanel* self)
{
GtkWindow* _tmp0_;
g_return_if_fail (self != NULL);
_tmp0_ = self->priv->m_toplevel;
gtk_widget_show_all ((GtkWidget*) _tmp0_);
}
void
candidate_panel_hide (CandidatePanel* self)
{
GtkWindow* _tmp0_;
g_return_if_fail (self != NULL);
_tmp0_ = self->priv->m_toplevel;
gtk_widget_hide ((GtkWidget*) _tmp0_);
}
static void
candidate_panel_move (CandidatePanel* self,
gint x,
gint y)
{
GtkWindow* _tmp0_;
g_return_if_fail (self != NULL);
_tmp0_ = self->priv->m_toplevel;
gtk_window_move (_tmp0_, x, y);
}
static void
candidate_panel_adjust_window_position (CandidatePanel* self)
{
gboolean _tmp0_;
g_return_if_fail (self != NULL);
_tmp0_ = self->priv->m_vertical_writing;
if (!_tmp0_) {
candidate_panel_adjust_window_position_horizontal (self);
} else {
candidate_panel_adjust_window_position_vertical (self);
}
}
static void
candidate_panel_get_monitor_geometry (CandidatePanel* self,
GdkRectangle* result)
{
GdkRectangle monitor_area = {0};
GdkRectangle _tmp0_ = {0};
GdkMonitor* monitor = NULL;
GdkDisplay* _tmp1_;
GdkRectangle _tmp2_;
gint _tmp3_;
GdkRectangle _tmp4_;
gint _tmp5_;
GdkMonitor* _tmp6_;
GdkMonitor* _tmp7_;
GdkRectangle _tmp8_ = {0};
g_return_if_fail (self != NULL);
_tmp0_.x = 0;
monitor_area = _tmp0_;
_tmp1_ = gdk_display_get_default ();
_tmp2_ = self->priv->m_cursor_location;
_tmp3_ = _tmp2_.x;
_tmp4_ = self->priv->m_cursor_location;
_tmp5_ = _tmp4_.y;
_tmp6_ = gdk_display_get_monitor_at_point (_tmp1_, _tmp3_, _tmp5_);
_tmp7_ = _g_object_ref0 (_tmp6_);
monitor = _tmp7_;
gdk_monitor_get_geometry (monitor, &_tmp8_);
monitor_area = _tmp8_;
*result = monitor_area;
_g_object_unref0 (monitor);
return;
}
static void
candidate_panel_adjust_window_position_horizontal (CandidatePanel* self)
{
GdkPoint cursor_right_bottom = {0};
GdkRectangle _tmp0_;
gint _tmp1_;
GdkRectangle _tmp2_;
gint _tmp3_;
GdkRectangle _tmp4_;
gint _tmp5_;
GdkPoint _tmp6_ = {0};
GtkAllocation allocation = {0};
GtkWindow* _tmp7_;
GtkAllocation _tmp8_ = {0};
GdkPoint window_right_bottom = {0};
GdkPoint _tmp9_;
gint _tmp10_;
GtkAllocation _tmp11_;
gint _tmp12_;
GdkPoint _tmp13_;
gint _tmp14_;
GtkAllocation _tmp15_;
gint _tmp16_;
GdkPoint _tmp17_ = {0};
GdkRectangle monitor_area = {0};
GdkRectangle _tmp18_ = {0};
gint monitor_right = 0;
GdkRectangle _tmp19_;
gint _tmp20_;
GdkRectangle _tmp21_;
gint _tmp22_;
gint monitor_bottom = 0;
GdkRectangle _tmp23_;
gint _tmp24_;
GdkRectangle _tmp25_;
gint _tmp26_;
gint x = 0;
gint y = 0;
GdkPoint _tmp27_;
gint _tmp28_;
gint _tmp29_;
gint _tmp35_;
GdkPoint _tmp36_;
gint _tmp37_;
gint _tmp38_;
gint _tmp45_;
gint _tmp46_;
gint _tmp47_;
g_return_if_fail (self != NULL);
_tmp0_ = self->priv->m_cursor_location;
_tmp1_ = _tmp0_.x;
_tmp2_ = self->priv->m_cursor_location;
_tmp3_ = _tmp2_.y;
_tmp4_ = self->priv->m_cursor_location;
_tmp5_ = _tmp4_.height;
_tmp6_.x = _tmp1_;
_tmp6_.y = _tmp3_ + _tmp5_;
cursor_right_bottom = _tmp6_;
_tmp7_ = self->priv->m_toplevel;
gtk_widget_get_allocation ((GtkWidget*) _tmp7_, &_tmp8_);
allocation = _tmp8_;
_tmp9_ = cursor_right_bottom;
_tmp10_ = _tmp9_.x;
_tmp11_ = allocation;
_tmp12_ = _tmp11_.width;
_tmp13_ = cursor_right_bottom;
_tmp14_ = _tmp13_.y;
_tmp15_ = allocation;
_tmp16_ = _tmp15_.height;
_tmp17_.x = _tmp10_ + _tmp12_;
_tmp17_.y = _tmp14_ + _tmp16_;
window_right_bottom = _tmp17_;
candidate_panel_get_monitor_geometry (self, &_tmp18_);
monitor_area = _tmp18_;
_tmp19_ = monitor_area;
_tmp20_ = _tmp19_.x;
_tmp21_ = monitor_area;
_tmp22_ = _tmp21_.width;
monitor_right = _tmp20_ + _tmp22_;
_tmp23_ = monitor_area;
_tmp24_ = _tmp23_.y;
_tmp25_ = monitor_area;
_tmp26_ = _tmp25_.height;
monitor_bottom = _tmp24_ + _tmp26_;
_tmp27_ = window_right_bottom;
_tmp28_ = _tmp27_.x;
_tmp29_ = monitor_right;
if (_tmp28_ > _tmp29_) {
gint _tmp30_;
GtkAllocation _tmp31_;
gint _tmp32_;
_tmp30_ = monitor_right;
_tmp31_ = allocation;
_tmp32_ = _tmp31_.width;
x = _tmp30_ - _tmp32_;
} else {
GdkPoint _tmp33_;
gint _tmp34_;
_tmp33_ = cursor_right_bottom;
_tmp34_ = _tmp33_.x;
x = _tmp34_;
}
_tmp35_ = x;
if (_tmp35_ < 0) {
x = 0;
}
_tmp36_ = window_right_bottom;
_tmp37_ = _tmp36_.y;
_tmp38_ = monitor_bottom;
if (_tmp37_ > _tmp38_) {
GdkRectangle _tmp39_;
gint _tmp40_;
GtkAllocation _tmp41_;
gint _tmp42_;
_tmp39_ = self->priv->m_cursor_location;
_tmp40_ = _tmp39_.y;
_tmp41_ = allocation;
_tmp42_ = _tmp41_.height;
y = _tmp40_ - _tmp42_;
} else {
GdkPoint _tmp43_;
gint _tmp44_;
_tmp43_ = cursor_right_bottom;
_tmp44_ = _tmp43_.y;
y = _tmp44_;
}
_tmp45_ = y;
if (_tmp45_ < 0) {
y = 0;
}
_tmp46_ = x;
_tmp47_ = y;
candidate_panel_move (self, _tmp46_, _tmp47_);
}
static void
candidate_panel_adjust_window_position_vertical (CandidatePanel* self)
{
gint char_size = 0;
GdkRectangle _tmp0_;
gint _tmp1_;
GdkRectangle _tmp2_;
gint _tmp3_;
GdkPoint cursor_right_bottom = {0};
GdkRectangle _tmp4_;
gint _tmp5_;
gint _tmp6_;
GdkRectangle _tmp7_;
gint _tmp8_;
gint _tmp9_;
GdkPoint _tmp10_ = {0};
GtkAllocation allocation = {0};
GtkWindow* _tmp11_;
GtkAllocation _tmp12_ = {0};
GdkPoint hwindow_right_bottom = {0};
GdkRectangle _tmp13_;
gint _tmp14_;
GtkAllocation _tmp15_;
gint _tmp16_;
GdkPoint _tmp17_;
gint _tmp18_;
GtkAllocation _tmp19_;
gint _tmp20_;
GdkPoint _tmp21_ = {0};
GdkPoint vwindow_left_bottom = {0};
GdkRectangle _tmp22_;
gint _tmp23_;
GtkAllocation _tmp24_;
gint _tmp25_;
GdkRectangle _tmp26_;
gint _tmp27_;
GtkAllocation _tmp28_;
gint _tmp29_;
GdkPoint _tmp30_ = {0};
GdkRectangle monitor_area = {0};
GdkRectangle _tmp31_ = {0};
gint monitor_right = 0;
GdkRectangle _tmp32_;
gint _tmp33_;
GdkRectangle _tmp34_;
gint _tmp35_;
gint monitor_bottom = 0;
GdkRectangle _tmp36_;
gint _tmp37_;
GdkRectangle _tmp38_;
gint _tmp39_;
gint x = 0;
gint y = 0;
CandidateArea* _tmp40_;
gint _tmp78_;
gint _tmp79_;
gint _tmp80_;
gint _tmp81_;
g_return_if_fail (self != NULL);
_tmp0_ = self->priv->m_cursor_location;
_tmp1_ = _tmp0_.width;
_tmp2_ = self->priv->m_cursor_location;
_tmp3_ = _tmp2_.height;
char_size = MAX (_tmp1_, _tmp3_);
_tmp4_ = self->priv->m_cursor_location;
_tmp5_ = _tmp4_.x;
_tmp6_ = char_size;
_tmp7_ = self->priv->m_cursor_location;
_tmp8_ = _tmp7_.y;
_tmp9_ = char_size;
_tmp10_.x = _tmp5_ + _tmp6_;
_tmp10_.y = _tmp8_ + _tmp9_;
cursor_right_bottom = _tmp10_;
_tmp11_ = self->priv->m_toplevel;
gtk_widget_get_allocation ((GtkWidget*) _tmp11_, &_tmp12_);
allocation = _tmp12_;
_tmp13_ = self->priv->m_cursor_location;
_tmp14_ = _tmp13_.x;
_tmp15_ = allocation;
_tmp16_ = _tmp15_.width;
_tmp17_ = cursor_right_bottom;
_tmp18_ = _tmp17_.y;
_tmp19_ = allocation;
_tmp20_ = _tmp19_.height;
_tmp21_.x = _tmp14_ + _tmp16_;
_tmp21_.y = _tmp18_ + _tmp20_;
hwindow_right_bottom = _tmp21_;
_tmp22_ = self->priv->m_cursor_location;
_tmp23_ = _tmp22_.x;
_tmp24_ = allocation;
_tmp25_ = _tmp24_.width;
_tmp26_ = self->priv->m_cursor_location;
_tmp27_ = _tmp26_.y;
_tmp28_ = allocation;
_tmp29_ = _tmp28_.height;
_tmp30_.x = _tmp23_ - _tmp25_;
_tmp30_.y = _tmp27_ + _tmp29_;
vwindow_left_bottom = _tmp30_;
candidate_panel_get_monitor_geometry (self, &_tmp31_);
monitor_area = _tmp31_;
_tmp32_ = monitor_area;
_tmp33_ = _tmp32_.x;
_tmp34_ = monitor_area;
_tmp35_ = _tmp34_.width;
monitor_right = _tmp33_ + _tmp35_;
_tmp36_ = monitor_area;
_tmp37_ = _tmp36_.y;
_tmp38_ = monitor_area;
_tmp39_ = _tmp38_.height;
monitor_bottom = _tmp37_ + _tmp39_;
_tmp40_ = self->priv->m_candidate_area;
if (!candidate_area_get_vertical (_tmp40_)) {
GdkPoint _tmp41_;
gint _tmp42_;
gint _tmp43_;
GdkPoint _tmp49_;
gint _tmp50_;
gint _tmp51_;
_tmp41_ = hwindow_right_bottom;
_tmp42_ = _tmp41_.x;
_tmp43_ = monitor_right;
if (_tmp42_ > _tmp43_) {
gint _tmp44_;
GtkAllocation _tmp45_;
gint _tmp46_;
_tmp44_ = monitor_right;
_tmp45_ = allocation;
_tmp46_ = _tmp45_.width;
x = _tmp44_ - _tmp46_;
} else {
GdkRectangle _tmp47_;
gint _tmp48_;
_tmp47_ = self->priv->m_cursor_location;
_tmp48_ = _tmp47_.x;
x = _tmp48_;
}
_tmp49_ = hwindow_right_bottom;
_tmp50_ = _tmp49_.y;
_tmp51_ = monitor_bottom;
if (_tmp50_ > _tmp51_) {
GdkRectangle _tmp52_;
gint _tmp53_;
GtkAllocation _tmp54_;
gint _tmp55_;
_tmp52_ = self->priv->m_cursor_location;
_tmp53_ = _tmp52_.y;
_tmp54_ = allocation;
_tmp55_ = _tmp54_.height;
y = _tmp53_ - _tmp55_;
} else {
GdkPoint _tmp56_;
gint _tmp57_;
_tmp56_ = cursor_right_bottom;
_tmp57_ = _tmp56_.y;
y = _tmp57_;
}
} else {
GdkPoint _tmp58_;
gint _tmp59_;
gint _tmp60_;
GdkPoint _tmp70_;
gint _tmp71_;
gint _tmp72_;
_tmp58_ = vwindow_left_bottom;
_tmp59_ = _tmp58_.x;
_tmp60_ = monitor_right;
if (_tmp59_ > _tmp60_) {
gint _tmp61_;
GtkAllocation _tmp62_;
gint _tmp63_;
_tmp61_ = monitor_right;
_tmp62_ = allocation;
_tmp63_ = _tmp62_.width;
x = _tmp61_ - _tmp63_;
} else {
GdkPoint _tmp64_;
gint _tmp65_;
_tmp64_ = vwindow_left_bottom;
_tmp65_ = _tmp64_.x;
if (_tmp65_ < 0) {
GdkPoint _tmp66_;
gint _tmp67_;
_tmp66_ = cursor_right_bottom;
_tmp67_ = _tmp66_.x;
x = _tmp67_;
} else {
GdkPoint _tmp68_;
gint _tmp69_;
_tmp68_ = vwindow_left_bottom;
_tmp69_ = _tmp68_.x;
x = _tmp69_;
}
}
_tmp70_ = vwindow_left_bottom;
_tmp71_ = _tmp70_.y;
_tmp72_ = monitor_bottom;
if (_tmp71_ > _tmp72_) {
gint _tmp73_;
GtkAllocation _tmp74_;
gint _tmp75_;
_tmp73_ = monitor_bottom;
_tmp74_ = allocation;
_tmp75_ = _tmp74_.height;
y = _tmp73_ - _tmp75_;
} else {
GdkRectangle _tmp76_;
gint _tmp77_;
_tmp76_ = self->priv->m_cursor_location;
_tmp77_ = _tmp76_.y;
y = _tmp77_;
}
}
_tmp78_ = x;
if (_tmp78_ < 0) {
x = 0;
}
_tmp79_ = y;
if (_tmp79_ < 0) {
y = 0;
}
_tmp80_ = x;
_tmp81_ = y;
candidate_panel_move (self, _tmp80_, _tmp81_);
}
static void
g_cclosure_user_marshal_VOID__UINT_UINT_UINT (GClosure * closure,
GValue * return_value,
guint n_param_values,
const GValue * param_values,
gpointer invocation_hint,
gpointer marshal_data)
{
typedef void (*GMarshalFunc_VOID__UINT_UINT_UINT) (gpointer data1, guint arg_1, guint arg_2, guint arg_3, gpointer data2);
register GMarshalFunc_VOID__UINT_UINT_UINT callback;
register GCClosure * cc;
register gpointer data1;
register gpointer data2;
cc = (GCClosure *) closure;
g_return_if_fail (n_param_values == 4);
if (G_CCLOSURE_SWAP_DATA (closure)) {
data1 = closure->data;
data2 = param_values->data[0].v_pointer;
} else {
data1 = param_values->data[0].v_pointer;
data2 = closure->data;
}
callback = (GMarshalFunc_VOID__UINT_UINT_UINT) (marshal_data ? marshal_data : cc->callback);
callback (data1, g_value_get_uint (param_values + 1), g_value_get_uint (param_values + 2), g_value_get_uint (param_values + 3), data2);
}
static void
candidate_panel_class_init (CandidatePanelClass * klass)
{
candidate_panel_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (CandidatePanelPrivate));
G_OBJECT_CLASS (klass)->finalize = candidate_panel_finalize;
candidate_panel_signals[CANDIDATE_PANEL_CURSOR_UP_SIGNAL] = g_signal_new ("cursor-up", TYPE_CANDIDATE_PANEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
candidate_panel_signals[CANDIDATE_PANEL_CURSOR_DOWN_SIGNAL] = g_signal_new ("cursor-down", TYPE_CANDIDATE_PANEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
candidate_panel_signals[CANDIDATE_PANEL_PAGE_UP_SIGNAL] = g_signal_new ("page-up", TYPE_CANDIDATE_PANEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
candidate_panel_signals[CANDIDATE_PANEL_PAGE_DOWN_SIGNAL] = g_signal_new ("page-down", TYPE_CANDIDATE_PANEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
candidate_panel_signals[CANDIDATE_PANEL_CANDIDATE_CLICKED_SIGNAL] = g_signal_new ("candidate-clicked", TYPE_CANDIDATE_PANEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__UINT_UINT_UINT, G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
}
static void
candidate_panel_instance_init (CandidatePanel * self)
{
self->priv = CANDIDATE_PANEL_GET_PRIVATE (self);
self->priv->m_vertical_panel_system = TRUE;
}
static void
candidate_panel_finalize (GObject * obj)
{
CandidatePanel * self;
self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_CANDIDATE_PANEL, CandidatePanel);
_g_object_unref0 (self->priv->m_toplevel);
_g_object_unref0 (self->priv->m_vbox);
_g_object_unref0 (self->priv->m_preedit_label);
_g_object_unref0 (self->priv->m_aux_label);
_g_object_unref0 (self->priv->m_candidate_area);
_g_object_unref0 (self->priv->m_hseparator);
G_OBJECT_CLASS (candidate_panel_parent_class)->finalize (obj);
}
GType
candidate_panel_get_type (void)
{
static volatile gsize candidate_panel_type_id__volatile = 0;
if (g_once_init_enter (&candidate_panel_type_id__volatile)) {
static const GTypeInfo g_define_type_info = { sizeof (CandidatePanelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) candidate_panel_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CandidatePanel), 0, (GInstanceInitFunc) candidate_panel_instance_init, NULL };
GType candidate_panel_type_id;
candidate_panel_type_id = g_type_register_static (gtk_box_get_type (), "CandidatePanel", &g_define_type_info, 0);
g_once_init_leave (&candidate_panel_type_id__volatile, candidate_panel_type_id);
}
return candidate_panel_type_id__volatile;
}
static void
_vala_array_destroy (gpointer array,
gint array_length,
GDestroyNotify destroy_func)
{
if ((array != NULL) && (destroy_func != NULL)) {
int i;
for (i = 0; i < array_length; i = i + 1) {
if (((gpointer*) array)[i] != NULL) {
destroy_func (((gpointer*) array)[i]);
}
}
}
}
static void
_vala_array_free (gpointer array,
gint array_length,
GDestroyNotify destroy_func)
{
_vala_array_destroy (array, array_length, destroy_func);
g_free (array);
}