annotate src/lirc.c @ 1167:e812b1a7adda

Add a back button in the toolbar: it allows to go back and forth between two directories. Experimental, please test and comment on ml.
author zas_
date Sat, 22 Nov 2008 16:24:23 +0000
parents 1646720364cf
children 0b94f0e6e3d0
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
1022
9962b24b6b43 Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents: 1000
diff changeset
3 #include "misc.h"
9962b24b6b43 Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents: 1000
diff changeset
4
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
5 #ifdef HAVE_LIRC
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
6 #include <lirc/lirc_client.h>
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
7 #include "layout_image.h"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
8
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
9 gint lirc_fd = -1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
10 struct lirc_config *config = NULL;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
11 guint input_tag;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
12 GIOChannel *gio_chan;
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 *-----------------------------------------------------------------------------
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
16 * LIRC callback
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
610
33a375d16181 Make lirc_cleanup() and lirc_input_callback() static.
zas_
parents: 609
diff changeset
20 static void lirc_cleanup(void)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
21 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
22 if (config)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
23 {
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
24 g_source_remove(input_tag);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
25 lirc_freeconfig(config);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
26 config = NULL;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
27 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
28 if (lirc_fd != -1)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
29 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
30 lirc_deinit();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
31 lirc_fd = -1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
32 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
33 if (gio_chan)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
34 {
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
35 g_io_channel_shutdown(gio_chan, TRUE, NULL);
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
36 g_io_channel_unref(gio_chan);
528
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
610
33a375d16181 Make lirc_cleanup() and lirc_input_callback() static.
zas_
parents: 609
diff changeset
40 static gboolean lirc_input_callback(GIOChannel *source, GIOCondition condition,
33a375d16181 Make lirc_cleanup() and lirc_input_callback() static.
zas_
parents: 609
diff changeset
41 gpointer data)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
42 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
43 LayoutWindow *lw = data;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
44 gchar *ptr;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
45 gint ret;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
46 gint x = 0;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
47 gint y = 0;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
48
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
49 /* LIRC code and corresponding geeqie command (and parameters)*/
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
50 gchar *code;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
51 gchar *cmd;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
52
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
53 /* parameters for geeqie command */
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
54 gint i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
55 gfloat fl_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
56
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
57 while ((ret = lirc_nextcode(&code)) == 0 && code)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
58 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
59 while ((ret = lirc_code2char(config, code, &cmd)) == 0 && cmd)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
60 {
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
61 if (g_ascii_strncasecmp("LEFT", cmd, 4) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
62 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
63 ptr = cmd + 4;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
64 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
65 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
66
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
67 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
68 x -= i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
69 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
70 else if (g_ascii_strncasecmp("RIGHT", cmd, 5) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
71 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
72 ptr = cmd + 5;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
73 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
74 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
75
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
76 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
77 x += i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
78 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
79 else if (g_ascii_strncasecmp("UP", cmd, 2) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
80 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
81 ptr = cmd + 2;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
82 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
83 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
84
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
85 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
86 y -= i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
87 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
88 else if (g_ascii_strncasecmp("DOWN", cmd, 4) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
89 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
90 ptr = cmd + 4;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
91 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
92 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
93
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
94 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
95 y += i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
96 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
97 else if (g_ascii_strcasecmp("PREV", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
98 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
99 layout_image_prev(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
100 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
101 else if (g_ascii_strcasecmp("NEXT", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
102 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
103 layout_image_next(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
104 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
105 else if (g_ascii_strncasecmp("ZOOM_IN", cmd, 7) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
106 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
107 ptr = cmd + 7;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
108 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
109 fl_parm = atoi(ptr) / 10.0;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
110
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
111 if (fl_parm <= 0.01) fl_parm = get_zoom_increment();
1047
81ec7d977d5f use SHIFT for connected scroll and zoom
nadvornik
parents: 1022
diff changeset
112 layout_image_zoom_adjust(lw, fl_parm, FALSE);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
113 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
114 else if (g_ascii_strncasecmp("ZOOM_OUT", cmd, 8) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
115 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
116 ptr = cmd + 8;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
117 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
118 fl_parm = atoi(ptr) / 10.0;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
119
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
120 if (fl_parm <= 0.01) fl_parm = get_zoom_increment();
1047
81ec7d977d5f use SHIFT for connected scroll and zoom
nadvornik
parents: 1022
diff changeset
121 layout_image_zoom_adjust(lw, -fl_parm, FALSE);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
122 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
123 else if (g_ascii_strcasecmp("ZOOM_MAX", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
124 {
1047
81ec7d977d5f use SHIFT for connected scroll and zoom
nadvornik
parents: 1022
diff changeset
125 layout_image_zoom_set(lw, 0.0, FALSE);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
126 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
127 else if (g_ascii_strncasecmp("SET_ZOOM", cmd, 8) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
128 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
129 ptr = cmd + 8;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
130 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
131 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
132
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
133 if (i_parm <= 0) i_parm = 1;
1047
81ec7d977d5f use SHIFT for connected scroll and zoom
nadvornik
parents: 1022
diff changeset
134 layout_image_zoom_set(lw, 1.0, FALSE);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
135 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
136 else if (g_ascii_strncasecmp("SET_INV_ZOOM", cmd, 12) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
137 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
138 ptr = cmd + 12;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
139 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
140 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
141
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
142 if (i_parm <= 0) i_parm = 1;
1047
81ec7d977d5f use SHIFT for connected scroll and zoom
nadvornik
parents: 1022
diff changeset
143 layout_image_zoom_set(lw, -i_parm, FALSE);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
144 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
145 else if (g_ascii_strcasecmp("FIRST", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
146 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
147 layout_image_first(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
148 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
149 else if (g_ascii_strcasecmp("LAST", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
150 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
151 layout_image_last(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
152 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
153 else if (g_ascii_strcasecmp("PAUSE", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
154 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
155 layout_image_slideshow_pause_toggle(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
156 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
157 else if (g_ascii_strcasecmp("ROTATE_90", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
158 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
159 layout_image_alter(lw, ALTER_ROTATE_90);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
160 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
161 else if (g_ascii_strcasecmp("ROTATE_90_CC", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
162 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
163 layout_image_alter(lw, ALTER_ROTATE_90_CC);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
164 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
165 else if (g_ascii_strcasecmp("INFO", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
166 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
167 layout_image_overlay_toggle(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
168 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
169 else if (g_ascii_strcasecmp("EXIT", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
170 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
171 exit_program();
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 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
174 free(code);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
175 if (ret == -1) break;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
176 }
610
33a375d16181 Make lirc_cleanup() and lirc_input_callback() static.
zas_
parents: 609
diff changeset
177 if (x != 0 || y != 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
178 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
179 layout_image_scroll(lw, x, y);
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
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
182 if (ret == -1)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
183 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
184 /* something went badly wrong */
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
185 fprintf(stderr, _("disconnected from LIRC\n"));
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
186 lirc_cleanup();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
187 return (gboolean)FALSE;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
188 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
189 return (gboolean)TRUE;
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
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
192 void layout_image_lirc_init(LayoutWindow *lw)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
193 {
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 995
diff changeset
194 gint flags;
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
195
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
196 DEBUG_1("Initializing LIRC...");
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
197 lirc_fd = lirc_init(GQ_APPNAME_LC, get_debug_level() > 0);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
198 if (lirc_fd == -1)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
199 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
200 fprintf(stderr, _("Could not init LIRC support\n"));
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
201 return;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
202 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
203 if (lirc_readconfig(NULL, &config, NULL) == -1)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
204 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
205 lirc_deinit();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
206 fprintf(stderr,
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
207 _("could not read LIRC config file\n"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
208 "please read the documentation of LIRC to \n"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
209 "know how to create a proper config file\n"));
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
210 return;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
211 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
212 gio_chan = g_io_channel_unix_new(lirc_fd);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
213 input_tag = g_io_add_watch(gio_chan, G_IO_IN,
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 671
diff changeset
214 lirc_input_callback, lw);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
215 fcntl(lirc_fd, F_SETOWN, getpid());
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
216 flags = fcntl(lirc_fd, F_GETFL, 0);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
217 if (flags != -1) fcntl(lirc_fd, F_SETFL, flags|O_NONBLOCK);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
218 fflush(stderr);
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
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
221 #endif /* HAVE_LIRC */
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1047
diff changeset
222 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */