/* emojierapp.c generated by valac 0.40.8, the Vala compiler
* generated from emojierapp.vala, do not modify */
/* vim:set et sts=4 sw=4:
*
* ibus - The Input Bus
*
* Copyright (c) 2017 Peng Wu <alexepico@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 <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <gdk/gdk.h>
#include <config.h>
#include <stdio.h>
#include <ibus.h>
#define TYPE_EMOJI_APPLICATION (emoji_application_get_type ())
#define EMOJI_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_EMOJI_APPLICATION, EmojiApplication))
#define EMOJI_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_EMOJI_APPLICATION, EmojiApplicationClass))
#define IS_EMOJI_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_EMOJI_APPLICATION))
#define IS_EMOJI_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_EMOJI_APPLICATION))
#define EMOJI_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_EMOJI_APPLICATION, EmojiApplicationClass))
typedef struct _EmojiApplication EmojiApplication;
typedef struct _EmojiApplicationClass EmojiApplicationClass;
typedef struct _EmojiApplicationPrivate EmojiApplicationPrivate;
#define TYPE_IBUS_EMOJIER (ibus_emojier_get_type ())
#define IBUS_EMOJIER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_IBUS_EMOJIER, IBusEmojier))
#define IBUS_EMOJIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_IBUS_EMOJIER, IBusEmojierClass))
#define IS_IBUS_EMOJIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_IBUS_EMOJIER))
#define IS_IBUS_EMOJIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_IBUS_EMOJIER))
#define IBUS_EMOJIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_IBUS_EMOJIER, IBusEmojierClass))
typedef struct _IBusEmojier IBusEmojier;
typedef struct _IBusEmojierClass IBusEmojierClass;
enum {
EMOJI_APPLICATION_0_PROPERTY,
EMOJI_APPLICATION_NUM_PROPERTIES
};
static GParamSpec* emoji_application_properties[EMOJI_APPLICATION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_option_context_free0(var) ((var == NULL) ? NULL : (var = (g_option_context_free (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define __vala_GdkEvent_free0(var) ((var == NULL) ? NULL : (var = (_vala_GdkEvent_free (var), NULL)))
struct _EmojiApplication {
GtkApplication parent_instance;
EmojiApplicationPrivate * priv;
};
struct _EmojiApplicationClass {
GtkApplicationClass parent_class;
};
struct _EmojiApplicationPrivate {
IBusEmojier* m_emojier;
GSettings* m_settings_emoji;
GApplicationCommandLine* m_command_line;
};
extern gchar* emoji_font;
gchar* emoji_font = NULL;
extern gchar* annotation_lang;
gchar* annotation_lang = NULL;
extern gboolean partial_match;
gboolean partial_match = FALSE;
extern gint partial_match_length;
gint partial_match_length = -1;
extern gint partial_match_condition;
gint partial_match_condition = -1;
static gpointer emoji_application_parent_class = NULL;
GType emoji_application_get_type (void) G_GNUC_CONST;
GType ibus_emojier_get_type (void) G_GNUC_CONST;
#define EMOJI_APPLICATION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_EMOJI_APPLICATION, EmojiApplicationPrivate))
static EmojiApplication* emoji_application_new (void);
static EmojiApplication* emoji_application_construct (GType object_type);
static void emoji_application_show_dialog (EmojiApplication* self,
GApplicationCommandLine* command_line);
void ibus_emojier_reset (IBusEmojier* self);
void ibus_emojier_set_annotation (IBusEmojier* self,
const gchar* annotation);
void emoji_application_candidate_clicked_lookup_table (EmojiApplication* self,
guint index,
guint button,
guint state);
#define IBUS_EMOJIER_BUTTON_CLOSE_BUTTON ((guint) 1000)
guint ibus_emojier_get_number_of_candidates (IBusEmojier* self);
void ibus_emojier_set_cursor_pos (IBusEmojier* self,
guint cursor_pos);
gboolean ibus_emojier_has_variants (IBusEmojier* self,
guint index);
gchar* ibus_emojier_get_current_candidate (IBusEmojier* self);
static void _vala_array_add1 (gchar** * array,
int* length,
int* size,
gchar* value);
void emoji_application_activate_dialog (EmojiApplication* self,
GApplicationCommandLine* command_line);
static gint _emoji_application_command_line (EmojiApplication* self,
GApplicationCommandLine* command_line);
void ibus_emojier_set_emoji_font (const gchar* emoji_font);
gboolean ibus_emojier_is_running (IBusEmojier* self);
void ibus_emojier_present_centralize (IBusEmojier* self,
GdkEvent* event);
static void _vala_GdkEvent_free (GdkEvent* self);
void ibus_emojier_set_annotation_lang (const gchar* lang);
void ibus_emojier_set_partial_match (gboolean has_partial_match);
void ibus_emojier_set_partial_match_length (gint length);
void ibus_emojier_set_partial_match_condition (gint condition);
void ibus_emojier_set_favorites (gchar** unowned_favorites,
int unowned_favorites_length1,
gchar** unowned_favorite_annotations,
int unowned_favorite_annotations_length1);
void ibus_emojier_load_unicode_dict (void);
IBusEmojier* ibus_emojier_new (void);
IBusEmojier* ibus_emojier_construct (GType object_type);
static void ___lambda28_ (EmojiApplication* self,
guint i,
guint b,
guint s);
static void ____lambda28__ibus_emojier_candidate_clicked (IBusEmojier* _sender,
guint index,
guint button,
guint state,
gpointer self);
static gint emoji_application_real_command_line (GApplication* base,
GApplicationCommandLine* command_line);
static void emoji_application_real_shutdown (GApplication* base);
gint emoji_application_main (gchar** args,
int args_length1);
static void emoji_application_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 gint _vala_array_length (gpointer array);
static EmojiApplication*
emoji_application_construct (GType object_type)
{
EmojiApplication * self = NULL;
self = (EmojiApplication*) g_object_new (object_type, "application-id", "org.freedesktop.IBus.Panel.Emojier", "flags", G_APPLICATION_HANDLES_COMMAND_LINE, NULL);
g_application_set_inactivity_timeout ((GApplication*) self, (guint) 100000);
return self;
}
static EmojiApplication*
emoji_application_new (void)
{
return emoji_application_construct (TYPE_EMOJI_APPLICATION);
}
static gpointer
_g_object_ref0 (gpointer self)
{
return self ? g_object_ref (self) : NULL;
}
static void
emoji_application_show_dialog (EmojiApplication* self,
GApplicationCommandLine* command_line)
{
GApplicationCommandLine* _tmp0_;
IBusEmojier* _tmp1_;
IBusEmojier* _tmp2_;
IBusEmojier* _tmp3_;
g_return_if_fail (self != NULL);
g_return_if_fail (command_line != NULL);
_tmp0_ = _g_object_ref0 (command_line);
_g_object_unref0 (self->priv->m_command_line);
self->priv->m_command_line = _tmp0_;
_tmp1_ = self->priv->m_emojier;
ibus_emojier_reset (_tmp1_);
_tmp2_ = self->priv->m_emojier;
ibus_emojier_set_annotation (_tmp2_, "");
_tmp3_ = self->priv->m_emojier;
gtk_widget_show_all ((GtkWidget*) _tmp3_);
}
static void
_vala_array_add1 (gchar** * array,
int* length,
int* size,
gchar* value)
{
if ((*length) == (*size)) {
*size = (*size) ? (2 * (*size)) : 4;
*array = g_renew (gchar*, *array, (*size) + 1);
}
(*array)[(*length)++] = value;
(*array)[*length] = NULL;
}
void
emoji_application_candidate_clicked_lookup_table (EmojiApplication* self,
guint index,
guint button,
guint state)
{
GApplicationCommandLine* _tmp0_;
IBusEmojier* _tmp3_;
gboolean show_candidate = FALSE;
guint ncandidates = 0U;
IBusEmojier* _tmp4_;
gboolean _tmp5_ = FALSE;
guint _tmp6_;
gboolean _tmp10_;
gchar* emoji = NULL;
IBusEmojier* _tmp11_;
gchar* _tmp12_;
IBusEmojier* _tmp13_;
GtkClipboard* clipboard = NULL;
GtkClipboard* _tmp14_;
GtkClipboard* _tmp15_;
GtkClipboard* _tmp16_;
const gchar* _tmp17_;
GtkClipboard* _tmp18_;
gchar** emojier_favorites = NULL;
GSettings* _tmp19_;
gchar** _tmp20_;
gchar** _tmp21_;
gint emojier_favorites_length1;
gint _emojier_favorites_size_;
gboolean has_favorite = FALSE;
gchar** _tmp22_;
gint _tmp22__length1;
gboolean _tmp25_;
GApplicationCommandLine* _tmp31_;
g_return_if_fail (self != NULL);
_tmp0_ = self->priv->m_command_line;
if (_tmp0_ == NULL) {
return;
}
if (button == IBUS_EMOJIER_BUTTON_CLOSE_BUTTON) {
IBusEmojier* _tmp1_;
GApplicationCommandLine* _tmp2_;
_tmp1_ = self->priv->m_emojier;
gtk_widget_hide ((GtkWidget*) _tmp1_);
_tmp2_ = self->priv->m_command_line;
g_application_command_line_print (_tmp2_, "%s\n", _ ("Canceled to choose an emoji."));
_g_object_unref0 (self->priv->m_command_line);
self->priv->m_command_line = NULL;
return;
}
_tmp3_ = self->priv->m_emojier;
if (_tmp3_ == NULL) {
return;
}
show_candidate = FALSE;
_tmp4_ = self->priv->m_emojier;
ncandidates = ibus_emojier_get_number_of_candidates (_tmp4_);
_tmp6_ = ncandidates;
if (_tmp6_ > ((guint) 0)) {
guint _tmp7_;
_tmp7_ = ncandidates;
_tmp5_ = _tmp7_ >= index;
} else {
_tmp5_ = FALSE;
}
if (_tmp5_) {
IBusEmojier* _tmp8_;
IBusEmojier* _tmp9_;
_tmp8_ = self->priv->m_emojier;
ibus_emojier_set_cursor_pos (_tmp8_, index);
_tmp9_ = self->priv->m_emojier;
show_candidate = ibus_emojier_has_variants (_tmp9_, index);
} else {
return;
}
_tmp10_ = show_candidate;
if (_tmp10_) {
return;
}
_tmp11_ = self->priv->m_emojier;
_tmp12_ = ibus_emojier_get_current_candidate (_tmp11_);
emoji = _tmp12_;
_tmp13_ = self->priv->m_emojier;
gtk_widget_hide ((GtkWidget*) _tmp13_);
_tmp14_ = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
_tmp15_ = _g_object_ref0 (_tmp14_);
clipboard = _tmp15_;
_tmp16_ = clipboard;
_tmp17_ = emoji;
gtk_clipboard_set_text (_tmp16_, _tmp17_, -1);
_tmp18_ = clipboard;
gtk_clipboard_store (_tmp18_);
_tmp19_ = self->priv->m_settings_emoji;
_tmp21_ = _tmp20_ = g_settings_get_strv (_tmp19_, "favorites");
emojier_favorites = _tmp21_;
emojier_favorites_length1 = _vala_array_length (_tmp20_);
_emojier_favorites_size_ = emojier_favorites_length1;
has_favorite = FALSE;
_tmp22_ = emojier_favorites;
_tmp22__length1 = emojier_favorites_length1;
{
gchar** favorite_collection = NULL;
gint favorite_collection_length1 = 0;
gint _favorite_collection_size_ = 0;
gint favorite_it = 0;
favorite_collection = _tmp22_;
favorite_collection_length1 = _tmp22__length1;
for (favorite_it = 0; favorite_it < _tmp22__length1; favorite_it = favorite_it + 1) {
const gchar* favorite = NULL;
favorite = favorite_collection[favorite_it];
{
const gchar* _tmp23_;
const gchar* _tmp24_;
_tmp23_ = favorite;
_tmp24_ = emoji;
if (g_strcmp0 (_tmp23_, _tmp24_) == 0) {
has_favorite = TRUE;
break;
}
}
}
}
_tmp25_ = has_favorite;
if (!_tmp25_) {
gchar** _tmp26_;
gint _tmp26__length1;
const gchar* _tmp27_;
gchar* _tmp28_;
GSettings* _tmp29_;
gchar** _tmp30_;
gint _tmp30__length1;
_tmp26_ = emojier_favorites;
_tmp26__length1 = emojier_favorites_length1;
_tmp27_ = emoji;
_tmp28_ = g_strdup (_tmp27_);
_vala_array_add1 (&emojier_favorites, &emojier_favorites_length1, &_emojier_favorites_size_, _tmp28_);
_tmp29_ = self->priv->m_settings_emoji;
_tmp30_ = emojier_favorites;
_tmp30__length1 = emojier_favorites_length1;
g_settings_set_strv (_tmp29_, "favorites", _tmp30_);
}
_tmp31_ = self->priv->m_command_line;
g_application_command_line_print (_tmp31_, "%s\n", _ ("Copied an emoji to your clipboard."));
_g_object_unref0 (self->priv->m_command_line);
self->priv->m_command_line = NULL;
emojier_favorites = (_vala_array_free (emojier_favorites, emojier_favorites_length1, (GDestroyNotify) g_free), NULL);
_g_object_unref0 (clipboard);
_g_free0 (emoji);
}
void
emoji_application_activate_dialog (EmojiApplication* self,
GApplicationCommandLine* command_line)
{
g_return_if_fail (self != NULL);
g_return_if_fail (command_line != NULL);
g_application_hold ((GApplication*) self);
emoji_application_show_dialog (self, command_line);
g_application_release ((GApplication*) self);
}
static void
_vala_GdkEvent_free (GdkEvent* self)
{
g_boxed_free (gdk_event_get_type (), self);
}
static void
___lambda28_ (EmojiApplication* self,
guint i,
guint b,
guint s)
{
emoji_application_candidate_clicked_lookup_table (self, i, b, s);
}
static void
____lambda28__ibus_emojier_candidate_clicked (IBusEmojier* _sender,
guint index,
guint button,
guint state,
gpointer self)
{
___lambda28_ ((EmojiApplication*) self, index, button, state);
}
static gint
_emoji_application_command_line (EmojiApplication* self,
GApplicationCommandLine* command_line)
{
gint result = 0;
GSettings* _tmp0_;
gchar* _tmp1_;
gchar* _tmp2_;
static const GOptionEntry options[6] = {{"font", (gchar) 0, 0, G_OPTION_ARG_STRING, &emoji_font, N_ ("\"FONT\" for emoji characters on emoji dialog"), N_ ("FONT")}, {"lang", (gchar) 0, 0, G_OPTION_ARG_STRING, &annotation_lang, N_ ("\"LANG\" for annotations on emoji dialog. E.g. \"en\""), N_ ("LANG")}, {"partial-match", (gchar) 0, 0, G_OPTION_ARG_NONE, &partial_match, N_ ("Emoji annotations can be match partially"), NULL}, {"partial-match-length", (gchar) 0, 0, G_OPTION_ARG_INT, &partial_match_length, N_ ("Match with the length of the specified integer"), NULL}, {"partial-match-condition", (gchar) 0, 0, G_OPTION_ARG_INT, &partial_match_condition, N_ ("Match with the condition of the specified integer"), NULL}, {NULL}};
GOptionContext* option = NULL;
GOptionContext* _tmp3_;
GOptionContext* _tmp4_;
gchar** args = NULL;
gint _tmp5_;
gchar** _tmp6_;
gint args_length1;
gint _args_size_;
const gchar** _args = NULL;
gchar** _tmp7_;
gint _tmp7__length1;
gchar** _tmp8_;
gint _args_length1;
gint __args_size_;
gboolean _tmp26_ = FALSE;
IBusEmojier* _tmp27_;
const gchar* _tmp35_;
const gchar* _tmp38_;
gboolean _tmp39_;
gint _tmp40_;
gint _tmp43_;
const gchar* _tmp48_;
GSettings* _tmp50_;
gchar** _tmp51_;
gchar** _tmp52_;
gchar** _tmp53_;
gint _tmp53__length1;
GSettings* _tmp54_;
gchar** _tmp55_;
gchar** _tmp56_;
gchar** _tmp57_;
gint _tmp57__length1;
IBusEmojier* _tmp58_;
GError * _inner_error_ = NULL;
g_return_val_if_fail (self != NULL, 0);
g_return_val_if_fail (command_line != NULL, 0);
_tmp0_ = self->priv->m_settings_emoji;
_tmp1_ = g_settings_get_string (_tmp0_, "font");
_tmp2_ = _tmp1_;
ibus_emojier_set_emoji_font (_tmp2_);
_g_free0 (_tmp2_);
_tmp3_ = g_option_context_new (NULL);
option = _tmp3_;
_tmp4_ = option;
g_option_context_add_main_entries (_tmp4_, options, GETTEXT_PACKAGE);
_tmp6_ = g_application_command_line_get_arguments (command_line, &_tmp5_);
args = _tmp6_;
args_length1 = _tmp5_;
_args_size_ = args_length1;
_tmp7_ = args;
_tmp7__length1 = args_length1;
_tmp8_ = g_new0 (gchar*, _tmp7__length1 + 1);
_args = _tmp8_;
_args_length1 = _tmp7__length1;
__args_size_ = _args_length1;
{
gint i = 0;
i = 0;
{
gboolean _tmp9_ = FALSE;
_tmp9_ = TRUE;
while (TRUE) {
gint _tmp11_;
gchar** _tmp12_;
gint _tmp12__length1;
const gchar** _tmp13_;
gint _tmp13__length1;
gint _tmp14_;
gchar** _tmp15_;
gint _tmp15__length1;
gint _tmp16_;
const gchar* _tmp17_;
const gchar* _tmp18_;
if (!_tmp9_) {
gint _tmp10_;
_tmp10_ = i;
i = _tmp10_ + 1;
}
_tmp9_ = FALSE;
_tmp11_ = i;
_tmp12_ = args;
_tmp12__length1 = args_length1;
if (!(_tmp11_ < _tmp12__length1)) {
break;
}
_tmp13_ = _args;
_tmp13__length1 = _args_length1;
_tmp14_ = i;
_tmp15_ = args;
_tmp15__length1 = args_length1;
_tmp16_ = i;
_tmp17_ = _tmp15_[_tmp16_];
_tmp13_[_tmp14_] = _tmp17_;
_tmp18_ = _tmp13_[_tmp14_];
}
}
}
_g_free0 (emoji_font);
emoji_font = NULL;
_g_free0 (annotation_lang);
annotation_lang = NULL;
{
gchar** tmp = NULL;
const gchar** _tmp19_;
gint _tmp19__length1;
gint tmp_length1;
gint _tmp_size_;
GOptionContext* _tmp20_;
_tmp19_ = _args;
_tmp19__length1 = _args_length1;
tmp = _tmp19_;
tmp_length1 = _tmp19__length1;
_tmp_size_ = tmp_length1;
_tmp20_ = option;
g_option_context_parse (_tmp20_, &tmp_length1, &tmp, &_inner_error_);
if (G_UNLIKELY (_inner_error_ != NULL)) {
gint _tmp21_ = -1;
if (_inner_error_->domain == G_OPTION_ERROR) {
goto __catch0_g_option_error;
}
_args = (g_free (_args), NULL);
args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_free), NULL);
_g_option_context_free0 (option);
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return _tmp21_;
}
}
goto __finally0;
__catch0_g_option_error:
{
GError* e = NULL;
FILE* _tmp22_;
GError* _tmp23_;
const gchar* _tmp24_;
e = _inner_error_;
_inner_error_ = NULL;
_tmp22_ = stderr;
_tmp23_ = e;
_tmp24_ = _tmp23_->message;
fprintf (_tmp22_, "%s\n", _tmp24_);
result = EXIT_FAILURE;
_g_error_free0 (e);
_args = (g_free (_args), NULL);
args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_free), NULL);
_g_option_context_free0 (option);
return result;
}
__finally0:
if (G_UNLIKELY (_inner_error_ != NULL)) {
gint _tmp25_ = -1;
_args = (g_free (_args), NULL);
args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_free), NULL);
_g_option_context_free0 (option);
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return _tmp25_;
}
_tmp27_ = self->priv->m_emojier;
if (_tmp27_ != NULL) {
IBusEmojier* _tmp28_;
_tmp28_ = self->priv->m_emojier;
_tmp26_ = ibus_emojier_is_running (_tmp28_);
} else {
_tmp26_ = FALSE;
}
if (_tmp26_) {
GdkEvent* event = NULL;
GdkEvent* _tmp29_;
GdkEvent* _tmp30_;
GdkEventKey* _tmp31_;
GdkEventKey* _tmp32_;
IBusEmojier* _tmp33_;
GdkEvent* _tmp34_;
_tmp29_ = gdk_event_new (GDK_KEY_PRESS);
event = _tmp29_;
_tmp30_ = event;
_tmp31_ = (GdkEventKey *) (_tmp30_);
_tmp32_ = _tmp31_;
_tmp32_->time = (guint32) GDK_CURRENT_TIME;
_tmp33_ = self->priv->m_emojier;
_tmp34_ = event;
ibus_emojier_present_centralize (_tmp33_, _tmp34_);
result = EXIT_SUCCESS;
__vala_GdkEvent_free0 (event);
_args = (g_free (_args), NULL);
args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_free), NULL);
_g_option_context_free0 (option);
return result;
}
_tmp35_ = annotation_lang;
if (_tmp35_ == NULL) {
GSettings* _tmp36_;
gchar* _tmp37_;
_tmp36_ = self->priv->m_settings_emoji;
_tmp37_ = g_settings_get_string (_tmp36_, "lang");
_g_free0 (annotation_lang);
annotation_lang = _tmp37_;
}
_tmp38_ = annotation_lang;
ibus_emojier_set_annotation_lang (_tmp38_);
_tmp39_ = partial_match;
ibus_emojier_set_partial_match (_tmp39_);
_tmp40_ = partial_match_length;
if (_tmp40_ > 0) {
gint _tmp41_;
_tmp41_ = partial_match_length;
ibus_emojier_set_partial_match_length (_tmp41_);
} else {
GSettings* _tmp42_;
_tmp42_ = self->priv->m_settings_emoji;
ibus_emojier_set_partial_match_length (g_settings_get_int (_tmp42_, "partial-match-length"));
}
_tmp43_ = partial_match_condition;
if (_tmp43_ > 2) {
GSettings* _tmp44_;
g_warning ("emojierapp.vala:178: Need condition between 0 and 2.");
_tmp44_ = self->priv->m_settings_emoji;
ibus_emojier_set_partial_match_condition (g_settings_get_int (_tmp44_, "partial-match-condition"));
} else {
gint _tmp45_;
_tmp45_ = partial_match_condition;
if (_tmp45_ >= 0) {
gint _tmp46_;
_tmp46_ = partial_match_condition;
ibus_emojier_set_partial_match_condition (_tmp46_);
} else {
GSettings* _tmp47_;
_tmp47_ = self->priv->m_settings_emoji;
ibus_emojier_set_partial_match_condition (g_settings_get_int (_tmp47_, "partial-match-condition"));
}
}
_tmp48_ = emoji_font;
if (_tmp48_ != NULL) {
const gchar* _tmp49_;
_tmp49_ = emoji_font;
ibus_emojier_set_emoji_font (_tmp49_);
}
_tmp50_ = self->priv->m_settings_emoji;
_tmp52_ = _tmp51_ = g_settings_get_strv (_tmp50_, "favorites");
_tmp53_ = _tmp52_;
_tmp53__length1 = _vala_array_length (_tmp51_);
_tmp54_ = self->priv->m_settings_emoji;
_tmp56_ = _tmp55_ = g_settings_get_strv (_tmp54_, "favorite-annotations");
_tmp57_ = _tmp56_;
_tmp57__length1 = _vala_array_length (_tmp55_);
ibus_emojier_set_favorites (_tmp53_, _vala_array_length (_tmp51_), _tmp57_, _vala_array_length (_tmp55_));
_tmp57_ = (_vala_array_free (_tmp57_, _tmp57__length1, (GDestroyNotify) g_free), NULL);
_tmp53_ = (_vala_array_free (_tmp53_, _tmp53__length1, (GDestroyNotify) g_free), NULL);
ibus_emojier_load_unicode_dict ();
_tmp58_ = self->priv->m_emojier;
if (_tmp58_ == NULL) {
IBusEmojier* _tmp59_;
IBusEmojier* _tmp60_;
IBusEmojier* _tmp61_;
_tmp59_ = ibus_emojier_new ();
g_object_ref_sink (_tmp59_);
_g_object_unref0 (self->priv->m_emojier);
self->priv->m_emojier = _tmp59_;
_tmp60_ = self->priv->m_emojier;
gtk_application_add_window ((GtkApplication*) self, (GtkWindow*) _tmp60_);
_tmp61_ = self->priv->m_emojier;
g_signal_connect_object (_tmp61_, "candidate-clicked", (GCallback) ____lambda28__ibus_emojier_candidate_clicked, self, 0);
}
emoji_application_activate_dialog (self, command_line);
result = EXIT_SUCCESS;
_args = (g_free (_args), NULL);
args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_free), NULL);
_g_option_context_free0 (option);
return result;
}
static gint
emoji_application_real_command_line (GApplication* base,
GApplicationCommandLine* command_line)
{
EmojiApplication * self;
gint result = 0;
gint _result_ = 0;
self = (EmojiApplication*) base;
g_return_val_if_fail (command_line != NULL, 0);
g_application_hold ((GApplication*) self);
_result_ = _emoji_application_command_line (self, command_line);
g_application_release ((GApplication*) self);
result = _result_;
return result;
}
static void
emoji_application_real_shutdown (GApplication* base)
{
EmojiApplication * self;
IBusEmojier* _tmp0_;
self = (EmojiApplication*) base;
G_APPLICATION_CLASS (emoji_application_parent_class)->shutdown ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_application_get_type (), GtkApplication));
_tmp0_ = self->priv->m_emojier;
gtk_application_remove_window ((GtkApplication*) self, (GtkWindow*) _tmp0_);
_g_object_unref0 (self->priv->m_emojier);
self->priv->m_emojier = NULL;
}
gint
emoji_application_main (gchar** args,
int args_length1)
{
gint result = 0;
EmojiApplication* app = NULL;
EmojiApplication* _tmp0_;
gint status = 0;
bindtextdomain (GETTEXT_PACKAGE, GLIB_LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
ibus_init ();
gtk_init (&args_length1, &args);
_tmp0_ = emoji_application_new ();
app = _tmp0_;
status = g_application_run ((GApplication*) app, args_length1, args);
result = status;
_g_object_unref0 (app);
return result;
}
int
main (int argc,
char ** argv)
{
return emoji_application_main (argv, argc);
}
static void
emoji_application_class_init (EmojiApplicationClass * klass)
{
emoji_application_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (EmojiApplicationPrivate));
((GApplicationClass *) klass)->command_line = (gint (*) (GApplication *, GApplicationCommandLine*)) emoji_application_real_command_line;
((GApplicationClass *) klass)->shutdown = (void (*) (GApplication *)) emoji_application_real_shutdown;
G_OBJECT_CLASS (klass)->finalize = emoji_application_finalize;
}
static void
emoji_application_instance_init (EmojiApplication * self)
{
GSettings* _tmp0_;
self->priv = EMOJI_APPLICATION_GET_PRIVATE (self);
_tmp0_ = g_settings_new ("org.freedesktop.ibus.panel.emoji");
self->priv->m_settings_emoji = _tmp0_;
self->priv->m_command_line = NULL;
}
static void
emoji_application_finalize (GObject * obj)
{
EmojiApplication * self;
self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_EMOJI_APPLICATION, EmojiApplication);
_g_object_unref0 (self->priv->m_emojier);
_g_object_unref0 (self->priv->m_settings_emoji);
_g_object_unref0 (self->priv->m_command_line);
G_OBJECT_CLASS (emoji_application_parent_class)->finalize (obj);
}
GType
emoji_application_get_type (void)
{
static volatile gsize emoji_application_type_id__volatile = 0;
if (g_once_init_enter (&emoji_application_type_id__volatile)) {
static const GTypeInfo g_define_type_info = { sizeof (EmojiApplicationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) emoji_application_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmojiApplication), 0, (GInstanceInitFunc) emoji_application_instance_init, NULL };
GType emoji_application_type_id;
emoji_application_type_id = g_type_register_static (gtk_application_get_type (), "EmojiApplication", &g_define_type_info, 0);
g_once_init_leave (&emoji_application_type_id__volatile, emoji_application_type_id);
}
return emoji_application_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);
}
static gint
_vala_array_length (gpointer array)
{
int length;
length = 0;
if (array) {
while (((gpointer*) array)[length]) {
length++;
}
}
return length;
}