gboolean touch_poll_event(gpointer data) { int mic_ret = hu_aap_mic_get (); if (mic_change_state == 0 && mic_ret == 2) { printf("SHAI1 : Mic Started\n"); mic_change_state = 2; gst_element_set_state (mic_pipeline, GST_STATE_PLAYING); } if (mic_change_state == 2 && mic_ret == 1) { printf("SHAI1 : Mic Stopped\n"); mic_change_state = 0; gst_element_set_state (mic_pipeline, GST_STATE_READY); } struct input_event event[64]; const size_t ev_size = sizeof(struct input_event); const size_t buffer_size = ev_size * 64; ssize_t size; gst_app_t *app = (gst_app_t *)data; fd_set set; struct timeval timeout; int unblocked; FD_ZERO(&set); FD_SET(mTouch.fd, &set); timeout.tv_sec = 0; timeout.tv_usec = 10000; unblocked = select(mTouch.fd + 1, &set, NULL, NULL, &timeout); if (unblocked == -1) { printf("Error in read...\n"); g_main_loop_quit(app->loop); return FALSE; } else if (unblocked == 0) { return TRUE; } size = read(mTouch.fd, &event, buffer_size); if (size == 0 || size == -1) return FALSE; if (size < ev_size) { printf("Error size when reading\n"); g_main_loop_quit(app->loop); return FALSE; } int num_chars = size / ev_size; int i; for (i=0;i < num_chars;i++) { switch (event[i].type) { case EV_ABS: switch (event[i].code) { case ABS_MT_POSITION_X: mTouch.x = event[i].value * 800/4095; break; case ABS_MT_POSITION_Y: mTouch.y = event[i].value * 480/4095; break; } break; case EV_KEY: if (event[i].code == BTN_TOUCH) { mTouch.action_recvd = 1; if (event[i].value == 1) { mTouch.action = ACTION_DOWN; } else { mTouch.action = ACTION_UP; } } break; case EV_SYN: if (mTouch.action_recvd == 0) { mTouch.action = ACTION_MOVE; aa_touch_event(mTouch.action, mTouch.x, mTouch.y); } else { aa_touch_event(mTouch.action, mTouch.x, mTouch.y); mTouch.action_recvd = 0; } break; } } return TRUE; }
static void gui_gtk_quit(void) { g_main_loop_quit (loop); }
static void quit_main_loop_if_finished (AddAccountData *data) { if (data->ret != NULL && data->close_received) g_main_loop_quit (data->loop); }
static void exit_loop_sighandler(int sig) { if (main_loop_) { // TODO(hzeller): revisit - this is not safe to do. g_main_loop_quit(main_loop_); } }
static void keyboard_cb (const gchar * key_input, gpointer user_data) { GstPlay *play = (GstPlay *) user_data; gchar key = '\0'; /* only want to switch/case on single char, not first char of string */ if (key_input[0] != '\0' && key_input[1] == '\0') key = g_ascii_tolower (key_input[0]); switch (key) { case 'k': print_keyboard_help (); break; case ' ': toggle_paused (play); break; case 'q': case 'Q': g_main_loop_quit (play->loop); break; case '>': if (!play_next (play)) { g_print ("\n%s\n", _("Reached end of play list.")); g_main_loop_quit (play->loop); } break; case '<': play_prev (play); break; case '+': if (play->rate > -0.2 && play->rate < 0.0) play_set_relative_playback_rate (play, 0.0, TRUE); else if (ABS (play->rate) < 2.0) play_set_relative_playback_rate (play, 0.1, FALSE); else if (ABS (play->rate) < 4.0) play_set_relative_playback_rate (play, 0.5, FALSE); else play_set_relative_playback_rate (play, 1.0, FALSE); break; case '-': if (play->rate > 0.0 && play->rate < 0.20) play_set_relative_playback_rate (play, 0.0, TRUE); else if (ABS (play->rate) <= 2.0) play_set_relative_playback_rate (play, -0.1, FALSE); else if (ABS (play->rate) <= 4.0) play_set_relative_playback_rate (play, -0.5, FALSE); else play_set_relative_playback_rate (play, -1.0, FALSE); break; case 'd': play_set_relative_playback_rate (play, 0.0, TRUE); break; case 't': play_switch_trick_mode (play); break; case 27: /* ESC */ if (key_input[1] == '\0') { g_main_loop_quit (play->loop); break; } case 'a': play_cycle_track_selection (play, GST_PLAY_TRACK_TYPE_AUDIO); break; case 'v': play_cycle_track_selection (play, GST_PLAY_TRACK_TYPE_VIDEO); break; case 's': play_cycle_track_selection (play, GST_PLAY_TRACK_TYPE_SUBTITLE); break; /* fall through */ default: if (strcmp (key_input, GST_PLAY_KB_ARROW_RIGHT) == 0) { relative_seek (play, +0.08); } else if (strcmp (key_input, GST_PLAY_KB_ARROW_LEFT) == 0) { relative_seek (play, -0.01); } else if (strcmp (key_input, GST_PLAY_KB_ARROW_UP) == 0) { play_set_relative_volume (play, +1.0 / VOLUME_STEPS); } else if (strcmp (key_input, GST_PLAY_KB_ARROW_DOWN) == 0) { play_set_relative_volume (play, -1.0 / VOLUME_STEPS); } else { GST_INFO ("keyboard input:"); for (; *key_input != '\0'; ++key_input) GST_INFO (" code %3d", *key_input); } break; } }
static void disconnect_callback(DBusConnection *conn, void *user_data) { syslog(LOG_ERR, "D-Bus disconnect"); g_main_loop_quit(main_loop); }
void InterfaceManagerImpl::stopListening() { if(mLoop != nullptr){ g_main_loop_quit(mLoop); } }
static gboolean read_data(GIOChannel *chan, GIOCondition cond, gpointer data) { int count; char buf[BUFSIZE]; /* receive data packet containing formatted data */ count = recv(sock, buf, sizeof(buf), 0); if (count > 0) { if (count == 23) { // FillBufWith32bit(com_trans.buf, 1, gps_lat); gps_lat = buf2uint(&buf[0]); // FillBufWith32bit(com_trans.buf, 5, gps_lon); gps_lon = buf2uint(&buf[4]); // FillBufWith16bit(com_trans.buf, 9, (int16_t)(gps_alt/100)); // meters gps_alt = buf2ushort(&buf[8]) * 100; // FillBufWith16bit(com_trans.buf, 11, gps_gspeed); // ground speed gps_gspeed = buf2ushort(&buf[10]); // FillBufWith16bit(com_trans.buf, 13, gps_course); // course gps_course = buf2ushort(&buf[12]); // FillBufWith16bit(com_trans.buf, 15, (uint16_t)(estimator_airspeed*100)); // TAS (cm/s) estimator_airspeed = buf2ushort(&buf[14]); // com_trans.buf[16] = electrical.vsupply; // should be (estimator_airspeed is two bytes): // com_trans.buf[17] = electrical.vsupply; electrical_vsupply = buf[16]; // com_trans.buf[17] = (uint8_t)(energy*10); energy = buf[17] / 10; // com_trans.buf[18] = (uint8_t)(ap_state->commands[COMMAND_THROTTLE]*100/MAX_PPRZ); throttle = buf[18]; // com_trans.buf[19] = pprz_mode; pprz_mode = buf[19]; // com_trans.buf[20] = nav_block; nav_block = buf[20]; // FillBufWith16bit(com_trans.buf, 21, estimator_flight_time); estimator_flight_time = buf2ushort(&buf[21]); //gps_lat = 52.2648312 * 1e7; //gps_lon = 9.9939456 * 1e7; //gps_alt = 169 * 1000; //gps_gspeed = 13 * 100; //gps_course = 60 * 10; //estimator_airspeed = 15 * 100; //electrical_vsupply = 126; //energy = 9; //throttle = 51; //pprz_mode = 2; //nav_block = 1; //estimator_flight_time = 123; nav_utm_zone0 = (gps_lon/10000000+180) / 6 + 1; latlong_utm_of(RadOfDeg(gps_lat/1e7), RadOfDeg(gps_lon/1e7), nav_utm_zone0); gps_utm_east = latlong_utm_x * 100; gps_utm_north = latlong_utm_y * 100; gps_utm_zone = nav_utm_zone0; printf("gps_lat %f\n", gps_lat/1e7); printf("gps_lon %f\n", gps_lon/1e7); printf("gps_alt %d\n", gps_alt); printf("gps_gspeed %d\n", gps_gspeed); printf("gps_course %d\n", gps_course); printf("estimator_airspeed %d\n", estimator_airspeed); printf("electrical_vsupply %d\n", electrical_vsupply); printf("energy %d\n", energy); printf("throttle %d\n", throttle); printf("pprz_mode %d\n", pprz_mode); printf("nav_block %d\n", nav_block); printf("estimator_flight_time %d\n", estimator_flight_time); printf("gps_utm_east %d\n", gps_utm_east); printf("gps_utm_north %d\n", gps_utm_north); printf("gps_utm_zone %d\n", gps_utm_zone); /* <message name="GPS" id="8"> <field name="mode" type="uint8" unit="byte_mask"/> <field name="utm_east" type="int32" unit="cm" alt_unit="m"/> <field name="utm_north" type="int32" unit="cm" alt_unit="m"/> <field name="course" type="int16" unit="decideg" alt_unit="deg"/> <field name="alt" type="int32" unit="mm" alt_unit="m"/> <field name="speed" type="uint16" unit="cm/s" alt_unit="m/s"/> <field name="climb" type="int16" unit="cm/s" alt_unit="m/s"/> <field name="week" type="uint16" unit="weeks"/> <field name="itow" type="uint32" unit="ms"/> <field name="utm_zone" type="uint8"/> <field name="gps_nb_err" type="uint8"/> </message> */ IvySendMsg("%d GPS %d %d %d %d %d %d %d %d %d %d %d", AC_ID, 3, // mode = 3D gps_utm_east, gps_utm_north, gps_course, gps_alt, gps_gspeed, 0, // climb 0, // week 0, //itow gps_utm_zone, 0); // gps_nb_err /* <message name="PPRZ_MODE" id="11"> <field name="ap_mode" type="uint8" values="MANUAL|AUTO1|AUTO2|HOME|NOGPS|FAILSAFE"/> <field name="ap_gaz" type="uint8" values="MANUAL|AUTO_THROTTLE|AUTO_CLIMB|AUTO_ALT"/> <field name="ap_lateral" type="uint8" values="MANUAL|ROLL_RATE|ROLL|COURSE"/> <field name="ap_horizontal" type="uint8" values="WAYPOINT|ROUTE|CIRCLE"/> <field name="if_calib_mode" type="uint8" values="NONE|DOWN|UP"/> <field name="mcu1_status" type="uint8" values="LOST|OK|REALLY_LOST"/> </message> */ IvySendMsg("%d PPRZ_MODE %d %d %d %d %d %d", AC_ID, pprz_mode, 0, // ap_gaz 0, // ap_lateral 0, // ap_horizontal 0, // if_calib_mode 0); // mcu1_status /* <message name="AIRSPEED" id="54"> <field name="airspeed" type="float" unit="m/s"/> <field name="airspeed_sp" type="float" unit="m/s"/> <field name="airspeed_cnt" type="float" unit="m/s"/> <field name="groundspeed_sp" type="float" unit="m/s"/> </message> */ IvySendMsg("%d AIRSPEED %f %d %d %d", AC_ID, (float)(estimator_airspeed / 100.), 0, // airspeed_sp 0, // airspeed_cnt 0); // groundspeed_sp /* <message name="BAT" id="12"> <field name="throttle" type="int16" unit="pprz"/> <field name="voltage" type="uint8" unit="1e-1V" alt_unit="V" alt_unit_coef="0.1"/> <field name="amps" type="int16" unit="A" alt_unit="A" /> <field name="flight_time" type="uint16" unit="s"/> <field name="kill_auto_throttle" type="uint8" unit="bool"/> <field name="block_time" type="uint16" unit="s"/> <field name="stage_time" type="uint16" unit="s"/> <field name="energy" type="int16" unit="mAh"/> </message> */ IvySendMsg("%d BAT %d %d %d %d %d %d %d %d", AC_ID, throttle * MAX_PPRZ / 100, electrical_vsupply, 0, // amps estimator_flight_time, 0, // kill_auto_throttle 0, // block_time 0, // stage_time energy); /* <message name="NAVIGATION" id="10"> <field name="cur_block" type="uint8"/> <field name="cur_stage" type="uint8"/> <field name="pos_x" type="float" unit="m" format="%.1f"/> <field name="pos_y" type="float" unit="m" format="%.1f"/> <field name="dist2_wp" type="float" format="%.1f" unit="m^2"/> <field name="dist2_home" type="float" format="%.1f" unit="m^2"/> <field name="circle_count" type="uint8"/> <field name="oval_count" type="uint8"/> </message> */ IvySendMsg("%d NAVIGATION %d %d %d %d %d %d %d %d", AC_ID, nav_block, 0, // cur_stage 0, // pos_x 0, // pos_y 0, // dist2_wp 0, // dist2_home 0, // circle_count 0); // oval_count /* <message name="ESTIMATOR" id="42"> <field name="z" type="float" unit="m"/> <field name="z_dot" type="float" unit="m/s"/> </message> */ IvySendMsg("%d ESTIMATOR %f %d", AC_ID, gps_alt / 1000., 0); // z_dot /* <message name="ATTITUDE" id="6"> <field name="phi" type="float" unit="rad" alt_unit="deg"/> <field name="psi" type="float" unit="rad" alt_unit="deg"/> <field name="theta" type="float" unit="rad" alt_unit="deg"/> </message> */ IvySendMsg("%d ATTITUDE %f %f %f", AC_ID, 0., // phi RadOfDeg(gps_course / 10.), 0.); // theta } } else { printf("disconnect\n"); close(sock); g_main_loop_quit(ml); return 0; } return 1; }
void CoreManager::quitMainLoop() { g_main_loop_quit(gmainloop); }
static void runJavaScriptFromGResourceReadyCallback(GObject*, GAsyncResult* result, WebViewTest* test) { test->m_javascriptResult = webkit_web_view_run_javascript_from_gresource_finish(test->m_webView, result, test->m_javascriptError); g_main_loop_quit(test->m_mainLoop); }
static void main_sigint_handler (gint sig) { signal (SIGINT, SIG_DFL); g_main_loop_quit (loop); }
void WebViewTest::quitMainLoop() { g_main_loop_quit(m_mainLoop); }
static int handle_quit (xmmsv_t *val, void *data) { g_main_loop_quit ((GMainLoop *) data); return 0; }
gboolean commander_poll_event(gpointer data) { return TRUE; const struct timespec timeout = { .tv_sec = 0, .tv_nsec = 10000}; struct input_event event[64]; const size_t ev_size = sizeof(struct input_event); const size_t buffer_size = ev_size * 64; ssize_t size; gst_app_t *app = (gst_app_t *)data; struct timespec tp; uint8_t *cmd_buf = NULL; int cmd_size = 0; sigset_t sigmask; struct pollfd fds[1]; int ret; unsigned char* buf = 0; int len; sigemptyset(&sigmask); fds[0].events = POLLIN; fds[0].fd = mCommander.fd; fds[0].revents = 0; ret = ppoll(fds, sizeof(fds) / sizeof(struct pollfd), &timeout, &sigmask); if (fds[0].revents & POLLIN) { size = read(mCommander.fd, &event, buffer_size); if (size == 0 || size == -1) return FALSE; if (size < ev_size) { printf("Error size when reading\n"); g_main_loop_quit(app->loop); return FALSE; } int num_chars = size / ev_size; int i; for (i=0;i < num_chars;i++) { if (event[i].type == EV_KEY && event[i].value == 1) { switch (event[i].code) { case KEY_UP: cmd_buf = cd_up1; cmd_size = sizeof(cd_up1); break; case KEY_DOWN: cmd_buf = cd_down1; cmd_size = sizeof(cd_down1); break; case KEY_LEFT: cmd_buf = cd_left1; cmd_size = sizeof(cd_left1); break; case KEY_RIGHT: cmd_buf = cd_right1; cmd_size = sizeof(cd_right1); break; case KEY_N: cmd_buf = cd_lefturn; cmd_size = sizeof(cd_lefturn); break; case KEY_M: cmd_buf = cd_rightturn; cmd_size = sizeof(cd_rightturn); break; case KEY_ENTER: cmd_buf = cd_enter1; cmd_size = sizeof(cd_enter1); break; case KEY_BACKSPACE: cmd_buf = cd_back1; cmd_size = sizeof(cd_back1); break; } if (cmd_buf != NULL) { clock_gettime(CLOCK_REALTIME, &tp); uint8_t *buf = (uint8_t *)malloc(cmd_size); memcpy(buf, cmd_buf, cmd_size); varint_encode(tp.tv_sec * 1000000000 +tp.tv_nsec, buf,3); printf("\n { "); for (i = 0; i < cmd_size; i++) { if (i > 0) printf(","); printf("0x%02X", (char) buf[i]); } printf(" } \n"); queueSend(0,AA_CH_TOU, buf, cmd_size, TRUE); } } if (event[i].type == EV_KEY && event[i].value == 0) { cmd_buf = NULL; switch (event[i].code) { case KEY_UP: cmd_buf = cd_up2; cmd_size = sizeof(cd_up2); break; case KEY_DOWN: cmd_buf = cd_down2; cmd_size = sizeof(cd_down2); break; case KEY_LEFT: cmd_buf = cd_left2; cmd_size = sizeof(cd_left2); break; case KEY_RIGHT: cmd_buf = cd_right2; cmd_size = sizeof(cd_right2); break; case KEY_ENTER: cmd_buf = cd_enter2; cmd_size = sizeof(cd_enter2); break; case KEY_BACKSPACE: cmd_buf = cd_back2; cmd_size = sizeof(cd_back2); break; } if (cmd_buf != NULL) { clock_gettime(CLOCK_REALTIME, &tp); uint8_t *buf = (uint8_t *)malloc(cmd_size); memcpy(buf, cmd_buf, cmd_size); printf("\n { "); for (i = 0; i < cmd_size; i++) { if (i > 0) printf(","); printf("0x%02X", (char) buf[i]); } printf(" } \n"); varint_encode(tp.tv_sec * 100000000 +tp.tv_nsec, buf,3); queueSend(0,AA_CH_TOU, buf, cmd_size, TRUE); } } } } return TRUE; } static void * input_thread(void *app) { while (touch_poll_event(app)) { commander_poll_event(app); ms_sleep(100); } } GMainLoop *mainloop; #define HMI_BUS_ADDRESS "unix:path=/tmp/dbus_hmi_socket" static void * nightmode_thread(void *app) { // Initialize HMI bus DBusConnection *hmi_bus; DBusError error; hmi_bus = dbus_connection_open(HMI_BUS_ADDRESS, &error); if (!hmi_bus) { printf("DBUS: failed to connect to HMI bus: %s: %s\n", error.name, error.message); } if (!dbus_bus_register(hmi_bus, &error)) { printf("DBUS: failed to register with HMI bus: %s: %s\n", error.name, error.message); } // Wait for mainloop to start ms_sleep(100); while (g_main_loop_is_running (mainloop)) { DBusMessage *msg = dbus_message_new_method_call("com.jci.BLM_TIME", "/com/jci/BLM_TIME", "com.jci.BLM_TIME", "GetClock"); DBusPendingCall *pending = NULL; if (!msg) { printf("DBUS: failed to create message \n"); } if (!dbus_connection_send_with_reply(hmi_bus, msg, &pending, -1)) { printf("DBUS: failed to send message \n"); } dbus_connection_flush(hmi_bus); dbus_message_unref(msg); dbus_pending_call_block(pending); msg = dbus_pending_call_steal_reply(pending); if (!msg) { printf("DBUS: received null reply \n"); } dbus_uint32_t nm_hour; dbus_uint32_t nm_min; dbus_uint32_t nm_timestamp; dbus_uint64_t nm_calltimestamp; if (!dbus_message_get_args(msg, &error, DBUS_TYPE_UINT32, &nm_hour, DBUS_TYPE_UINT32, &nm_min, DBUS_TYPE_UINT32, &nm_timestamp, DBUS_TYPE_UINT64, &nm_calltimestamp, DBUS_TYPE_INVALID)) { printf("DBUS: failed to get result %s: %s\n", error.name, error.message); } dbus_message_unref(msg); int nightmodenow = 1; if (nm_hour >= 6 && nm_hour <= 18) nightmodenow = 0; if (nightmode != nightmodenow) { nightmode = nightmodenow; byte* rspds = malloc(sizeof(byte) * 6); rspds[0] = -128; rspds[1] = 0x03; rspds[2] = 0x52; rspds[3] = 0x02; rspds[4] = 0x08; if (nightmode == 0) rspds[5]= 0x00; else rspds[5] = 0x01; queueSend(0,AA_CH_SEN, rspds, sizeof (byte) * 6, TRUE); // Send Sensor Night mode } sleep(600); } }
static gboolean quitMainLoopLater(GMainLoop* loop) { g_main_loop_quit(loop); return FALSE; }
static void max_conns_message_complete (SoupSession *session, SoupMessage *msg, gpointer user_data) { if (++msgs_done == TEST_CONNS) g_main_loop_quit (max_conns_loop); }
static void sig_term(int sig) { syslog(LOG_INFO, "Terminating"); g_main_loop_quit(main_loop); }
static void check_quit (void) { if (task_cnt == 0) g_main_loop_quit (loop); }
void gimp_plug_in_close (GimpPlugIn *plug_in, gboolean kill_it) { g_return_if_fail (GIMP_IS_PLUG_IN (plug_in)); g_return_if_fail (plug_in->open); plug_in->open = FALSE; if (plug_in->pid) { #ifndef G_OS_WIN32 gint status; #endif /* Ask the filter to exit gracefully, but not if it is closed because of a broken pipe. */ if (kill_it && ! plug_in->hup) { gp_quit_write (plug_in->my_write, plug_in); /* give the plug-in some time (10 ms) */ g_usleep (10000); } /* If necessary, kill the filter. */ #ifndef G_OS_WIN32 if (kill_it) { if (plug_in->manager->gimp->be_verbose) g_print ("Terminating plug-in: '%s'\n", gimp_file_get_utf8_name (plug_in->file)); /* If the plug-in opened a process group, kill the group instead * of only the plug-in, so we kill the plug-in's children too */ if (getpgid (0) != getpgid (plug_in->pid)) status = kill (- plug_in->pid, SIGKILL); else status = kill (plug_in->pid, SIGKILL); } /* Wait for the process to exit. This will happen * immediately if it was just killed. */ waitpid (plug_in->pid, &status, 0); #else /* G_OS_WIN32 */ if (kill_it) { /* Trying to avoid TerminateProcess (does mostly work). * Otherwise some of our needed DLLs may get into an * unstable state (see Win32 API docs). */ DWORD dwExitCode = STILL_ACTIVE; DWORD dwTries = 10; while (dwExitCode == STILL_ACTIVE && GetExitCodeProcess ((HANDLE) plug_in->pid, &dwExitCode) && (dwTries > 0)) { Sleep (10); dwTries--; } if (dwExitCode == STILL_ACTIVE) { if (plug_in->manager->gimp->be_verbose) g_print ("Terminating plug-in: '%s'\n", gimp_file_get_utf8_name (plug_in->file)); TerminateProcess ((HANDLE) plug_in->pid, 0); } } #endif /* G_OS_WIN32 */ g_spawn_close_pid (plug_in->pid); plug_in->pid = 0; } /* Remove the input handler. */ if (plug_in->input_id) { g_source_remove (plug_in->input_id); plug_in->input_id = 0; } /* Close the pipes. */ if (plug_in->my_read != NULL) { g_io_channel_unref (plug_in->my_read); plug_in->my_read = NULL; } if (plug_in->my_write != NULL) { g_io_channel_unref (plug_in->my_write); plug_in->my_write = NULL; } if (plug_in->his_read != NULL) { g_io_channel_unref (plug_in->his_read); plug_in->his_read = NULL; } if (plug_in->his_write != NULL) { g_io_channel_unref (plug_in->his_write); plug_in->his_write = NULL; } gimp_wire_clear_error (); while (plug_in->temp_proc_frames) { GimpPlugInProcFrame *proc_frame = plug_in->temp_proc_frames->data; #ifdef GIMP_UNSTABLE g_printerr ("plug-in '%s' aborted before sending its " "temporary procedure return values\n", gimp_object_get_name (plug_in)); #endif if (proc_frame->main_loop && g_main_loop_is_running (proc_frame->main_loop)) { g_main_loop_quit (proc_frame->main_loop); } /* pop the frame here, because normally this only happens in * gimp_plug_in_handle_temp_proc_return(), which can't * be called after plug_in_close() */ gimp_plug_in_proc_frame_pop (plug_in); } if (plug_in->main_proc_frame.main_loop && g_main_loop_is_running (plug_in->main_proc_frame.main_loop)) { #ifdef GIMP_UNSTABLE g_printerr ("plug-in '%s' aborted before sending its " "procedure return values\n", gimp_object_get_name (plug_in)); #endif g_main_loop_quit (plug_in->main_proc_frame.main_loop); } if (plug_in->ext_main_loop && g_main_loop_is_running (plug_in->ext_main_loop)) { #ifdef GIMP_UNSTABLE g_printerr ("extension '%s' aborted before sending its " "extension_ack message\n", gimp_object_get_name (plug_in)); #endif g_main_loop_quit (plug_in->ext_main_loop); } /* Unregister any temporary procedures. */ while (plug_in->temp_procedures) gimp_plug_in_remove_temp_proc (plug_in, plug_in->temp_procedures->data); gimp_plug_in_manager_remove_open_plug_in (plug_in->manager, plug_in); }
/* FIXME: this is a little bit dirty... */ static void on_src_file_info_finished(FmFileInfoJob* job, FmDndDest* dd) { dd->src_files = fm_list_ref(job->file_infos); dd->info_type = FM_DND_DEST_TARGET_FM_LIST; g_main_loop_quit(dd->mainloop); }
static gboolean do_command (GDBusConnection *connection) { GDBusMessage *reply; if (do_quit) { reply = screensaver_send_message_void (connection, "Quit", FALSE); goto done; } if (do_query) { GVariant *body; gboolean v; if (! screensaver_is_running (connection)) { g_message ("Screensaver is not running!"); goto done; } reply = screensaver_send_message_void (connection, "GetActive", TRUE); if (reply == NULL) { g_message ("Did not receive a reply from the screensaver."); goto done; } body = g_dbus_message_get_body (reply); g_variant_get (body, "(b)", &v); g_object_unref (reply); if (v) { g_print (_("The screensaver is active\n")); } else { g_print (_("The screensaver is inactive\n")); } } if (do_time) { GVariant *body; gboolean v; gint32 t; reply = screensaver_send_message_void (connection, "GetActive", TRUE); if (reply == NULL) { g_message ("Did not receive a reply from the screensaver."); goto done; } body = g_dbus_message_get_body (reply); g_variant_get (body, "(b)", &v); g_object_unref (reply); if (v) { reply = screensaver_send_message_void (connection, "GetActiveTime", TRUE); if (reply == NULL) { g_message ("Did not receive a reply from the screensaver."); goto done; } body = g_dbus_message_get_body (reply); g_variant_get (body, "(u)", &t); g_object_unref (reply); g_print (ngettext ("The screensaver has been active for %d second.\n", "The screensaver has been active for %d seconds.\n", t), t); } else { g_print (_("The screensaver is not currently active.\n")); } } if (do_lock) { if (g_strcmp0 (away_message, "DEFAULT") == 0) { reply = screensaver_send_message_string (connection, "Lock", away_message); } else { gchar * custom_message = g_strdup_printf("CUSTOM###%s", away_message); reply = screensaver_send_message_string (connection, "Lock", custom_message); g_free (custom_message); } if (reply == NULL) { g_message ("Did not receive a reply from the screensaver."); goto done; } g_object_unref (reply); } if (do_activate) { reply = screensaver_send_message_bool (connection, "SetActive", TRUE); if (reply == NULL) { g_message ("Did not receive a reply from the screensaver."); goto done; } g_object_unref (reply); } if (do_deactivate) { reply = screensaver_send_message_bool (connection, "SetActive", FALSE); if (reply == NULL) { g_message ("Did not receive a reply from the screensaver."); goto done; } g_object_unref (reply); } done: g_main_loop_quit (loop); return FALSE; }
static void sig_term(int sig) { io_cancel(); g_main_loop_quit(event_loop); }
static gboolean play_bus_msg (GstBus * bus, GstMessage * msg, gpointer user_data) { GstPlay *play = user_data; switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_ASYNC_DONE: /* dump graph on preroll */ GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (play->playbin), GST_DEBUG_GRAPH_SHOW_ALL, "gst-play.async-done"); g_print ("Prerolled.\r"); if (play->missing != NULL && play_install_missing_plugins (play)) { g_print ("New plugins installed, trying again...\n"); --play->cur_idx; play_next (play); } break; case GST_MESSAGE_BUFFERING:{ gint percent; if (!play->buffering) g_print ("\n"); gst_message_parse_buffering (msg, &percent); g_print ("%s %d%% \r", _("Buffering..."), percent); if (percent == 100) { /* a 100% message means buffering is done */ if (play->buffering) { play->buffering = FALSE; /* no state management needed for live pipelines */ if (!play->is_live) gst_element_set_state (play->playbin, play->desired_state); } } else { /* buffering... */ if (!play->buffering) { if (!play->is_live) gst_element_set_state (play->playbin, GST_STATE_PAUSED); play->buffering = TRUE; } } break; } case GST_MESSAGE_CLOCK_LOST:{ g_print (_("Clock lost, selecting a new one\n")); gst_element_set_state (play->playbin, GST_STATE_PAUSED); gst_element_set_state (play->playbin, GST_STATE_PLAYING); break; } case GST_MESSAGE_LATENCY: g_print ("Redistribute latency...\n"); gst_bin_recalculate_latency (GST_BIN (play->playbin)); break; case GST_MESSAGE_REQUEST_STATE:{ GstState state; gchar *name; name = gst_object_get_path_string (GST_MESSAGE_SRC (msg)); gst_message_parse_request_state (msg, &state); g_print ("Setting state to %s as requested by %s...\n", gst_element_state_get_name (state), name); gst_element_set_state (play->playbin, state); g_free (name); break; } case GST_MESSAGE_EOS: /* print final position at end */ play_timeout (play); g_print ("\n"); /* and switch to next item in list */ if (!play_next (play)) { g_print ("%s\n", _("Reached end of play list.")); g_main_loop_quit (play->loop); } break; case GST_MESSAGE_WARNING:{ GError *err; gchar *dbg = NULL; /* dump graph on warning */ GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (play->playbin), GST_DEBUG_GRAPH_SHOW_ALL, "gst-play.warning"); gst_message_parse_warning (msg, &err, &dbg); g_printerr ("WARNING %s\n", err->message); if (dbg != NULL) g_printerr ("WARNING debug information: %s\n", dbg); g_error_free (err); g_free (dbg); break; } case GST_MESSAGE_ERROR:{ GError *err; gchar *dbg; /* dump graph on error */ GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (play->playbin), GST_DEBUG_GRAPH_SHOW_ALL, "gst-play.error"); gst_message_parse_error (msg, &err, &dbg); g_printerr ("ERROR %s for %s\n", err->message, play->uris[play->cur_idx]); if (dbg != NULL) g_printerr ("ERROR debug information: %s\n", dbg); g_error_free (err); g_free (dbg); /* flush any other error messages from the bus and clean up */ gst_element_set_state (play->playbin, GST_STATE_NULL); if (play->missing != NULL && play_install_missing_plugins (play)) { g_print ("New plugins installed, trying again...\n"); --play->cur_idx; play_next (play); break; } /* try next item in list then */ if (!play_next (play)) { g_print ("%s\n", _("Reached end of play list.")); g_main_loop_quit (play->loop); } break; } case GST_MESSAGE_ELEMENT: { GstNavigationMessageType mtype = gst_navigation_message_get_type (msg); if (mtype == GST_NAVIGATION_MESSAGE_EVENT) { GstEvent *ev = NULL; if (gst_navigation_message_parse_event (msg, &ev)) { GstNavigationEventType e_type = gst_navigation_event_get_type (ev); switch (e_type) { case GST_NAVIGATION_EVENT_KEY_PRESS: { const gchar *key; if (gst_navigation_event_parse_key_event (ev, &key)) { GST_INFO ("Key press: %s", key); if (strcmp (key, "Left") == 0) key = GST_PLAY_KB_ARROW_LEFT; else if (strcmp (key, "Right") == 0) key = GST_PLAY_KB_ARROW_RIGHT; else if (strcmp (key, "Up") == 0) key = GST_PLAY_KB_ARROW_UP; else if (strcmp (key, "Down") == 0) key = GST_PLAY_KB_ARROW_DOWN; else if (strcmp (key, "space") == 0) key = " "; else if (strlen (key) > 1) break; keyboard_cb (key, user_data); } break; } case GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS: { gint button; if (gst_navigation_event_parse_mouse_button_event (ev, &button, NULL, NULL)) { if (button == 4) { /* wheel up */ relative_seek (play, +0.08); } else if (button == 5) { /* wheel down */ relative_seek (play, -0.01); } } break; } default: break; } } if (ev) gst_event_unref (ev); } break; } default: if (gst_is_missing_plugin_message (msg)) { gchar *desc; desc = gst_missing_plugin_message_get_description (msg); g_print ("Missing plugin: %s\n", desc); g_free (desc); play->missing = g_list_append (play->missing, gst_message_ref (msg)); } break; } return TRUE; }
static void cmd_exit(int argcp, char **argvp) { rl_callback_handler_remove(); g_main_loop_quit(event_loop); }
static void _discoverer_finished (GstDiscoverer * dc, GMainLoop * ml) { g_main_loop_quit (ml); }
JNIEXPORT jint JNICALL CAST_JNI(mainLoopStop,jlong gloopLong) { GMainLoop *tmp_gloop = (GMainLoop *)gloopLong; g_main_loop_quit(gloopLong); }
/** * event_pipe callback function for PIPE_EVENT_SHUTDOWN */ static void shutdown_event_emitted(void) { g_main_loop_quit(main_loop); }
static WebKitWebView* createCallback(WebKitWebView* webView, CreateCallbackData* data) { data->triedToOpenWindow = true; g_main_loop_quit(data->mainLoop); return 0; }
gboolean delayed_destroy(gpointer data) { gtk_widget_destroy(GTK_WIDGET(data)); g_main_loop_quit(loop); return FALSE; }
void ncdc_quit() { g_main_loop_quit(main_loop); }