summaryrefslogtreecommitdiff
path: root/pickme.c
diff options
context:
space:
mode:
Diffstat (limited to 'pickme.c')
-rw-r--r--pickme.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/pickme.c b/pickme.c
index f120a5a..02899b0 100644
--- a/pickme.c
+++ b/pickme.c
@@ -1,7 +1,4 @@
#include <HsFFI.h>
-#ifdef __GLASGOW_HASKELL__
-//#include "unicode_stub.h"
-#endif /* __GLASGOW_HASKELL__ */
#include <stdlib.h>
#include <gtk/gtk.h>
@@ -19,17 +16,12 @@ GtkWidget **buttons;
bool inited = false;
extern char *searchCharacterByName (const char *);
+extern char *favoriteEmojis (void);
-void
-on_click (GtkWidget *widget,
- gpointer data)
-{
- gdk_clipboard_set_text (gtk_widget_get_primary_clipboard (widget), (char *)data);
-}
+// forward declaration
+void on_click (GtkWidget *widget, gpointer data);
-void
-on_input (GtkText *text,
- gpointer user_data)
+void draw_results (GtkText *text, char *results)
{
if (!inited)
{
@@ -59,10 +51,6 @@ on_input (GtkText *text,
}
gsize buf_size = gtk_entry_buffer_get_bytes (input_buffer);
- const char *buffer_contents = gtk_entry_buffer_get_text (input_buffer);
- char *results;
-
- results = searchCharacterByName (buffer_contents);
size_t l = strlen (results);
if (l == 0)
@@ -109,8 +97,21 @@ on_input (GtkText *text,
}
void
-activate (GtkApplication *app,
- gpointer user_data)
+on_click (GtkWidget *widget, gpointer data)
+{
+ gdk_clipboard_set_text (gtk_widget_get_primary_clipboard (widget), (char *)data);
+}
+
+void
+on_input (GtkText *text, gpointer user_data)
+{
+ const char *buffer_contents = gtk_entry_buffer_get_text (input_buffer);
+ char *results = searchCharacterByName (buffer_contents);
+ draw_results (text, results);
+}
+
+void
+activate (GtkApplication *app, gpointer user_data)
{
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "pickme");
@@ -126,11 +127,15 @@ activate (GtkApplication *app,
gtk_window_set_child (GTK_WINDOW (window), box);
gtk_window_present (GTK_WINDOW (window));
+
+ if (strcmp (favoriteEmojis (), ""))
+ {
+ draw_results (GTK_TEXT (input), favoriteEmojis ());
+ }
}
void
-shutdown (GtkApplication *app,
- gpointer user_data)
+shutdown (GtkApplication *app, gpointer user_data)
{
if (!inited)
{