├── config.ini ├── README.md ├── gray_shm.c ├── main.ui ├── fbink.c ├── LICENSE ├── file_picker.c └── retrocore.c /config.ini: -------------------------------------------------------------------------------- 1 | 2 | [General] 3 | fullscreen=true 4 | audio=true 5 | dark_mode=false 6 | fbink_mode=false 7 | max_fps=30 8 | brightness=50 9 | contrast=50 10 | last_dir=/mnt/us 11 | 12 | [Cores] 13 | gb.name=gambatte 14 | gb.path=gambatte_libretro-.so 15 | gb.joypad=Gameboy 16 | gb.env.gambatte_mix_frames=disabled 17 | 18 | gbc.name=gambatte 19 | gbc.path=gambatte_libretro-.so 20 | gbc.joypad=Gameboy 21 | gbc.env.gambatte_gbc_color_correction=disabled 22 | gbc.env.gambatte_mix_frames=disabled 23 | 24 | gba.name=mgba 25 | gba.path=mgba_libretro-.so 26 | gba.joypad=GameboyAdvance 27 | gba.env.mgba_interframe_blending=mix 28 | 29 | #label = id; show_label; rel_x; rel_y; rel_radius; || [rel_width; rel_height]; visible 30 | 31 | [Joypad.Gameboy] 32 | SELECT=2;true;39;87;0;13;07;true 33 | START=3;true;61;87;0;13;07;true 34 | UP=4;false;24;15;0;14;14;true 35 | DOWN=5;false;24;65;0;14;14;true 36 | LEFT=6;false;10;40;0;14;14;true 37 | RIGHT=7;false;38;40;0;14;14;true 38 | A=8;true;89;24;8;0;0;true 39 | B=0;true;67;43;8;0;0;true 40 | 41 | # 2x speed buton 42 | FF=99;false;100;100;20;0;0;false 43 | 44 | # unmapped buttons: 45 | # 9 46 | 47 | [Joypad.GameboyAdvance] 48 | SELECT=2;true;39;87;0;13;07;true 49 | START=3;true;61;87;0;13;07;true 50 | UP=4;false;24;27;0;14;14;true 51 | DOWN=5;false;24;65;0;14;14;true 52 | LEFT=6;false;10;46;0;14;14;true 53 | RIGHT=7;false;38;46;0;14;14;true 54 | A=8;true;89;31;8;0;0;true 55 | B=0;true;67;50;8;0;0;true 56 | L=10;true;25;7;0;30;07;true 57 | R=11;true;75;7;0;30;07;true 58 | 59 | # 2x speed buton 60 | FF=99;false;100;100;20;0;0;false 61 | 62 | # unmapped buttons: 63 | # 9 64 | # 1 65 | # 12 66 | # 13 67 | # 15 68 | # 14 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gambatte-K2: Game Boy Emulator for Kindle (GTK2/FBInk) 2 | 3 | **Gambatte-K2** is a Game Boy / Game Boy Color (`.gb`, `.gbc` ROMS) emulator frontend for Kindle e-ink devices, built with performance in mind. It leverages the [gambatte-libretro](https://github.com/libretro/gambatte-libretro) core and provides a GTK2 interface, as well as direct framebuffer rendering mode via [FBInk](https://github.com/NiLuJe/FBInk). 4 | 5 | > Audio support is now included! Just pair your headphones with the Kindle. 6 | 7 | Built for `armel` and `armhf` (tested on 5.14.3 and 5.17.1) 8 | 9 | --- 10 | 11 | 12 | 13 | 14 | ## Usage 15 | 16 | Grab the zip (`gambatte-k2.zip`), unpack on `/mnt/us/extensions` as any other extension: 17 | 18 | Launch via KUAL and/or copy the shortcut (`shortcut_gambatte-k2.sh`) to `/mnt/us/documents` so it shows on your library. 19 | 20 | Open a game/ROM using the "Open" button. 21 | 22 | > **Note:** 23 | > You must provide your own Game Boy / Game Boy Color ROM files (`.gb`, `.gbc`). 24 | 25 | 26 | > **Known Issues:** 27 | > - Sometimes `.gb` games freeze on start. 28 | > - Buttons may get stuck. Just exit the emulator and run again. These issues will be adressed at some point. 29 | 30 | ## TL-DR Technical Features 31 | 32 | - **Fast, Lightweight UI:** 33 | Minimal dependencies (`3Mb` binary), runs pretty well on low-RAM e-ink Kindles using around ~~`~15Mb` of RAM and `~50%` CPU.~~ **`~3Mb` of RAM and `~20%` CPU.** (on GTK2/XCB mode) 34 | - **Two Rendering Modes:** 35 | - **GTK2:** Standard X11/~~GTK2~~/XCB SHM drawing mode using the OS e-ink refreshing. 36 | - **FBInk:** Direct framebuffer output for maximum speed, a little quirky, with more ghosting. 37 | - **Performance-Oriented Design:** 38 | - ~~Only **one main loop** in the frame processing path doing scaling and dithering at once.~~ ARM NEON implementation. 39 | - **Ordered dithering (BW)** (Bayer 16x16) ~~applied during a first scaling stage for improved frame speed processing.~~ 40 | - **Nearest-neighbor scaling** ~~in the second stage for fast upscaling.~~ 41 | - **Single ~~GdkPixbuf~~ 8bit Grayscale Grame** reused for all frames to minimize RAM usage and allocations. 42 | - **LUT (Lookup Table):** Precomputed 65536-entry lookup table with RGB565→RGB888→grayscale conversion for fast pixel processing. 43 | - **Touch & Multi-Touch Controls:** 44 | - On-screen virtual Game Boy like buttons with ad-hoc multi-touch support (up to 2 touches) listening directly on the `/dev/input/eventX` device events. 45 | > **Note:** 46 | > as an e-ink device, designed for reading, with just a two-point multi-touch capacitive touch-screen, it may not be extremely responsive at the end. 47 | - **~~Dynamic Quality/Size Controls:~~** removed 48 | - ~~Toggle between some scaling/quality presets.~~ 49 | - **Threaded Frame Processing:** 50 | - Frame conversion and drawing are offloaded to a worker thread to keep the UI responsive (on FBInk mode only). 51 | - **Minimal External Dependencies:** 52 | - Only needs GTK2, ~~GDK-Pixbuf,~~ and FBInk (for direct mode). 53 | 54 | --- 55 | 56 | 57 | -------------------------------------------------------------------------------- /gray_shm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | #define TYPE_GRAY_SHM (gray_shm_get_type ()) 7 | #define GRAY_SHM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GRAY_SHM, GrayShm)) 8 | #define GRAY_SHM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GRAY_SHM, GrayShmClass)) 9 | #define IS_GRAY_SHM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GRAY_SHM)) 10 | #define IS_GRAY_SHM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GRAY_SHM)) 11 | #define GRAY_SHM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GRAY_SHM, GrayShmClass)) 12 | 13 | typedef struct _GrayShm GrayShm; 14 | typedef struct _GrayShmClass GrayShmClass; 15 | typedef struct _GrayShmPrivate GrayShmPrivate; 16 | 17 | typedef enum { 18 | GRAY_SHM_ERROR_ERROR 19 | } GrayShmError; 20 | #define GRAY_SHM_ERROR gray_shm_error_quark () 21 | struct _GrayShm { 22 | GObject parent_instance; 23 | GrayShmPrivate * priv; 24 | }; 25 | 26 | struct _GrayShmClass { 27 | GObjectClass parent_class; 28 | }; 29 | 30 | struct _GrayShmPrivate { 31 | void* native_handle; 32 | }; 33 | 34 | 35 | static gpointer gray_shm_parent_class = NULL; 36 | 37 | GQuark gray_shm_error_quark (void); 38 | GType gray_shm_get_type (void) G_GNUC_CONST; 39 | #define GRAY_SHM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_GRAY_SHM, GrayShmPrivate)) 40 | enum { 41 | GRAY_SHM_DUMMY_PROPERTY, 42 | GRAY_SHM_WIDTH, 43 | GRAY_SHM_HEIGHT 44 | }; 45 | void gray_shm_destroy (void* shm); 46 | GrayShm* gray_shm_oop_new (xcb_window_t xid, gint width, gint height); 47 | GrayShm* gray_shm_oop_construct (GType object_type, xcb_window_t xid, gint width, gint height); 48 | void* gray_shm_create (xcb_window_t xid, gint width, gint height); 49 | void gray_shm_oop_resize (GrayShm* self, gint width, gint height); 50 | void gray_shm_resize (void* shm, gint w, gint h); 51 | void gray_shm_oop_commit_rect (GrayShm* self, gint x, gint y, gint width, gint height); 52 | void gray_shm_commit_rect (void* shm, gint x, gint y, gint w, gint h); 53 | guint8* gray_shm_oop_get_buffer (GrayShm* self); 54 | guint8* gray_shm_get_buffer (void* shm); 55 | gint gray_shm_get_width (void* shm); 56 | gint gray_shm_get_height (void* shm); 57 | gint gray_shm_oop_get_width (GrayShm* self); 58 | gint gray_shm_oop_get_height (GrayShm* self); 59 | static void gray_shm_finalize (GObject* obj); 60 | static void _vala_gray_shm_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); 61 | 62 | 63 | GQuark gray_shm_error_quark (void) { 64 | return g_quark_from_static_string ("gray_shm_error-quark"); 65 | } 66 | 67 | 68 | GrayShm* gray_shm_oop_construct (GType object_type, xcb_window_t xid, gint width, gint height) { 69 | GrayShm * self = NULL; 70 | xcb_window_t _tmp0_ = 0; 71 | gint _tmp1_ = 0; 72 | gint _tmp2_ = 0; 73 | void* _tmp3_ = NULL; 74 | void* _tmp4_ = NULL; 75 | GError * _inner_error_ = NULL; 76 | self = (GrayShm*) g_object_new (object_type, NULL); 77 | _tmp0_ = xid; 78 | _tmp1_ = width; 79 | _tmp2_ = height; 80 | _tmp3_ = gray_shm_create (_tmp0_, _tmp1_, _tmp2_); 81 | self->priv->native_handle = _tmp3_; 82 | _tmp4_ = self->priv->native_handle; 83 | if (_tmp4_ == NULL) { 84 | GError* _tmp5_ = NULL; 85 | _tmp5_ = g_error_new_literal (GRAY_SHM_ERROR, GRAY_SHM_ERROR_ERROR, "gray_shm_create failed"); 86 | _inner_error_ = _tmp5_; 87 | 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); 88 | g_clear_error (&_inner_error_); 89 | return NULL; 90 | } 91 | return self; 92 | } 93 | 94 | 95 | GrayShm* gray_shm_oop_new (xcb_window_t xid, gint width, gint height) { 96 | return gray_shm_oop_construct (TYPE_GRAY_SHM, xid, width, height); 97 | } 98 | 99 | 100 | void gray_shm_oop_resize (GrayShm* self, gint width, gint height) { 101 | void* _tmp0_ = NULL; 102 | gint _tmp1_ = 0; 103 | gint _tmp2_ = 0; 104 | g_return_if_fail (self != NULL); 105 | _tmp0_ = self->priv->native_handle; 106 | _tmp1_ = width; 107 | _tmp2_ = height; 108 | gray_shm_resize (_tmp0_, _tmp1_, _tmp2_); 109 | } 110 | 111 | 112 | void gray_shm_oop_commit_rect (GrayShm* self, gint x, gint y, gint width, gint height) { 113 | void* _tmp0_ = NULL; 114 | gint _tmp1_ = 0; 115 | gint _tmp2_ = 0; 116 | gint _tmp3_ = 0; 117 | gint _tmp4_ = 0; 118 | g_return_if_fail (self != NULL); 119 | _tmp0_ = self->priv->native_handle; 120 | _tmp1_ = x; 121 | _tmp2_ = y; 122 | _tmp3_ = width; 123 | _tmp4_ = height; 124 | gray_shm_commit_rect (_tmp0_, _tmp1_, _tmp2_, _tmp3_, _tmp4_); 125 | } 126 | 127 | 128 | guint8* gray_shm_oop_get_buffer (GrayShm* self) { 129 | guint8* result = NULL; 130 | void* _tmp0_ = NULL; 131 | guint8* _tmp1_ = NULL; 132 | g_return_val_if_fail (self != NULL, NULL); 133 | _tmp0_ = self->priv->native_handle; 134 | _tmp1_ = gray_shm_get_buffer (_tmp0_); 135 | result = _tmp1_; 136 | return result; 137 | } 138 | 139 | 140 | gint gray_shm_oop_get_width (GrayShm* self) { 141 | gint result; 142 | void* _tmp0_ = NULL; 143 | gint _tmp1_ = 0; 144 | g_return_val_if_fail (self != NULL, 0); 145 | _tmp0_ = self->priv->native_handle; 146 | _tmp1_ = gray_shm_get_width (_tmp0_); 147 | result = _tmp1_; 148 | return result; 149 | } 150 | 151 | 152 | gint gray_shm_oop_get_height (GrayShm* self) { 153 | gint result; 154 | void* _tmp0_ = NULL; 155 | gint _tmp1_ = 0; 156 | g_return_val_if_fail (self != NULL, 0); 157 | _tmp0_ = self->priv->native_handle; 158 | _tmp1_ = gray_shm_get_height (_tmp0_); 159 | result = _tmp1_; 160 | return result; 161 | } 162 | 163 | 164 | static void gray_shm_class_init (GrayShmClass * klass) { 165 | gray_shm_parent_class = g_type_class_peek_parent (klass); 166 | g_type_class_add_private (klass, sizeof (GrayShmPrivate)); 167 | G_OBJECT_CLASS (klass)->get_property = _vala_gray_shm_get_property; 168 | G_OBJECT_CLASS (klass)->finalize = gray_shm_finalize; 169 | g_object_class_install_property (G_OBJECT_CLASS (klass), GRAY_SHM_WIDTH, g_param_spec_int ("width", "width", "width", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); 170 | g_object_class_install_property (G_OBJECT_CLASS (klass), GRAY_SHM_HEIGHT, g_param_spec_int ("height", "height", "height", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE)); 171 | } 172 | 173 | 174 | static void gray_shm_instance_init (GrayShm * self) { 175 | self->priv = GRAY_SHM_GET_PRIVATE (self); 176 | } 177 | 178 | 179 | static void gray_shm_finalize (GObject* obj) { 180 | GrayShm * self; 181 | void* _tmp0_ = NULL; 182 | self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_GRAY_SHM, GrayShm); 183 | _tmp0_ = self->priv->native_handle; 184 | if (_tmp0_ != NULL) { 185 | void* _tmp1_ = NULL; 186 | _tmp1_ = self->priv->native_handle; 187 | gray_shm_destroy (_tmp1_); 188 | self->priv->native_handle = NULL; 189 | } 190 | G_OBJECT_CLASS (gray_shm_parent_class)->finalize (obj); 191 | } 192 | 193 | 194 | GType gray_shm_get_type (void) { 195 | static volatile gsize gray_shm_type_id__volatile = 0; 196 | if (g_once_init_enter (&gray_shm_type_id__volatile)) { 197 | static const GTypeInfo g_define_type_info = { sizeof (GrayShmClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gray_shm_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GrayShm), 0, (GInstanceInitFunc) gray_shm_instance_init, NULL }; 198 | GType gray_shm_type_id; 199 | gray_shm_type_id = g_type_register_static (G_TYPE_OBJECT, "GrayShm", &g_define_type_info, 0); 200 | g_once_init_leave (&gray_shm_type_id__volatile, gray_shm_type_id); 201 | } 202 | return gray_shm_type_id__volatile; 203 | } 204 | 205 | 206 | static void _vala_gray_shm_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { 207 | GrayShm * self; 208 | self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_GRAY_SHM, GrayShm); 209 | switch (property_id) { 210 | case GRAY_SHM_WIDTH: 211 | g_value_set_int (value, gray_shm_oop_get_width (self)); 212 | break; 213 | case GRAY_SHM_HEIGHT: 214 | g_value_set_int (value, gray_shm_oop_get_height (self)); 215 | break; 216 | default: 217 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); 218 | break; 219 | } 220 | } 221 | 222 | 223 | 224 | -------------------------------------------------------------------------------- /main.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | main-vbox-dark 4 | 0 5 | 6 | 7 | center 8 | 9 | 10 | 11 | Open Game 12 | 13 | 14 | False 15 | False 16 | 17 | 18 | 19 | 40 | 41 | 42 | 43 | Options 44 | 45 | 46 | False 47 | False 48 | 49 | 50 | 51 | 52 | 53 | Fullscreen 54 | 55 | 56 | False 57 | False 58 | 59 | 60 | 61 | 62 | 63 | Quit 64 | 65 | 66 | False 67 | False 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | False 78 | False 79 | 80 | 81 | 82 | 83 | 10 84 | 85 | 86 | 87 | False 88 | False 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | True 97 | False 98 | 99 | 100 | 101 | True 102 | True 103 | 0 104 | 105 | 106 | 107 | 108 | 109 | drawing-area-container 110 | 111 | 112 | 113 | 114 | 5 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 5 124 | 125 | 126 | 127 | 128 | 129 | 130 | drawing-area 131 | 1 132 | 1 133 | 134 | 135 | 136 | 137 | 138 | 139 | 5 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 5 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | False 160 | False 161 | 162 | 163 | 164 | 165 | 166 | True 167 | False 168 | 169 | 170 | 171 | True 172 | False 173 | 174 | 175 | 176 | 177 | 178 | 179 | False 180 | False 181 | 182 | 183 | 184 | 185 | 10 186 | 187 | 188 | 189 | False 190 | False 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | True 199 | False 200 | False 201 | False 202 | 203 | 204 | 205 | joystick-area 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | Contrast 219 | Game brightness adjustment. 220 | 0 221 | 222 | 223 | 224 | 225 | 226 | Brightness 227 | Game brightness adjustment 228 | 0 229 | 230 | 231 | 232 | 233 | 234 | Max FPS 235 | Maximum number of frames sent to the renderer. 236 | 0 237 | 238 | 239 | 240 | 241 | 242 | Dark mode 243 | 244 | 245 | 246 | 247 | 248 | 249 | FBInk mode 250 | Fast rendering at the cost of reduced image quality. 251 | 252 | 253 | 254 | 255 | 256 | Audio 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | -------------------------------------------------------------------------------- /fbink.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | #define TYPE_FB_INK (fb_ink_get_type ()) 7 | #define FB_INK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FB_INK, FBInk)) 8 | #define FB_INK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FB_INK, FBInkClass)) 9 | #define IS_FB_INK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FB_INK)) 10 | #define IS_FB_INK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FB_INK)) 11 | #define FB_INK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FB_INK, FBInkClass)) 12 | 13 | typedef struct _FBInk FBInk; 14 | typedef struct _FBInkClass FBInkClass; 15 | typedef struct _FBInkPrivate FBInkPrivate; 16 | 17 | #define FB_INK_TYPE_CONFIG (fb_ink_config_get_type ()) 18 | typedef struct _FBInkConfig FBInkConfig; 19 | 20 | #define FB_INK_TYPE_FBFD (fb_ink_fbfd_get_type ()) 21 | 22 | #define FB_INK_TYPE_WFM_MODE_INDEX_E (fb_ink_wfm_mode_index_e_get_type ()) 23 | 24 | #define FB_INK_TYPE_HW_DITHER_INDEX_E (fb_ink_hw_dither_index_e_get_type ()) 25 | 26 | #define FB_INK_TYPE_INPUT_DEVICE_TYPE_E (fb_ink_input_device_type_e_get_type ()) 27 | 28 | #define FB_INK_TYPE_INPUT_DEVICE (fb_ink_input_device_get_type ()) 29 | typedef struct _FBInkInputDevice FBInkInputDevice; 30 | #define _g_free0(var) (var = (g_free (var), NULL)) 31 | 32 | typedef enum { 33 | FB_INK_ERROR_ERROR 34 | } FBInkError; 35 | #define FB_INK_ERROR fb_ink_error_quark () 36 | struct _FBInk { 37 | GObject parent_instance; 38 | FBInkPrivate * priv; 39 | }; 40 | 41 | struct _FBInkClass { 42 | GObjectClass parent_class; 43 | }; 44 | 45 | struct _FBInkConfig { 46 | gshort row; 47 | gshort col; 48 | guint8 fontmult; 49 | guint8 fontname; 50 | guint8 is_inverted; 51 | guint8 is_flashing; 52 | guint8 is_cleared; 53 | guint8 is_centered; 54 | gshort hoffset; 55 | gshort voffset; 56 | guint8 is_halfway; 57 | guint8 is_padded; 58 | guint8 is_rpadded; 59 | guint8 fg_color; 60 | guint8 bg_color; 61 | guint8 is_overlay; 62 | guint8 is_bgless; 63 | guint8 is_fgless; 64 | guint8 no_viewport; 65 | guint8 is_verbose; 66 | guint8 is_quiet; 67 | guint8 ignore_alpha; 68 | guint8 halign; 69 | guint8 valign; 70 | gshort scaled_width; 71 | gshort scaled_height; 72 | guint8 wfm_mode; 73 | guint8 dithering_mode; 74 | guint8 sw_dithering; 75 | guint8 cfa_mode; 76 | guint8 is_nightmode; 77 | guint8 no_refresh; 78 | guint8 no_merge; 79 | guint8 is_animated; 80 | guint8 saturation_boost; 81 | guint8 to_syslog; 82 | }; 83 | 84 | struct _FBInkPrivate { 85 | gint fbfd; 86 | FBInkConfig cfg; 87 | }; 88 | 89 | typedef enum { 90 | FB_INK_FBFD_AUTO = -1 91 | } FBInkFBFD; 92 | 93 | typedef enum { 94 | FB_INK_WFM_MODE_INDEX_E_AUTO = 0, 95 | FB_INK_WFM_MODE_INDEX_E_DU, 96 | FB_INK_WFM_MODE_INDEX_E_GC16, 97 | FB_INK_WFM_MODE_INDEX_E_GC4, 98 | FB_INK_WFM_MODE_INDEX_E_A2, 99 | FB_INK_WFM_MODE_INDEX_E_GL16, 100 | FB_INK_WFM_MODE_INDEX_E_REAGL, 101 | FB_INK_WFM_MODE_INDEX_E_REAGLD, 102 | FB_INK_WFM_MODE_INDEX_E_GC16_FAST, 103 | FB_INK_WFM_MODE_INDEX_E_GL16_FAST, 104 | FB_INK_WFM_MODE_INDEX_E_DU4, 105 | FB_INK_WFM_MODE_INDEX_E_GL4, 106 | FB_INK_WFM_MODE_INDEX_E_GL16_INV, 107 | FB_INK_WFM_MODE_INDEX_E_GCK16, 108 | FB_INK_WFM_MODE_INDEX_E_GLKW16, 109 | FB_INK_WFM_MODE_INDEX_E_INIT, 110 | FB_INK_WFM_MODE_INDEX_E_UNKNOWN, 111 | FB_INK_WFM_MODE_INDEX_E_INIT2, 112 | FB_INK_WFM_MODE_INDEX_E_A2IN, 113 | FB_INK_WFM_MODE_INDEX_E_A2OUT, 114 | FB_INK_WFM_MODE_INDEX_E_GC16HQ, 115 | FB_INK_WFM_MODE_INDEX_E_GS16, 116 | FB_INK_WFM_MODE_INDEX_E_GU16, 117 | FB_INK_WFM_MODE_INDEX_E_GLK16, 118 | FB_INK_WFM_MODE_INDEX_E_CLEAR, 119 | FB_INK_WFM_MODE_INDEX_E_GC4L, 120 | FB_INK_WFM_MODE_INDEX_E_GCC16, 121 | FB_INK_WFM_MODE_INDEX_E_GLRC16, 122 | FB_INK_WFM_MODE_INDEX_E_GC16_PARTIAL, 123 | FB_INK_WFM_MODE_INDEX_E_GCK16_PARTIAL, 124 | FB_INK_WFM_MODE_INDEX_E_DUNM, 125 | FB_INK_WFM_MODE_INDEX_E_P2SW, 126 | FB_INK_WFM_MODE_INDEX_E_GCCK16, 127 | FB_INK_WFM_MODE_INDEX_E_GLRCK16, 128 | FB_INK_WFM_MODE_INDEX_E_MAX = 255 129 | } FBInkWFM_MODE_INDEX_E; 130 | 131 | typedef enum { 132 | FB_INK_HW_DITHER_INDEX_E_PASSTHROUGH = 0, 133 | FB_INK_HW_DITHER_INDEX_E_FLOYD_STEINBERG, 134 | FB_INK_HW_DITHER_INDEX_E_ATKINSON, 135 | FB_INK_HW_DITHER_INDEX_E_ORDERED, 136 | FB_INK_HW_DITHER_INDEX_E_QUANT_ONLY, 137 | FB_INK_HW_DITHER_INDEX_E_LEGACY = 255 138 | } FBInkHW_DITHER_INDEX_E; 139 | 140 | typedef enum { 141 | FB_INK_INPUT_DEVICE_TYPE_E_UNKNOWN = 0, 142 | FB_INK_INPUT_DEVICE_TYPE_E_POINTINGSTICK = 1 << 0, 143 | FB_INK_INPUT_DEVICE_TYPE_E_MOUSE = 1 << 1, 144 | FB_INK_INPUT_DEVICE_TYPE_E_TOUCHPAD = 1 << 2, 145 | FB_INK_INPUT_DEVICE_TYPE_E_TOUCHSCREEN = 1 << 3, 146 | FB_INK_INPUT_DEVICE_TYPE_E_JOYSTICK = 1 << 4, 147 | FB_INK_INPUT_DEVICE_TYPE_E_TABLET = 1 << 5, 148 | FB_INK_INPUT_DEVICE_TYPE_E_KEY = 1 << 6, 149 | FB_INK_INPUT_DEVICE_TYPE_E_KEYBOARD = 1 << 7, 150 | FB_INK_INPUT_DEVICE_TYPE_E_ACCELEROMETER = 1 << 8, 151 | FB_INK_INPUT_DEVICE_TYPE_E_POWER_BUTTON = 1 << 16, 152 | FB_INK_INPUT_DEVICE_TYPE_E_SLEEP_COVER = 1 << 17, 153 | FB_INK_INPUT_DEVICE_TYPE_E_PAGINATION_BUTTONS = 1 << 18, 154 | FB_INK_INPUT_DEVICE_TYPE_E_HOME_BUTTON = 1 << 19, 155 | FB_INK_INPUT_DEVICE_TYPE_E_LIGHT_BUTTON = 1 << 20, 156 | FB_INK_INPUT_DEVICE_TYPE_E_MENU_BUTTON = 1 << 21, 157 | FB_INK_INPUT_DEVICE_TYPE_E_DPAD = 1 << 22, 158 | FB_INK_INPUT_DEVICE_TYPE_E_ROTATION_EVENT = 1 << 23, 159 | FB_INK_INPUT_DEVICE_TYPE_E_SCALED_TABLET = 1 << 24, 160 | FB_INK_INPUT_DEVICE_TYPE_E_VOLUME_BUTTONS = 1 << 25 161 | } FBInkINPUT_DEVICE_TYPE_E; 162 | 163 | struct _FBInkInputDevice { 164 | guint32 type; 165 | gint fd; 166 | guint8 matched; 167 | gchar name[256]; 168 | gchar path[4096]; 169 | }; 170 | 171 | 172 | static gpointer fb_ink_parent_class = NULL; 173 | 174 | GQuark fb_ink_error_quark (void); 175 | GType fb_ink_get_type (void) G_GNUC_CONST; 176 | GType fb_ink_config_get_type (void) G_GNUC_CONST; 177 | FBInkConfig* fb_ink_config_dup (const FBInkConfig* self); 178 | void fb_ink_config_free (FBInkConfig* self); 179 | #define FB_INK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_FB_INK, FBInkPrivate)) 180 | enum { 181 | FB_INK_DUMMY_PROPERTY 182 | }; 183 | gint fbink_close (gint fbfd); 184 | GType fb_ink_fbfd_get_type (void) G_GNUC_CONST; 185 | GType fb_ink_wfm_mode_index_e_get_type (void) G_GNUC_CONST; 186 | GType fb_ink_hw_dither_index_e_get_type (void) G_GNUC_CONST; 187 | GType fb_ink_input_device_type_e_get_type (void) G_GNUC_CONST; 188 | gint fbink_open (void); 189 | gint fbink_init (gint fbfd, FBInkConfig* fbink_cfg); 190 | gint fbink_print_raw_data (gint fbfd, guint8* data, gint w, gint h, gsize len, gint x_off, gint y_off, FBInkConfig* fbink_cfg); 191 | gint fbink_refresh (gint fbfd, guint32 region_top, guint32 region_left, guint32 region_width, guint32 region_height, FBInkConfig* fbink_cfg); 192 | GType fb_ink_input_device_get_type (void) G_GNUC_CONST; 193 | FBInkInputDevice* fb_ink_input_device_dup (const FBInkInputDevice* self); 194 | void fb_ink_input_device_free (FBInkInputDevice* self); 195 | FBInkInputDevice* fbink_input_scan (guint32 match_types, guint32 exclude_types, guint32 settings, size_t* result_length1); 196 | FBInk* fb_ink_new (FBInkConfig* fbink_cfg, GError** error); 197 | FBInk* fb_ink_construct (GType object_type, FBInkConfig* fbink_cfg, GError** error); 198 | gint fb_ink_refresh (FBInk* self, guint x, guint y, guint w, guint h); 199 | gint fb_ink_print_raw_data (FBInk* self, guint8* data, gint w, gint h, gsize len, gint x_off, gint y_off); 200 | gchar* fb_ink_detect_touch_device (void); 201 | static void fb_ink_finalize (GObject* obj); 202 | 203 | 204 | GQuark fb_ink_error_quark (void) { 205 | return g_quark_from_static_string ("fb_ink_error-quark"); 206 | } 207 | 208 | 209 | GType fb_ink_fbfd_get_type (void) { 210 | static volatile gsize fb_ink_fbfd_type_id__volatile = 0; 211 | if (g_once_init_enter (&fb_ink_fbfd_type_id__volatile)) { 212 | static const GEnumValue values[] = {{FB_INK_FBFD_AUTO, "FB_INK_FBFD_AUTO", "auto"}, {0, NULL, NULL}}; 213 | GType fb_ink_fbfd_type_id; 214 | fb_ink_fbfd_type_id = g_enum_register_static ("FBInkFBFD", values); 215 | g_once_init_leave (&fb_ink_fbfd_type_id__volatile, fb_ink_fbfd_type_id); 216 | } 217 | return fb_ink_fbfd_type_id__volatile; 218 | } 219 | 220 | 221 | GType fb_ink_wfm_mode_index_e_get_type (void) { 222 | static volatile gsize fb_ink_wfm_mode_index_e_type_id__volatile = 0; 223 | if (g_once_init_enter (&fb_ink_wfm_mode_index_e_type_id__volatile)) { 224 | static const GEnumValue values[] = {{FB_INK_WFM_MODE_INDEX_E_AUTO, "FB_INK_WFM_MODE_INDEX_E_AUTO", "auto"}, {FB_INK_WFM_MODE_INDEX_E_DU, "FB_INK_WFM_MODE_INDEX_E_DU", "du"}, {FB_INK_WFM_MODE_INDEX_E_GC16, "FB_INK_WFM_MODE_INDEX_E_GC16", "gc16"}, {FB_INK_WFM_MODE_INDEX_E_GC4, "FB_INK_WFM_MODE_INDEX_E_GC4", "gc4"}, {FB_INK_WFM_MODE_INDEX_E_A2, "FB_INK_WFM_MODE_INDEX_E_A2", "a2"}, {FB_INK_WFM_MODE_INDEX_E_GL16, "FB_INK_WFM_MODE_INDEX_E_GL16", "gl16"}, {FB_INK_WFM_MODE_INDEX_E_REAGL, "FB_INK_WFM_MODE_INDEX_E_REAGL", "reagl"}, {FB_INK_WFM_MODE_INDEX_E_REAGLD, "FB_INK_WFM_MODE_INDEX_E_REAGLD", "reagld"}, {FB_INK_WFM_MODE_INDEX_E_GC16_FAST, "FB_INK_WFM_MODE_INDEX_E_GC16_FAST", "gc16-fast"}, {FB_INK_WFM_MODE_INDEX_E_GL16_FAST, "FB_INK_WFM_MODE_INDEX_E_GL16_FAST", "gl16-fast"}, {FB_INK_WFM_MODE_INDEX_E_DU4, "FB_INK_WFM_MODE_INDEX_E_DU4", "du4"}, {FB_INK_WFM_MODE_INDEX_E_GL4, "FB_INK_WFM_MODE_INDEX_E_GL4", "gl4"}, {FB_INK_WFM_MODE_INDEX_E_GL16_INV, "FB_INK_WFM_MODE_INDEX_E_GL16_INV", "gl16-inv"}, {FB_INK_WFM_MODE_INDEX_E_GCK16, "FB_INK_WFM_MODE_INDEX_E_GCK16", "gck16"}, {FB_INK_WFM_MODE_INDEX_E_GLKW16, "FB_INK_WFM_MODE_INDEX_E_GLKW16", "glkw16"}, {FB_INK_WFM_MODE_INDEX_E_INIT, "FB_INK_WFM_MODE_INDEX_E_INIT", "init"}, {FB_INK_WFM_MODE_INDEX_E_UNKNOWN, "FB_INK_WFM_MODE_INDEX_E_UNKNOWN", "unknown"}, {FB_INK_WFM_MODE_INDEX_E_INIT2, "FB_INK_WFM_MODE_INDEX_E_INIT2", "init2"}, {FB_INK_WFM_MODE_INDEX_E_A2IN, "FB_INK_WFM_MODE_INDEX_E_A2IN", "a2in"}, {FB_INK_WFM_MODE_INDEX_E_A2OUT, "FB_INK_WFM_MODE_INDEX_E_A2OUT", "a2out"}, {FB_INK_WFM_MODE_INDEX_E_GC16HQ, "FB_INK_WFM_MODE_INDEX_E_GC16HQ", "gc16hq"}, {FB_INK_WFM_MODE_INDEX_E_GS16, "FB_INK_WFM_MODE_INDEX_E_GS16", "gs16"}, {FB_INK_WFM_MODE_INDEX_E_GU16, "FB_INK_WFM_MODE_INDEX_E_GU16", "gu16"}, {FB_INK_WFM_MODE_INDEX_E_GLK16, "FB_INK_WFM_MODE_INDEX_E_GLK16", "glk16"}, {FB_INK_WFM_MODE_INDEX_E_CLEAR, "FB_INK_WFM_MODE_INDEX_E_CLEAR", "clear"}, {FB_INK_WFM_MODE_INDEX_E_GC4L, "FB_INK_WFM_MODE_INDEX_E_GC4L", "gc4l"}, {FB_INK_WFM_MODE_INDEX_E_GCC16, "FB_INK_WFM_MODE_INDEX_E_GCC16", "gcc16"}, {FB_INK_WFM_MODE_INDEX_E_GLRC16, "FB_INK_WFM_MODE_INDEX_E_GLRC16", "glrc16"}, {FB_INK_WFM_MODE_INDEX_E_GC16_PARTIAL, "FB_INK_WFM_MODE_INDEX_E_GC16_PARTIAL", "gc16-partial"}, {FB_INK_WFM_MODE_INDEX_E_GCK16_PARTIAL, "FB_INK_WFM_MODE_INDEX_E_GCK16_PARTIAL", "gck16-partial"}, {FB_INK_WFM_MODE_INDEX_E_DUNM, "FB_INK_WFM_MODE_INDEX_E_DUNM", "dunm"}, {FB_INK_WFM_MODE_INDEX_E_P2SW, "FB_INK_WFM_MODE_INDEX_E_P2SW", "p2sw"}, {FB_INK_WFM_MODE_INDEX_E_GCCK16, "FB_INK_WFM_MODE_INDEX_E_GCCK16", "gcck16"}, {FB_INK_WFM_MODE_INDEX_E_GLRCK16, "FB_INK_WFM_MODE_INDEX_E_GLRCK16", "glrck16"}, {FB_INK_WFM_MODE_INDEX_E_MAX, "FB_INK_WFM_MODE_INDEX_E_MAX", "max"}, {0, NULL, NULL}}; 225 | GType fb_ink_wfm_mode_index_e_type_id; 226 | fb_ink_wfm_mode_index_e_type_id = g_enum_register_static ("FBInkWFM_MODE_INDEX_E", values); 227 | g_once_init_leave (&fb_ink_wfm_mode_index_e_type_id__volatile, fb_ink_wfm_mode_index_e_type_id); 228 | } 229 | return fb_ink_wfm_mode_index_e_type_id__volatile; 230 | } 231 | 232 | 233 | GType fb_ink_hw_dither_index_e_get_type (void) { 234 | static volatile gsize fb_ink_hw_dither_index_e_type_id__volatile = 0; 235 | if (g_once_init_enter (&fb_ink_hw_dither_index_e_type_id__volatile)) { 236 | static const GEnumValue values[] = {{FB_INK_HW_DITHER_INDEX_E_PASSTHROUGH, "FB_INK_HW_DITHER_INDEX_E_PASSTHROUGH", "passthrough"}, {FB_INK_HW_DITHER_INDEX_E_FLOYD_STEINBERG, "FB_INK_HW_DITHER_INDEX_E_FLOYD_STEINBERG", "floyd-steinberg"}, {FB_INK_HW_DITHER_INDEX_E_ATKINSON, "FB_INK_HW_DITHER_INDEX_E_ATKINSON", "atkinson"}, {FB_INK_HW_DITHER_INDEX_E_ORDERED, "FB_INK_HW_DITHER_INDEX_E_ORDERED", "ordered"}, {FB_INK_HW_DITHER_INDEX_E_QUANT_ONLY, "FB_INK_HW_DITHER_INDEX_E_QUANT_ONLY", "quant-only"}, {FB_INK_HW_DITHER_INDEX_E_LEGACY, "FB_INK_HW_DITHER_INDEX_E_LEGACY", "legacy"}, {0, NULL, NULL}}; 237 | GType fb_ink_hw_dither_index_e_type_id; 238 | fb_ink_hw_dither_index_e_type_id = g_enum_register_static ("FBInkHW_DITHER_INDEX_E", values); 239 | g_once_init_leave (&fb_ink_hw_dither_index_e_type_id__volatile, fb_ink_hw_dither_index_e_type_id); 240 | } 241 | return fb_ink_hw_dither_index_e_type_id__volatile; 242 | } 243 | 244 | 245 | GType fb_ink_input_device_type_e_get_type (void) { 246 | static volatile gsize fb_ink_input_device_type_e_type_id__volatile = 0; 247 | if (g_once_init_enter (&fb_ink_input_device_type_e_type_id__volatile)) { 248 | static const GFlagsValue values[] = {{FB_INK_INPUT_DEVICE_TYPE_E_UNKNOWN, "FB_INK_INPUT_DEVICE_TYPE_E_UNKNOWN", "unknown"}, {FB_INK_INPUT_DEVICE_TYPE_E_POINTINGSTICK, "FB_INK_INPUT_DEVICE_TYPE_E_POINTINGSTICK", "pointingstick"}, {FB_INK_INPUT_DEVICE_TYPE_E_MOUSE, "FB_INK_INPUT_DEVICE_TYPE_E_MOUSE", "mouse"}, {FB_INK_INPUT_DEVICE_TYPE_E_TOUCHPAD, "FB_INK_INPUT_DEVICE_TYPE_E_TOUCHPAD", "touchpad"}, {FB_INK_INPUT_DEVICE_TYPE_E_TOUCHSCREEN, "FB_INK_INPUT_DEVICE_TYPE_E_TOUCHSCREEN", "touchscreen"}, {FB_INK_INPUT_DEVICE_TYPE_E_JOYSTICK, "FB_INK_INPUT_DEVICE_TYPE_E_JOYSTICK", "joystick"}, {FB_INK_INPUT_DEVICE_TYPE_E_TABLET, "FB_INK_INPUT_DEVICE_TYPE_E_TABLET", "tablet"}, {FB_INK_INPUT_DEVICE_TYPE_E_KEY, "FB_INK_INPUT_DEVICE_TYPE_E_KEY", "key"}, {FB_INK_INPUT_DEVICE_TYPE_E_KEYBOARD, "FB_INK_INPUT_DEVICE_TYPE_E_KEYBOARD", "keyboard"}, {FB_INK_INPUT_DEVICE_TYPE_E_ACCELEROMETER, "FB_INK_INPUT_DEVICE_TYPE_E_ACCELEROMETER", "accelerometer"}, {FB_INK_INPUT_DEVICE_TYPE_E_POWER_BUTTON, "FB_INK_INPUT_DEVICE_TYPE_E_POWER_BUTTON", "power-button"}, {FB_INK_INPUT_DEVICE_TYPE_E_SLEEP_COVER, "FB_INK_INPUT_DEVICE_TYPE_E_SLEEP_COVER", "sleep-cover"}, {FB_INK_INPUT_DEVICE_TYPE_E_PAGINATION_BUTTONS, "FB_INK_INPUT_DEVICE_TYPE_E_PAGINATION_BUTTONS", "pagination-buttons"}, {FB_INK_INPUT_DEVICE_TYPE_E_HOME_BUTTON, "FB_INK_INPUT_DEVICE_TYPE_E_HOME_BUTTON", "home-button"}, {FB_INK_INPUT_DEVICE_TYPE_E_LIGHT_BUTTON, "FB_INK_INPUT_DEVICE_TYPE_E_LIGHT_BUTTON", "light-button"}, {FB_INK_INPUT_DEVICE_TYPE_E_MENU_BUTTON, "FB_INK_INPUT_DEVICE_TYPE_E_MENU_BUTTON", "menu-button"}, {FB_INK_INPUT_DEVICE_TYPE_E_DPAD, "FB_INK_INPUT_DEVICE_TYPE_E_DPAD", "dpad"}, {FB_INK_INPUT_DEVICE_TYPE_E_ROTATION_EVENT, "FB_INK_INPUT_DEVICE_TYPE_E_ROTATION_EVENT", "rotation-event"}, {FB_INK_INPUT_DEVICE_TYPE_E_SCALED_TABLET, "FB_INK_INPUT_DEVICE_TYPE_E_SCALED_TABLET", "scaled-tablet"}, {FB_INK_INPUT_DEVICE_TYPE_E_VOLUME_BUTTONS, "FB_INK_INPUT_DEVICE_TYPE_E_VOLUME_BUTTONS", "volume-buttons"}, {0, NULL, NULL}}; 249 | GType fb_ink_input_device_type_e_type_id; 250 | fb_ink_input_device_type_e_type_id = g_flags_register_static ("FBInkINPUT_DEVICE_TYPE_E", values); 251 | g_once_init_leave (&fb_ink_input_device_type_e_type_id__volatile, fb_ink_input_device_type_e_type_id); 252 | } 253 | return fb_ink_input_device_type_e_type_id__volatile; 254 | } 255 | 256 | 257 | FBInk* fb_ink_construct (GType object_type, FBInkConfig* fbink_cfg, GError** error) { 258 | FBInk * self = NULL; 259 | FBInkConfig _tmp0_ = {0}; 260 | gint _tmp1_ = 0; 261 | gint _tmp2_ = 0; 262 | gint _tmp3_ = 0; 263 | g_return_val_if_fail (fbink_cfg != NULL, NULL); 264 | self = (FBInk*) g_object_new (object_type, NULL); 265 | _tmp0_ = *fbink_cfg; 266 | self->priv->cfg = _tmp0_; 267 | _tmp1_ = fbink_open (); 268 | self->priv->fbfd = _tmp1_; 269 | _tmp2_ = self->priv->fbfd; 270 | _tmp3_ = fbink_init (_tmp2_, &self->priv->cfg); 271 | if (_tmp3_ != 0) { 272 | } 273 | return self; 274 | } 275 | 276 | 277 | FBInk* fb_ink_new (FBInkConfig* fbink_cfg, GError** error) { 278 | return fb_ink_construct (TYPE_FB_INK, fbink_cfg, error); 279 | } 280 | 281 | 282 | gint fb_ink_refresh (FBInk* self, guint x, guint y, guint w, guint h) { 283 | gint result = 0; 284 | gint _tmp0_ = 0; 285 | guint _tmp1_ = 0U; 286 | guint _tmp2_ = 0U; 287 | guint _tmp3_ = 0U; 288 | guint _tmp4_ = 0U; 289 | gint _tmp5_ = 0; 290 | g_return_val_if_fail (self != NULL, 0); 291 | _tmp0_ = self->priv->fbfd; 292 | _tmp1_ = y; 293 | _tmp2_ = x; 294 | _tmp3_ = w; 295 | _tmp4_ = h; 296 | _tmp5_ = fbink_refresh (_tmp0_, (guint32) _tmp1_, (guint32) _tmp2_, (guint32) _tmp3_, (guint32) _tmp4_, &self->priv->cfg); 297 | result = _tmp5_; 298 | return result; 299 | } 300 | 301 | 302 | gint fb_ink_print_raw_data (FBInk* self, guint8* data, gint w, gint h, gsize len, gint x_off, gint y_off) { 303 | gint result = 0; 304 | gint _tmp0_ = 0; 305 | guint8* _tmp1_ = NULL; 306 | gint _tmp2_ = 0; 307 | gint _tmp3_ = 0; 308 | gsize _tmp4_ = 0UL; 309 | gint _tmp5_ = 0; 310 | gint _tmp6_ = 0; 311 | gint _tmp7_ = 0; 312 | g_return_val_if_fail (self != NULL, 0); 313 | _tmp0_ = self->priv->fbfd; 314 | _tmp1_ = data; 315 | _tmp2_ = w; 316 | _tmp3_ = h; 317 | _tmp4_ = len; 318 | _tmp5_ = x_off; 319 | _tmp6_ = y_off; 320 | _tmp7_ = fbink_print_raw_data (_tmp0_, _tmp1_, _tmp2_, _tmp3_, _tmp4_, _tmp5_, _tmp6_, &self->priv->cfg); 321 | result = _tmp7_; 322 | return result; 323 | } 324 | 325 | 326 | gchar* fb_ink_detect_touch_device (void) { 327 | gchar* result = NULL; 328 | gchar* detected_touch_path = NULL; 329 | gchar* _tmp0_ = NULL; 330 | guint32 match_mask = 0U; 331 | FBInkInputDevice* devices = NULL; 332 | guint32 _tmp1_ = 0U; 333 | size_t _tmp2_; 334 | FBInkInputDevice* _tmp3_ = NULL; 335 | gint devices_length1 = 0; 336 | gint _devices_size_ = 0; 337 | FBInkInputDevice* _tmp4_ = NULL; 338 | gint _tmp4__length1 = 0; 339 | _tmp0_ = g_strdup ("/dev/input/event1"); 340 | detected_touch_path = _tmp0_; 341 | match_mask = (guint32) (FB_INK_INPUT_DEVICE_TYPE_E_TOUCHSCREEN | FB_INK_INPUT_DEVICE_TYPE_E_SCALED_TABLET); 342 | _tmp1_ = match_mask; 343 | _tmp3_ = fbink_input_scan (_tmp1_, (guint32) 0, (guint32) 0, &_tmp2_); 344 | devices = _tmp3_; 345 | devices_length1 = _tmp2_; 346 | _devices_size_ = devices_length1; 347 | _tmp4_ = devices; 348 | _tmp4__length1 = devices_length1; 349 | { 350 | FBInkInputDevice* device_collection = NULL; 351 | gint device_collection_length1 = 0; 352 | gint _device_collection_size_ = 0; 353 | gint device_it = 0; 354 | device_collection = _tmp4_; 355 | device_collection_length1 = _tmp4__length1; 356 | for (device_it = 0; device_it < _tmp4__length1; device_it = device_it + 1) { 357 | FBInkInputDevice device = {0}; 358 | device = device_collection[device_it]; 359 | { 360 | FBInkInputDevice _tmp5_ = {0}; 361 | guint8 _tmp6_ = 0U; 362 | _tmp5_ = device; 363 | _tmp6_ = _tmp5_.matched; 364 | if (((gint) _tmp6_) == 1) { 365 | FBInkInputDevice _tmp7_ = {0}; 366 | gchar* _tmp8_ = NULL; 367 | _tmp7_ = device; 368 | _tmp8_ = g_strdup ((const gchar*) _tmp7_.path); 369 | _g_free0 (detected_touch_path); 370 | detected_touch_path = _tmp8_; 371 | break; 372 | } 373 | } 374 | } 375 | } 376 | result = detected_touch_path; 377 | devices = (g_free (devices), NULL); 378 | return result; 379 | } 380 | 381 | 382 | FBInkConfig* fb_ink_config_dup (const FBInkConfig* self) { 383 | FBInkConfig* dup; 384 | dup = g_new0 (FBInkConfig, 1); 385 | memcpy (dup, self, sizeof (FBInkConfig)); 386 | return dup; 387 | } 388 | 389 | 390 | void fb_ink_config_free (FBInkConfig* self) { 391 | g_free (self); 392 | } 393 | 394 | 395 | GType fb_ink_config_get_type (void) { 396 | static volatile gsize fb_ink_config_type_id__volatile = 0; 397 | if (g_once_init_enter (&fb_ink_config_type_id__volatile)) { 398 | GType fb_ink_config_type_id; 399 | fb_ink_config_type_id = g_boxed_type_register_static ("FBInkConfig", (GBoxedCopyFunc) fb_ink_config_dup, (GBoxedFreeFunc) fb_ink_config_free); 400 | g_once_init_leave (&fb_ink_config_type_id__volatile, fb_ink_config_type_id); 401 | } 402 | return fb_ink_config_type_id__volatile; 403 | } 404 | 405 | 406 | FBInkInputDevice* fb_ink_input_device_dup (const FBInkInputDevice* self) { 407 | FBInkInputDevice* dup; 408 | dup = g_new0 (FBInkInputDevice, 1); 409 | memcpy (dup, self, sizeof (FBInkInputDevice)); 410 | return dup; 411 | } 412 | 413 | 414 | void fb_ink_input_device_free (FBInkInputDevice* self) { 415 | g_free (self); 416 | } 417 | 418 | 419 | GType fb_ink_input_device_get_type (void) { 420 | static volatile gsize fb_ink_input_device_type_id__volatile = 0; 421 | if (g_once_init_enter (&fb_ink_input_device_type_id__volatile)) { 422 | GType fb_ink_input_device_type_id; 423 | fb_ink_input_device_type_id = g_boxed_type_register_static ("FBInkInputDevice", (GBoxedCopyFunc) fb_ink_input_device_dup, (GBoxedFreeFunc) fb_ink_input_device_free); 424 | g_once_init_leave (&fb_ink_input_device_type_id__volatile, fb_ink_input_device_type_id); 425 | } 426 | return fb_ink_input_device_type_id__volatile; 427 | } 428 | 429 | 430 | static void fb_ink_class_init (FBInkClass * klass) { 431 | fb_ink_parent_class = g_type_class_peek_parent (klass); 432 | g_type_class_add_private (klass, sizeof (FBInkPrivate)); 433 | G_OBJECT_CLASS (klass)->finalize = fb_ink_finalize; 434 | } 435 | 436 | 437 | static void fb_ink_instance_init (FBInk * self) { 438 | self->priv = FB_INK_GET_PRIVATE (self); 439 | } 440 | 441 | 442 | static void fb_ink_finalize (GObject* obj) { 443 | FBInk * self; 444 | gint _tmp0_ = 0; 445 | self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_FB_INK, FBInk); 446 | _tmp0_ = self->priv->fbfd; 447 | fbink_close (_tmp0_); 448 | G_OBJECT_CLASS (fb_ink_parent_class)->finalize (obj); 449 | } 450 | 451 | 452 | GType fb_ink_get_type (void) { 453 | static volatile gsize fb_ink_type_id__volatile = 0; 454 | if (g_once_init_enter (&fb_ink_type_id__volatile)) { 455 | static const GTypeInfo g_define_type_info = { sizeof (FBInkClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) fb_ink_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FBInk), 0, (GInstanceInitFunc) fb_ink_instance_init, NULL }; 456 | GType fb_ink_type_id; 457 | fb_ink_type_id = g_type_register_static (G_TYPE_OBJECT, "FBInk", &g_define_type_info, 0); 458 | g_once_init_leave (&fb_ink_type_id__volatile, fb_ink_type_id); 459 | } 460 | return fb_ink_type_id__volatile; 461 | } 462 | 463 | 464 | 465 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /file_picker.c: -------------------------------------------------------------------------------- 1 | /* valac --pkg gtk+-2.0 --pkg gee-0.8 simple_file_picker.vala*/ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | #define TYPE_SIMPLE_FILE_PICKER (simple_file_picker_get_type ()) 18 | #define SIMPLE_FILE_PICKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SIMPLE_FILE_PICKER, SimpleFilePicker)) 19 | #define SIMPLE_FILE_PICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SIMPLE_FILE_PICKER, SimpleFilePickerClass)) 20 | #define IS_SIMPLE_FILE_PICKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SIMPLE_FILE_PICKER)) 21 | #define IS_SIMPLE_FILE_PICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SIMPLE_FILE_PICKER)) 22 | #define SIMPLE_FILE_PICKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SIMPLE_FILE_PICKER, SimpleFilePickerClass)) 23 | 24 | typedef struct _SimpleFilePicker SimpleFilePicker; 25 | typedef struct _SimpleFilePickerClass SimpleFilePickerClass; 26 | typedef struct _SimpleFilePickerPrivate SimpleFilePickerPrivate; 27 | #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) 28 | #define _g_free0(var) (var = (g_free (var), NULL)) 29 | typedef struct _Block6Data Block6Data; 30 | #define _gtk_tree_path_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL))) 31 | #define _g_dir_close0(var) ((var == NULL) ? NULL : (var = (g_dir_close (var), NULL))) 32 | #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) 33 | 34 | struct _SimpleFilePicker { 35 | GtkWindow parent_instance; 36 | SimpleFilePickerPrivate * priv; 37 | }; 38 | 39 | struct _SimpleFilePickerClass { 40 | GtkWindowClass parent_class; 41 | }; 42 | 43 | struct _SimpleFilePickerPrivate { 44 | GtkListStore* store; 45 | GtkTreeView* tree; 46 | gchar* cwd; 47 | GtkLabel* path_label; 48 | gchar* current_dir; 49 | }; 50 | 51 | struct _Block6Data { 52 | int _ref_count_; 53 | SimpleFilePicker* self; 54 | GtkScrolledWindow* scrolled; 55 | gulong destroy_handler_id; 56 | gchar* full; 57 | gboolean is_dragging; 58 | gdouble press_y; 59 | guint32 press_time; 60 | gdouble last_y; 61 | guint32 last_time; 62 | gdouble _delta; 63 | GeeSet* ext; 64 | }; 65 | 66 | 67 | static gpointer simple_file_picker_parent_class = NULL; 68 | 69 | GType simple_file_picker_get_type (void) G_GNUC_CONST; 70 | #define SIMPLE_FILE_PICKER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_SIMPLE_FILE_PICKER, SimpleFilePickerPrivate)) 71 | enum { 72 | SIMPLE_FILE_PICKER_DUMMY_PROPERTY 73 | }; 74 | SimpleFilePicker* simple_file_picker_new (GtkWindow* parent, GeeSet* ext, const gchar* start_dir, GError** error); 75 | SimpleFilePicker* simple_file_picker_construct (GType object_type, GtkWindow* parent, GeeSet* ext, const gchar* start_dir, GError** error); 76 | static Block6Data* block6_data_ref (Block6Data* _data6_); 77 | static void block6_data_unref (void * _userdata_); 78 | static void __lambda36_ (SimpleFilePicker* self, GtkObject* event); 79 | static void ___lambda36__gtk_object_destroy (GtkObject* _sender, gpointer self); 80 | static void __lambda37_ (SimpleFilePicker* self); 81 | static void ___lambda37__gtk_button_clicked (GtkButton* _sender, gpointer self); 82 | static gboolean __lambda38_ (SimpleFilePicker* self, GdkEventScroll* event); 83 | static gboolean ___lambda38__gtk_widget_scroll_event (GtkWidget* _sender, GdkEventScroll* event, gpointer self); 84 | static gboolean __lambda39_ (Block6Data* _data6_, GdkEventButton* event); 85 | static gboolean simple_file_picker_get_path_at_event (SimpleFilePicker* self, GdkEventButton* event, gboolean* is_dir, gchar** full); 86 | static gboolean ___lambda39__gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self); 87 | static gboolean __lambda40_ (Block6Data* _data6_, GdkEventMotion* event); 88 | static gboolean ___lambda40__gtk_widget_motion_notify_event (GtkWidget* _sender, GdkEventMotion* event, gpointer self); 89 | static gboolean __lambda41_ (Block6Data* _data6_, GdkEventButton* event); 90 | static void simple_file_picker_change_dir (SimpleFilePicker* self, const gchar* path, GeeSet* extensions); 91 | static gboolean ___lambda41__gtk_widget_button_release_event (GtkWidget* _sender, GdkEventButton* event, gpointer self); 92 | static gint ___lambda42_ (SimpleFilePicker* self, const gchar* a, const gchar* b); 93 | static gint ____lambda42__gcompare_data_func (gconstpointer a, gconstpointer b, gpointer self); 94 | static gint ___lambda43_ (SimpleFilePicker* self, const gchar* a, const gchar* b); 95 | static gint ____lambda43__gcompare_data_func (gconstpointer a, gconstpointer b, gpointer self); 96 | static void g_cclosure_user_marshal_VOID__STRING_STRING (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data); 97 | static void simple_file_picker_finalize (GObject* obj); 98 | 99 | 100 | static gpointer _g_object_ref0 (gpointer self) { 101 | return self ? g_object_ref (self) : NULL; 102 | } 103 | 104 | 105 | static Block6Data* block6_data_ref (Block6Data* _data6_) { 106 | g_atomic_int_inc (&_data6_->_ref_count_); 107 | return _data6_; 108 | } 109 | 110 | 111 | static void block6_data_unref (void * _userdata_) { 112 | Block6Data* _data6_; 113 | _data6_ = (Block6Data*) _userdata_; 114 | if (g_atomic_int_dec_and_test (&_data6_->_ref_count_)) { 115 | SimpleFilePicker* self; 116 | self = _data6_->self; 117 | _g_free0 (_data6_->full); 118 | _g_object_unref0 (_data6_->scrolled); 119 | _g_object_unref0 (_data6_->ext); 120 | _g_object_unref0 (self); 121 | g_slice_free (Block6Data, _data6_); 122 | } 123 | } 124 | 125 | 126 | static void __lambda36_ (SimpleFilePicker* self, GtkObject* event) { 127 | const gchar* _tmp0_ = NULL; 128 | g_return_if_fail (event != NULL); 129 | _tmp0_ = self->priv->current_dir; 130 | g_signal_emit_by_name (self, "file-selected", NULL, _tmp0_); 131 | } 132 | 133 | 134 | static void ___lambda36__gtk_object_destroy (GtkObject* _sender, gpointer self) { 135 | __lambda36_ ((SimpleFilePicker*) self, _sender); 136 | } 137 | 138 | 139 | static void __lambda37_ (SimpleFilePicker* self) { 140 | gtk_object_destroy ((GtkObject*) self); 141 | } 142 | 143 | 144 | static void ___lambda37__gtk_button_clicked (GtkButton* _sender, gpointer self) { 145 | __lambda37_ ((SimpleFilePicker*) self); 146 | } 147 | 148 | 149 | static gboolean __lambda38_ (SimpleFilePicker* self, GdkEventScroll* event) { 150 | gboolean result = FALSE; 151 | g_return_val_if_fail (event != NULL, FALSE); 152 | result = TRUE; 153 | return result; 154 | } 155 | 156 | 157 | static gboolean ___lambda38__gtk_widget_scroll_event (GtkWidget* _sender, GdkEventScroll* event, gpointer self) { 158 | gboolean result; 159 | result = __lambda38_ ((SimpleFilePicker*) self, event); 160 | return result; 161 | } 162 | 163 | 164 | static gboolean __lambda39_ (Block6Data* _data6_, GdkEventButton* event) { 165 | SimpleFilePicker* self; 166 | gboolean result = FALSE; 167 | FILE* _tmp0_ = NULL; 168 | GdkEventButton _tmp1_ = {0}; 169 | gdouble _tmp2_ = 0.0; 170 | GdkEventButton _tmp3_ = {0}; 171 | gdouble _tmp4_ = 0.0; 172 | GdkEventButton _tmp5_ = {0}; 173 | guint32 _tmp6_ = 0U; 174 | GdkEventButton _tmp7_ = {0}; 175 | gdouble _tmp8_ = 0.0; 176 | GdkEventButton _tmp9_ = {0}; 177 | gdouble _tmp10_ = 0.0; 178 | GdkEventButton _tmp11_ = {0}; 179 | guint32 _tmp12_ = 0U; 180 | GdkEventButton _tmp13_ = {0}; 181 | guint32 _tmp14_ = 0U; 182 | gchar* _full = NULL; 183 | GdkEventButton _tmp15_ = {0}; 184 | gchar* _tmp16_ = NULL; 185 | gboolean _tmp17_ = FALSE; 186 | self = _data6_->self; 187 | g_return_val_if_fail (event != NULL, FALSE); 188 | _tmp0_ = stdout; 189 | _tmp1_ = *event; 190 | _tmp2_ = _tmp1_.x; 191 | _tmp3_ = *event; 192 | _tmp4_ = _tmp3_.y; 193 | _tmp5_ = *event; 194 | _tmp6_ = _tmp5_.time; 195 | fprintf (_tmp0_, "button_press_event: x: %f y: %f time: %d\n", _tmp2_, _tmp4_, (gint) _tmp6_); 196 | _tmp7_ = *event; 197 | _tmp8_ = _tmp7_.y; 198 | _data6_->press_y = _tmp8_; 199 | _tmp9_ = *event; 200 | _tmp10_ = _tmp9_.y; 201 | _data6_->last_y = _tmp10_; 202 | _tmp11_ = *event; 203 | _tmp12_ = _tmp11_.time; 204 | _data6_->press_time = _tmp12_; 205 | _tmp13_ = *event; 206 | _tmp14_ = _tmp13_.time; 207 | _data6_->last_time = _tmp14_; 208 | _data6_->is_dragging = FALSE; 209 | _tmp15_ = *event; 210 | _tmp17_ = simple_file_picker_get_path_at_event (self, &_tmp15_, NULL, &_tmp16_); 211 | _g_free0 (_full); 212 | _full = _tmp16_; 213 | if (_tmp17_) { 214 | const gchar* _tmp18_ = NULL; 215 | gchar* _tmp19_ = NULL; 216 | _tmp18_ = _full; 217 | _tmp19_ = g_strdup (_tmp18_); 218 | _g_free0 (_data6_->full); 219 | _data6_->full = _tmp19_; 220 | } 221 | result = FALSE; 222 | _g_free0 (_full); 223 | return result; 224 | } 225 | 226 | 227 | static gboolean ___lambda39__gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) { 228 | gboolean result; 229 | result = __lambda39_ (self, event); 230 | return result; 231 | } 232 | 233 | 234 | static gboolean __lambda40_ (Block6Data* _data6_, GdkEventMotion* event) { 235 | SimpleFilePicker* self; 236 | gboolean result = FALSE; 237 | GdkEventMotion _tmp0_ = {0}; 238 | GdkModifierType _tmp1_ = 0; 239 | self = _data6_->self; 240 | g_return_val_if_fail (event != NULL, FALSE); 241 | _tmp0_ = *event; 242 | _tmp1_ = _tmp0_.state; 243 | if ((_tmp1_ & GDK_BUTTON1_MASK) != 0) { 244 | GtkAdjustment* vadj = NULL; 245 | GtkScrolledWindow* _tmp2_ = NULL; 246 | GtkAdjustment* _tmp3_ = NULL; 247 | GtkAdjustment* _tmp4_ = NULL; 248 | gint s_height = 0; 249 | GtkScrolledWindow* _tmp5_ = NULL; 250 | GtkAllocation _tmp6_ = {0}; 251 | gint _tmp7_ = 0; 252 | gdouble delta = 0.0; 253 | gdouble _tmp8_ = 0.0; 254 | GdkEventMotion _tmp9_ = {0}; 255 | gdouble _tmp10_ = 0.0; 256 | gboolean _tmp11_ = FALSE; 257 | gboolean _tmp12_ = FALSE; 258 | gboolean _tmp13_ = FALSE; 259 | gboolean _tmp33_ = FALSE; 260 | gboolean _tmp34_ = FALSE; 261 | gdouble _tmp35_ = 0.0; 262 | gdouble _tmp46_ = 0.0; 263 | GdkEventMotion _tmp47_ = {0}; 264 | gdouble _tmp48_ = 0.0; 265 | _tmp2_ = _data6_->scrolled; 266 | _tmp3_ = gtk_scrolled_window_get_vadjustment (_tmp2_); 267 | _tmp4_ = _g_object_ref0 (_tmp3_); 268 | vadj = _tmp4_; 269 | _tmp5_ = _data6_->scrolled; 270 | _tmp6_ = ((GtkWidget*) _tmp5_)->allocation; 271 | _tmp7_ = _tmp6_.height; 272 | s_height = _tmp7_; 273 | _tmp8_ = _data6_->last_y; 274 | _tmp9_ = *event; 275 | _tmp10_ = _tmp9_.y; 276 | delta = _tmp8_ - _tmp10_; 277 | _tmp13_ = _data6_->is_dragging; 278 | if (_tmp13_) { 279 | GtkAdjustment* _tmp14_ = NULL; 280 | gdouble _tmp15_ = 0.0; 281 | gdouble _tmp16_ = 0.0; 282 | gdouble _tmp17_ = 0.0; 283 | _tmp14_ = vadj; 284 | _tmp15_ = gtk_adjustment_get_value (_tmp14_); 285 | _tmp16_ = _tmp15_; 286 | _tmp17_ = delta; 287 | _tmp12_ = (_tmp16_ + _tmp17_) > ((gdouble) 0); 288 | } else { 289 | _tmp12_ = FALSE; 290 | } 291 | if (_tmp12_) { 292 | GtkAdjustment* _tmp18_ = NULL; 293 | gdouble _tmp19_ = 0.0; 294 | gdouble _tmp20_ = 0.0; 295 | gint _tmp21_ = 0; 296 | GtkAdjustment* _tmp22_ = NULL; 297 | gdouble _tmp23_ = 0.0; 298 | gdouble _tmp24_ = 0.0; 299 | gdouble _tmp25_ = 0.0; 300 | _tmp18_ = vadj; 301 | _tmp19_ = gtk_adjustment_get_upper (_tmp18_); 302 | _tmp20_ = _tmp19_; 303 | _tmp21_ = s_height; 304 | _tmp22_ = vadj; 305 | _tmp23_ = gtk_adjustment_get_value (_tmp22_); 306 | _tmp24_ = _tmp23_; 307 | _tmp25_ = delta; 308 | _tmp11_ = (_tmp20_ - _tmp21_) > (_tmp24_ + _tmp25_); 309 | } else { 310 | _tmp11_ = FALSE; 311 | } 312 | if (_tmp11_) { 313 | GtkAdjustment* _tmp26_ = NULL; 314 | GtkAdjustment* _tmp27_ = NULL; 315 | gdouble _tmp28_ = 0.0; 316 | gdouble _tmp29_ = 0.0; 317 | gdouble _tmp30_ = 0.0; 318 | GtkScrolledWindow* _tmp31_ = NULL; 319 | GtkAdjustment* _tmp32_ = NULL; 320 | _tmp26_ = vadj; 321 | _tmp27_ = vadj; 322 | _tmp28_ = gtk_adjustment_get_value (_tmp27_); 323 | _tmp29_ = _tmp28_; 324 | _tmp30_ = delta; 325 | gtk_adjustment_set_value (_tmp26_, _tmp29_ + _tmp30_); 326 | _tmp31_ = _data6_->scrolled; 327 | _tmp32_ = vadj; 328 | gtk_scrolled_window_set_vadjustment (_tmp31_, _tmp32_); 329 | } 330 | _tmp35_ = _data6_->_delta; 331 | if (_tmp35_ < ((gdouble) 0)) { 332 | gdouble _tmp36_ = 0.0; 333 | _tmp36_ = delta; 334 | _tmp34_ = _tmp36_ > ((gdouble) 0); 335 | } else { 336 | _tmp34_ = FALSE; 337 | } 338 | if (_tmp34_) { 339 | _tmp33_ = TRUE; 340 | } else { 341 | gboolean _tmp37_ = FALSE; 342 | gdouble _tmp38_ = 0.0; 343 | _tmp38_ = _data6_->_delta; 344 | if (_tmp38_ > ((gdouble) 0)) { 345 | gdouble _tmp39_ = 0.0; 346 | _tmp39_ = delta; 347 | _tmp37_ = _tmp39_ < ((gdouble) 0); 348 | } else { 349 | _tmp37_ = FALSE; 350 | } 351 | _tmp33_ = _tmp37_; 352 | } 353 | if (_tmp33_) { 354 | FILE* _tmp40_ = NULL; 355 | gdouble _tmp41_ = 0.0; 356 | GdkEventMotion _tmp42_ = {0}; 357 | gdouble _tmp43_ = 0.0; 358 | GdkEventMotion _tmp44_ = {0}; 359 | guint32 _tmp45_ = 0U; 360 | _tmp40_ = stdout; 361 | _tmp41_ = delta; 362 | fprintf (_tmp40_, "switched direction motion_notify_event delta %f\n", _tmp41_); 363 | _tmp42_ = *event; 364 | _tmp43_ = _tmp42_.y; 365 | _data6_->press_y = _tmp43_; 366 | _tmp44_ = *event; 367 | _tmp45_ = _tmp44_.time; 368 | _data6_->press_time = _tmp45_; 369 | } 370 | _tmp46_ = delta; 371 | _data6_->_delta = _tmp46_; 372 | _tmp47_ = *event; 373 | _tmp48_ = _tmp47_.y; 374 | _data6_->last_y = _tmp48_; 375 | _data6_->is_dragging = TRUE; 376 | _g_object_unref0 (vadj); 377 | } 378 | result = FALSE; 379 | return result; 380 | } 381 | 382 | 383 | static gboolean ___lambda40__gtk_widget_motion_notify_event (GtkWidget* _sender, GdkEventMotion* event, gpointer self) { 384 | gboolean result; 385 | result = __lambda40_ (self, event); 386 | return result; 387 | } 388 | 389 | 390 | static gboolean __lambda41_ (Block6Data* _data6_, GdkEventButton* event) { 391 | SimpleFilePicker* self; 392 | gboolean result = FALSE; 393 | gdouble delta_y = 0.0; 394 | GdkEventButton _tmp0_ = {0}; 395 | gdouble _tmp1_ = 0.0; 396 | gdouble _tmp2_ = 0.0; 397 | gdouble delta_t = 0.0; 398 | GdkEventButton _tmp3_ = {0}; 399 | guint32 _tmp4_ = 0U; 400 | guint32 _tmp5_ = 0U; 401 | FILE* _tmp6_ = NULL; 402 | GdkEventButton _tmp7_ = {0}; 403 | gdouble _tmp8_ = 0.0; 404 | GdkEventButton _tmp9_ = {0}; 405 | gdouble _tmp10_ = 0.0; 406 | gdouble _tmp11_ = 0.0; 407 | gdouble _tmp12_ = 0.0; 408 | GdkEventButton _tmp13_ = {0}; 409 | guint32 _tmp14_ = 0U; 410 | GdkEventButton _tmp15_ = {0}; 411 | gdouble _tmp16_ = 0.0; 412 | gdouble _tmp17_ = 0.0; 413 | gdouble _tmp18_ = 0.0; 414 | gboolean is_dir = FALSE; 415 | gchar* _full = NULL; 416 | gboolean _tmp19_ = FALSE; 417 | GdkEventButton _tmp20_ = {0}; 418 | gboolean _tmp21_ = FALSE; 419 | gchar* _tmp22_ = NULL; 420 | gboolean _tmp23_ = FALSE; 421 | gboolean _tmp26_ = FALSE; 422 | self = _data6_->self; 423 | g_return_val_if_fail (event != NULL, FALSE); 424 | _tmp0_ = *event; 425 | _tmp1_ = _tmp0_.y; 426 | _tmp2_ = _data6_->press_y; 427 | delta_y = _tmp1_ - _tmp2_; 428 | _tmp3_ = *event; 429 | _tmp4_ = _tmp3_.time; 430 | _tmp5_ = _data6_->press_time; 431 | delta_t = (gdouble) (_tmp4_ - _tmp5_); 432 | _tmp6_ = stdout; 433 | _tmp7_ = *event; 434 | _tmp8_ = _tmp7_.x; 435 | _tmp9_ = *event; 436 | _tmp10_ = _tmp9_.y; 437 | _tmp11_ = delta_y; 438 | _tmp12_ = delta_t; 439 | _tmp13_ = *event; 440 | _tmp14_ = _tmp13_.time; 441 | fprintf (_tmp6_, "button_release_event: x: %f y: %f delta_y: %f delta_t: %f time: %d\n", _tmp8_, _tmp10_, _tmp11_, _tmp12_, (gint) _tmp14_); 442 | _tmp15_ = *event; 443 | _tmp16_ = _tmp15_.y; 444 | _tmp17_ = _data6_->press_y; 445 | _tmp18_ = fabs (_tmp16_ - _tmp17_); 446 | if (_tmp18_ > ((gdouble) 5)) { 447 | result = FALSE; 448 | return result; 449 | } 450 | _tmp20_ = *event; 451 | _tmp23_ = simple_file_picker_get_path_at_event (self, &_tmp20_, &_tmp21_, &_tmp22_); 452 | is_dir = _tmp21_; 453 | _g_free0 (_full); 454 | _full = _tmp22_; 455 | if (!_tmp23_) { 456 | _tmp19_ = TRUE; 457 | } else { 458 | const gchar* _tmp24_ = NULL; 459 | const gchar* _tmp25_ = NULL; 460 | _tmp24_ = _data6_->full; 461 | _tmp25_ = _full; 462 | _tmp19_ = g_strcmp0 (_tmp24_, _tmp25_) != 0; 463 | } 464 | if (_tmp19_) { 465 | result = FALSE; 466 | _g_free0 (_full); 467 | return result; 468 | } 469 | _tmp26_ = is_dir; 470 | if (_tmp26_) { 471 | const gchar* _tmp27_ = NULL; 472 | GeeSet* _tmp28_ = NULL; 473 | GtkTreePath* _path = NULL; 474 | GtkTreePath* _tmp29_ = NULL; 475 | GtkTreeView* _tmp30_ = NULL; 476 | GtkTreePath* _tmp31_ = NULL; 477 | _tmp27_ = _data6_->full; 478 | _tmp28_ = _data6_->ext; 479 | simple_file_picker_change_dir (self, _tmp27_, _tmp28_); 480 | _tmp29_ = gtk_tree_path_new_from_indices (0, -1, -1); 481 | _path = _tmp29_; 482 | _tmp30_ = self->priv->tree; 483 | _tmp31_ = _path; 484 | gtk_tree_view_scroll_to_cell (_tmp30_, _tmp31_, NULL, TRUE, 0.0f, 0.0f); 485 | _gtk_tree_path_free0 (_path); 486 | } else { 487 | gulong _tmp32_ = 0UL; 488 | const gchar* _tmp33_ = NULL; 489 | const gchar* _tmp34_ = NULL; 490 | _tmp32_ = _data6_->destroy_handler_id; 491 | g_signal_handler_disconnect ((GObject*) self, _tmp32_); 492 | _tmp33_ = _data6_->full; 493 | _tmp34_ = self->priv->current_dir; 494 | g_signal_emit_by_name (self, "file-selected", _tmp33_, _tmp34_); 495 | gtk_object_destroy ((GtkObject*) self); 496 | } 497 | result = FALSE; 498 | _g_free0 (_full); 499 | return result; 500 | } 501 | 502 | 503 | static gboolean ___lambda41__gtk_widget_button_release_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) { 504 | gboolean result; 505 | result = __lambda41_ (self, event); 506 | return result; 507 | } 508 | 509 | 510 | SimpleFilePicker* simple_file_picker_construct (GType object_type, GtkWindow* parent, GeeSet* ext, const gchar* start_dir, GError** error) { 511 | SimpleFilePicker * self = NULL; 512 | Block6Data* _data6_; 513 | GeeSet* _tmp0_ = NULL; 514 | GeeSet* _tmp1_ = NULL; 515 | gchar* ui_template = NULL; 516 | gchar* _tmp2_ = NULL; 517 | GtkBuilder* builder = NULL; 518 | GtkBuilder* _tmp3_ = NULL; 519 | gint _tmp4_ = 0; 520 | gint _tmp5_ = 0; 521 | GtkWindow* _tmp6_ = NULL; 522 | GtkVBox* main_vbox = NULL; 523 | GObject* _tmp8_ = NULL; 524 | GtkVBox* _tmp9_ = NULL; 525 | GtkVBox* _tmp10_ = NULL; 526 | GObject* _tmp11_ = NULL; 527 | GtkLabel* _tmp12_ = NULL; 528 | GObject* _tmp13_ = NULL; 529 | GtkScrolledWindow* _tmp14_ = NULL; 530 | GtkListStore* _tmp15_ = NULL; 531 | GObject* _tmp16_ = NULL; 532 | GtkTreeView* _tmp17_ = NULL; 533 | GtkTreeView* _tmp18_ = NULL; 534 | GtkTreeView* _tmp19_ = NULL; 535 | GtkTreeView* _tmp20_ = NULL; 536 | GtkListStore* _tmp21_ = NULL; 537 | GtkCellRendererText* renderer = NULL; 538 | GtkCellRendererText* _tmp22_ = NULL; 539 | GtkCellRendererText* _tmp23_ = NULL; 540 | GValue _tmp24_ = {0}; 541 | GtkCellRendererText* _tmp25_ = NULL; 542 | GtkCellRendererText* _tmp26_ = NULL; 543 | GtkTreeViewColumn* col = NULL; 544 | GtkTreeViewColumn* _tmp27_ = NULL; 545 | GtkTreeViewColumn* _tmp28_ = NULL; 546 | GtkCellRendererText* _tmp29_ = NULL; 547 | GtkTreeViewColumn* _tmp30_ = NULL; 548 | GtkCellRendererText* _tmp31_ = NULL; 549 | GtkTreeView* _tmp32_ = NULL; 550 | GtkTreeViewColumn* _tmp33_ = NULL; 551 | GtkTreeView* _tmp34_ = NULL; 552 | GtkTreeSelection* _tmp35_ = NULL; 553 | GtkButton* cancel_button = NULL; 554 | GObject* _tmp36_ = NULL; 555 | GtkButton* _tmp37_ = NULL; 556 | gulong _tmp38_ = 0UL; 557 | GtkButton* _tmp39_ = NULL; 558 | GtkTreeView* _tmp40_ = NULL; 559 | gchar* _tmp41_ = NULL; 560 | GtkTreeView* _tmp42_ = NULL; 561 | GtkTreeView* _tmp43_ = NULL; 562 | GtkTreeView* _tmp44_ = NULL; 563 | gchar* _tmp45_ = NULL; 564 | const gchar* _tmp46_ = NULL; 565 | gchar* _tmp50_ = NULL; 566 | const gchar* _tmp51_ = NULL; 567 | GeeSet* _tmp52_ = NULL; 568 | GError * _inner_error_ = NULL; 569 | g_return_val_if_fail (parent != NULL, NULL); 570 | g_return_val_if_fail (ext != NULL, NULL); 571 | g_return_val_if_fail (start_dir != NULL, NULL); 572 | _data6_ = g_slice_new0 (Block6Data); 573 | _data6_->_ref_count_ = 1; 574 | _tmp0_ = ext; 575 | _tmp1_ = _g_object_ref0 (_tmp0_); 576 | _g_object_unref0 (_data6_->ext); 577 | _data6_->ext = _tmp1_; 578 | self = (SimpleFilePicker*) g_object_new (object_type, NULL); 579 | _data6_->self = g_object_ref (self); 580 | gtk_window_set_title ((GtkWindow*) self, "L:A_N:application_ID:gambatte_PC:N_O:URL_DM:PZ_O:U"); 581 | _tmp2_ = g_strdup ("\n" \ 582 | " \n" \ 583 | " \n" \ 584 | " 10\n" \ 585 | " 5\n" \ 586 | " \n" \ 587 | " \n" \ 588 | " \n" \ 589 | " \n" \ 591 | " cancel\n" \ 593 | " \n" \ 594 | " \n" \ 595 | " False\n" \ 597 | " False\n" \ 599 | " \n" \ 600 | " \n" \ 601 | " \n" \ 602 | " \n" \ 603 | " label\n" \ 605 | " \n" \ 606 | " \n" \ 607 | " False\n" \ 609 | " False\n" \ 611 | " 10\n" \ 613 | " \n" \ 614 | " \n" \ 615 | " \n" \ 616 | " \n" \ 617 | " False\n" \ 618 | " False\n" \ 619 | " \n" \ 620 | " \n" \ 621 | " \n" \ 622 | " \n" \ 624 | " never\n" \ 626 | " \n" \ 627 | " \n" \ 629 | " \n" \ 630 | " \n" \ 631 | " \n" \ 632 | " \n" \ 633 | " \n" \ 634 | " \n" \ 635 | " \n" \ 636 | " \n" \ 637 | " "); 638 | ui_template = _tmp2_; 639 | _tmp3_ = gtk_builder_new (); 640 | builder = _tmp3_; 641 | _tmp4_ = strlen (ui_template); 642 | _tmp5_ = _tmp4_; 643 | gtk_builder_add_from_string (builder, ui_template, (gsize) _tmp5_, &_inner_error_); 644 | if (G_UNLIKELY (_inner_error_ != NULL)) { 645 | g_propagate_error (error, _inner_error_); 646 | _g_object_unref0 (builder); 647 | _g_free0 (ui_template); 648 | block6_data_unref (_data6_); 649 | _data6_ = NULL; 650 | _g_object_unref0 (self); 651 | return NULL; 652 | } 653 | _tmp6_ = parent; 654 | if (_tmp6_ != NULL) { 655 | GtkWindow* _tmp7_ = NULL; 656 | _tmp7_ = parent; 657 | gtk_window_set_transient_for ((GtkWindow*) self, _tmp7_); 658 | gtk_window_set_modal ((GtkWindow*) self, TRUE); 659 | } 660 | _tmp8_ = gtk_builder_get_object (builder, "main_vbox"); 661 | _tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp8_, GTK_TYPE_VBOX) ? ((GtkVBox*) _tmp8_) : NULL); 662 | main_vbox = _tmp9_; 663 | _tmp10_ = main_vbox; 664 | gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp10_); 665 | _tmp11_ = gtk_builder_get_object (builder, "label1"); 666 | _tmp12_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp11_, GTK_TYPE_LABEL) ? ((GtkLabel*) _tmp11_) : NULL); 667 | _g_object_unref0 (self->priv->path_label); 668 | self->priv->path_label = _tmp12_; 669 | _tmp13_ = gtk_builder_get_object (builder, "scrolledwindow1"); 670 | _tmp14_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp13_, GTK_TYPE_SCROLLED_WINDOW) ? ((GtkScrolledWindow*) _tmp13_) : NULL); 671 | _data6_->scrolled = _tmp14_; 672 | _tmp15_ = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); 673 | _g_object_unref0 (self->priv->store); 674 | self->priv->store = _tmp15_; 675 | _tmp16_ = gtk_builder_get_object (builder, "treeview1"); 676 | _tmp17_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp16_, GTK_TYPE_TREE_VIEW) ? ((GtkTreeView*) _tmp16_) : NULL); 677 | _g_object_unref0 (self->priv->tree); 678 | self->priv->tree = _tmp17_; 679 | _tmp18_ = self->priv->tree; 680 | gtk_tree_view_set_headers_visible (_tmp18_, FALSE); 681 | _tmp19_ = self->priv->tree; 682 | gtk_tree_view_set_rules_hint (_tmp19_, FALSE); 683 | _tmp20_ = self->priv->tree; 684 | _tmp21_ = self->priv->store; 685 | gtk_tree_view_set_model (_tmp20_, (GtkTreeModel*) _tmp21_); 686 | _tmp22_ = (GtkCellRendererText*) gtk_cell_renderer_text_new (); 687 | g_object_ref_sink (_tmp22_); 688 | renderer = _tmp22_; 689 | _tmp23_ = renderer; 690 | g_value_init (&_tmp24_, G_TYPE_STRING); 691 | g_value_set_string (&_tmp24_, "Sans 16"); 692 | g_object_set_property ((GObject*) _tmp23_, "font", &_tmp24_); 693 | G_IS_VALUE (&_tmp24_) ? (g_value_unset (&_tmp24_), NULL) : NULL; 694 | _tmp25_ = renderer; 695 | g_object_set (_tmp25_, "wrap-mode", PANGO_WRAP_WORD_CHAR, NULL); 696 | _tmp26_ = renderer; 697 | gtk_cell_renderer_set_padding ((GtkCellRenderer*) _tmp26_, 6, 8); 698 | _tmp27_ = gtk_tree_view_column_new (); 699 | g_object_ref_sink (_tmp27_); 700 | col = _tmp27_; 701 | _tmp28_ = col; 702 | _tmp29_ = renderer; 703 | gtk_cell_layout_pack_start ((GtkCellLayout*) _tmp28_, (GtkCellRenderer*) _tmp29_, TRUE); 704 | _tmp30_ = col; 705 | _tmp31_ = renderer; 706 | gtk_cell_layout_add_attribute ((GtkCellLayout*) _tmp30_, (GtkCellRenderer*) _tmp31_, "text", 0); 707 | _tmp32_ = self->priv->tree; 708 | _tmp33_ = col; 709 | gtk_tree_view_append_column (_tmp32_, _tmp33_); 710 | _tmp34_ = self->priv->tree; 711 | _tmp35_ = gtk_tree_view_get_selection (_tmp34_); 712 | gtk_tree_selection_set_mode (_tmp35_, GTK_SELECTION_SINGLE); 713 | _tmp36_ = gtk_builder_get_object (builder, "cancel_button"); 714 | _tmp37_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp36_, GTK_TYPE_BUTTON) ? ((GtkButton*) _tmp36_) : NULL); 715 | cancel_button = _tmp37_; 716 | _tmp38_ = g_signal_connect_object ((GtkObject*) self, "destroy", (GCallback) ___lambda36__gtk_object_destroy, self, 0); 717 | _data6_->destroy_handler_id = _tmp38_; 718 | _tmp39_ = cancel_button; 719 | g_signal_connect_object (_tmp39_, "clicked", (GCallback) ___lambda37__gtk_button_clicked, self, 0); 720 | _tmp40_ = self->priv->tree; 721 | g_signal_connect_object ((GtkWidget*) _tmp40_, "scroll-event", (GCallback) ___lambda38__gtk_widget_scroll_event, self, 0); 722 | _tmp41_ = g_strdup (""); 723 | _data6_->full = _tmp41_; 724 | _data6_->is_dragging = FALSE; 725 | _data6_->press_y = -1.0; 726 | _data6_->press_time = (guint32) 0; 727 | _data6_->last_y = -1.0; 728 | _data6_->last_time = (guint32) 0; 729 | _tmp42_ = self->priv->tree; 730 | g_signal_connect_data ((GtkWidget*) _tmp42_, "button-press-event", (GCallback) ___lambda39__gtk_widget_button_press_event, block6_data_ref (_data6_), (GClosureNotify) block6_data_unref, 0); 731 | _data6_->_delta = 0.0; 732 | _tmp43_ = self->priv->tree; 733 | g_signal_connect_data ((GtkWidget*) _tmp43_, "motion-notify-event", (GCallback) ___lambda40__gtk_widget_motion_notify_event, block6_data_ref (_data6_), (GClosureNotify) block6_data_unref, 0); 734 | _tmp44_ = self->priv->tree; 735 | g_signal_connect_data ((GtkWidget*) _tmp44_, "button-release-event", (GCallback) ___lambda41__gtk_widget_button_release_event, block6_data_ref (_data6_), (GClosureNotify) block6_data_unref, 0); 736 | _tmp46_ = start_dir; 737 | if (_tmp46_ != NULL) { 738 | const gchar* _tmp47_ = NULL; 739 | gchar* _tmp48_ = NULL; 740 | _tmp47_ = start_dir; 741 | _tmp48_ = g_strdup (_tmp47_); 742 | _g_free0 (_tmp45_); 743 | _tmp45_ = _tmp48_; 744 | } else { 745 | gchar* _tmp49_ = NULL; 746 | _tmp49_ = g_get_current_dir (); 747 | _g_free0 (_tmp45_); 748 | _tmp45_ = _tmp49_; 749 | } 750 | _tmp50_ = g_strdup (_tmp45_); 751 | _g_free0 (self->priv->cwd); 752 | self->priv->cwd = _tmp50_; 753 | _tmp51_ = self->priv->cwd; 754 | _tmp52_ = _data6_->ext; 755 | simple_file_picker_change_dir (self, _tmp51_, _tmp52_); 756 | gtk_widget_show_all ((GtkWidget*) self); 757 | _g_free0 (_tmp45_); 758 | _g_object_unref0 (cancel_button); 759 | _g_object_unref0 (col); 760 | _g_object_unref0 (renderer); 761 | _g_object_unref0 (main_vbox); 762 | _g_object_unref0 (builder); 763 | _g_free0 (ui_template); 764 | block6_data_unref (_data6_); 765 | _data6_ = NULL; 766 | return self; 767 | } 768 | 769 | 770 | SimpleFilePicker* simple_file_picker_new (GtkWindow* parent, GeeSet* ext, const gchar* start_dir, GError** error) { 771 | return simple_file_picker_construct (TYPE_SIMPLE_FILE_PICKER, parent, ext, start_dir, error); 772 | } 773 | 774 | 775 | static gboolean simple_file_picker_get_path_at_event (SimpleFilePicker* self, GdkEventButton* event, gboolean* is_dir, gchar** full) { 776 | gboolean _vala_is_dir = FALSE; 777 | gchar* _vala_full = NULL; 778 | gboolean result = FALSE; 779 | gint tx = 0; 780 | GdkEventButton _tmp0_ = {0}; 781 | gdouble _tmp1_ = 0.0; 782 | gint ty = 0; 783 | GdkEventButton _tmp2_ = {0}; 784 | gdouble _tmp3_ = 0.0; 785 | GtkTreePath* path = NULL; 786 | GtkTreeViewColumn* column = NULL; 787 | gint cx = 0; 788 | gint cy = 0; 789 | GtkTreeView* _tmp4_ = NULL; 790 | gint _tmp5_ = 0; 791 | gint _tmp6_ = 0; 792 | GtkTreePath* _tmp7_ = NULL; 793 | GtkTreeViewColumn* _tmp8_ = NULL; 794 | gint _tmp9_ = 0; 795 | gint _tmp10_ = 0; 796 | gboolean _tmp11_ = FALSE; 797 | GtkTreeViewColumn* _tmp12_ = NULL; 798 | GtkTreeIter iter = {0}; 799 | GtkTreeModel* model = NULL; 800 | GtkTreeView* _tmp13_ = NULL; 801 | GtkTreeModel* _tmp14_ = NULL; 802 | GtkTreeModel* _tmp15_ = NULL; 803 | GtkTreeModel* _tmp16_ = NULL; 804 | GtkTreePath* _tmp17_ = NULL; 805 | GtkTreeIter _tmp18_ = {0}; 806 | gboolean _tmp19_ = FALSE; 807 | GtkListStore* _tmp20_ = NULL; 808 | GtkTreeIter _tmp21_ = {0}; 809 | g_return_val_if_fail (self != NULL, FALSE); 810 | g_return_val_if_fail (event != NULL, FALSE); 811 | _tmp0_ = *event; 812 | _tmp1_ = _tmp0_.x; 813 | tx = (gint) _tmp1_; 814 | _tmp2_ = *event; 815 | _tmp3_ = _tmp2_.y; 816 | ty = (gint) _tmp3_; 817 | _tmp4_ = self->priv->tree; 818 | _tmp5_ = tx; 819 | _tmp6_ = ty; 820 | _tmp11_ = gtk_tree_view_get_path_at_pos (_tmp4_, _tmp5_, _tmp6_, &_tmp7_, &_tmp8_, &_tmp9_, &_tmp10_); 821 | _gtk_tree_path_free0 (path); 822 | path = _tmp7_; 823 | _g_object_unref0 (column); 824 | _tmp12_ = _g_object_ref0 (_tmp8_); 825 | column = _tmp12_; 826 | cx = _tmp9_; 827 | cy = _tmp10_; 828 | if (!_tmp11_) { 829 | result = FALSE; 830 | _g_object_unref0 (column); 831 | _gtk_tree_path_free0 (path); 832 | if (is_dir) { 833 | *is_dir = _vala_is_dir; 834 | } 835 | if (full) { 836 | *full = _vala_full; 837 | } else { 838 | _g_free0 (_vala_full); 839 | } 840 | return result; 841 | } 842 | _tmp13_ = self->priv->tree; 843 | _tmp14_ = gtk_tree_view_get_model (_tmp13_); 844 | _tmp15_ = _g_object_ref0 (_tmp14_); 845 | model = _tmp15_; 846 | _tmp16_ = model; 847 | _tmp17_ = path; 848 | _tmp19_ = gtk_tree_model_get_iter (_tmp16_, &_tmp18_, _tmp17_); 849 | iter = _tmp18_; 850 | if (!_tmp19_) { 851 | result = FALSE; 852 | _g_object_unref0 (model); 853 | _g_object_unref0 (column); 854 | _gtk_tree_path_free0 (path); 855 | if (is_dir) { 856 | *is_dir = _vala_is_dir; 857 | } 858 | if (full) { 859 | *full = _vala_full; 860 | } else { 861 | _g_free0 (_vala_full); 862 | } 863 | return result; 864 | } 865 | _tmp20_ = self->priv->store; 866 | _tmp21_ = iter; 867 | gtk_tree_model_get ((GtkTreeModel*) _tmp20_, &_tmp21_, 2, &_vala_is_dir, 1, &_vala_full, -1); 868 | result = TRUE; 869 | _g_object_unref0 (model); 870 | _g_object_unref0 (column); 871 | _gtk_tree_path_free0 (path); 872 | if (is_dir) { 873 | *is_dir = _vala_is_dir; 874 | } 875 | if (full) { 876 | *full = _vala_full; 877 | } else { 878 | _g_free0 (_vala_full); 879 | } 880 | return result; 881 | } 882 | 883 | 884 | static gint ___lambda42_ (SimpleFilePicker* self, const gchar* a, const gchar* b) { 885 | gint result = 0; 886 | gint _tmp0_ = 0; 887 | const gchar* _tmp1_ = NULL; 888 | const gchar* _tmp2_ = NULL; 889 | g_return_val_if_fail (a != NULL, 0); 890 | g_return_val_if_fail (b != NULL, 0); 891 | _tmp1_ = a; 892 | _tmp2_ = b; 893 | if (g_strcmp0 (_tmp1_, _tmp2_) == 0) { 894 | _tmp0_ = 0; 895 | } else { 896 | gint _tmp3_ = 0; 897 | const gchar* _tmp4_ = NULL; 898 | const gchar* _tmp5_ = NULL; 899 | _tmp4_ = a; 900 | _tmp5_ = b; 901 | if (g_strcmp0 (_tmp4_, _tmp5_) > 0) { 902 | _tmp3_ = 1; 903 | } else { 904 | _tmp3_ = -1; 905 | } 906 | _tmp0_ = _tmp3_; 907 | } 908 | result = _tmp0_; 909 | return result; 910 | } 911 | 912 | 913 | static gint ____lambda42__gcompare_data_func (gconstpointer a, gconstpointer b, gpointer self) { 914 | gint result; 915 | result = ___lambda42_ ((SimpleFilePicker*) self, (const gchar*) a, (const gchar*) b); 916 | return result; 917 | } 918 | 919 | 920 | static gint ___lambda43_ (SimpleFilePicker* self, const gchar* a, const gchar* b) { 921 | gint result = 0; 922 | gint _tmp0_ = 0; 923 | const gchar* _tmp1_ = NULL; 924 | const gchar* _tmp2_ = NULL; 925 | g_return_val_if_fail (a != NULL, 0); 926 | g_return_val_if_fail (b != NULL, 0); 927 | _tmp1_ = a; 928 | _tmp2_ = b; 929 | if (g_strcmp0 (_tmp1_, _tmp2_) == 0) { 930 | _tmp0_ = 0; 931 | } else { 932 | gint _tmp3_ = 0; 933 | const gchar* _tmp4_ = NULL; 934 | const gchar* _tmp5_ = NULL; 935 | _tmp4_ = a; 936 | _tmp5_ = b; 937 | if (g_strcmp0 (_tmp4_, _tmp5_) > 0) { 938 | _tmp3_ = 1; 939 | } else { 940 | _tmp3_ = -1; 941 | } 942 | _tmp0_ = _tmp3_; 943 | } 944 | result = _tmp0_; 945 | return result; 946 | } 947 | 948 | 949 | static gint ____lambda43__gcompare_data_func (gconstpointer a, gconstpointer b, gpointer self) { 950 | gint result; 951 | result = ___lambda43_ ((SimpleFilePicker*) self, (const gchar*) a, (const gchar*) b); 952 | return result; 953 | } 954 | 955 | 956 | static void simple_file_picker_change_dir (SimpleFilePicker* self, const gchar* path, GeeSet* extensions) { 957 | const gchar* _tmp0_ = NULL; 958 | gchar* _tmp1_ = NULL; 959 | GError * _inner_error_ = NULL; 960 | g_return_if_fail (self != NULL); 961 | g_return_if_fail (path != NULL); 962 | g_return_if_fail (extensions != NULL); 963 | _tmp0_ = path; 964 | _tmp1_ = g_strdup (_tmp0_); 965 | _g_free0 (self->priv->current_dir); 966 | self->priv->current_dir = _tmp1_; 967 | { 968 | GtkListStore* _tmp2_ = NULL; 969 | const gchar* _tmp3_ = NULL; 970 | GeeArrayList* dirs = NULL; 971 | GeeArrayList* _tmp11_ = NULL; 972 | GeeArrayList* files = NULL; 973 | GeeArrayList* _tmp12_ = NULL; 974 | GDir* dir = NULL; 975 | const gchar* _tmp13_ = NULL; 976 | GDir* _tmp14_ = NULL; 977 | gchar* name = NULL; 978 | GeeArrayList* _tmp41_ = NULL; 979 | GeeArrayList* _tmp42_ = NULL; 980 | const gchar* _tmp85_ = NULL; 981 | gchar* _tmp86_ = NULL; 982 | GtkLabel* _tmp87_ = NULL; 983 | const gchar* _tmp88_ = NULL; 984 | _tmp2_ = self->priv->store; 985 | gtk_list_store_clear (_tmp2_); 986 | _tmp3_ = path; 987 | if (g_strcmp0 (_tmp3_, "/") != 0) { 988 | GtkTreeIter pit = {0}; 989 | GtkListStore* _tmp4_ = NULL; 990 | GtkTreeIter _tmp5_ = {0}; 991 | GtkListStore* _tmp6_ = NULL; 992 | GtkTreeIter _tmp7_ = {0}; 993 | const gchar* _tmp8_ = NULL; 994 | gchar* _tmp9_ = NULL; 995 | gchar* _tmp10_ = NULL; 996 | _tmp4_ = self->priv->store; 997 | gtk_list_store_append (_tmp4_, &_tmp5_); 998 | pit = _tmp5_; 999 | _tmp6_ = self->priv->store; 1000 | _tmp7_ = pit; 1001 | _tmp8_ = path; 1002 | _tmp9_ = g_path_get_dirname (_tmp8_); 1003 | _tmp10_ = _tmp9_; 1004 | gtk_list_store_set (_tmp6_, &_tmp7_, 0, "..", 1, _tmp10_, 2, TRUE, -1); 1005 | _g_free0 (_tmp10_); 1006 | } 1007 | _tmp11_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL); 1008 | dirs = _tmp11_; 1009 | _tmp12_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL); 1010 | files = _tmp12_; 1011 | _tmp13_ = path; 1012 | _tmp14_ = g_dir_open (_tmp13_, (guint) 0, &_inner_error_); 1013 | dir = _tmp14_; 1014 | if (G_UNLIKELY (_inner_error_ != NULL)) { 1015 | _g_object_unref0 (files); 1016 | _g_object_unref0 (dirs); 1017 | goto __catch47_g_error; 1018 | } 1019 | while (TRUE) { 1020 | GDir* _tmp15_ = NULL; 1021 | const gchar* _tmp16_ = NULL; 1022 | gchar* _tmp17_ = NULL; 1023 | const gchar* _tmp18_ = NULL; 1024 | gchar* full = NULL; 1025 | const gchar* _tmp19_ = NULL; 1026 | const gchar* _tmp20_ = NULL; 1027 | gchar* _tmp21_ = NULL; 1028 | gboolean is_dir = FALSE; 1029 | const gchar* _tmp22_ = NULL; 1030 | gboolean _tmp23_ = FALSE; 1031 | gboolean _tmp24_ = FALSE; 1032 | _tmp15_ = dir; 1033 | _tmp16_ = g_dir_read_name (_tmp15_); 1034 | _tmp17_ = g_strdup (_tmp16_); 1035 | _g_free0 (name); 1036 | name = _tmp17_; 1037 | _tmp18_ = name; 1038 | if (!(_tmp18_ != NULL)) { 1039 | break; 1040 | } 1041 | _tmp19_ = path; 1042 | _tmp20_ = name; 1043 | _tmp21_ = g_build_filename (_tmp19_, _tmp20_, NULL); 1044 | full = _tmp21_; 1045 | _tmp22_ = full; 1046 | _tmp23_ = g_file_test (_tmp22_, G_FILE_TEST_IS_DIR); 1047 | is_dir = _tmp23_; 1048 | _tmp24_ = is_dir; 1049 | if (_tmp24_) { 1050 | GeeArrayList* _tmp25_ = NULL; 1051 | const gchar* _tmp26_ = NULL; 1052 | _tmp25_ = dirs; 1053 | _tmp26_ = name; 1054 | gee_abstract_collection_add ((GeeAbstractCollection*) _tmp25_, _tmp26_); 1055 | _g_free0 (full); 1056 | continue; 1057 | } 1058 | { 1059 | GeeIterator* _suffix_it = NULL; 1060 | GeeSet* _tmp27_ = NULL; 1061 | GeeIterator* _tmp28_ = NULL; 1062 | _tmp27_ = extensions; 1063 | _tmp28_ = gee_iterable_iterator ((GeeIterable*) _tmp27_); 1064 | _suffix_it = _tmp28_; 1065 | while (TRUE) { 1066 | GeeIterator* _tmp29_ = NULL; 1067 | gboolean _tmp30_ = FALSE; 1068 | gchar* suffix = NULL; 1069 | GeeIterator* _tmp31_ = NULL; 1070 | gpointer _tmp32_ = NULL; 1071 | const gchar* _tmp33_ = NULL; 1072 | const gchar* _tmp34_ = NULL; 1073 | gchar* _tmp35_ = NULL; 1074 | gchar* _tmp36_ = NULL; 1075 | gboolean _tmp37_ = FALSE; 1076 | gboolean _tmp38_ = FALSE; 1077 | _tmp29_ = _suffix_it; 1078 | _tmp30_ = gee_iterator_next (_tmp29_); 1079 | if (!_tmp30_) { 1080 | break; 1081 | } 1082 | _tmp31_ = _suffix_it; 1083 | _tmp32_ = gee_iterator_get (_tmp31_); 1084 | suffix = (gchar*) _tmp32_; 1085 | _tmp33_ = name; 1086 | _tmp34_ = suffix; 1087 | _tmp35_ = g_strconcat (".", _tmp34_, NULL); 1088 | _tmp36_ = _tmp35_; 1089 | _tmp37_ = g_str_has_suffix (_tmp33_, _tmp36_); 1090 | _tmp38_ = _tmp37_; 1091 | _g_free0 (_tmp36_); 1092 | if (_tmp38_) { 1093 | GeeArrayList* _tmp39_ = NULL; 1094 | const gchar* _tmp40_ = NULL; 1095 | _tmp39_ = files; 1096 | _tmp40_ = name; 1097 | gee_abstract_collection_add ((GeeAbstractCollection*) _tmp39_, _tmp40_); 1098 | _g_free0 (suffix); 1099 | break; 1100 | } 1101 | _g_free0 (suffix); 1102 | } 1103 | _g_object_unref0 (_suffix_it); 1104 | } 1105 | _g_free0 (full); 1106 | } 1107 | _tmp41_ = dirs; 1108 | gee_list_sort ((GeeList*) _tmp41_, ____lambda42__gcompare_data_func, g_object_ref (self), g_object_unref); 1109 | _tmp42_ = files; 1110 | gee_list_sort ((GeeList*) _tmp42_, ____lambda43__gcompare_data_func, g_object_ref (self), g_object_unref); 1111 | { 1112 | GeeArrayList* _d_list = NULL; 1113 | GeeArrayList* _tmp43_ = NULL; 1114 | GeeArrayList* _tmp44_ = NULL; 1115 | gint _d_size = 0; 1116 | GeeArrayList* _tmp45_ = NULL; 1117 | gint _tmp46_ = 0; 1118 | gint _tmp47_ = 0; 1119 | gint _d_index = 0; 1120 | _tmp43_ = dirs; 1121 | _tmp44_ = _g_object_ref0 (_tmp43_); 1122 | _d_list = _tmp44_; 1123 | _tmp45_ = _d_list; 1124 | _tmp46_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp45_); 1125 | _tmp47_ = _tmp46_; 1126 | _d_size = _tmp47_; 1127 | _d_index = -1; 1128 | while (TRUE) { 1129 | gint _tmp48_ = 0; 1130 | gint _tmp49_ = 0; 1131 | gint _tmp50_ = 0; 1132 | gchar* d = NULL; 1133 | GeeArrayList* _tmp51_ = NULL; 1134 | gint _tmp52_ = 0; 1135 | gpointer _tmp53_ = NULL; 1136 | gchar* full = NULL; 1137 | const gchar* _tmp54_ = NULL; 1138 | const gchar* _tmp55_ = NULL; 1139 | gchar* _tmp56_ = NULL; 1140 | GtkTreeIter it = {0}; 1141 | GtkListStore* _tmp57_ = NULL; 1142 | GtkTreeIter _tmp58_ = {0}; 1143 | GtkListStore* _tmp59_ = NULL; 1144 | GtkTreeIter _tmp60_ = {0}; 1145 | const gchar* _tmp61_ = NULL; 1146 | gchar* _tmp62_ = NULL; 1147 | gchar* _tmp63_ = NULL; 1148 | const gchar* _tmp64_ = NULL; 1149 | _tmp48_ = _d_index; 1150 | _d_index = _tmp48_ + 1; 1151 | _tmp49_ = _d_index; 1152 | _tmp50_ = _d_size; 1153 | if (!(_tmp49_ < _tmp50_)) { 1154 | break; 1155 | } 1156 | _tmp51_ = _d_list; 1157 | _tmp52_ = _d_index; 1158 | _tmp53_ = gee_abstract_list_get ((GeeAbstractList*) _tmp51_, _tmp52_); 1159 | d = (gchar*) _tmp53_; 1160 | _tmp54_ = path; 1161 | _tmp55_ = d; 1162 | _tmp56_ = g_build_filename (_tmp54_, _tmp55_, NULL); 1163 | full = _tmp56_; 1164 | _tmp57_ = self->priv->store; 1165 | gtk_list_store_append (_tmp57_, &_tmp58_); 1166 | it = _tmp58_; 1167 | _tmp59_ = self->priv->store; 1168 | _tmp60_ = it; 1169 | _tmp61_ = d; 1170 | _tmp62_ = g_strconcat (_tmp61_, "/", NULL); 1171 | _tmp63_ = _tmp62_; 1172 | _tmp64_ = full; 1173 | gtk_list_store_set (_tmp59_, &_tmp60_, 0, _tmp63_, 1, _tmp64_, 2, TRUE, -1); 1174 | _g_free0 (_tmp63_); 1175 | _g_free0 (full); 1176 | _g_free0 (d); 1177 | } 1178 | _g_object_unref0 (_d_list); 1179 | } 1180 | { 1181 | GeeArrayList* _f_list = NULL; 1182 | GeeArrayList* _tmp65_ = NULL; 1183 | GeeArrayList* _tmp66_ = NULL; 1184 | gint _f_size = 0; 1185 | GeeArrayList* _tmp67_ = NULL; 1186 | gint _tmp68_ = 0; 1187 | gint _tmp69_ = 0; 1188 | gint _f_index = 0; 1189 | _tmp65_ = files; 1190 | _tmp66_ = _g_object_ref0 (_tmp65_); 1191 | _f_list = _tmp66_; 1192 | _tmp67_ = _f_list; 1193 | _tmp68_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp67_); 1194 | _tmp69_ = _tmp68_; 1195 | _f_size = _tmp69_; 1196 | _f_index = -1; 1197 | while (TRUE) { 1198 | gint _tmp70_ = 0; 1199 | gint _tmp71_ = 0; 1200 | gint _tmp72_ = 0; 1201 | gchar* f = NULL; 1202 | GeeArrayList* _tmp73_ = NULL; 1203 | gint _tmp74_ = 0; 1204 | gpointer _tmp75_ = NULL; 1205 | gchar* full = NULL; 1206 | const gchar* _tmp76_ = NULL; 1207 | const gchar* _tmp77_ = NULL; 1208 | gchar* _tmp78_ = NULL; 1209 | GtkTreeIter it = {0}; 1210 | GtkListStore* _tmp79_ = NULL; 1211 | GtkTreeIter _tmp80_ = {0}; 1212 | GtkListStore* _tmp81_ = NULL; 1213 | GtkTreeIter _tmp82_ = {0}; 1214 | const gchar* _tmp83_ = NULL; 1215 | const gchar* _tmp84_ = NULL; 1216 | _tmp70_ = _f_index; 1217 | _f_index = _tmp70_ + 1; 1218 | _tmp71_ = _f_index; 1219 | _tmp72_ = _f_size; 1220 | if (!(_tmp71_ < _tmp72_)) { 1221 | break; 1222 | } 1223 | _tmp73_ = _f_list; 1224 | _tmp74_ = _f_index; 1225 | _tmp75_ = gee_abstract_list_get ((GeeAbstractList*) _tmp73_, _tmp74_); 1226 | f = (gchar*) _tmp75_; 1227 | _tmp76_ = path; 1228 | _tmp77_ = f; 1229 | _tmp78_ = g_build_filename (_tmp76_, _tmp77_, NULL); 1230 | full = _tmp78_; 1231 | _tmp79_ = self->priv->store; 1232 | gtk_list_store_append (_tmp79_, &_tmp80_); 1233 | it = _tmp80_; 1234 | _tmp81_ = self->priv->store; 1235 | _tmp82_ = it; 1236 | _tmp83_ = f; 1237 | _tmp84_ = full; 1238 | gtk_list_store_set (_tmp81_, &_tmp82_, 0, _tmp83_, 1, _tmp84_, 2, FALSE, -1); 1239 | _g_free0 (full); 1240 | _g_free0 (f); 1241 | } 1242 | _g_object_unref0 (_f_list); 1243 | } 1244 | _tmp85_ = path; 1245 | _tmp86_ = g_strdup (_tmp85_); 1246 | _g_free0 (self->priv->cwd); 1247 | self->priv->cwd = _tmp86_; 1248 | _tmp87_ = self->priv->path_label; 1249 | _tmp88_ = self->priv->cwd; 1250 | gtk_label_set_label (_tmp87_, _tmp88_); 1251 | _g_free0 (name); 1252 | _g_dir_close0 (dir); 1253 | _g_object_unref0 (files); 1254 | _g_object_unref0 (dirs); 1255 | } 1256 | goto __finally47; 1257 | __catch47_g_error: 1258 | { 1259 | GError* e = NULL; 1260 | FILE* _tmp89_ = NULL; 1261 | const gchar* _tmp90_ = NULL; 1262 | GError* _tmp91_ = NULL; 1263 | const gchar* _tmp92_ = NULL; 1264 | e = _inner_error_; 1265 | _inner_error_ = NULL; 1266 | _tmp89_ = stderr; 1267 | _tmp90_ = path; 1268 | _tmp91_ = e; 1269 | _tmp92_ = _tmp91_->message; 1270 | fprintf (_tmp89_, "Cannot open directory %s: %s\n", _tmp90_, _tmp92_); 1271 | _g_error_free0 (e); 1272 | } 1273 | __finally47: 1274 | { 1275 | } 1276 | if (G_UNLIKELY (_inner_error_ != NULL)) { 1277 | 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); 1278 | g_clear_error (&_inner_error_); 1279 | return; 1280 | } 1281 | } 1282 | 1283 | 1284 | static void g_cclosure_user_marshal_VOID__STRING_STRING (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) { 1285 | typedef void (*GMarshalFunc_VOID__STRING_STRING) (gpointer data1, const char* arg_1, const char* arg_2, gpointer data2); 1286 | register GMarshalFunc_VOID__STRING_STRING callback; 1287 | register GCClosure * cc; 1288 | register gpointer data1; 1289 | register gpointer data2; 1290 | cc = (GCClosure *) closure; 1291 | g_return_if_fail (n_param_values == 3); 1292 | if (G_CCLOSURE_SWAP_DATA (closure)) { 1293 | data1 = closure->data; 1294 | data2 = param_values->data[0].v_pointer; 1295 | } else { 1296 | data1 = param_values->data[0].v_pointer; 1297 | data2 = closure->data; 1298 | } 1299 | callback = (GMarshalFunc_VOID__STRING_STRING) (marshal_data ? marshal_data : cc->callback); 1300 | callback (data1, g_value_get_string (param_values + 1), g_value_get_string (param_values + 2), data2); 1301 | } 1302 | 1303 | 1304 | static void simple_file_picker_class_init (SimpleFilePickerClass * klass) { 1305 | simple_file_picker_parent_class = g_type_class_peek_parent (klass); 1306 | g_type_class_add_private (klass, sizeof (SimpleFilePickerPrivate)); 1307 | G_OBJECT_CLASS (klass)->finalize = simple_file_picker_finalize; 1308 | g_signal_new ("file_selected", TYPE_SIMPLE_FILE_PICKER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__STRING_STRING, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); 1309 | } 1310 | 1311 | 1312 | static void simple_file_picker_instance_init (SimpleFilePicker * self) { 1313 | self->priv = SIMPLE_FILE_PICKER_GET_PRIVATE (self); 1314 | } 1315 | 1316 | 1317 | static void simple_file_picker_finalize (GObject* obj) { 1318 | SimpleFilePicker * self; 1319 | self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SIMPLE_FILE_PICKER, SimpleFilePicker); 1320 | _g_object_unref0 (self->priv->store); 1321 | _g_object_unref0 (self->priv->tree); 1322 | _g_free0 (self->priv->cwd); 1323 | _g_object_unref0 (self->priv->path_label); 1324 | _g_free0 (self->priv->current_dir); 1325 | G_OBJECT_CLASS (simple_file_picker_parent_class)->finalize (obj); 1326 | } 1327 | 1328 | 1329 | GType simple_file_picker_get_type (void) { 1330 | static volatile gsize simple_file_picker_type_id__volatile = 0; 1331 | if (g_once_init_enter (&simple_file_picker_type_id__volatile)) { 1332 | static const GTypeInfo g_define_type_info = { sizeof (SimpleFilePickerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) simple_file_picker_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SimpleFilePicker), 0, (GInstanceInitFunc) simple_file_picker_instance_init, NULL }; 1333 | GType simple_file_picker_type_id; 1334 | simple_file_picker_type_id = g_type_register_static (GTK_TYPE_WINDOW, "SimpleFilePicker", &g_define_type_info, 0); 1335 | g_once_init_leave (&simple_file_picker_type_id__volatile, simple_file_picker_type_id); 1336 | } 1337 | return simple_file_picker_type_id__volatile; 1338 | } 1339 | 1340 | 1341 | 1342 | -------------------------------------------------------------------------------- /retrocore.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | #define TYPE_RETRO_CORE (retro_core_get_type ()) 13 | #define RETRO_CORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_RETRO_CORE, RetroCore)) 14 | #define RETRO_CORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_RETRO_CORE, RetroCoreClass)) 15 | #define IS_RETRO_CORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_RETRO_CORE)) 16 | #define IS_RETRO_CORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_RETRO_CORE)) 17 | #define RETRO_CORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_RETRO_CORE, RetroCoreClass)) 18 | 19 | typedef struct _RetroCore RetroCore; 20 | typedef struct _RetroCoreClass RetroCoreClass; 21 | typedef struct _RetroCorePrivate RetroCorePrivate; 22 | 23 | #define RETRO_CORE_TYPE_RETRO_GAME_INFO (retro_core_retro_game_info_get_type ()) 24 | typedef struct _RetroCoreRetroGameInfo RetroCoreRetroGameInfo; 25 | 26 | #define RETRO_CORE_TYPE_RETRO_SYSTEM_AV_INFO (retro_core_retro_system_av_info_get_type ()) 27 | 28 | #define RETRO_CORE_TYPE_RETRO_GAME_GEOMETRY (retro_core_retro_game_geometry_get_type ()) 29 | typedef struct _RetroCoreRetroGameGeometry RetroCoreRetroGameGeometry; 30 | 31 | #define RETRO_CORE_TYPE_RETRO_SYSTEM_TIMING (retro_core_retro_system_timing_get_type ()) 32 | typedef struct _RetroCoreRetroSystemTiming RetroCoreRetroSystemTiming; 33 | typedef struct _RetroCoreRetroSystemAvInfo RetroCoreRetroSystemAvInfo; 34 | 35 | #define RETRO_CORE_TYPE_RETRO_PIXEL_FORMAT (retro_core_retro_pixel_format_get_type ()) 36 | 37 | #define RETRO_CORE_TYPE_RETRO_ENVIRONMENT_SET (retro_core_retro_environment_set_get_type ()) 38 | 39 | #define RETRO_CORE_TYPE_RETRO_ENVIRONMENT_GET (retro_core_retro_environment_get_get_type ()) 40 | #define _g_module_close0(var) ((var == NULL) ? NULL : (var = (g_module_close (var), NULL))) 41 | 42 | #define RETRO_CORE_TYPE_RETRO_VARIABLE (retro_core_retro_variable_get_type ()) 43 | typedef struct _RetroCoreRetroVariable RetroCoreRetroVariable; 44 | #define _g_free0(var) (var = (g_free (var), NULL)) 45 | #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) 46 | #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL))) 47 | 48 | typedef enum { 49 | PLUGIN_ERROR_SYMBOL_NOT_FOUND 50 | } PluginError; 51 | #define PLUGIN_ERROR plugin_error_quark () 52 | typedef void (*RetroCoreRetroInit) (); 53 | typedef void (*RetroCoreRetroDeinit) (); 54 | typedef guint (*RetroCoreRetroApiVersion) (); 55 | struct _RetroCoreRetroGameInfo { 56 | gchar* path; 57 | guint8* data; 58 | gint data_length1; 59 | gsize size; 60 | gchar* meta; 61 | }; 62 | 63 | typedef gboolean (*RetroCoreRetroLoadGame) (RetroCoreRetroGameInfo* game_info); 64 | typedef void (*RetroCoreRetroUnloadGame) (); 65 | typedef void (*RetroCoreRetroRun) (); 66 | typedef void (*RetroCoreRetroReset) (); 67 | struct _RetroCoreRetroGameGeometry { 68 | guint base_width; 69 | guint base_height; 70 | guint max_width; 71 | guint max_height; 72 | gfloat aspect_ratio; 73 | }; 74 | 75 | struct _RetroCoreRetroSystemTiming { 76 | gdouble fps; 77 | gdouble sample_rate; 78 | }; 79 | 80 | struct _RetroCoreRetroSystemAvInfo { 81 | RetroCoreRetroGameGeometry geometry; 82 | RetroCoreRetroSystemTiming timing; 83 | }; 84 | 85 | typedef void (*RetroCoreRetroGetSystemAvInfo) (RetroCoreRetroSystemAvInfo* info); 86 | typedef void* (*RetroCoreRetroGetMemoryData) (guint id); 87 | typedef gsize (*RetroCoreRetroGetMemorySize) (guint id); 88 | typedef gsize (*RetroCoreRetroSerializeSize) (); 89 | typedef gsize (*RetroCoreRetroSerialize) (void* data, gsize size); 90 | typedef gsize (*RetroCoreRetroUnserialize) (void* data, gsize size); 91 | struct _RetroCore { 92 | GObject parent_instance; 93 | RetroCorePrivate * priv; 94 | gboolean loaded; 95 | RetroCoreRetroInit retro_init; 96 | RetroCoreRetroDeinit retro_deinit; 97 | RetroCoreRetroApiVersion retro_api_version; 98 | RetroCoreRetroLoadGame retro_load_game; 99 | RetroCoreRetroUnloadGame retro_unload_game; 100 | RetroCoreRetroRun retro_run; 101 | RetroCoreRetroReset retro_reset; 102 | RetroCoreRetroGetSystemAvInfo retro_get_system_av_info; 103 | RetroCoreRetroGetMemoryData retro_get_memory_data; 104 | RetroCoreRetroGetMemorySize retro_get_memory_size; 105 | RetroCoreRetroSerializeSize retro_serialize_size; 106 | RetroCoreRetroSerialize retro_serialize; 107 | RetroCoreRetroUnserialize retro_unserialize; 108 | gchar* game_checksum; 109 | }; 110 | 111 | struct _RetroCoreClass { 112 | GObjectClass parent_class; 113 | }; 114 | 115 | struct _RetroCorePrivate { 116 | GModule* module; 117 | }; 118 | 119 | typedef enum { 120 | RETRO_CORE_RETRO_PIXEL_FORMAT__0RGB1555 = 0, 121 | RETRO_CORE_RETRO_PIXEL_FORMAT_XRGB8888 = 1, 122 | RETRO_CORE_RETRO_PIXEL_FORMAT_RGB565 = 2 123 | } RetroCoreRetroPixelFormat; 124 | 125 | typedef enum { 126 | RETRO_CORE_RETRO_ENVIRONMENT_SET_PIXEL_FORMAT = 10 127 | } RetroCoreRetroEnvironmentSet; 128 | 129 | typedef enum { 130 | RETRO_CORE_RETRO_ENVIRONMENT_GET_VARIABLE = 15, 131 | RETRO_CORE_RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY = 9, 132 | RETRO_CORE_RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY = 31, 133 | RETRO_CORE_RETRO_ENVIRONMENT_GET_CAN_DUPE = 3 134 | } RetroCoreRetroEnvironmentGet; 135 | 136 | struct _RetroCoreRetroVariable { 137 | gchar* key; 138 | gchar* value; 139 | }; 140 | 141 | typedef void (*RetroCoreRetroVideoRefreshT) (void* data, guint width, guint height, gsize pitch); 142 | typedef gsize (*RetroCoreRetroAudioSampleBatchT) (void* data, gsize frames); 143 | typedef void (*RetroCoreRetroInputPollT) (); 144 | typedef gint16 (*RetroCoreRetroInputStateT) (guint port, guint device, guint index, guint id); 145 | typedef gboolean (*RetroCoreRetroEnvironmentT) (guint cmd, void* data); 146 | typedef void (*RetroCoreRetroSetEnvironment) (RetroCoreRetroEnvironmentT cb); 147 | typedef void (*RetroCoreRetroSetVideoRefresh) (RetroCoreRetroVideoRefreshT cb); 148 | typedef void (*RetroCoreRetroSetAudioSampleBatch) (RetroCoreRetroAudioSampleBatchT cb); 149 | typedef void (*RetroCoreRetroSetInputPoll) (RetroCoreRetroInputPollT cb); 150 | typedef void (*RetroCoreRetroSetInputState) (RetroCoreRetroInputStateT cb); 151 | 152 | static gpointer retro_core_parent_class = NULL; 153 | static RetroCoreRetroVariable* retro_core_environment_vars; 154 | static gint retro_core_environment_vars_length1; 155 | static RetroCoreRetroVariable* retro_core_environment_vars = NULL; 156 | static gint retro_core_environment_vars_length1 = 0; 157 | static gint _retro_core_environment_vars_size_ = 0; 158 | 159 | GQuark plugin_error_quark (void); 160 | GType retro_core_get_type (void) G_GNUC_CONST; 161 | GType retro_core_retro_game_info_get_type (void) G_GNUC_CONST; 162 | RetroCoreRetroGameInfo* retro_core_retro_game_info_dup (const RetroCoreRetroGameInfo* self); 163 | void retro_core_retro_game_info_free (RetroCoreRetroGameInfo* self); 164 | void retro_core_retro_game_info_copy (const RetroCoreRetroGameInfo* self, RetroCoreRetroGameInfo* dest); 165 | void retro_core_retro_game_info_destroy (RetroCoreRetroGameInfo* self); 166 | GType retro_core_retro_system_av_info_get_type (void) G_GNUC_CONST; 167 | GType retro_core_retro_game_geometry_get_type (void) G_GNUC_CONST; 168 | RetroCoreRetroGameGeometry* retro_core_retro_game_geometry_dup (const RetroCoreRetroGameGeometry* self); 169 | void retro_core_retro_game_geometry_free (RetroCoreRetroGameGeometry* self); 170 | GType retro_core_retro_system_timing_get_type (void) G_GNUC_CONST; 171 | RetroCoreRetroSystemTiming* retro_core_retro_system_timing_dup (const RetroCoreRetroSystemTiming* self); 172 | void retro_core_retro_system_timing_free (RetroCoreRetroSystemTiming* self); 173 | RetroCoreRetroSystemAvInfo* retro_core_retro_system_av_info_dup (const RetroCoreRetroSystemAvInfo* self); 174 | void retro_core_retro_system_av_info_free (RetroCoreRetroSystemAvInfo* self); 175 | #define RETRO_CORE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_RETRO_CORE, RetroCorePrivate)) 176 | enum { 177 | RETRO_CORE_DUMMY_PROPERTY 178 | }; 179 | void retro_core_unload (RetroCore* self); 180 | GType retro_core_retro_pixel_format_get_type (void) G_GNUC_CONST; 181 | GType retro_core_retro_environment_set_get_type (void) G_GNUC_CONST; 182 | GType retro_core_retro_environment_get_get_type (void) G_GNUC_CONST; 183 | GType retro_core_retro_variable_get_type (void) G_GNUC_CONST; 184 | RetroCoreRetroVariable* retro_core_retro_variable_dup (const RetroCoreRetroVariable* self); 185 | void retro_core_retro_variable_free (RetroCoreRetroVariable* self); 186 | void retro_core_retro_variable_copy (const RetroCoreRetroVariable* self, RetroCoreRetroVariable* dest); 187 | void retro_core_retro_variable_destroy (RetroCoreRetroVariable* self); 188 | RetroCore* retro_core_new (const gchar* so_path, const gchar* game_rom_path, RetroCoreRetroVariable* game_env_vars, int game_env_vars_length1, RetroCoreRetroVideoRefreshT video_refresh_cb, RetroCoreRetroAudioSampleBatchT audio_sample_batch_cb, RetroCoreRetroInputPollT input_poll_cb, RetroCoreRetroInputStateT input_state_cb, GError** error); 189 | RetroCore* retro_core_construct (GType object_type, const gchar* so_path, const gchar* game_rom_path, RetroCoreRetroVariable* game_env_vars, int game_env_vars_length1, RetroCoreRetroVideoRefreshT video_refresh_cb, RetroCoreRetroAudioSampleBatchT audio_sample_batch_cb, RetroCoreRetroInputPollT input_poll_cb, RetroCoreRetroInputStateT input_state_cb, GError** error); 190 | static void* retro_core_load_symbol (RetroCore* self, const gchar* name, GError** error); 191 | static RetroCoreRetroVariable* _vala_array_dup3 (RetroCoreRetroVariable* self, int length); 192 | static void _vala_RetroCoreRetroVariable_array_free (RetroCoreRetroVariable* array, gint array_length); 193 | static gboolean retro_core_environment_cb (guint cmd, void* data); 194 | static gboolean _retro_core_environment_cb_retro_core_retro_environment_t (guint cmd, void* data); 195 | static void retro_core_load_game (RetroCore* self, const gchar* game_rom_path, RetroCoreRetroGameInfo* game); 196 | static guint8* _vala_array_dup4 (guint8* self, int length); 197 | static guint8* _vala_array_dup5 (guint8* self, int length); 198 | static void retro_core_finalize (GObject* obj); 199 | 200 | 201 | GQuark plugin_error_quark (void) { 202 | return g_quark_from_static_string ("plugin_error-quark"); 203 | } 204 | 205 | 206 | GType retro_core_retro_pixel_format_get_type (void) { 207 | static volatile gsize retro_core_retro_pixel_format_type_id__volatile = 0; 208 | if (g_once_init_enter (&retro_core_retro_pixel_format_type_id__volatile)) { 209 | static const GEnumValue values[] = {{RETRO_CORE_RETRO_PIXEL_FORMAT__0RGB1555, "RETRO_CORE_RETRO_PIXEL_FORMAT__0RGB1555", "-0rgb1555"}, {RETRO_CORE_RETRO_PIXEL_FORMAT_XRGB8888, "RETRO_CORE_RETRO_PIXEL_FORMAT_XRGB8888", "xrgb8888"}, {RETRO_CORE_RETRO_PIXEL_FORMAT_RGB565, "RETRO_CORE_RETRO_PIXEL_FORMAT_RGB565", "rgb565"}, {0, NULL, NULL}}; 210 | GType retro_core_retro_pixel_format_type_id; 211 | retro_core_retro_pixel_format_type_id = g_enum_register_static ("RetroCoreRetroPixelFormat", values); 212 | g_once_init_leave (&retro_core_retro_pixel_format_type_id__volatile, retro_core_retro_pixel_format_type_id); 213 | } 214 | return retro_core_retro_pixel_format_type_id__volatile; 215 | } 216 | 217 | 218 | GType retro_core_retro_environment_set_get_type (void) { 219 | static volatile gsize retro_core_retro_environment_set_type_id__volatile = 0; 220 | if (g_once_init_enter (&retro_core_retro_environment_set_type_id__volatile)) { 221 | static const GEnumValue values[] = {{RETRO_CORE_RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, "RETRO_CORE_RETRO_ENVIRONMENT_SET_PIXEL_FORMAT", "pixel-format"}, {0, NULL, NULL}}; 222 | GType retro_core_retro_environment_set_type_id; 223 | retro_core_retro_environment_set_type_id = g_enum_register_static ("RetroCoreRetroEnvironmentSet", values); 224 | g_once_init_leave (&retro_core_retro_environment_set_type_id__volatile, retro_core_retro_environment_set_type_id); 225 | } 226 | return retro_core_retro_environment_set_type_id__volatile; 227 | } 228 | 229 | 230 | GType retro_core_retro_environment_get_get_type (void) { 231 | static volatile gsize retro_core_retro_environment_get_type_id__volatile = 0; 232 | if (g_once_init_enter (&retro_core_retro_environment_get_type_id__volatile)) { 233 | static const GEnumValue values[] = {{RETRO_CORE_RETRO_ENVIRONMENT_GET_VARIABLE, "RETRO_CORE_RETRO_ENVIRONMENT_GET_VARIABLE", "variable"}, {RETRO_CORE_RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, "RETRO_CORE_RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY", "system-directory"}, {RETRO_CORE_RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, "RETRO_CORE_RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY", "save-directory"}, {RETRO_CORE_RETRO_ENVIRONMENT_GET_CAN_DUPE, "RETRO_CORE_RETRO_ENVIRONMENT_GET_CAN_DUPE", "can-dupe"}, {0, NULL, NULL}}; 234 | GType retro_core_retro_environment_get_type_id; 235 | retro_core_retro_environment_get_type_id = g_enum_register_static ("RetroCoreRetroEnvironmentGet", values); 236 | g_once_init_leave (&retro_core_retro_environment_get_type_id__volatile, retro_core_retro_environment_get_type_id); 237 | } 238 | return retro_core_retro_environment_get_type_id__volatile; 239 | } 240 | 241 | 242 | static RetroCoreRetroVariable* _vala_array_dup3 (RetroCoreRetroVariable* self, int length) { 243 | RetroCoreRetroVariable* result; 244 | int i; 245 | result = g_new0 (RetroCoreRetroVariable, length); 246 | for (i = 0; i < length; i++) { 247 | RetroCoreRetroVariable _tmp0_ = {0}; 248 | retro_core_retro_variable_copy (&self[i], &_tmp0_); 249 | result[i] = _tmp0_; 250 | } 251 | return result; 252 | } 253 | 254 | 255 | static void _vala_RetroCoreRetroVariable_array_free (RetroCoreRetroVariable* array, gint array_length) { 256 | if (array != NULL) { 257 | int i; 258 | for (i = 0; i < array_length; i = i + 1) { 259 | retro_core_retro_variable_destroy (&array[i]); 260 | } 261 | } 262 | g_free (array); 263 | } 264 | 265 | 266 | static gboolean _retro_core_environment_cb_retro_core_retro_environment_t (guint cmd, void* data) { 267 | gboolean result; 268 | result = retro_core_environment_cb (cmd, data); 269 | return result; 270 | } 271 | 272 | 273 | static glong string_strnlen (gchar* str, glong maxlen) { 274 | glong result = 0L; 275 | gchar* end = NULL; 276 | gchar* _tmp0_ = NULL; 277 | glong _tmp1_ = 0L; 278 | gchar* _tmp2_ = NULL; 279 | gchar* _tmp3_ = NULL; 280 | _tmp0_ = str; 281 | _tmp1_ = maxlen; 282 | _tmp2_ = memchr (_tmp0_, 0, (gsize) _tmp1_); 283 | end = _tmp2_; 284 | _tmp3_ = end; 285 | if (_tmp3_ == NULL) { 286 | glong _tmp4_ = 0L; 287 | _tmp4_ = maxlen; 288 | result = _tmp4_; 289 | return result; 290 | } else { 291 | gchar* _tmp5_ = NULL; 292 | gchar* _tmp6_ = NULL; 293 | _tmp5_ = end; 294 | _tmp6_ = str; 295 | result = (glong) (_tmp5_ - _tmp6_); 296 | return result; 297 | } 298 | } 299 | 300 | 301 | static gchar* string_substring (const gchar* self, glong offset, glong len) { 302 | gchar* result = NULL; 303 | glong string_length = 0L; 304 | gboolean _tmp0_ = FALSE; 305 | glong _tmp1_ = 0L; 306 | glong _tmp8_ = 0L; 307 | glong _tmp14_ = 0L; 308 | glong _tmp17_ = 0L; 309 | glong _tmp18_ = 0L; 310 | glong _tmp19_ = 0L; 311 | glong _tmp20_ = 0L; 312 | glong _tmp21_ = 0L; 313 | gchar* _tmp22_ = NULL; 314 | g_return_val_if_fail (self != NULL, NULL); 315 | _tmp1_ = offset; 316 | if (_tmp1_ >= ((glong) 0)) { 317 | glong _tmp2_ = 0L; 318 | _tmp2_ = len; 319 | _tmp0_ = _tmp2_ >= ((glong) 0); 320 | } else { 321 | _tmp0_ = FALSE; 322 | } 323 | if (_tmp0_) { 324 | glong _tmp3_ = 0L; 325 | glong _tmp4_ = 0L; 326 | glong _tmp5_ = 0L; 327 | _tmp3_ = offset; 328 | _tmp4_ = len; 329 | _tmp5_ = string_strnlen ((gchar*) self, _tmp3_ + _tmp4_); 330 | string_length = _tmp5_; 331 | } else { 332 | gint _tmp6_ = 0; 333 | gint _tmp7_ = 0; 334 | _tmp6_ = strlen (self); 335 | _tmp7_ = _tmp6_; 336 | string_length = (glong) _tmp7_; 337 | } 338 | _tmp8_ = offset; 339 | if (_tmp8_ < ((glong) 0)) { 340 | glong _tmp9_ = 0L; 341 | glong _tmp10_ = 0L; 342 | glong _tmp11_ = 0L; 343 | _tmp9_ = string_length; 344 | _tmp10_ = offset; 345 | offset = _tmp9_ + _tmp10_; 346 | _tmp11_ = offset; 347 | g_return_val_if_fail (_tmp11_ >= ((glong) 0), NULL); 348 | } else { 349 | glong _tmp12_ = 0L; 350 | glong _tmp13_ = 0L; 351 | _tmp12_ = offset; 352 | _tmp13_ = string_length; 353 | g_return_val_if_fail (_tmp12_ <= _tmp13_, NULL); 354 | } 355 | _tmp14_ = len; 356 | if (_tmp14_ < ((glong) 0)) { 357 | glong _tmp15_ = 0L; 358 | glong _tmp16_ = 0L; 359 | _tmp15_ = string_length; 360 | _tmp16_ = offset; 361 | len = _tmp15_ - _tmp16_; 362 | } 363 | _tmp17_ = offset; 364 | _tmp18_ = len; 365 | _tmp19_ = string_length; 366 | g_return_val_if_fail ((_tmp17_ + _tmp18_) <= _tmp19_, NULL); 367 | _tmp20_ = offset; 368 | _tmp21_ = len; 369 | _tmp22_ = g_strndup (((gchar*) self) + _tmp20_, (gsize) _tmp21_); 370 | result = _tmp22_; 371 | return result; 372 | } 373 | 374 | 375 | RetroCore* retro_core_construct (GType object_type, const gchar* so_path, const gchar* game_rom_path, RetroCoreRetroVariable* game_env_vars, int game_env_vars_length1, RetroCoreRetroVideoRefreshT video_refresh_cb, RetroCoreRetroAudioSampleBatchT audio_sample_batch_cb, RetroCoreRetroInputPollT input_poll_cb, RetroCoreRetroInputStateT input_state_cb, GError** error) { 376 | RetroCore * self = NULL; 377 | const gchar* _tmp0_ = NULL; 378 | GModule* _tmp1_ = NULL; 379 | GModule* _tmp2_ = NULL; 380 | void* _tmp6_ = NULL; 381 | void* _tmp7_ = NULL; 382 | void* _tmp8_ = NULL; 383 | void* _tmp9_ = NULL; 384 | void* _tmp10_ = NULL; 385 | void* _tmp11_ = NULL; 386 | void* _tmp12_ = NULL; 387 | void* _tmp13_ = NULL; 388 | void* _tmp14_ = NULL; 389 | void* _tmp15_ = NULL; 390 | void* _tmp16_ = NULL; 391 | void* _tmp17_ = NULL; 392 | void* _tmp18_ = NULL; 393 | void* _tmp19_ = NULL; 394 | void* _tmp20_ = NULL; 395 | void* _tmp21_ = NULL; 396 | RetroCoreRetroSetEnvironment retro_set_environment = NULL; 397 | void* _tmp22_ = NULL; 398 | void* _tmp23_ = NULL; 399 | RetroCoreRetroSetVideoRefresh retro_set_video_refresh = NULL; 400 | void* _tmp24_ = NULL; 401 | void* _tmp25_ = NULL; 402 | RetroCoreRetroSetAudioSampleBatch retro_set_audio_sample_batch = NULL; 403 | void* _tmp26_ = NULL; 404 | void* _tmp27_ = NULL; 405 | RetroCoreRetroSetInputPoll retro_set_input_poll = NULL; 406 | void* _tmp28_ = NULL; 407 | void* _tmp29_ = NULL; 408 | RetroCoreRetroSetInputState retro_set_input_state = NULL; 409 | void* _tmp30_ = NULL; 410 | void* _tmp31_ = NULL; 411 | void* _tmp32_ = NULL; 412 | void* _tmp33_ = NULL; 413 | void* _tmp34_ = NULL; 414 | void* _tmp35_ = NULL; 415 | void* _tmp36_ = NULL; 416 | void* _tmp37_ = NULL; 417 | void* _tmp38_ = NULL; 418 | void* _tmp39_ = NULL; 419 | void* _tmp40_ = NULL; 420 | void* _tmp41_ = NULL; 421 | RetroCoreRetroVariable* _tmp42_ = NULL; 422 | gint _tmp42__length1 = 0; 423 | RetroCoreRetroVariable* _tmp43_ = NULL; 424 | gint _tmp43__length1 = 0; 425 | RetroCoreRetroSetEnvironment _tmp44_ = NULL; 426 | RetroCoreRetroSetVideoRefresh _tmp45_ = NULL; 427 | RetroCoreRetroVideoRefreshT _tmp46_ = NULL; 428 | RetroCoreRetroSetAudioSampleBatch _tmp47_ = NULL; 429 | RetroCoreRetroAudioSampleBatchT _tmp48_ = NULL; 430 | RetroCoreRetroSetInputPoll _tmp49_ = NULL; 431 | RetroCoreRetroInputPollT _tmp50_ = NULL; 432 | RetroCoreRetroSetInputState _tmp51_ = NULL; 433 | RetroCoreRetroInputStateT _tmp52_ = NULL; 434 | RetroCoreRetroInit _tmp53_ = NULL; 435 | RetroCoreRetroGameInfo game_info = {0}; 436 | RetroCoreRetroGameInfo _tmp54_ = {0}; 437 | const gchar* _tmp55_ = NULL; 438 | RetroCoreRetroLoadGame _tmp56_ = NULL; 439 | gboolean _tmp57_ = FALSE; 440 | RetroCoreRetroGameInfo _tmp59_ = {0}; 441 | guint8* _tmp60_ = NULL; 442 | gint _tmp60__length1 = 0; 443 | gchar* _tmp61_ = NULL; 444 | FILE* _tmp62_ = NULL; 445 | const gchar* _tmp63_ = NULL; 446 | gchar* _tmp64_ = NULL; 447 | gchar* _tmp65_ = NULL; 448 | GError * _inner_error_ = NULL; 449 | g_return_val_if_fail (so_path != NULL, NULL); 450 | g_return_val_if_fail (game_rom_path != NULL, NULL); 451 | self = (RetroCore*) g_object_new (object_type, NULL); 452 | _tmp0_ = so_path; 453 | _tmp1_ = g_module_open (_tmp0_, G_MODULE_BIND_LAZY); 454 | _g_module_close0 (self->priv->module); 455 | self->priv->module = _tmp1_; 456 | _tmp2_ = self->priv->module; 457 | if (_tmp2_ == NULL) { 458 | const gchar* _tmp3_ = NULL; 459 | const gchar* _tmp4_ = NULL; 460 | GError* _tmp5_ = NULL; 461 | _tmp3_ = so_path; 462 | _tmp4_ = g_module_error (); 463 | _tmp5_ = g_error_new (PLUGIN_ERROR, PLUGIN_ERROR_SYMBOL_NOT_FOUND, "Failed to open %s: %s", _tmp3_, _tmp4_); 464 | _inner_error_ = _tmp5_; 465 | if (_inner_error_->domain == PLUGIN_ERROR) { 466 | g_propagate_error (error, _inner_error_); 467 | _g_object_unref0 (self); 468 | return NULL; 469 | } else { 470 | 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); 471 | g_clear_error (&_inner_error_); 472 | return NULL; 473 | } 474 | } 475 | _tmp7_ = retro_core_load_symbol (self, "retro_init", &_inner_error_); 476 | _tmp6_ = _tmp7_; 477 | if (G_UNLIKELY (_inner_error_ != NULL)) { 478 | if (_inner_error_->domain == PLUGIN_ERROR) { 479 | g_propagate_error (error, _inner_error_); 480 | _g_object_unref0 (self); 481 | return NULL; 482 | } else { 483 | 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); 484 | g_clear_error (&_inner_error_); 485 | return NULL; 486 | } 487 | } 488 | self->retro_init = (RetroCoreRetroInit) _tmp6_; 489 | _tmp9_ = retro_core_load_symbol (self, "retro_deinit", &_inner_error_); 490 | _tmp8_ = _tmp9_; 491 | if (G_UNLIKELY (_inner_error_ != NULL)) { 492 | if (_inner_error_->domain == PLUGIN_ERROR) { 493 | g_propagate_error (error, _inner_error_); 494 | _g_object_unref0 (self); 495 | return NULL; 496 | } else { 497 | 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); 498 | g_clear_error (&_inner_error_); 499 | return NULL; 500 | } 501 | } 502 | self->retro_deinit = (RetroCoreRetroDeinit) _tmp8_; 503 | _tmp11_ = retro_core_load_symbol (self, "retro_api_version", &_inner_error_); 504 | _tmp10_ = _tmp11_; 505 | if (G_UNLIKELY (_inner_error_ != NULL)) { 506 | if (_inner_error_->domain == PLUGIN_ERROR) { 507 | g_propagate_error (error, _inner_error_); 508 | _g_object_unref0 (self); 509 | return NULL; 510 | } else { 511 | 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); 512 | g_clear_error (&_inner_error_); 513 | return NULL; 514 | } 515 | } 516 | self->retro_api_version = (RetroCoreRetroApiVersion) _tmp10_; 517 | _tmp13_ = retro_core_load_symbol (self, "retro_load_game", &_inner_error_); 518 | _tmp12_ = _tmp13_; 519 | if (G_UNLIKELY (_inner_error_ != NULL)) { 520 | if (_inner_error_->domain == PLUGIN_ERROR) { 521 | g_propagate_error (error, _inner_error_); 522 | _g_object_unref0 (self); 523 | return NULL; 524 | } else { 525 | 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); 526 | g_clear_error (&_inner_error_); 527 | return NULL; 528 | } 529 | } 530 | self->retro_load_game = (RetroCoreRetroLoadGame) _tmp12_; 531 | _tmp15_ = retro_core_load_symbol (self, "retro_unload_game", &_inner_error_); 532 | _tmp14_ = _tmp15_; 533 | if (G_UNLIKELY (_inner_error_ != NULL)) { 534 | if (_inner_error_->domain == PLUGIN_ERROR) { 535 | g_propagate_error (error, _inner_error_); 536 | _g_object_unref0 (self); 537 | return NULL; 538 | } else { 539 | 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); 540 | g_clear_error (&_inner_error_); 541 | return NULL; 542 | } 543 | } 544 | self->retro_unload_game = (RetroCoreRetroUnloadGame) _tmp14_; 545 | _tmp17_ = retro_core_load_symbol (self, "retro_run", &_inner_error_); 546 | _tmp16_ = _tmp17_; 547 | if (G_UNLIKELY (_inner_error_ != NULL)) { 548 | if (_inner_error_->domain == PLUGIN_ERROR) { 549 | g_propagate_error (error, _inner_error_); 550 | _g_object_unref0 (self); 551 | return NULL; 552 | } else { 553 | 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); 554 | g_clear_error (&_inner_error_); 555 | return NULL; 556 | } 557 | } 558 | self->retro_run = (RetroCoreRetroRun) _tmp16_; 559 | _tmp19_ = retro_core_load_symbol (self, "retro_reset", &_inner_error_); 560 | _tmp18_ = _tmp19_; 561 | if (G_UNLIKELY (_inner_error_ != NULL)) { 562 | if (_inner_error_->domain == PLUGIN_ERROR) { 563 | g_propagate_error (error, _inner_error_); 564 | _g_object_unref0 (self); 565 | return NULL; 566 | } else { 567 | 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); 568 | g_clear_error (&_inner_error_); 569 | return NULL; 570 | } 571 | } 572 | self->retro_reset = (RetroCoreRetroReset) _tmp18_; 573 | _tmp21_ = retro_core_load_symbol (self, "retro_set_environment", &_inner_error_); 574 | _tmp20_ = _tmp21_; 575 | if (G_UNLIKELY (_inner_error_ != NULL)) { 576 | if (_inner_error_->domain == PLUGIN_ERROR) { 577 | g_propagate_error (error, _inner_error_); 578 | _g_object_unref0 (self); 579 | return NULL; 580 | } else { 581 | 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); 582 | g_clear_error (&_inner_error_); 583 | return NULL; 584 | } 585 | } 586 | retro_set_environment = (RetroCoreRetroSetEnvironment) _tmp20_; 587 | _tmp23_ = retro_core_load_symbol (self, "retro_set_video_refresh", &_inner_error_); 588 | _tmp22_ = _tmp23_; 589 | if (G_UNLIKELY (_inner_error_ != NULL)) { 590 | if (_inner_error_->domain == PLUGIN_ERROR) { 591 | g_propagate_error (error, _inner_error_); 592 | _g_object_unref0 (self); 593 | return NULL; 594 | } else { 595 | 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); 596 | g_clear_error (&_inner_error_); 597 | return NULL; 598 | } 599 | } 600 | retro_set_video_refresh = (RetroCoreRetroSetVideoRefresh) _tmp22_; 601 | _tmp25_ = retro_core_load_symbol (self, "retro_set_audio_sample_batch", &_inner_error_); 602 | _tmp24_ = _tmp25_; 603 | if (G_UNLIKELY (_inner_error_ != NULL)) { 604 | if (_inner_error_->domain == PLUGIN_ERROR) { 605 | g_propagate_error (error, _inner_error_); 606 | _g_object_unref0 (self); 607 | return NULL; 608 | } else { 609 | 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); 610 | g_clear_error (&_inner_error_); 611 | return NULL; 612 | } 613 | } 614 | retro_set_audio_sample_batch = (RetroCoreRetroSetAudioSampleBatch) _tmp24_; 615 | _tmp27_ = retro_core_load_symbol (self, "retro_set_input_poll", &_inner_error_); 616 | _tmp26_ = _tmp27_; 617 | if (G_UNLIKELY (_inner_error_ != NULL)) { 618 | if (_inner_error_->domain == PLUGIN_ERROR) { 619 | g_propagate_error (error, _inner_error_); 620 | _g_object_unref0 (self); 621 | return NULL; 622 | } else { 623 | 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); 624 | g_clear_error (&_inner_error_); 625 | return NULL; 626 | } 627 | } 628 | retro_set_input_poll = (RetroCoreRetroSetInputPoll) _tmp26_; 629 | _tmp29_ = retro_core_load_symbol (self, "retro_set_input_state", &_inner_error_); 630 | _tmp28_ = _tmp29_; 631 | if (G_UNLIKELY (_inner_error_ != NULL)) { 632 | if (_inner_error_->domain == PLUGIN_ERROR) { 633 | g_propagate_error (error, _inner_error_); 634 | _g_object_unref0 (self); 635 | return NULL; 636 | } else { 637 | 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); 638 | g_clear_error (&_inner_error_); 639 | return NULL; 640 | } 641 | } 642 | retro_set_input_state = (RetroCoreRetroSetInputState) _tmp28_; 643 | _tmp31_ = retro_core_load_symbol (self, "retro_get_system_av_info", &_inner_error_); 644 | _tmp30_ = _tmp31_; 645 | if (G_UNLIKELY (_inner_error_ != NULL)) { 646 | if (_inner_error_->domain == PLUGIN_ERROR) { 647 | g_propagate_error (error, _inner_error_); 648 | _g_object_unref0 (self); 649 | return NULL; 650 | } else { 651 | 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); 652 | g_clear_error (&_inner_error_); 653 | return NULL; 654 | } 655 | } 656 | self->retro_get_system_av_info = (RetroCoreRetroGetSystemAvInfo) _tmp30_; 657 | _tmp33_ = retro_core_load_symbol (self, "retro_get_memory_data", &_inner_error_); 658 | _tmp32_ = _tmp33_; 659 | if (G_UNLIKELY (_inner_error_ != NULL)) { 660 | if (_inner_error_->domain == PLUGIN_ERROR) { 661 | g_propagate_error (error, _inner_error_); 662 | _g_object_unref0 (self); 663 | return NULL; 664 | } else { 665 | 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); 666 | g_clear_error (&_inner_error_); 667 | return NULL; 668 | } 669 | } 670 | self->retro_get_memory_data = (RetroCoreRetroGetMemoryData) _tmp32_; 671 | _tmp35_ = retro_core_load_symbol (self, "retro_get_memory_size", &_inner_error_); 672 | _tmp34_ = _tmp35_; 673 | if (G_UNLIKELY (_inner_error_ != NULL)) { 674 | if (_inner_error_->domain == PLUGIN_ERROR) { 675 | g_propagate_error (error, _inner_error_); 676 | _g_object_unref0 (self); 677 | return NULL; 678 | } else { 679 | 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); 680 | g_clear_error (&_inner_error_); 681 | return NULL; 682 | } 683 | } 684 | self->retro_get_memory_size = (RetroCoreRetroGetMemorySize) _tmp34_; 685 | _tmp37_ = retro_core_load_symbol (self, "retro_serialize_size", &_inner_error_); 686 | _tmp36_ = _tmp37_; 687 | if (G_UNLIKELY (_inner_error_ != NULL)) { 688 | if (_inner_error_->domain == PLUGIN_ERROR) { 689 | g_propagate_error (error, _inner_error_); 690 | _g_object_unref0 (self); 691 | return NULL; 692 | } else { 693 | 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); 694 | g_clear_error (&_inner_error_); 695 | return NULL; 696 | } 697 | } 698 | self->retro_serialize_size = (RetroCoreRetroSerializeSize) _tmp36_; 699 | _tmp39_ = retro_core_load_symbol (self, "retro_serialize", &_inner_error_); 700 | _tmp38_ = _tmp39_; 701 | if (G_UNLIKELY (_inner_error_ != NULL)) { 702 | if (_inner_error_->domain == PLUGIN_ERROR) { 703 | g_propagate_error (error, _inner_error_); 704 | _g_object_unref0 (self); 705 | return NULL; 706 | } else { 707 | 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); 708 | g_clear_error (&_inner_error_); 709 | return NULL; 710 | } 711 | } 712 | self->retro_serialize = (RetroCoreRetroSerialize) _tmp38_; 713 | _tmp41_ = retro_core_load_symbol (self, "retro_unserialize", &_inner_error_); 714 | _tmp40_ = _tmp41_; 715 | if (G_UNLIKELY (_inner_error_ != NULL)) { 716 | if (_inner_error_->domain == PLUGIN_ERROR) { 717 | g_propagate_error (error, _inner_error_); 718 | _g_object_unref0 (self); 719 | return NULL; 720 | } else { 721 | 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); 722 | g_clear_error (&_inner_error_); 723 | return NULL; 724 | } 725 | } 726 | self->retro_unserialize = (RetroCoreRetroUnserialize) _tmp40_; 727 | _tmp42_ = game_env_vars; 728 | _tmp42__length1 = game_env_vars_length1; 729 | _tmp43_ = (_tmp42_ != NULL) ? _vala_array_dup3 (_tmp42_, _tmp42__length1) : ((gpointer) _tmp42_); 730 | _tmp43__length1 = _tmp42__length1; 731 | retro_core_environment_vars = (_vala_RetroCoreRetroVariable_array_free (retro_core_environment_vars, retro_core_environment_vars_length1), NULL); 732 | retro_core_environment_vars = _tmp43_; 733 | retro_core_environment_vars_length1 = _tmp43__length1; 734 | _retro_core_environment_vars_size_ = retro_core_environment_vars_length1; 735 | _tmp44_ = retro_set_environment; 736 | _tmp44_ (_retro_core_environment_cb_retro_core_retro_environment_t); 737 | _tmp45_ = retro_set_video_refresh; 738 | _tmp46_ = video_refresh_cb; 739 | _tmp45_ (_tmp46_); 740 | _tmp47_ = retro_set_audio_sample_batch; 741 | _tmp48_ = audio_sample_batch_cb; 742 | _tmp47_ (_tmp48_); 743 | _tmp49_ = retro_set_input_poll; 744 | _tmp50_ = input_poll_cb; 745 | _tmp49_ (_tmp50_); 746 | _tmp51_ = retro_set_input_state; 747 | _tmp52_ = input_state_cb; 748 | _tmp51_ (_tmp52_); 749 | _tmp53_ = self->retro_init; 750 | _tmp53_ (); 751 | game_info = _tmp54_; 752 | _tmp55_ = game_rom_path; 753 | retro_core_load_game (self, _tmp55_, &game_info); 754 | _tmp56_ = self->retro_load_game; 755 | _tmp57_ = _tmp56_ (&game_info); 756 | if (!_tmp57_) { 757 | FILE* _tmp58_ = NULL; 758 | _tmp58_ = stderr; 759 | fprintf (_tmp58_, "Failed to load game\n"); 760 | retro_core_retro_game_info_destroy (&game_info); 761 | return self; 762 | } 763 | _tmp59_ = game_info; 764 | _tmp60_ = _tmp59_.data; 765 | _tmp60__length1 = _tmp59_.data_length1; 766 | _tmp61_ = g_compute_checksum_for_data (G_CHECKSUM_MD5, _tmp60_, _tmp60__length1); 767 | _g_free0 (self->game_checksum); 768 | self->game_checksum = _tmp61_; 769 | _tmp62_ = stdout; 770 | _tmp63_ = self->game_checksum; 771 | _tmp64_ = string_substring (_tmp63_, (glong) 0, (glong) 10); 772 | _tmp65_ = _tmp64_; 773 | fprintf (_tmp62_, "Checksum %s\n", _tmp65_); 774 | _g_free0 (_tmp65_); 775 | self->loaded = TRUE; 776 | retro_core_retro_game_info_destroy (&game_info); 777 | return self; 778 | } 779 | 780 | 781 | RetroCore* retro_core_new (const gchar* so_path, const gchar* game_rom_path, RetroCoreRetroVariable* game_env_vars, int game_env_vars_length1, RetroCoreRetroVideoRefreshT video_refresh_cb, RetroCoreRetroAudioSampleBatchT audio_sample_batch_cb, RetroCoreRetroInputPollT input_poll_cb, RetroCoreRetroInputStateT input_state_cb, GError** error) { 782 | return retro_core_construct (TYPE_RETRO_CORE, so_path, game_rom_path, game_env_vars, game_env_vars_length1, video_refresh_cb, audio_sample_batch_cb, input_poll_cb, input_state_cb, error); 783 | } 784 | 785 | 786 | static void* retro_core_load_symbol (RetroCore* self, const gchar* name, GError** error) { 787 | void* result = NULL; 788 | void* sym = NULL; 789 | gboolean _tmp0_ = FALSE; 790 | GModule* _tmp1_ = NULL; 791 | const gchar* _tmp2_ = NULL; 792 | void* _tmp3_ = NULL; 793 | gboolean _tmp4_ = FALSE; 794 | void* _tmp8_ = NULL; 795 | GError * _inner_error_ = NULL; 796 | g_return_val_if_fail (self != NULL, NULL); 797 | g_return_val_if_fail (name != NULL, NULL); 798 | sym = NULL; 799 | _tmp1_ = self->priv->module; 800 | _tmp2_ = name; 801 | _tmp4_ = g_module_symbol (_tmp1_, _tmp2_, &_tmp3_); 802 | sym = _tmp3_; 803 | if (!_tmp4_) { 804 | _tmp0_ = TRUE; 805 | } else { 806 | void* _tmp5_ = NULL; 807 | _tmp5_ = sym; 808 | _tmp0_ = _tmp5_ == NULL; 809 | } 810 | if (_tmp0_) { 811 | const gchar* _tmp6_ = NULL; 812 | GError* _tmp7_ = NULL; 813 | _tmp6_ = name; 814 | _tmp7_ = g_error_new (PLUGIN_ERROR, PLUGIN_ERROR_SYMBOL_NOT_FOUND, "Symbol %s not found", _tmp6_); 815 | _inner_error_ = _tmp7_; 816 | if (_inner_error_->domain == PLUGIN_ERROR) { 817 | g_propagate_error (error, _inner_error_); 818 | return NULL; 819 | } else { 820 | 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); 821 | g_clear_error (&_inner_error_); 822 | return NULL; 823 | } 824 | } 825 | _tmp8_ = sym; 826 | result = _tmp8_; 827 | return result; 828 | } 829 | 830 | 831 | static guint8* _vala_array_dup4 (guint8* self, int length) { 832 | return g_memdup (self, length * sizeof (guint8)); 833 | } 834 | 835 | 836 | static void retro_core_load_game (RetroCore* self, const gchar* game_rom_path, RetroCoreRetroGameInfo* game) { 837 | guint8* contents = NULL; 838 | gint contents_length1 = 0; 839 | gint _contents_size_ = 0; 840 | gchar* checksum = NULL; 841 | guint8* _tmp8_ = NULL; 842 | gint _tmp8__length1 = 0; 843 | gchar* _tmp9_ = NULL; 844 | FILE* _tmp10_ = NULL; 845 | const gchar* _tmp11_ = NULL; 846 | guint8* _tmp12_ = NULL; 847 | gint _tmp12__length1 = 0; 848 | guint8* _tmp13_ = NULL; 849 | gint _tmp13__length1 = 0; 850 | guint8* _tmp14_ = NULL; 851 | gint _tmp14__length1 = 0; 852 | GError * _inner_error_ = NULL; 853 | g_return_if_fail (self != NULL); 854 | g_return_if_fail (game_rom_path != NULL); 855 | g_return_if_fail (game != NULL); 856 | { 857 | GFile* file = NULL; 858 | const gchar* _tmp0_ = NULL; 859 | GFile* _tmp1_ = NULL; 860 | GFile* _tmp2_ = NULL; 861 | guint8* _tmp3_ = NULL; 862 | gsize _tmp4_; 863 | _tmp0_ = game_rom_path; 864 | _tmp1_ = g_file_new_for_path (_tmp0_); 865 | file = _tmp1_; 866 | _tmp2_ = file; 867 | g_file_load_contents (_tmp2_, NULL, &_tmp3_, &_tmp4_, NULL, &_inner_error_); 868 | contents = (g_free (contents), NULL); 869 | contents = _tmp3_; 870 | contents_length1 = _tmp4_; 871 | _contents_size_ = contents_length1; 872 | if (G_UNLIKELY (_inner_error_ != NULL)) { 873 | _g_object_unref0 (file); 874 | goto __catch22_g_error; 875 | } 876 | _g_object_unref0 (file); 877 | } 878 | goto __finally22; 879 | __catch22_g_error: 880 | { 881 | GError* e = NULL; 882 | FILE* _tmp5_ = NULL; 883 | GError* _tmp6_ = NULL; 884 | const gchar* _tmp7_ = NULL; 885 | e = _inner_error_; 886 | _inner_error_ = NULL; 887 | _tmp5_ = stderr; 888 | _tmp6_ = e; 889 | _tmp7_ = _tmp6_->message; 890 | fprintf (_tmp5_, "Failed to open game file: %s\n", _tmp7_); 891 | _g_error_free0 (e); 892 | contents = (g_free (contents), NULL); 893 | return; 894 | } 895 | __finally22: 896 | if (G_UNLIKELY (_inner_error_ != NULL)) { 897 | contents = (g_free (contents), NULL); 898 | 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); 899 | g_clear_error (&_inner_error_); 900 | return; 901 | } 902 | _tmp8_ = contents; 903 | _tmp8__length1 = contents_length1; 904 | _tmp9_ = g_compute_checksum_for_data (G_CHECKSUM_MD5, _tmp8_, _tmp8__length1); 905 | checksum = _tmp9_; 906 | _tmp10_ = stdout; 907 | _tmp11_ = checksum; 908 | fprintf (_tmp10_, "B Checksum %s\n", _tmp11_); 909 | _tmp12_ = contents; 910 | _tmp12__length1 = contents_length1; 911 | _tmp13_ = (_tmp12_ != NULL) ? _vala_array_dup4 (_tmp12_, _tmp12__length1) : ((gpointer) _tmp12_); 912 | _tmp13__length1 = _tmp12__length1; 913 | (*game).data = (g_free ((*game).data), NULL); 914 | (*game).data = _tmp13_; 915 | (*game).data_length1 = _tmp13__length1; 916 | _tmp14_ = contents; 917 | _tmp14__length1 = contents_length1; 918 | (*game).size = (gsize) _tmp14__length1; 919 | _g_free0 (checksum); 920 | contents = (g_free (contents), NULL); 921 | } 922 | 923 | 924 | static gboolean retro_core_environment_cb (guint cmd, void* data) { 925 | gboolean result = FALSE; 926 | guint _tmp0_ = 0U; 927 | _tmp0_ = cmd; 928 | switch (_tmp0_) { 929 | case RETRO_CORE_RETRO_ENVIRONMENT_GET_VARIABLE: 930 | { 931 | { 932 | RetroCoreRetroVariable* retrovar = NULL; 933 | void* _tmp1_ = NULL; 934 | RetroCoreRetroVariable* _tmp2_ = NULL; 935 | gint _tmp2__length1 = 0; 936 | FILE* _tmp16_ = NULL; 937 | RetroCoreRetroVariable* _tmp17_ = NULL; 938 | const gchar* _tmp18_ = NULL; 939 | _tmp1_ = data; 940 | retrovar = (RetroCoreRetroVariable*) _tmp1_; 941 | _tmp2_ = retro_core_environment_vars; 942 | _tmp2__length1 = retro_core_environment_vars_length1; 943 | { 944 | RetroCoreRetroVariable* game_env_var_collection = NULL; 945 | gint game_env_var_collection_length1 = 0; 946 | gint _game_env_var_collection_size_ = 0; 947 | gint game_env_var_it = 0; 948 | game_env_var_collection = _tmp2_; 949 | game_env_var_collection_length1 = _tmp2__length1; 950 | for (game_env_var_it = 0; game_env_var_it < _tmp2__length1; game_env_var_it = game_env_var_it + 1) { 951 | RetroCoreRetroVariable _tmp3_ = {0}; 952 | RetroCoreRetroVariable game_env_var = {0}; 953 | retro_core_retro_variable_copy (&game_env_var_collection[game_env_var_it], &_tmp3_); 954 | game_env_var = _tmp3_; 955 | { 956 | RetroCoreRetroVariable* _tmp4_ = NULL; 957 | const gchar* _tmp5_ = NULL; 958 | RetroCoreRetroVariable _tmp6_ = {0}; 959 | const gchar* _tmp7_ = NULL; 960 | RetroCoreRetroVariable _tmp8_ = {0}; 961 | const gchar* _tmp9_ = NULL; 962 | gchar* _tmp10_ = NULL; 963 | FILE* _tmp11_ = NULL; 964 | RetroCoreRetroVariable* _tmp12_ = NULL; 965 | const gchar* _tmp13_ = NULL; 966 | RetroCoreRetroVariable _tmp14_ = {0}; 967 | const gchar* _tmp15_ = NULL; 968 | _tmp4_ = retrovar; 969 | _tmp5_ = (*_tmp4_).key; 970 | _tmp6_ = game_env_var; 971 | _tmp7_ = _tmp6_.key; 972 | if (g_strcmp0 (_tmp5_, _tmp7_) != 0) { 973 | retro_core_retro_variable_destroy (&game_env_var); 974 | continue; 975 | } 976 | _tmp8_ = game_env_var; 977 | _tmp9_ = _tmp8_.value; 978 | _tmp10_ = g_strdup (_tmp9_); 979 | _g_free0 ((*retrovar).value); 980 | (*retrovar).value = _tmp10_; 981 | _tmp11_ = stdout; 982 | _tmp12_ = retrovar; 983 | _tmp13_ = (*_tmp12_).key; 984 | _tmp14_ = game_env_var; 985 | _tmp15_ = _tmp14_.value; 986 | fprintf (_tmp11_, "RetroEnvironmentGet.VARIABLE SET: '%s' TO '%s'\n", _tmp13_, _tmp15_); 987 | result = TRUE; 988 | retro_core_retro_variable_destroy (&game_env_var); 989 | return result; 990 | } 991 | } 992 | } 993 | _tmp16_ = stdout; 994 | _tmp17_ = retrovar; 995 | _tmp18_ = (*_tmp17_).key; 996 | fprintf (_tmp16_, "RetroEnvironmentGet.VARIABLE IGNORED: '%s'\n", _tmp18_); 997 | _g_free0 ((*retrovar).value); 998 | (*retrovar).value = NULL; 999 | result = FALSE; 1000 | return result; 1001 | } 1002 | } 1003 | case RETRO_CORE_RETRO_ENVIRONMENT_SET_PIXEL_FORMAT: 1004 | { 1005 | { 1006 | RetroCoreRetroPixelFormat* fmt = NULL; 1007 | void* _tmp19_ = NULL; 1008 | RetroCoreRetroPixelFormat* _tmp20_ = NULL; 1009 | _tmp19_ = data; 1010 | fmt = (RetroCoreRetroPixelFormat*) _tmp19_; 1011 | _tmp20_ = fmt; 1012 | if ((*_tmp20_) == RETRO_CORE_RETRO_PIXEL_FORMAT_RGB565) { 1013 | FILE* _tmp21_ = NULL; 1014 | _tmp21_ = stdout; 1015 | fprintf (_tmp21_, "RetroPixelFormat: RGB565\n"); 1016 | result = TRUE; 1017 | return result; 1018 | } 1019 | result = FALSE; 1020 | return result; 1021 | } 1022 | } 1023 | case RETRO_CORE_RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY: 1024 | { 1025 | { 1026 | const gchar** dir = NULL; 1027 | void* _tmp22_ = NULL; 1028 | const gchar** _tmp23_ = NULL; 1029 | const gchar* _tmp24_ = NULL; 1030 | _tmp22_ = data; 1031 | dir = (const gchar**) _tmp22_; 1032 | _tmp23_ = dir; 1033 | *_tmp23_ = "./.gambatte"; 1034 | _tmp24_ = *_tmp23_; 1035 | result = TRUE; 1036 | return result; 1037 | } 1038 | } 1039 | case RETRO_CORE_RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY: 1040 | { 1041 | { 1042 | const gchar** dir = NULL; 1043 | void* _tmp25_ = NULL; 1044 | const gchar** _tmp26_ = NULL; 1045 | const gchar* _tmp27_ = NULL; 1046 | _tmp25_ = data; 1047 | dir = (const gchar**) _tmp25_; 1048 | _tmp26_ = dir; 1049 | *_tmp26_ = "./.gambatte"; 1050 | _tmp27_ = *_tmp26_; 1051 | result = TRUE; 1052 | return result; 1053 | } 1054 | } 1055 | case RETRO_CORE_RETRO_ENVIRONMENT_GET_CAN_DUPE: 1056 | { 1057 | { 1058 | gboolean* can_dupe = NULL; 1059 | void* _tmp28_ = NULL; 1060 | gboolean* _tmp29_ = NULL; 1061 | gboolean _tmp30_ = FALSE; 1062 | _tmp28_ = data; 1063 | can_dupe = (gboolean*) _tmp28_; 1064 | _tmp29_ = can_dupe; 1065 | *_tmp29_ = TRUE; 1066 | _tmp30_ = *_tmp29_; 1067 | result = TRUE; 1068 | return result; 1069 | } 1070 | } 1071 | default: 1072 | { 1073 | result = FALSE; 1074 | return result; 1075 | } 1076 | } 1077 | } 1078 | 1079 | 1080 | void retro_core_unload (RetroCore* self) { 1081 | FILE* _tmp0_ = NULL; 1082 | gboolean _tmp1_ = FALSE; 1083 | gboolean _tmp2_ = FALSE; 1084 | RetroCoreRetroUnloadGame _tmp4_ = NULL; 1085 | RetroCoreRetroDeinit _tmp5_ = NULL; 1086 | FILE* _tmp6_ = NULL; 1087 | g_return_if_fail (self != NULL); 1088 | _tmp0_ = stdout; 1089 | fprintf (_tmp0_, "unload\n"); 1090 | _tmp2_ = self->loaded; 1091 | if (!_tmp2_) { 1092 | _tmp1_ = TRUE; 1093 | } else { 1094 | GModule* _tmp3_ = NULL; 1095 | _tmp3_ = self->priv->module; 1096 | _tmp1_ = _tmp3_ == NULL; 1097 | } 1098 | if (_tmp1_) { 1099 | return; 1100 | } 1101 | _tmp4_ = self->retro_unload_game; 1102 | _tmp4_ (); 1103 | _tmp5_ = self->retro_deinit; 1104 | _tmp5_ (); 1105 | _g_module_close0 (self->priv->module); 1106 | self->priv->module = NULL; 1107 | self->loaded = FALSE; 1108 | _tmp6_ = stdout; 1109 | fprintf (_tmp6_, "unload end\n"); 1110 | } 1111 | 1112 | 1113 | RetroCoreRetroGameGeometry* retro_core_retro_game_geometry_dup (const RetroCoreRetroGameGeometry* self) { 1114 | RetroCoreRetroGameGeometry* dup; 1115 | dup = g_new0 (RetroCoreRetroGameGeometry, 1); 1116 | memcpy (dup, self, sizeof (RetroCoreRetroGameGeometry)); 1117 | return dup; 1118 | } 1119 | 1120 | 1121 | void retro_core_retro_game_geometry_free (RetroCoreRetroGameGeometry* self) { 1122 | g_free (self); 1123 | } 1124 | 1125 | 1126 | GType retro_core_retro_game_geometry_get_type (void) { 1127 | static volatile gsize retro_core_retro_game_geometry_type_id__volatile = 0; 1128 | if (g_once_init_enter (&retro_core_retro_game_geometry_type_id__volatile)) { 1129 | GType retro_core_retro_game_geometry_type_id; 1130 | retro_core_retro_game_geometry_type_id = g_boxed_type_register_static ("RetroCoreRetroGameGeometry", (GBoxedCopyFunc) retro_core_retro_game_geometry_dup, (GBoxedFreeFunc) retro_core_retro_game_geometry_free); 1131 | g_once_init_leave (&retro_core_retro_game_geometry_type_id__volatile, retro_core_retro_game_geometry_type_id); 1132 | } 1133 | return retro_core_retro_game_geometry_type_id__volatile; 1134 | } 1135 | 1136 | 1137 | RetroCoreRetroSystemTiming* retro_core_retro_system_timing_dup (const RetroCoreRetroSystemTiming* self) { 1138 | RetroCoreRetroSystemTiming* dup; 1139 | dup = g_new0 (RetroCoreRetroSystemTiming, 1); 1140 | memcpy (dup, self, sizeof (RetroCoreRetroSystemTiming)); 1141 | return dup; 1142 | } 1143 | 1144 | 1145 | void retro_core_retro_system_timing_free (RetroCoreRetroSystemTiming* self) { 1146 | g_free (self); 1147 | } 1148 | 1149 | 1150 | GType retro_core_retro_system_timing_get_type (void) { 1151 | static volatile gsize retro_core_retro_system_timing_type_id__volatile = 0; 1152 | if (g_once_init_enter (&retro_core_retro_system_timing_type_id__volatile)) { 1153 | GType retro_core_retro_system_timing_type_id; 1154 | retro_core_retro_system_timing_type_id = g_boxed_type_register_static ("RetroCoreRetroSystemTiming", (GBoxedCopyFunc) retro_core_retro_system_timing_dup, (GBoxedFreeFunc) retro_core_retro_system_timing_free); 1155 | g_once_init_leave (&retro_core_retro_system_timing_type_id__volatile, retro_core_retro_system_timing_type_id); 1156 | } 1157 | return retro_core_retro_system_timing_type_id__volatile; 1158 | } 1159 | 1160 | 1161 | RetroCoreRetroSystemAvInfo* retro_core_retro_system_av_info_dup (const RetroCoreRetroSystemAvInfo* self) { 1162 | RetroCoreRetroSystemAvInfo* dup; 1163 | dup = g_new0 (RetroCoreRetroSystemAvInfo, 1); 1164 | memcpy (dup, self, sizeof (RetroCoreRetroSystemAvInfo)); 1165 | return dup; 1166 | } 1167 | 1168 | 1169 | void retro_core_retro_system_av_info_free (RetroCoreRetroSystemAvInfo* self) { 1170 | g_free (self); 1171 | } 1172 | 1173 | 1174 | GType retro_core_retro_system_av_info_get_type (void) { 1175 | static volatile gsize retro_core_retro_system_av_info_type_id__volatile = 0; 1176 | if (g_once_init_enter (&retro_core_retro_system_av_info_type_id__volatile)) { 1177 | GType retro_core_retro_system_av_info_type_id; 1178 | retro_core_retro_system_av_info_type_id = g_boxed_type_register_static ("RetroCoreRetroSystemAvInfo", (GBoxedCopyFunc) retro_core_retro_system_av_info_dup, (GBoxedFreeFunc) retro_core_retro_system_av_info_free); 1179 | g_once_init_leave (&retro_core_retro_system_av_info_type_id__volatile, retro_core_retro_system_av_info_type_id); 1180 | } 1181 | return retro_core_retro_system_av_info_type_id__volatile; 1182 | } 1183 | 1184 | 1185 | static guint8* _vala_array_dup5 (guint8* self, int length) { 1186 | return g_memdup (self, length * sizeof (guint8)); 1187 | } 1188 | 1189 | 1190 | void retro_core_retro_game_info_copy (const RetroCoreRetroGameInfo* self, RetroCoreRetroGameInfo* dest) { 1191 | const gchar* _tmp0_ = NULL; 1192 | gchar* _tmp1_ = NULL; 1193 | guint8* _tmp2_ = NULL; 1194 | gint _tmp2__length1 = 0; 1195 | guint8* _tmp3_ = NULL; 1196 | gint _tmp3__length1 = 0; 1197 | gsize _tmp4_ = 0UL; 1198 | const gchar* _tmp5_ = NULL; 1199 | gchar* _tmp6_ = NULL; 1200 | _tmp0_ = (*self).path; 1201 | _tmp1_ = g_strdup (_tmp0_); 1202 | _g_free0 ((*dest).path); 1203 | (*dest).path = _tmp1_; 1204 | _tmp2_ = (*self).data; 1205 | _tmp2__length1 = (*self).data_length1; 1206 | _tmp3_ = (_tmp2_ != NULL) ? _vala_array_dup5 (_tmp2_, _tmp2__length1) : ((gpointer) _tmp2_); 1207 | _tmp3__length1 = _tmp2__length1; 1208 | (*dest).data = (g_free ((*dest).data), NULL); 1209 | (*dest).data = _tmp3_; 1210 | (*dest).data_length1 = _tmp3__length1; 1211 | _tmp4_ = (*self).size; 1212 | (*dest).size = _tmp4_; 1213 | _tmp5_ = (*self).meta; 1214 | _tmp6_ = g_strdup (_tmp5_); 1215 | _g_free0 ((*dest).meta); 1216 | (*dest).meta = _tmp6_; 1217 | } 1218 | 1219 | 1220 | void retro_core_retro_game_info_destroy (RetroCoreRetroGameInfo* self) { 1221 | _g_free0 ((*self).path); 1222 | (*self).data = (g_free ((*self).data), NULL); 1223 | _g_free0 ((*self).meta); 1224 | } 1225 | 1226 | 1227 | RetroCoreRetroGameInfo* retro_core_retro_game_info_dup (const RetroCoreRetroGameInfo* self) { 1228 | RetroCoreRetroGameInfo* dup; 1229 | dup = g_new0 (RetroCoreRetroGameInfo, 1); 1230 | retro_core_retro_game_info_copy (self, dup); 1231 | return dup; 1232 | } 1233 | 1234 | 1235 | void retro_core_retro_game_info_free (RetroCoreRetroGameInfo* self) { 1236 | retro_core_retro_game_info_destroy (self); 1237 | g_free (self); 1238 | } 1239 | 1240 | 1241 | GType retro_core_retro_game_info_get_type (void) { 1242 | static volatile gsize retro_core_retro_game_info_type_id__volatile = 0; 1243 | if (g_once_init_enter (&retro_core_retro_game_info_type_id__volatile)) { 1244 | GType retro_core_retro_game_info_type_id; 1245 | retro_core_retro_game_info_type_id = g_boxed_type_register_static ("RetroCoreRetroGameInfo", (GBoxedCopyFunc) retro_core_retro_game_info_dup, (GBoxedFreeFunc) retro_core_retro_game_info_free); 1246 | g_once_init_leave (&retro_core_retro_game_info_type_id__volatile, retro_core_retro_game_info_type_id); 1247 | } 1248 | return retro_core_retro_game_info_type_id__volatile; 1249 | } 1250 | 1251 | 1252 | void retro_core_retro_variable_copy (const RetroCoreRetroVariable* self, RetroCoreRetroVariable* dest) { 1253 | const gchar* _tmp0_ = NULL; 1254 | gchar* _tmp1_ = NULL; 1255 | const gchar* _tmp2_ = NULL; 1256 | gchar* _tmp3_ = NULL; 1257 | _tmp0_ = (*self).key; 1258 | _tmp1_ = g_strdup (_tmp0_); 1259 | _g_free0 ((*dest).key); 1260 | (*dest).key = _tmp1_; 1261 | _tmp2_ = (*self).value; 1262 | _tmp3_ = g_strdup (_tmp2_); 1263 | _g_free0 ((*dest).value); 1264 | (*dest).value = _tmp3_; 1265 | } 1266 | 1267 | 1268 | void retro_core_retro_variable_destroy (RetroCoreRetroVariable* self) { 1269 | _g_free0 ((*self).key); 1270 | _g_free0 ((*self).value); 1271 | } 1272 | 1273 | 1274 | RetroCoreRetroVariable* retro_core_retro_variable_dup (const RetroCoreRetroVariable* self) { 1275 | RetroCoreRetroVariable* dup; 1276 | dup = g_new0 (RetroCoreRetroVariable, 1); 1277 | retro_core_retro_variable_copy (self, dup); 1278 | return dup; 1279 | } 1280 | 1281 | 1282 | void retro_core_retro_variable_free (RetroCoreRetroVariable* self) { 1283 | retro_core_retro_variable_destroy (self); 1284 | g_free (self); 1285 | } 1286 | 1287 | 1288 | GType retro_core_retro_variable_get_type (void) { 1289 | static volatile gsize retro_core_retro_variable_type_id__volatile = 0; 1290 | if (g_once_init_enter (&retro_core_retro_variable_type_id__volatile)) { 1291 | GType retro_core_retro_variable_type_id; 1292 | retro_core_retro_variable_type_id = g_boxed_type_register_static ("RetroCoreRetroVariable", (GBoxedCopyFunc) retro_core_retro_variable_dup, (GBoxedFreeFunc) retro_core_retro_variable_free); 1293 | g_once_init_leave (&retro_core_retro_variable_type_id__volatile, retro_core_retro_variable_type_id); 1294 | } 1295 | return retro_core_retro_variable_type_id__volatile; 1296 | } 1297 | 1298 | 1299 | static void retro_core_class_init (RetroCoreClass * klass) { 1300 | retro_core_parent_class = g_type_class_peek_parent (klass); 1301 | g_type_class_add_private (klass, sizeof (RetroCorePrivate)); 1302 | G_OBJECT_CLASS (klass)->finalize = retro_core_finalize; 1303 | } 1304 | 1305 | 1306 | static void retro_core_instance_init (RetroCore * self) { 1307 | self->priv = RETRO_CORE_GET_PRIVATE (self); 1308 | self->priv->module = NULL; 1309 | self->loaded = FALSE; 1310 | } 1311 | 1312 | 1313 | static void retro_core_finalize (GObject* obj) { 1314 | RetroCore * self; 1315 | FILE* _tmp0_ = NULL; 1316 | self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_RETRO_CORE, RetroCore); 1317 | _tmp0_ = stdout; 1318 | fprintf (_tmp0_, "unload RetroCore\n"); 1319 | retro_core_unload (self); 1320 | _g_module_close0 (self->priv->module); 1321 | _g_free0 (self->game_checksum); 1322 | G_OBJECT_CLASS (retro_core_parent_class)->finalize (obj); 1323 | } 1324 | 1325 | 1326 | GType retro_core_get_type (void) { 1327 | static volatile gsize retro_core_type_id__volatile = 0; 1328 | if (g_once_init_enter (&retro_core_type_id__volatile)) { 1329 | static const GTypeInfo g_define_type_info = { sizeof (RetroCoreClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) retro_core_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RetroCore), 0, (GInstanceInitFunc) retro_core_instance_init, NULL }; 1330 | GType retro_core_type_id; 1331 | retro_core_type_id = g_type_register_static (G_TYPE_OBJECT, "RetroCore", &g_define_type_info, 0); 1332 | g_once_init_leave (&retro_core_type_id__volatile, retro_core_type_id); 1333 | } 1334 | return retro_core_type_id__volatile; 1335 | } 1336 | 1337 | 1338 | 1339 | --------------------------------------------------------------------------------