1 #include "gcin.h"
2 #include "pho.h"
3 #include "gtab.h"
4 #include "win-sym.h"
5 #include "eggtrayicon.h"
6 #include "gst.h"
7 #include "pho-kbm-name.h"
8 
9 GtkWidget *win_screen_status, *icon_hf, *icon_inmd;
10 static int timeout_handle;
11 
12 static char *cur_file_hf, *cur_file_inmd;
13 
clear_timeout()14 static gboolean clear_timeout()
15 {
16   if (!timeout_handle)
17     return FALSE;
18   g_source_remove(timeout_handle);
19   timeout_handle = 0;
20   return TRUE;
21 }
22 
close_win_status()23 void close_win_status()
24 {
25   if (!clear_timeout())
26     return;
27   gtk_widget_hide(win_screen_status);
28 }
29 
timeout_hide(gpointer data)30 static gboolean timeout_hide(gpointer data)
31 {
32   close_win_status();
33   return FALSE;
34 }
35 
36 gboolean win_is_visible();
37 static int old_x, old_y;
38 
disp_win_screen_status(char * in_method,char * half_status)39 void disp_win_screen_status(char *in_method, char *half_status)
40 {
41   dbg("disp_win_screen_status\n");
42   if (
43 //  tss.c_len || ggg.gbufN ||
44   cur_file_hf && !strcmp(cur_file_hf, half_status) &&
45   cur_file_inmd && !strcmp(cur_file_inmd, in_method)
46 #if 0
47   && old_x==current_in_win_x && old_y==current_in_win_y
48 #endif
49   )
50     return;
51 
52   old_x = current_in_win_x;
53   old_y = current_in_win_y;
54 
55   clear_timeout();
56   free(cur_file_hf); cur_file_hf = strdup(half_status);
57   free(cur_file_inmd); cur_file_inmd = strdup(in_method);
58 
59   if (!win_screen_status) {
60     win_screen_status = create_no_focus_win();
61     GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
62     gtk_container_add(GTK_CONTAINER(win_screen_status), hbox);
63     icon_inmd = gtk_image_new_from_file(in_method);
64     gtk_box_pack_start (GTK_BOX (hbox), icon_inmd, FALSE, FALSE, 0);
65 #if 1
66     icon_hf = gtk_image_new_from_file(half_status);
67     gtk_box_pack_start (GTK_BOX (hbox), icon_hf, FALSE, FALSE, 0);
68 #endif
69   } else {
70 #if 1
71     gtk_image_set_from_file(GTK_IMAGE(icon_hf), half_status);
72 #endif
73     gtk_image_set_from_file(GTK_IMAGE(icon_inmd), in_method);
74   }
75 
76   gtk_widget_show_all(win_screen_status);
77   gtk_window_present(GTK_WINDOW(win_screen_status));
78 
79   timeout_handle = g_timeout_add(1000, timeout_hide, NULL);
80   int w,h;
81   get_win_size(win_screen_status, &w, &h);
82 
83   int x = current_in_win_x;
84   int y = current_in_win_y + (win_is_visible()?win_yl:0);
85 
86 
87   if (x + w > dpy_xl)
88     x = dpy_xl - w;
89 
90   if (y + h > dpy_yl)
91     y = win_y - h;
92 
93   gtk_window_move(GTK_WINDOW(win_screen_status), x, y);
94 }
95