annotate src/lirc.c @ 606:408f36d536a5

search_status_update(): slightly reduce code redundancy.
author zas_
date Thu, 08 May 2008 20:21:03 +0000
parents e8b28413ffbf
children b690cecbf5b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
1 #include "lirc.h"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
2
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
3 #ifdef HAVE_LIRC
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
4 #include <lirc/lirc_client.h>
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
5 #include "layout_image.h"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
6 #include "debug.h"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
7
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
8 gint lirc_fd = -1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
9 struct lirc_config *config = NULL;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
10 guint input_tag;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
11 GIOChannel *gio_chan;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
12
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
13 /*
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
14 *-----------------------------------------------------------------------------
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
15 * LIRC callback
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
16 *-----------------------------------------------------------------------------
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
17 */
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
18
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
19 void lirc_cleanup()
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
20 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
21 if (config)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
22 {
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
23 g_source_remove(input_tag);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
24 lirc_freeconfig(config);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
25 config = NULL;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
26 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
27 if (lirc_fd != -1)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
28 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
29 lirc_deinit();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
30 lirc_fd = -1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
31 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
32 if (gio_chan)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
33 {
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
34 g_io_channel_shutdown(gio_chan, TRUE, NULL);
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
35 g_io_channel_unref(gio_chan);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
36 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
37 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
38
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
39 gboolean lirc_input_callback(GIOChannel *source, GIOCondition condition,
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
40 gpointer data)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
41 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
42 LayoutWindow *lw = data;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
43 gchar *ptr;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
44 gint ret;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
45 gint x = 0;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
46 gint y = 0;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
47
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
48 /* LIRC code and corresponding geeqie command (and parameters)*/
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
49 gchar *code;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
50 gchar *cmd;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
51
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
52 /* parameters for geeqie command */
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
53 gint i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
54 gfloat fl_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
55
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
56 while ((ret = lirc_nextcode(&code)) == 0 && code)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
57 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
58 while ((ret = lirc_code2char(config, code, &cmd)) == 0 && cmd)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
59 {
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
60 if (g_ascii_strncasecmp("LEFT", cmd, 4) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
61 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
62 ptr = cmd + 4;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
63 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
64 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
65
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
66 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
67 x -= i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
68 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
69 else if (g_ascii_strncasecmp("RIGHT", cmd, 5) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
70 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
71 ptr = cmd + 5;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
72 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
73 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
74
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
75 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
76 x += i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
77 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
78 else if (g_ascii_strncasecmp("UP", cmd, 2) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
79 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
80 ptr = cmd + 2;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
81 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
82 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
83
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
84 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
85 y -= i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
86 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
87 else if (g_ascii_strncasecmp("DOWN", cmd, 4) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
88 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
89 ptr = cmd + 4;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
90 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
91 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
92
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
93 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
94 y += i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
95 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
96 else if (g_ascii_strcasecmp("PREV", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
97 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
98 layout_image_prev(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
99 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
100 else if (g_ascii_strcasecmp("NEXT", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
101 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
102 layout_image_next(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
103 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
104 else if (g_ascii_strncasecmp("ZOOM_IN", cmd, 7) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
105 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
106 ptr = cmd + 7;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
107 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
108 fl_parm = atoi(ptr) / 10.0;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
109
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
110 if (fl_parm <= 0.01) fl_parm = get_zoom_increment();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
111 layout_image_zoom_adjust(lw, fl_parm);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
112 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
113 else if (g_ascii_strncasecmp("ZOOM_OUT", cmd, 8) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
114 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
115 ptr = cmd + 8;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
116 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
117 fl_parm = atoi(ptr) / 10.0;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
118
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
119 if (fl_parm <= 0.01) fl_parm = get_zoom_increment();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
120 layout_image_zoom_adjust(lw, -fl_parm);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
121 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
122 else if (g_ascii_strcasecmp("ZOOM_MAX", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
123 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
124 layout_image_zoom_set(lw, 0.0);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
125 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
126 else if (g_ascii_strncasecmp("SET_ZOOM", cmd, 8) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
127 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
128 ptr = cmd + 8;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
129 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
130 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
131
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
132 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
133 layout_image_zoom_set(lw, 1.0);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
134 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
135 else if (g_ascii_strncasecmp("SET_INV_ZOOM", cmd, 12) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
136 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
137 ptr = cmd + 12;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
138 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
139 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
140
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
141 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
142 layout_image_zoom_set(lw, -i_parm);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
143 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
144 else if (g_ascii_strcasecmp("FIRST", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
145 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
146 layout_image_first(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
147 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
148 else if (g_ascii_strcasecmp("LAST", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
149 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
150 layout_image_last(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
151 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
152 else if (g_ascii_strcasecmp("PAUSE", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
153 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
154 layout_image_slideshow_pause_toggle(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
155 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
156 else if (g_ascii_strcasecmp("ROTATE_90", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
157 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
158 layout_image_alter(lw, ALTER_ROTATE_90);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
159 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
160 else if (g_ascii_strcasecmp("ROTATE_90_CC", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
161 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
162 layout_image_alter(lw, ALTER_ROTATE_90_CC);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
163 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
164 else if (g_ascii_strcasecmp("INFO", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
165 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
166 layout_image_overlay_toggle(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
167 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
168 else if (g_ascii_strcasecmp("EXIT", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
169 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
170 exit_program();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
171 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
172 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
173 free(code);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
174 if (ret == -1) break;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
175 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
176 if (x != 0 || y!= 0)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
177 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
178 layout_image_scroll(lw, x, y);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
179 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
180
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
181 if (ret == -1)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
182 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
183 /* something went badly wrong */
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
184 fprintf(stderr, _("disconnected from LIRC\n"));
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
185 lirc_cleanup();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
186 return (gboolean)FALSE;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
187 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
188 return (gboolean)TRUE;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
189 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
190
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
191 void layout_image_lirc_init(LayoutWindow *lw)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
192 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
193 int flags;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
194
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
195 DEBUG_1("Initializing LIRC...");
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
196 lirc_fd = lirc_init(GQ_APPNAME_LC, get_debug_level() > 0);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
197 if (lirc_fd == -1)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
198 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
199 fprintf(stderr, _("Could not init LIRC support\n"));
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
200 return;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
201 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
202 if (lirc_readconfig(NULL, &config, NULL) == -1)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
203 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
204 lirc_deinit();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
205 fprintf(stderr,
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
206 _("could not read LIRC config file\n"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
207 "please read the documentation of LIRC to \n"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
208 "know how to create a proper config file\n"));
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
209 return;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
210 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
211 gio_chan = g_io_channel_unix_new(lirc_fd);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
212 input_tag = g_io_add_watch(gio_chan, G_IO_IN,
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
213 lirc_input_callback, lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
214 fcntl(lirc_fd, F_SETOWN, getpid());
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
215 flags = fcntl(lirc_fd, F_GETFL, 0);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
216 if (flags != -1) fcntl(lirc_fd, F_SETFL, flags|O_NONBLOCK);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
217 fflush(stderr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
218 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
219
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
220 #endif /* HAVE_LIRC */