int main(int argc, char **argv) { if (initDecoderWithFile(filename)) return -1; init_queue(&video_pkt_queue); //初始化视频数据包队列 init_queue(&video_pic_queue); //初始化视频图像队列 init_queue(&audio_pkt_queue); init_queue(&audio_sam_queue); pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setscope(&attr, PTHREAD_SCOPE_PROCESS); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);//设置线程分离属性 //文件处理线程 if (0 != pthread_create(&file_tid, &attr, demux, (void*)filename)) printf("create file handler thread failed!\n"); //视频解码线程 if (0 != pthread_create(&dec_tid, &attr, video_decoder, NULL)) printf("create decode thread failed!\n"); if (0 != pthread_create(&audio_dec_tid, &attr, audio_decoder, NULL)) printf("create audio decode thread failed!\n"); if (0 != pthread_create(&audio_render_tid, &attr, audio_player, NULL)) printf("create audio render thread failed!\n"); /*以下是Gtk界面相关代码*/ if (!g_thread_supported()) g_thread_init(NULL); gdk_threads_init(); gdk_threads_enter(); GtkWidget *main_win;//主窗口 //GtkWidget *drawable;//图像绘制区域 gtk_init(&argc, &argv); char win_title[100]; sprintf(win_title, "AniPlayer--by Excalibur : %s", filename); main_win = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(main_win), win_title); GtkWidget *drawable = gtk_drawing_area_new(); gtk_container_add(GTK_CONTAINER(main_win), drawable); g_signal_connect(G_OBJECT(main_win), "delete-event", G_CALLBACK(exit_clean), NULL); //gtk_signal_connect(GTK_OBJECT(drawable), "expose-event", G_CALLBACK(on_darea_expose), NULL); gtk_widget_show_all(main_win); gtk_widget_set_size_request(drawable, g_player_ctx->width, g_player_ctx->height); //关闭自动刷新和双缓冲 gtk_widget_set_app_paintable(drawable, TRUE); gtk_widget_set_double_buffered(drawable, FALSE);//此乃大坑,之前没disable掉一直刷白屏 time_out = gtk_timeout_add(40, GSourceFunc(on_timer), drawable); gtk_main(); gdk_threads_leave(); _CrtDumpMemoryLeaks(); //getchar(); return 0; }
gint main (void) { NiceAgent *agent; NiceAddress addr_local, addr_remote; NiceCandidate *candidate; GSList *candidates, *i; guint stream_id; #ifdef G_OS_WIN32 WSADATA w; WSAStartup(0x0202, &w); #endif nice_address_init (&addr_local); nice_address_init (&addr_remote); g_type_init (); #if !GLIB_CHECK_VERSION(2,31,8) g_thread_init(NULL); #endif g_assert (nice_address_set_from_string (&addr_local, "127.0.0.1")); g_assert (nice_address_set_from_string (&addr_remote, "127.0.0.1")); nice_address_set_port (&addr_remote, 2345); agent = nice_agent_new ( NULL, NICE_COMPATIBILITY_RFC5245); g_assert (agent->local_addresses == NULL); /* add one local address */ nice_agent_add_local_address (agent, &addr_local); g_assert (agent->local_addresses != NULL); g_assert (g_slist_length (agent->local_addresses) == 1); g_assert (nice_address_equal (agent->local_addresses->data, &addr_local)); /* add a stream */ stream_id = nice_agent_add_stream (agent, 1); nice_agent_gather_candidates (agent, stream_id); /* adding a stream should cause host candidates to be generated */ candidates = nice_agent_get_local_candidates (agent, stream_id, 1); g_assert (g_slist_length (candidates) == 1); candidate = candidates->data; /* socket manager uses random port number */ nice_address_set_port (&addr_local, 1); nice_address_set_port (&(candidate->addr), 1); g_assert (nice_address_equal (&(candidate->addr), &addr_local)); g_assert (strncmp (candidate->foundation, "1", 1) == 0); for (i = candidates; i; i = i->next) nice_candidate_free ((NiceCandidate *) i->data); g_slist_free (candidates); /* clean up */ g_object_unref (agent); #ifdef G_OS_WIN32 WSACleanup(); #endif return 0; }
//static bool MediaPluginGStreamer010::startup() { // first - check if GStreamer is explicitly disabled if (NULL != getenv("LL_DISABLE_GSTREAMER")) return false; // only do global GStreamer initialization once. if (!mDoneInit) { #if !GLIB_CHECK_VERSION(2, 36, 0) #if !GLIB_CHECK_VERSION(2, 32, 0) if (!g_thread_supported()) g_thread_init(NULL); #endif // Init the glib type system - we need it. g_type_init(); #endif set_gst_plugin_path(); /* // Get symbols! #if LL_DARWIN if (! grab_gst_syms("libgstreamer-0.10.dylib", "libgstvideo-0.10.dylib") ) #elseif LL_WINDOWS if (! grab_gst_syms("libgstreamer-0.10.dll", "libgstvideo-0.10.dll") ) #else // linux or other ELFy unixoid if (! grab_gst_syms("libgstreamer-0.10.so.0", "libgstvideo-0.10.so.0") ) #endif { WARNMSG("Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled."); return false; } */ // if (gst_segtrap_set_enabled) // { gst_segtrap_set_enabled(FALSE); // } // else // { // WARNMSG("gst_segtrap_set_enabled() is not available; plugin crashes won't be caught."); // } /* #if LL_LINUX // Gstreamer tries a fork during init, waitpid-ing on it, // which conflicts with any installed SIGCHLD handler... struct sigaction tmpact, oldact; if (gst_registry_fork_set_enabled) { // if we can disable SIGCHLD-using forking behaviour, // do it. gst_registry_fork_set_enabled(false); } else { // else temporarily install default SIGCHLD handler // while GStreamer initialises tmpact.sa_handler = SIG_DFL; sigemptyset( &tmpact.sa_mask ); tmpact.sa_flags = SA_SIGINFO; sigaction(SIGCHLD, &tmpact, &oldact); } #endif // LL_LINUX */ // Protect against GStreamer resetting the locale, yuck. static std::string saved_locale; saved_locale = setlocale(LC_ALL, NULL); // finally, try to initialize GStreamer! GError *err = NULL; gboolean init_gst_success = gst_init_check(NULL, NULL, &err); // restore old locale setlocale(LC_ALL, saved_locale.c_str() ); /* #if LL_LINUX // restore old SIGCHLD handler if (!gst_registry_fork_set_enabled) sigaction(SIGCHLD, &oldact, NULL); #endif // LL_LINUX */ if (!init_gst_success) // fail { if (err) { WARNMSG("GST init failed: %s", err->message); g_error_free(err); } else { WARNMSG("GST init failed for unspecified reason."); } return false; } // Set up logging facilities gst_debug_remove_log_function( gst_debug_log_default ); // gst_debug_add_log_function( gstreamer_log, NULL ); // Init our custom plugins - only really need do this once. gst_slvideo_init_class(); /* // List the plugins GStreamer can find LL_DEBUGS("MediaImpl") << "Found GStreamer plugins:" << LL_ENDL; GList *list; GstRegistry *registry = gst_registry_get_default(); std::string loaded = ""; for (list = gst_registry_get_plugin_list(registry); list != NULL; list = g_list_next(list)) { GstPlugin *list_plugin = (GstPlugin *)list->data; (bool)gst_plugin_is_loaded(list_plugin) ? loaded = "Yes" : loaded = "No"; LL_DEBUGS("MediaImpl") << gst_plugin_get_name(list_plugin) << ", loaded? " << loaded << LL_ENDL; } gst_plugin_list_free(list); */ mDoneInit = true; } return true; }
//static bool MediaPluginGStreamer010::startup() { // first - check if GStreamer is explicitly disabled if (NULL != getenv("LL_DISABLE_GSTREAMER")) return false; // only do global GStreamer initialization once. if (!mDoneInit) { g_thread_init(NULL); // Init the glib type system - we need it. g_type_init(); // Get symbols! #if LL_DARWIN if (! grab_gst_syms("libgstreamer-0.10.dylib", "libgstvideo-0.10.dylib") ) #elseif LL_WINDOWS if (! grab_gst_syms("libgstreamer-0.10.dll", "libgstvideo-0.10.dll") ) #else // linux or other ELFy unixoid if (! grab_gst_syms("libgstreamer-0.10.so.0", "libgstvideo-0.10.so.0") ) #endif { WARNMSG("Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled."); return false; } if (llgst_segtrap_set_enabled) { llgst_segtrap_set_enabled(FALSE); } else { WARNMSG("gst_segtrap_set_enabled() is not available; plugin crashes won't be caught."); } #if LL_LINUX // Gstreamer tries a fork during init, waitpid-ing on it, // which conflicts with any installed SIGCHLD handler... struct sigaction tmpact, oldact; if (llgst_registry_fork_set_enabled) { // if we can disable SIGCHLD-using forking behaviour, // do it. llgst_registry_fork_set_enabled(false); } else { // else temporarily install default SIGCHLD handler // while GStreamer initialises tmpact.sa_handler = SIG_DFL; sigemptyset( &tmpact.sa_mask ); tmpact.sa_flags = SA_SIGINFO; sigaction(SIGCHLD, &tmpact, &oldact); } #endif // LL_LINUX // Protect against GStreamer resetting the locale, yuck. static std::string saved_locale; saved_locale = setlocale(LC_ALL, NULL); // finally, try to initialize GStreamer! GError *err = NULL; gboolean init_gst_success = llgst_init_check(NULL, NULL, &err); // restore old locale setlocale(LC_ALL, saved_locale.c_str() ); #if LL_LINUX // restore old SIGCHLD handler if (!llgst_registry_fork_set_enabled) sigaction(SIGCHLD, &oldact, NULL); #endif // LL_LINUX if (!init_gst_success) // fail { if (err) { WARNMSG("GST init failed: %s", err->message); g_error_free(err); } else { WARNMSG("GST init failed for unspecified reason."); } return false; } // Init our custom plugins - only really need do this once. gst_slvideo_init_class(); mDoneInit = true; } return true; }
/** * Main program entry point * * This function is the one called by the operating system to start Luna. * * This function sets {@link appArgc appArgc} and {@link appArgv appArgv}. * * @see appArgc * @see appArgv * * @param argc Number of command-line arguments * @param argv Pointer to list of char* of each of the arguments * * @return 0 = success, anything else = failure */ int main( int argc, char** argv) { appArgc = argc; appArgv = argv; std::set_terminate(generateGoodBacktraceTerminateHandler); g_thread_init(NULL); const char *renderMode; #if defined(TARGET_DEVICE) && defined(HAVE_OPENGL) ::setenv("QT_PLUGIN_PATH", "/usr/plugins", 1); renderMode = "HW egl"; #elif defined(TARGET_DEVICE) || defined(TARGET_EMULATOR) ::setenv("QT_PLUGIN_PATH", "/usr/plugins", 1); renderMode = "Software"; #elif defined(HAVE_OPENGL) renderMode = "HW OpenGL"; #else renderMode = "Software"; #endif WindowServer::markBootStart(); g_debug("SysMgr compiled against Qt %s, running on %s, %s render mode requested", QT_VERSION_STR, qVersion(), renderMode); // Command-Line options parseCommandlineOptions(argc, argv); if (s_debugTrapStr && 0 == strcasecmp(s_debugTrapStr, "on")) { debugCrashes = true; } if (s_mallocStatsFileStr) { setupMallocStats(s_mallocStatsFileStr); } sysmgrPid = getpid(); // Load Settings (first!) Settings* settings = Settings::LunaSettings(); // Initialize logging handler g_log_set_default_handler(logFilter, NULL); #if defined(TARGET_DESKTOP) // use terminal logging when running on desktop settings->logger_useTerminal = true; #endif // disable color logging using an environment variable. Useful when run from QtCreator const char* useColor = ::getenv("COLOR_LOGGING"); if (useColor) settings->logger_useColor = (useColor[0] != 0 && useColor[0] != '0'); HostBase* host = HostBase::instance(); // the resolution is just a hint, the actual // resolution may get picked up from the fb driver on arm host->init(settings->displayWidth, settings->displayHeight); #if defined(TARGET_DEVICE) pid_t animPid= spawnBootupAnimationProcess(); if(animPid < 0) { // failed to start the Animation process return -1; } #endif #if defined(TARGET_DEVICE) && defined(HAVE_OPENGL) && defined(HAVE_QPA) if (settings->forceSoftwareRendering) ::setenv("QT_QPA_PLATFORM", "palm-soft", 1); else ::setenv("QT_QPA_PLATFORM", "palm", 1); #endif #if defined(TARGET_DEVICE) && defined(HAVE_OPENGL) if (!settings->forceSoftwareRendering) ::setenv("QWS_DISPLAY", "egl", 1); #endif pid_t webKitPid= spawnWebKitProcess(); if(webKitPid < 0) { // failed to start the WebKit process return -1; } // Tie LunaSysMgr to Processor 0 setCpuAffinity(getpid(), 1); // Tie WebAppMgr to Processor 1 setCpuAffinity(webKitPid, 0); // Safe to create logging threads now logInit(); // Initialize Ipc Server (void) IpcServer::instance(); // Ipc Server is ready, so signal the WebAppMgr process (via pipe) to go ahead and connect ::write(WebAppMgrPipeFd, &msgOkToContinue, 1); ::close(WebAppMgrPipeFd); WebAppMgrPipeFd = -1; #if !defined(TARGET_DESKTOP) // Set "nice" property setpriority(PRIO_PROCESS,getpid(),-1); #endif #if !defined(TARGET_DESKTOP) && !defined(HAVE_QPA) QWSServer::setDefaultMouse("HiddTp"); QWSServer::setDefaultKeyboard("HiddKbd"); ::setenv("QWS_DBLCLICK_DISTANCE", QString("%0").arg(Settings::LunaSettings()->tapRadius).toAscii().constData(), 1); #endif qInstallMsgHandler(qtMsgHandler); QApplication app(argc, argv); QApplication::setStartDragDistance(settings->tapRadius); QApplication::setDoubleClickInterval (Settings::LunaSettings()->tapDoubleClickDuration); host->show(); initMallocStatsCb(HostBase::instance()->mainLoop(), s_mallocStatsInterval); // Initialize Preferences handler (void) Preferences::instance(); // Initialize Localization handler (void) Localization::instance(); //Register vibration/haptics support HapticsController::instance()->startService(); (void) DeviceInfo::instance(); // Initialize Security handler (void) Security::instance(); // Initialize the System Service SystemService::instance()->init(); // Initialize the application mgr ApplicationManager::instance()->init(); // Initialize the Application Installer ApplicationInstaller::instance(); // Start the window manager WindowServer *windowServer = WindowServer::instance(); windowServer->installEventFilter(windowServer); // Initialize the SysMgr MemoryMonitor MemoryMonitor::instance(); // load all set policies EASPolicyManager::instance()->load(); // Launching of the System UI launcher and headless apps has been moved to WebAppMgrProxy::connectWebAppMgr // Did user specify an app to launch if (s_appToLaunchStr) { WebAppMgrProxy::setAppToLaunchUponConnection(s_appToLaunchStr); } app.exec(); return 0; }
int main(int argc, char *argv[], char *env[]) { int i; const char* desktop_name; char *file; setlocale(LC_CTYPE, ""); #if !GLIB_CHECK_VERSION(2, 32, 0) g_thread_init(NULL); #endif /* gdk_threads_init(); gdk_threads_enter(); */ gtk_init(&argc, &argv); #ifdef ENABLE_NLS bindtextdomain ( GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR ); bind_textdomain_codeset ( GETTEXT_PACKAGE, "UTF-8" ); textdomain ( GETTEXT_PACKAGE ); #endif XSetLocaleModifiers(""); XSetErrorHandler((XErrorHandler) panel_handle_x_error); resolve_atoms(); desktop_name = g_getenv("XDG_CURRENT_DESKTOP"); is_in_lxde = desktop_name && (0 == strcmp(desktop_name, "LXDE")); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { usage(); exit(0); } else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) { printf("lxpanel %s\n", version); exit(0); } else if (!strcmp(argv[i], "--log")) { i++; if (i == argc) { g_critical( "lxpanel: missing log level"); usage(); exit(1); } else { /* deprecated */ } } else if (!strcmp(argv[i], "--configure") || !strcmp(argv[i], "-C")) { config = 1; } else if (!strcmp(argv[i], "--profile") || !strcmp(argv[i], "-p")) { i++; if (i == argc) { g_critical( "lxpanel: missing profile name"); usage(); exit(1); } else { cprofile = g_strdup(argv[i]); } } else { printf("lxpanel: unknown option - %s\n", argv[i]); usage(); exit(1); } } /* Add a gtkrc file to be parsed too. */ file = _user_config_file_name("gtkrc", NULL); gtk_rc_parse(file); g_free(file); /* Check for duplicated lxpanel instances */ if (!check_main_lock() && !config) { printf("There is already an instance of LXPanel. Now to exit\n"); exit(1); } _ensure_user_config_dirs(); /* Add our own icons to the search path of icon theme */ gtk_icon_theme_append_search_path( gtk_icon_theme_get_default(), PACKAGE_DATA_DIR "/images" ); fbev = fb_ev_new(); is_restarting = FALSE; /* init LibFM */ fm_gtk_init(NULL); /* prepare modules data */ lxpanel_prepare_modules(); init_static_plugins(); load_global_config(); /* NOTE: StructureNotifyMask is required by XRandR * See init_randr_support() in gdkscreen-x11.c of gtk+ for detail. */ gdk_window_set_events(gdk_get_default_root_window(), GDK_STRUCTURE_MASK | GDK_SUBSTRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK); gdk_window_add_filter(gdk_get_default_root_window (), (GdkFilterFunc)panel_event_filter, NULL); if( G_UNLIKELY( ! start_all_panels() ) ) g_warning( "Config files are not found.\n" ); /* * FIXME: configure?? if (config) configure(); */ gtk_main(); XSelectInput (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), GDK_ROOT_WINDOW(), NoEventMask); gdk_window_remove_filter(gdk_get_default_root_window (), (GdkFilterFunc)panel_event_filter, NULL); /* destroy all panels */ g_slist_foreach( all_panels, (GFunc) gtk_widget_destroy, NULL ); g_slist_free( all_panels ); all_panels = NULL; g_free( cfgfile ); free_global_config(); lxpanel_unload_modules(); fm_gtk_finalize(); /* gdk_threads_leave(); */ g_object_unref(fbev); if (!is_restarting) return 0; if (strchr(argv[0], G_DIR_SEPARATOR)) execve(argv[0], argv, env); else execve(g_find_program_in_path(argv[0]), argv, env); return 1; }
bool wxApp::Initialize(int& argc, wxChar **argv) { bool init_result; #if wxUSE_THREADS if (!g_thread_supported()) g_thread_init(NULL); wxgs_poll_func = g_main_context_get_poll_func(NULL); g_main_context_set_poll_func(NULL, wxapp_poll_func); #endif // wxUSE_THREADS gtk_set_locale(); // We should have the wxUSE_WCHAR_T test on the _outside_ #if wxUSE_WCHAR_T // gtk+ 2.0 supports Unicode through UTF-8 strings wxConvCurrent = &wxConvUTF8; #else // !wxUSE_WCHAR_T if (!wxOKlibc()) wxConvCurrent = (wxMBConv*) NULL; #endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T // decide which conversion to use for the file names // (1) this variable exists for the sole purpose of specifying the encoding // of the filenames for GTK+ programs, so use it if it is set wxString encName(wxGetenv(_T("G_FILENAME_ENCODING"))); encName = encName.BeforeFirst(_T(',')); if (encName.CmpNoCase(_T("@locale")) == 0) encName.clear(); encName.MakeUpper(); #if wxUSE_INTL if (encName.empty()) { // (2) if a non default locale is set, assume that the user wants his // filenames in this locale too encName = wxLocale::GetSystemEncodingName().Upper(); // (3) finally use UTF-8 by default if (encName.empty() || encName == _T("US-ASCII")) encName = _T("UTF-8"); wxSetEnv(_T("G_FILENAME_ENCODING"), encName); } #else if (encName.empty()) encName = _T("UTF-8"); #endif // wxUSE_INTL #if wxUSE_WCHAR_T static wxConvBrokenFileNames fileconv(encName); wxConvFileName = &fileconv; #endif // wxUSE_WCHAR_T #if wxUSE_UNICODE // gtk_init() wants UTF-8, not wchar_t, so convert int i; char **argvGTK = new char *[argc + 1]; for ( i = 0; i < argc; i++ ) { argvGTK[i] = wxStrdupA(wxConvUTF8.cWX2MB(argv[i])); } argvGTK[argc] = NULL; int argcGTK = argc; #ifdef __WXGPE__ init_result = true; // is there a _check() version of this? gpe_application_init( &argcGTK, &argvGTK ); #else init_result = gtk_init_check( &argcGTK, &argvGTK ); #endif if ( argcGTK != argc ) { // we have to drop the parameters which were consumed by GTK+ for ( i = 0; i < argcGTK; i++ ) { while ( strcmp(wxConvUTF8.cWX2MB(argv[i]), argvGTK[i]) != 0 ) { memmove(argv + i, argv + i + 1, (argc - i)*sizeof(*argv)); } } argc = argcGTK; } //else: gtk_init() didn't modify our parameters // free our copy for ( i = 0; i < argcGTK; i++ ) { free(argvGTK[i]); } delete [] argvGTK; #else // !wxUSE_UNICODE // gtk_init() shouldn't actually change argv itself (just its contents) so // it's ok to pass pointer to it init_result = gtk_init_check( &argc, &argv ); #endif // wxUSE_UNICODE/!wxUSE_UNICODE if (!init_result) { wxLogError(wxT("Unable to initialize gtk, is DISPLAY set properly?")); return false; } // update internal arg[cv] as GTK+ may have removed processed options: this->argc = argc; this->argv = argv; // we can not enter threads before gtk_init is done gdk_threads_enter(); if ( !wxAppBase::Initialize(argc, argv) ) { gdk_threads_leave(); return false; } wxSetDetectableAutoRepeat( true ); #if wxUSE_INTL wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); #endif return true; }
/* static void tvsub(struct timeval *tdiff, struct timeval *t1, struct timeval *t0) { tdiff->tv_sec = t1->tv_sec - t0->tv_sec; tdiff->tv_usec = t1->tv_usec - t0->tv_usec; while (tdiff->tv_usec < 0) tdiff->tv_sec--, tdiff->tv_usec += 1000000; } static int Nread(GstElement * dccpclientsrc) { sock=socket (AF_INET, SOCK_DCCP, IPPROTO_DCCP); g_object_get(G_OBJECT(dccpclientsrc), "sockfd", &sock, NULL); struct tfrc_rx_info tfrc; socklen_t len = sizeof(tfrc); struct timeval now, onow; getsockopt(sock, SOL_DCCP, DCCP_SOCKOPT_CCID_RX_INFO,(char*)&tfrc, &len); gettimeofday(&now, NULL); tvsub(&onow, &now, &time0); printf("%ld.%06ld %u %u %u\n", onow.tv_sec, onow.tv_usec, tfrc.tfrcrx_x_recv, tfrc.tfrcrx_rtt, tfrc.tfrcrx_p); //if (tfrc.tfrcrx_p>0) //tfrc.tfrcrx_p=0; //setsockopt(sock, SOL_DCCP, DCCP_SOCKOPT_CCID_TX_INFO,&tfrc, sizeof(tfrc)); return 1; } */ int main (int argc, char *argv[]){ GMainLoop *loop; GstBus *bus; GstElement *pipeline, *ffmpegcolorspace, *ximagesink, *h264parse, *ffdec_h264, *dccpclientsrc; gchar *host="127.0.0.1"; gint port = 4000; gint ccid = 3; GOptionContext *context = NULL; GError *err; /* Option Entry */ GOptionEntry entries[] = { {"Port", 'p', 0, G_OPTION_ARG_INT, &port, "The port to receive packets from (default: 4000)", NULL}, {"Host", 'i', 0, G_OPTION_ARG_STRING, &host, "The host IP address to receive packets from (default: localhost)", NULL}, {"ccid", 'c', 0, G_OPTION_ARG_INT, &ccid, "The Congestion Control IDentified to be used (default: 3)", NULL}, {NULL} }; if (!g_thread_supported()) g_thread_init (NULL); context = g_option_context_new("- TFRC over DCCP"); g_option_context_add_main_entries(context, entries, NULL); g_option_context_add_group(context, gst_init_get_option_group()); if (!g_option_context_parse(context, &argc, &argv, &err)) { g_error("%s\n", err->message); return FALSE; } /* initialize GStreamer */ gst_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); /* create elements */ pipeline = gst_pipeline_new ("video-sender"); ximagesink = gst_element_factory_make ("ximagesink", "ximagesink"); ffmpegcolorspace = gst_element_factory_make ("ffmpegcolorspace", "ffmpegcolorspace"); h264parse = gst_element_factory_make ("h264parse", "h264parse"); ffdec_h264 = gst_element_factory_make ("ffdec_h264", "ffdec_h264"); dccpclientsrc = gst_element_factory_make ("dccpclientsrc", "client-source"); if (!pipeline || !ximagesink || !ffmpegcolorspace || !h264parse || !ffdec_h264 || !dccpclientsrc) { g_print ("One element could not be created\n"); return -1; } g_object_set (G_OBJECT (dccpclientsrc), "host", host, NULL); g_object_set (G_OBJECT (dccpclientsrc), "port", port, NULL); g_object_set (G_OBJECT (dccpclientsrc), "ccid", ccid, NULL); bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_bus_add_watch (bus, bus_call, loop); gst_object_unref (bus); /* put all elements in a bin */ gst_bin_add_many (GST_BIN (pipeline), dccpclientsrc, h264parse, ffdec_h264,ffmpegcolorspace, ximagesink, NULL); gst_element_link_many (dccpclientsrc, h264parse, ffdec_h264,ffmpegcolorspace, ximagesink, NULL); /* Now set to playing and iterate. */ g_print ("Setting to PLAYING\n"); gst_element_set_state (pipeline, GST_STATE_PLAYING); g_print ("Running\n"); //g_timeout_add(1000,(GSourceFunc)Nread, dccpclientsrc); g_main_loop_run (loop); /* clean up nicely */ g_print ("Returned, stopping playback\n"); gst_element_set_state (pipeline, GST_STATE_NULL); g_print ("Deleting pipeline\n"); gst_object_unref (GST_OBJECT (pipeline)); return 0; }
int main (int argc, char *argv[]) { signal_user_data_t *ud; GValue *preset; GError *error = NULL; GOptionContext *context; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif if (!g_thread_supported()) g_thread_init(NULL); context = g_option_context_new ("- Transcode media formats"); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); #if defined(_ENABLE_GST) g_option_context_add_group (context, gst_init_get_option_group ()); #endif g_option_context_parse (context, &argc, &argv, &error); g_option_context_free(context); if (argc > 1 && dvd_device == NULL && argv[1][0] != '-') { dvd_device = argv[1]; } gtk_init (&argc, &argv); gtk_rc_parse_string(hud_rcstyle); g_type_class_unref(g_type_class_ref(GTK_TYPE_BUTTON)); g_object_set(gtk_settings_get_default(), "gtk-button-images", TRUE, NULL); #if !defined(_WIN32) notify_init("HandBrake"); #endif ghb_register_transforms(); ghb_resource_init(); ghb_load_icons(); #if !defined(_WIN32) dbus_g_thread_init(); #endif ghb_udev_init(); ghb_write_pid_file(); ud = g_malloc0(sizeof(signal_user_data_t)); ud->debug = ghb_debug; g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, debug_log_handler, ud); g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, warn_log_handler, ud); //g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL, warn_log_handler, ud); ud->settings = ghb_settings_new(); ud->builder = create_builder_or_die (BUILDER_NAME); // Enable events that alert us to media change events watch_volumes (ud); //GtkWidget *widget = GHB_WIDGET(ud->builder, "PictureDetelecineCustom"); //gtk_entry_set_inner_border(widget, 2); // Since GtkBuilder no longer assigns object ids to widget names // Assign a few that are necessary for style overrides to work GtkWidget *widget; #if defined(_NO_UPDATE_CHECK) widget = GHB_WIDGET(ud->builder, "check_updates_box"); gtk_widget_hide(widget); #endif widget = GHB_WIDGET(ud->builder, "preview_hud"); gtk_widget_set_name(widget, "preview_hud"); widget = GHB_WIDGET(ud->builder, "preview_window"); gtk_widget_set_name(widget, "preview_window"); // Set up the "hud" control overlay for the preview window GtkWidget *draw, *hud, *blender, *align; align = GHB_WIDGET(ud->builder, "preview_window_alignment"); draw = GHB_WIDGET(ud->builder, "preview_image_align"); hud = GHB_WIDGET(ud->builder, "preview_hud"); // Set up compositing for hud blender = ghb_compositor_new(); gtk_container_add(GTK_CONTAINER(align), blender); ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), draw, 1, 1); ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), hud, 2, .85); gtk_widget_show(blender); // Redirect stderr to the activity window ghb_preview_init(ud); IoRedirect(ud); ghb_log( "%s - %s - %s", HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE ); ghb_init_dep_map(); // Need to connect x264_options textview buffer to the changed signal // since it can't be done automatically GtkTextView *textview; GtkTextBuffer *buffer; textview = GTK_TEXT_VIEW(GHB_WIDGET (ud->builder, "x264Option")); buffer = gtk_text_view_get_buffer (textview); g_signal_connect(buffer, "changed", (GCallback)x264_entry_changed_cb, ud); ghb_combo_init(ud); g_debug("ud %p\n", ud); g_debug("ud->builder %p\n", ud->builder); bind_audio_tree_model(ud); bind_subtitle_tree_model(ud); bind_presets_tree_model(ud); bind_queue_tree_model(ud); bind_chapter_tree_model(ud); // Connect up the signals to their callbacks // I wrote my own connector so that I could pass user data // to the callbacks. Builder's standard autoconnect doesn't all this. gtk_builder_connect_signals_full (ud->builder, MyConnect, ud); // Load all internal settings ghb_settings_init(ud); // Load the presets files ghb_presets_load(ud); ghb_prefs_load(ud); ghb_prefs_to_ui(ud); gint logLevel; logLevel = ghb_settings_get_int(ud->settings, "LoggingLevel"); ghb_backend_init(logLevel); if (ghb_settings_get_boolean(ud->settings, "hbfd")) { ghb_hbfd(ud, TRUE); } gchar *source = ghb_settings_get_string(ud->settings, "default_source"); ghb_dvd_set_current(source, ud); g_free(source); // Parsing x264 options "" initializes x264 widgets to proper defaults ghb_x264_parse_options(ud, ""); // Populate the presets tree view ghb_presets_list_init(ud, NULL, 0); // Get the first preset name if (arg_preset != NULL) { preset = ghb_parse_preset_path(arg_preset); if (preset) { ghb_select_preset(ud->builder, preset); ghb_value_free(preset); } } else { ghb_select_default_preset(ud->builder); } // Grey out widgets that are dependent on a disabled feature ghb_check_all_depencencies (ud); if (dvd_device != NULL) { // Source overridden from command line option ghb_settings_set_string(ud->settings, "scan_source", dvd_device); g_idle_add((GSourceFunc)ghb_idle_scan, ud); } // Reload and check status of the last saved queue g_idle_add((GSourceFunc)ghb_reload_queue, ud); // Start timer for monitoring libhb status, 500ms g_timeout_add (500, ghb_timer_cb, (gpointer)ud); // Add dvd devices to File menu ghb_volname_cache_init(); g_thread_create((GThreadFunc)ghb_cache_volnames, ud, FALSE, NULL); #if defined(_USE_APP_IND) GtkUIManager * uim = GTK_UI_MANAGER(GHB_OBJECT(ud->builder, "uimanager1")); GtkMenu *ai_menu = GTK_MENU(gtk_ui_manager_get_widget(uim, "/ui/tray_menu")); ud->ai = app_indicator_new("HandBrake", "hb-icon", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); app_indicator_set_menu( ud->ai, ai_menu ); app_indicator_set_label( ud->ai, "", "99.99%"); if (ghb_settings_get_boolean(ud->settings, "show_status")) { app_indicator_set_status( ud->ai, APP_INDICATOR_STATUS_ACTIVE ); } else { app_indicator_set_status( ud->ai, APP_INDICATOR_STATUS_PASSIVE ); } GtkStatusIcon *si; si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status")); gtk_status_icon_set_visible(si, FALSE ); #else GtkStatusIcon *si; si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status")); gtk_status_icon_set_visible(si, ghb_settings_get_boolean(ud->settings, "show_status")); #if GTK_CHECK_VERSION(2, 16, 0) gtk_status_icon_set_has_tooltip(si, TRUE); g_signal_connect(si, "query-tooltip", status_icon_query_tooltip_cb, ud); #else gtk_status_icon_set_tooltip(si, "HandBrake"); #endif #endif // Ugly hack to keep subtitle table from bouncing around as I change // which set of controls are visible GtkRequisition req; gint width, height; widget = GHB_WIDGET(ud->builder, "SrtCodeset"); gtk_widget_size_request( widget, &req ); height = req.height; widget = GHB_WIDGET(ud->builder, "srt_code_label"); gtk_widget_size_request( widget, &req ); height += req.height; widget = GHB_WIDGET(ud->builder, "subtitle_table"); gtk_widget_set_size_request(widget, -1, height); widget = GHB_WIDGET (ud->builder, "hb_window"); GdkGeometry geo = { -1, -1, 1024, 768, -1, -1, 10, 10, 0, 0, GDK_GRAVITY_NORTH_WEST }; GdkWindowHints geo_mask; geo_mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE; gtk_window_set_geometry_hints( GTK_WINDOW(widget), widget, &geo, geo_mask); width = ghb_settings_get_int(ud->settings, "window_width"); height = ghb_settings_get_int(ud->settings, "window_height"); gtk_window_resize(GTK_WINDOW(widget), width, height); gtk_widget_show(widget); /* * Filter objects in GtkBuilder xml * Unfortunately, GtkFilter is poorly supported by GtkBuilder, * so a lot of the setup must happen in code. SourceFilterAll SourceFilterVideo SourceFilterTS SourceFilterMPG SourceFilterEVO SourceFilterVOB SourceFilterMKV SourceFilterMP4 SourceFilterAVI SourceFilterMOV SourceFilterOGG SourceFilterFLV SourceFilterWMV */ // Add filters to source chooser GtkFileFilter *filter; GtkFileChooser *chooser; chooser = GTK_FILE_CHOOSER(GHB_WIDGET(ud->builder, "source_dialog")); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAll")); gtk_file_filter_set_name(filter, "All"); gtk_file_filter_add_pattern(filter, "*"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterVideo")); gtk_file_filter_set_name(filter, "Video"); gtk_file_filter_add_mime_type(filter, "video/*"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterTS")); gtk_file_filter_set_name(filter, "TS"); gtk_file_filter_add_pattern(filter, "*.ts"); gtk_file_filter_add_pattern(filter, "*.TS"); gtk_file_filter_add_pattern(filter, "*.m2ts"); gtk_file_filter_add_pattern(filter, "*.M2TS"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMPG")); gtk_file_filter_set_name(filter, "MPG"); gtk_file_filter_add_pattern(filter, "*.mpg"); gtk_file_filter_add_pattern(filter, "*.MPG"); gtk_file_filter_add_pattern(filter, "*.mepg"); gtk_file_filter_add_pattern(filter, "*.MEPG"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterEVO")); gtk_file_filter_set_name(filter, "EVO"); gtk_file_filter_add_pattern(filter, "*.evo"); gtk_file_filter_add_pattern(filter, "*.EVO"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterVOB")); gtk_file_filter_set_name(filter, "VOB"); gtk_file_filter_add_pattern(filter, "*.vob"); gtk_file_filter_add_pattern(filter, "*.VOB"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMKV")); gtk_file_filter_set_name(filter, "MKV"); gtk_file_filter_add_pattern(filter, "*.mkv"); gtk_file_filter_add_pattern(filter, "*.MKV"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMP4")); gtk_file_filter_set_name(filter, "MP4"); gtk_file_filter_add_pattern(filter, "*.mp4"); gtk_file_filter_add_pattern(filter, "*.MP4"); gtk_file_filter_add_pattern(filter, "*.m4v"); gtk_file_filter_add_pattern(filter, "*.M4V"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMOV")); gtk_file_filter_set_name(filter, "MOV"); gtk_file_filter_add_pattern(filter, "*.mov"); gtk_file_filter_add_pattern(filter, "*.MOV"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAVI")); gtk_file_filter_set_name(filter, "AVI"); gtk_file_filter_add_pattern(filter, "*.avi"); gtk_file_filter_add_pattern(filter, "*.AVI"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterOGG")); gtk_file_filter_set_name(filter, "OGG"); gtk_file_filter_add_pattern(filter, "*.ogg"); gtk_file_filter_add_pattern(filter, "*.OGG"); gtk_file_filter_add_pattern(filter, "*.ogv"); gtk_file_filter_add_pattern(filter, "*.OGV"); gtk_file_filter_add_pattern(filter, "*.ogm"); gtk_file_filter_add_pattern(filter, "*.OGM"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterFLV")); gtk_file_filter_set_name(filter, "FLV"); gtk_file_filter_add_pattern(filter, "*.flv"); gtk_file_filter_add_pattern(filter, "*.FLV"); gtk_file_chooser_add_filter(chooser, filter); filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterWMV")); gtk_file_filter_set_name(filter, "WMV"); gtk_file_filter_add_pattern(filter, "*.wmv"); gtk_file_filter_add_pattern(filter, "*.WMV"); gtk_file_chooser_add_filter(chooser, filter); // Gtk has a really stupid bug. If the file chooser is showing // hidden files AND there is no filter set, it will not select // the filename when gtk_file_chooser_set_filename is called. // So add a completely unnessary filter to prevent this behavior. filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAll")); gtk_file_chooser_set_filter(chooser, filter); PangoFontDescription *font_desc; font_desc = pango_font_description_from_string ("monospace 10"); textview = GTK_TEXT_VIEW(GHB_WIDGET (ud->builder, "activity_view")); gtk_widget_modify_font(GTK_WIDGET(textview), font_desc); pango_font_description_free (font_desc); // Everything should be go-to-go. Lets rock! gtk_main (); gtk_status_icon_set_visible(si, FALSE); ghb_backend_close(); if (ud->queue) ghb_value_free(ud->queue); ghb_value_free(ud->settings); g_io_channel_unref(ud->activity_log); ghb_settings_close(); #if !defined(_WIN32) notify_uninit(); #endif g_free(ud); return 0; }
int main(int argc, char **argv) { int rc; int result = EXIT_FAILURE; struct device *upnp_renderer; rc = process_cmdline(argc, argv); if (rc != 0) { goto out; } if (show_version) { do_show_version(); exit(EXIT_SUCCESS); } if (show_connmgr_scpd) { upnp_renderer_dump_connmgr_scpd(); exit(EXIT_SUCCESS); } if (show_control_scpd) { upnp_renderer_dump_control_scpd(); exit(EXIT_SUCCESS); } if (show_transport_scpd) { upnp_renderer_dump_transport_scpd(); exit(EXIT_SUCCESS); } if (show_outputs) { output_dump_modules(); exit(EXIT_SUCCESS); } if (pid_file && pid_file[0] != '/') { // We need to canonicalize the filename because our // cwd will change after becoming a daemon. char *buf = (char*) malloc(PATH_MAX); // will leak. Ok. char *result = getcwd(buf, PATH_MAX); result = strcat(result, "/"); pid_file = strcat(result, pid_file); } if (daemon_mode) { daemon(0, 0); // TODO: check for daemon() in configure. } if (pid_file) { FILE *p = fopen(pid_file, "w+"); if (p) { fprintf(p, "%d\n", getpid()); fclose(p); } else { perror("Failed to write pid file"); } } if (!g_thread_get_initialized()) { g_thread_init(NULL); } upnp_renderer = upnp_renderer_new(friendly_name, uuid); if (upnp_renderer == NULL) { goto out; } if (show_devicedesc) { char *buf; buf = upnp_get_device_desc(upnp_renderer); assert(buf != NULL); fputs(buf, stdout); exit(EXIT_SUCCESS); } rc = output_init(output); if (rc != 0) { fprintf(stderr,"ERROR: Failed to initialize Output subsystem\n"); goto out; } struct device_private *device; device = upnp_device_init(upnp_renderer, ip_address); if (device == NULL) { fprintf(stderr,"ERROR: Failed to initialize UPnP device\n"); goto out; } upnp_transport_init(device); upnp_control_init(); printf("Ready for rendering..\n"); output_loop(); result = EXIT_SUCCESS; out: return result; }
int main(void){ GThread *theThread; GtkWidget *window; GtkWidget *save; GtkWidget *hbox; GtkWidget *theTable; GtkWidget *eBox, *eBox2; GtkWidget *lsh,*lsl,*lvh,*lvl; gtk_init(0,NULL); loadVars("segVals.dat",theVars); //int index=getIndex(); window=gtk_window_new(GTK_WINDOW_TOPLEVEL); hbox=gtk_hbox_new(FALSE,2); image=gtk_image_new(); gseg=gtk_image_new(); eBox=gtk_event_box_new(); eBox2=gtk_event_box_new(); theTable=gtk_table_new(5,2,TRUE); save = gtk_button_new_with_label("Save!"); spinvh=gtk_spin_button_new_with_range(0,255,1); spinvl=gtk_spin_button_new_with_range(0,255,1); spinsh=gtk_spin_button_new_with_range(0,255,1); spinsl=gtk_spin_button_new_with_range(0,255,1); lsh=gtk_label_new_with_mnemonic("sh"); lsl=gtk_label_new_with_mnemonic("sl"); lvh=gtk_label_new_with_mnemonic("vh"); lvl=gtk_label_new_with_mnemonic("vl"); hval=gtk_label_new_with_mnemonic("Hue=0"); gtk_window_set_title(GTK_WINDOW(window),"gtk application"); g_signal_connect(window,"delete_event",G_CALLBACK(kill_window),NULL); g_signal_connect(eBox,"button_press_event",G_CALLBACK(pressed),image); g_signal_connect(eBox2,"button_press_event",G_CALLBACK(pressed),image); g_signal_connect(save,"button_press_event",G_CALLBACK(theSaver),NULL); g_signal_connect(spinsh,"changed",G_CALLBACK(updateValue), (gpointer)1); g_signal_connect(spinsl,"changed",G_CALLBACK(updateValue),(gpointer)2); g_signal_connect(spinvh,"changed",G_CALLBACK(updateValue),(gpointer)3); g_signal_connect(spinvl,"changed",G_CALLBACK(updateValue),(gpointer)4);//*/ gtk_table_attach_defaults(GTK_TABLE(theTable),spinsh,0,1,0,1); gtk_table_attach_defaults(GTK_TABLE(theTable),spinsl,0,1,1,2); gtk_table_attach_defaults(GTK_TABLE(theTable),spinvh,0,1,2,3); gtk_table_attach_defaults(GTK_TABLE(theTable),spinvl,0,1,3,4); gtk_table_attach_defaults(GTK_TABLE(theTable),lsh,1,2,0,1); gtk_table_attach_defaults(GTK_TABLE(theTable),lsl,1,2,1,2); gtk_table_attach_defaults(GTK_TABLE(theTable),lvh,1,2,2,3); gtk_table_attach_defaults(GTK_TABLE(theTable),lvl,1,2,3,4); gtk_table_attach_defaults(GTK_TABLE(theTable),hval,0,2,4,5); updateLimits(); /*gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinsh),theVars[7+theIndex*2].theInt); gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinsl),theVars[6+theIndex*2].theInt); gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinvh),theVars[13+theIndex*2].theInt); gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinvl),theVars[12+theIndex*2].theInt);//*/ gtk_container_add(GTK_CONTAINER(eBox),image); gtk_container_add(GTK_CONTAINER(eBox2),gseg); //gtk_box_pack_start(GTK_BOX(hbox),gseg,FALSE,FALSE,2); gtk_box_pack_start(GTK_BOX(hbox),eBox2,FALSE,FALSE,2); gtk_box_pack_start(GTK_BOX(hbox),eBox,FALSE,FALSE,2); gtk_box_pack_start(GTK_BOX(hbox),theTable,FALSE,FALSE,2); gtk_box_pack_start(GTK_BOX(hbox),save,TRUE,TRUE,2); //gtk_box_pack_start(GTK_BOX(hbox),save,FALSE,FALSE,2); gtk_container_add(GTK_CONTAINER(window),hbox); if( g_thread_supported() ) { g_thread_init(NULL); gdk_threads_init(); // Called to initialize internal mutex "gdk_threads_mutex". printf("g_thread supported\n"); } else { printf("g_thread NOT supported\n"); exit(0); } theThread = g_thread_create((GThreadFunc)ocvThread, NULL, TRUE, NULL); assert(theThread!=NULL); gtk_widget_show_all(window); gtk_main(); return 0; }
/* main */ int main (int argc, char *argv[]) { GOptionContext *context; gboolean clipboard_arg = FALSE; gboolean window_arg = FALSE; gboolean area_arg = FALSE; gboolean include_border_arg = FALSE; gboolean disable_border_arg = FALSE; gboolean interactive_arg = FALSE; gchar *border_effect_arg = NULL; guint delay_arg = 0; GError *error = NULL; gboolean res; const GOptionEntry entries[] = { { "clipboard", 'c', 0, G_OPTION_ARG_NONE, &clipboard_arg, N_("Send the grab directly to the clipboard"), NULL }, { "window", 'w', 0, G_OPTION_ARG_NONE, &window_arg, N_("Grab a window instead of the entire screen"), NULL }, { "area", 'a', 0, G_OPTION_ARG_NONE, &area_arg, N_("Grab an area of the screen instead of the entire screen"), NULL }, { "include-border", 'b', 0, G_OPTION_ARG_NONE, &include_border_arg, N_("Include the window border with the screenshot"), NULL }, { "remove-border", 'B', 0, G_OPTION_ARG_NONE, &disable_border_arg, N_("Remove the window border from the screenshot"), NULL }, { "delay", 'd', 0, G_OPTION_ARG_INT, &delay_arg, N_("Take screenshot after specified delay [in seconds]"), N_("seconds") }, { "border-effect", 'e', 0, G_OPTION_ARG_STRING, &border_effect_arg, N_("Effect to add to the border (shadow, border or none)"), N_("effect") }, { "interactive", 'i', 0, G_OPTION_ARG_NONE, &interactive_arg, N_("Interactively set options"), NULL }, { NULL }, }; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); g_thread_init (NULL); context = g_option_context_new (_("Take a picture of the screen")); g_option_context_set_ignore_unknown_options (context, FALSE); g_option_context_set_help_enabled (context, TRUE); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_parse (context, &argc, &argv, &error); if (error) { g_critical ("Unable to parse arguments: %s", error->message); g_error_free (error); g_option_context_free (context); exit (1); } g_option_context_free (context); res = screenshot_load_config (clipboard_arg, window_arg, area_arg, include_border_arg, disable_border_arg, border_effect_arg, delay_arg, interactive_arg); if (!res || !screenshot_app_init ()) exit (1); /* interactive mode: trigger the dialog and wait for the response */ if (interactive_arg) { GtkWidget *dialog; dialog = screenshot_interactive_dialog_new (); gtk_widget_show (dialog); g_signal_connect (dialog, "response", G_CALLBACK (interactive_dialog_response_cb), NULL); } else { screenshot_start (); } gtk_main (); g_clear_object (&connection); return EXIT_SUCCESS; }
int AP_Win32App::WinMain(const char * szAppName, HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { if (!g_thread_supported ()) g_thread_init (NULL); bool bShowApp = true; BOOL bInitialized = FALSE; // this is a static function and doesn't have a 'this' pointer. MSG msg; #ifdef _MSC_VER _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_DEBUG ); _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_DEBUG ); _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_WNDW); #endif // HACK: load least-common-denominator Rich Edit control // TODO: fix Spell dlg so we don't rely on this // ALT: make it a Preview widget instead HINSTANCE hinstRich = LoadLibraryW(L"riched32.dll"); if (!hinstRich) hinstRich = LoadLibraryW(L"riched20.dll"); UT_return_val_if_fail (hinstRich, 1); AP_Win32App * pMyWin32App; // OLE Stuff if (SUCCEEDED(OleInitialize(NULL))) bInitialized = TRUE; // We put this in a block to force the destruction of Args in the stack { UT_Win32LocaleString scnv; UT_UTF8String sUTFCmdLine; // Load the command line into an XAP_Args class scnv.fromLocale(GetCommandLineW()); sUTFCmdLine=scnv.utf8_str(); XAP_Args XArgs = XAP_Args(sUTFCmdLine.utf8_str()); // Step 1: Initialize our application. pMyWin32App = new AP_Win32App(hInstance, szAppName); AP_Args Args = AP_Args(&XArgs, szAppName, pMyWin32App); Args.parseOptions(); pMyWin32App->initialize(); // Step 2: Handle all non-window args. // process args (calls common arg handler, which then calls platform specific) // As best I understand, it returns true to continue and show window, or // false if no window should be shown (and thus we should simply exit). bool windowlessArgsWereSuccessful = true; if (!Args.doWindowlessArgs(windowlessArgsWereSuccessful)) { pMyWin32App->shutdown(); // properly shutdown the app 1st delete pMyWin32App; return (windowlessArgsWereSuccessful ? 0 : -1); } // Step 3: Create windows as appropriate. // if some args are botched, it returns false and we should // continue out the door. // We used to check for bShowApp here. It shouldn't be needed // anymore, because doWindowlessArgs was supposed to bail already. -PL if (!pMyWin32App->openCmdLineFiles(&Args)) { pMyWin32App->shutdown(); // properly shutdown the app 1st delete pMyWin32App; return 0; } } // // This block is controlled by the Structured Exception Handle // if any crash happens here we will recover it and save the file (cross fingers) // try { UT_uint32 iHeight = 0, iWidth = 0, t_flag =0; UT_sint32 iPosX = 0, iPosY = 0; if (!((XAP_App::getApp()->getGeometry(&iPosX,&iPosY,&iWidth,&iHeight,&t_flag)) && ((iWidth > 0) && (iHeight > 0))) ) XAP_App::getApp()->getDefaultGeometry(iWidth,iHeight,t_flag); if ((t_flag & PREF_FLAG_GEOMETRY_MAXIMIZED)==PREF_FLAG_GEOMETRY_MAXIMIZED) iCmdShow = SW_SHOWMAXIMIZED; if (bShowApp) { // display the windows for(UT_sint32 i = 0; i < pMyWin32App->m_vecFrames.getItemCount(); i++) { AP_Win32Frame * curFrame = (AP_Win32Frame*)pMyWin32App->m_vecFrames[i]; UT_continue_if_fail(curFrame); HWND hwnd = curFrame->getTopLevelWindow(); ShowWindow(hwnd, iCmdShow); UpdateWindow(hwnd); } // do dispatch loop while(UT_GetMessage(&msg, NULL, 0, 0)) { // TranslateMessage is not called because AbiWord // has its own way of decoding keyboard accelerators if (pMyWin32App->handleModelessDialogMessage(&msg)) continue; TranslateMessage(&msg); UT_DispatchMessage(&msg); // Check for idle condition while( !UT_Win32Idle::_isEmpty() && !PeekMessageW(&msg, NULL, 0, 0, PM_NOREMOVE) ) { // Fire idle functions when no pending messages UT_Win32Idle::_fireall(); } } } // Un-init OLE if (bInitialized) OleUninitialize(); FreeLibrary(hinstRich); // unload all loaded plugins (remove some of the memory leaks shown at shutdown :-) XAP_ModuleManager::instance().unloadAllPlugins(); // Step 4: Destroy the App. It should take care of deleting all frames. pMyWin32App->shutdown(); delete pMyWin32App; }// end of thes block is controlled by the Exception Handler // // If an exception happens, with "catch" the block // and then the save it into disk // catch (...) { #ifdef DEBUG throw; #endif AP_Win32App *pApp = (AP_Win32App *) XAP_App::getApp(); UT_return_val_if_fail (pApp,1); // first of all, try to save the current prefs (so that any log entries are dumped // onto disk -- this allows us to save useful info for dbg purposes) we will enclose // this inside of a try/catch block, so that in the (unlikely) case something goes // badly wrong when writing the prefs file, we still get chance to save the open // documents try { if(pApp->getPrefs()) { pApp->getPrefs()->savePrefsFile(); } } catch(...) { // do nothing } IEFileType abiType = IE_Imp::fileTypeForSuffix(".abw"); for (UT_sint32 i = 0; i < pApp->m_vecFrames.getItemCount(); i++) { AP_Win32Frame * curFrame = (AP_Win32Frame*)pApp->m_vecFrames[i]; UT_continue_if_fail(curFrame); // again, we want to catch any exception thrown while saving individual documents, // in order to run through the whole loop try { if (NULL == curFrame->getFilename()) curFrame->backup(".abw.saved", abiType); else curFrame->backup(".saved", abiType); } catch(...) { // do nothing } } // Tell the user was has just happened AP_Win32Frame * curFrame = (AP_Win32Frame*)pApp->m_vecFrames[0]; if (curFrame) { curFrame->showMessageBox(AP_STRING_ID_MSG_Exception,XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK); } }// end of except SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF ); return msg.wParam; }
int main (int argc, char **argv) { GtkBuilder *builder; GtkWidget *widget; GtkAccelGroup *ag; OsmGpsMap *map; OsmGpsMapLayer *osd; OsmGpsMapTrack *rightclicktrack; const char *repo_uri; char *cachedir, *cachebasedir; GError *error = NULL; GOptionContext *context; g_thread_init(NULL); gtk_init (&argc, &argv); context = g_option_context_new ("- Map browser"); g_option_context_set_help_enabled(context, FALSE); g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { usage(context); return 1; } /* Only use the repo_uri to check if the user has supplied a valid map source ID */ repo_uri = osm_gps_map_source_get_repo_uri(opt_map_provider); if ( repo_uri == NULL ) { usage(context); return 2; } cachebasedir = osm_gps_map_get_default_cache_directory(); if (opt_cache_base_dir && g_file_test(opt_cache_base_dir, G_FILE_TEST_IS_DIR)) { cachedir = g_strdup(OSM_GPS_MAP_CACHE_AUTO); cachebasedir = g_strdup(opt_cache_base_dir); } else if (opt_friendly_cache) { cachedir = g_strdup(OSM_GPS_MAP_CACHE_FRIENDLY); } else if (opt_no_cache) { cachedir = g_strdup(OSM_GPS_MAP_CACHE_DISABLED); } else { cachedir = g_strdup(OSM_GPS_MAP_CACHE_AUTO); } if (opt_debug) gdk_window_set_debug_updates(TRUE); g_debug("Map Cache Dir: %s", cachedir); g_debug("Map Provider: %s (%d)", osm_gps_map_source_get_friendly_name(opt_map_provider), opt_map_provider); map = g_object_new (OSM_TYPE_GPS_MAP, "map-source",opt_map_provider, "tile-cache",cachedir, "tile-cache-base", cachebasedir, "proxy-uri",g_getenv("http_proxy"), NULL); osd = g_object_new (OSM_TYPE_GPS_MAP_OSD, "show-scale",TRUE, "show-coordinates",TRUE, "show-crosshair",TRUE, "show-dpad",TRUE, "show-zoom",TRUE, "show-gps-in-dpad",TRUE, "show-gps-in-zoom",FALSE, "dpad-radius", 30, NULL); osm_gps_map_layer_add(OSM_GPS_MAP(map), osd); g_object_unref(G_OBJECT(osd)); //Add a second track for right clicks rightclicktrack = osm_gps_map_track_new(); osm_gps_map_track_add(OSM_GPS_MAP(map), rightclicktrack); g_free(cachedir); g_free(cachebasedir); //Enable keyboard navigation osm_gps_map_set_keyboard_shortcut(map, OSM_GPS_MAP_KEY_FULLSCREEN, GDK_F11); osm_gps_map_set_keyboard_shortcut(map, OSM_GPS_MAP_KEY_UP, GDK_Up); osm_gps_map_set_keyboard_shortcut(map, OSM_GPS_MAP_KEY_DOWN, GDK_Down); osm_gps_map_set_keyboard_shortcut(map, OSM_GPS_MAP_KEY_LEFT, GDK_Left); osm_gps_map_set_keyboard_shortcut(map, OSM_GPS_MAP_KEY_RIGHT, GDK_Right); //Build the UI g_star_image = gdk_pixbuf_new_from_file_at_size ("poi.png", 24,24,NULL); builder = gtk_builder_new(); gtk_builder_add_from_file (builder, "mapviewer.ui", &error); if (error) g_error ("ERROR: %s\n", error->message); gtk_box_pack_start ( GTK_BOX(gtk_builder_get_object(builder, "map_box")), GTK_WIDGET(map), TRUE, TRUE, 0); //Init values float lw,a; GdkColor c; OsmGpsMapTrack *gpstrack = osm_gps_map_gps_get_track (map); g_object_get (gpstrack, "line-width", &lw, "alpha", &a, NULL); osm_gps_map_track_get_color(gpstrack, &c); gtk_adjustment_set_value ( GTK_ADJUSTMENT(gtk_builder_get_object(builder, "gps_width_adjustment")), lw); gtk_adjustment_set_value ( GTK_ADJUSTMENT(gtk_builder_get_object(builder, "gps_alpha_adjustment")), a); gtk_adjustment_set_value ( GTK_ADJUSTMENT(gtk_builder_get_object(builder, "star_xalign_adjustment")), 0.5); gtk_adjustment_set_value ( GTK_ADJUSTMENT(gtk_builder_get_object(builder, "star_yalign_adjustment")), 0.5); gtk_color_button_set_color ( GTK_COLOR_BUTTON(gtk_builder_get_object(builder, "gps_colorbutton")), &c); //Connect to signals g_signal_connect ( gtk_builder_get_object(builder, "zoom_in_button"), "clicked", G_CALLBACK (on_zoom_in_clicked_event), (gpointer) map); g_signal_connect ( gtk_builder_get_object(builder, "zoom_out_button"), "clicked", G_CALLBACK (on_zoom_out_clicked_event), (gpointer) map); g_signal_connect ( gtk_builder_get_object(builder, "home_button"), "clicked", G_CALLBACK (on_home_clicked_event), (gpointer) map); g_signal_connect ( gtk_builder_get_object(builder, "cache_button"), "clicked", G_CALLBACK (on_cache_clicked_event), (gpointer) map); g_signal_connect ( gtk_builder_get_object(builder, "gps_alpha_adjustment"), "value-changed", G_CALLBACK (on_gps_alpha_changed), (gpointer) map); g_signal_connect ( gtk_builder_get_object(builder, "gps_width_adjustment"), "value-changed", G_CALLBACK (on_gps_width_changed), (gpointer) map); g_signal_connect ( gtk_builder_get_object(builder, "star_xalign_adjustment"), "value-changed", G_CALLBACK (on_star_align_changed), (gpointer) "x-align"); g_signal_connect ( gtk_builder_get_object(builder, "star_yalign_adjustment"), "value-changed", G_CALLBACK (on_star_align_changed), (gpointer) "y-align"); g_signal_connect ( gtk_builder_get_object(builder, "gps_colorbutton"), "color-set", G_CALLBACK (on_gps_color_changed), (gpointer) gpstrack); g_signal_connect (G_OBJECT (map), "button-press-event", G_CALLBACK (on_button_press_event), (gpointer) rightclicktrack); g_signal_connect (G_OBJECT (map), "button-release-event", G_CALLBACK (on_button_release_event), (gpointer) gtk_builder_get_object(builder, "text_entry")); g_signal_connect (G_OBJECT (map), "notify::tiles-queued", G_CALLBACK (on_tiles_queued_changed), (gpointer) gtk_builder_get_object(builder, "cache_label")); widget = GTK_WIDGET(gtk_builder_get_object(builder, "window1")); g_signal_connect (widget, "destroy", G_CALLBACK (on_close), (gpointer) map); //Setup accelerators. ag = gtk_accel_group_new(); gtk_accel_group_connect(ag, GDK_w, GDK_CONTROL_MASK, GTK_ACCEL_MASK, g_cclosure_new(gtk_main_quit, NULL, NULL)); gtk_accel_group_connect(ag, GDK_q, GDK_CONTROL_MASK, GTK_ACCEL_MASK, g_cclosure_new(gtk_main_quit, NULL, NULL)); gtk_window_add_accel_group(GTK_WINDOW(widget), ag); gtk_widget_show_all (widget); g_log_set_handler ("OsmGpsMap", G_LOG_LEVEL_MASK, g_log_default_handler, NULL); osm_gps_map_set_center_and_zoom(map, 48.858387,2.346268,12); gtk_main (); return 0; }
/* build a simple gui w/: * - a combo box to select the desired video device * - the zbar widget to display video * - a non-editable text box to display any results */ int main (int argc, char *argv[]) { g_thread_init(NULL); gdk_threads_init(); gdk_threads_enter(); gtk_init(&argc, &argv); const char *video_arg = NULL; if(argc > 1) video_arg = argv[1]; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "test_gtk"); gtk_container_set_border_width(GTK_CONTAINER(window), 8); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); GtkWidget *zbar = zbar_gtk_new(); g_signal_connect(G_OBJECT(zbar), "decoded", G_CALLBACK(decoded), NULL); /* video device list combo box */ GtkWidget *video_list = gtk_combo_box_new_text(); g_signal_connect(G_OBJECT(video_list), "changed", G_CALLBACK(video_changed), zbar); /* enable/disable status button */ GtkWidget *status_button = gtk_toggle_button_new(); status_image = gtk_image_new_from_stock(GTK_STOCK_NO, GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(status_button), status_image); gtk_button_set_label(GTK_BUTTON(status_button), "closed"); gtk_widget_set_sensitive(status_button, FALSE); /* bind status button state and video state */ g_signal_connect(G_OBJECT(status_button), "toggled", G_CALLBACK(status_button_toggled), zbar); g_signal_connect(G_OBJECT(zbar), "notify::video-enabled", G_CALLBACK(video_enabled), status_button); g_signal_connect(G_OBJECT(zbar), "notify::video-opened", G_CALLBACK(video_opened), status_button); /* open image file button */ GtkWidget *open_button = gtk_button_new_from_stock(GTK_STOCK_OPEN); g_signal_connect(G_OBJECT(open_button), "clicked", G_CALLBACK(open_button_clicked), zbar); gtk_combo_box_append_text(GTK_COMBO_BOX(video_list), "<none>"); int active = scan_video(gtk_combo_box_append_text, video_list, video_arg); if(active >= 0) gtk_combo_box_set_active(GTK_COMBO_BOX(video_list), active); /* hbox for combo box and buttons */ GtkWidget *hbox = gtk_hbox_new(FALSE, 8); gtk_box_pack_start(GTK_BOX(hbox), video_list, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), status_button, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), open_button, FALSE, FALSE, 0); /* text box for holding results */ results = GTK_TEXT_VIEW(gtk_text_view_new()); gtk_widget_set_size_request(GTK_WIDGET(results), 320, 64); gtk_text_view_set_editable(results, FALSE); gtk_text_view_set_cursor_visible(results, FALSE); gtk_text_view_set_left_margin(results, 4); /* vbox for hbox, zbar test widget and result text box */ GtkWidget *vbox = gtk_vbox_new(FALSE, 8); gtk_container_add(GTK_CONTAINER(window), vbox); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), zbar, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(results), FALSE, FALSE, 0); GdkGeometry hints; hints.min_width = 320; hints.min_height = 240; gtk_window_set_geometry_hints(GTK_WINDOW(window), zbar, &hints, GDK_HINT_MIN_SIZE); gtk_widget_show_all(window); gtk_main(); gdk_threads_leave(); return(0); }
void gtkfb_init(void) { /* This is called in all GTK applications. Arguments are parsed * from the command line and are returned to the application. */ g_thread_init(NULL); gdk_threads_init(); gdk_threads_enter(); gtk_init (NULL, NULL); /* create a new window */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); /* When the window is given the "delete_event" signal (this is given * by the window manager, usually by the "close" option, or on the * titlebar), we ask it to call the delete_event () function * as defined above. The data passed to the callback * function is NULL and is ignored in the callback function. */ g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (delete_event), NULL); /* Here we connect the "destroy" event to a signal handler. * This event occurs when we call gtk_widget_destroy() on the window, * or if we return FALSE in the "delete_event" callback. */ g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy), NULL); /* Sets the border width of the window. */ gtk_container_set_border_width (GTK_CONTAINER (window), 10); pixmap = gdk_pixmap_new(NULL, SIZEX*SCALE, SIZEY*SCALE, 24); // img = gtk_image_new_from_pixmap (pixmap, NULL); drawing_area = gtk_drawing_area_new(); g_signal_connect (G_OBJECT (drawing_area), "expose_event", G_CALLBACK (expose_event_callback), NULL); gtk_widget_set_size_request (drawing_area, SIZEX*SCALE, SIZEY*SCALE); alignment = gtk_alignment_new (0.5,0.5,0,0); gtk_container_add(GTK_CONTAINER(alignment), drawing_area); // gtk_container_add(GTK_CONTAINER(alignment), img); gtk_container_add(GTK_CONTAINER(window), alignment); gtk_widget_show (drawing_area); // gtk_widget_show (img); gtk_widget_show (alignment); /* and the window */ gtk_widget_show (window); gdk_draw_rectangle(pixmap,drawing_area->style->bg_gc[GTK_WIDGET_STATE (drawing_area)], TRUE, 0, 0, SIZEX*SCALE, SIZEY*SCALE); /* All GTK applications must have a gtk_main(). Control ends here * and waits for an event to occur (like a key press or * mouse event). */ /* Create independent threads each of which will execute function */ g_timeout_add (100, &refresh, NULL); pthread_create( >k_thread, NULL, gtk_main, NULL); }
int main (int argc, char **argv) { gboolean threaded = FALSE, synchronous = FALSE; gboolean use_connectable = FALSE; #ifdef G_OS_UNIX GIOChannel *chan; guint watch; #endif /* We can't use GOptionContext because we use the arguments to * decide whether or not to call g_thread_init(). */ while (argc >= 2 && argv[1][0] == '-') { if (!strcmp (argv[1], "-t")) { g_thread_init (NULL); threaded = TRUE; } else if (!strcmp (argv[1], "-s")) synchronous = TRUE; else if (!strcmp (argv[1], "-c")) use_connectable = TRUE; else usage (); argv++; argc--; } g_type_init (); if (argc < 2 || (argc > 2 && use_connectable)) usage (); resolver = g_resolver_get_default (); cancellable = g_cancellable_new (); #ifdef G_OS_UNIX /* Set up cancellation; we want to cancel if the user ^C's the * program, but we can't cancel directly from an interrupt. */ signal (SIGINT, interrupted); if (pipe (cancel_fds) == -1) { perror ("pipe"); exit (1); } chan = g_io_channel_unix_new (cancel_fds[0]); watch = g_io_add_watch (chan, G_IO_IN, async_cancel, cancellable); g_io_channel_unref (chan); #endif nlookups = argc - 1; loop = g_main_loop_new (NULL, TRUE); if (use_connectable) do_connectable (argv[1], synchronous); else { if (threaded && synchronous) start_threaded_lookups (argv + 1, argc - 1); else if (synchronous) start_sync_lookups (argv + 1, argc - 1); else start_async_lookups (argv + 1, argc - 1); } g_main_loop_run (loop); g_main_loop_unref (loop); #ifdef G_OS_UNIX g_source_remove (watch); #endif g_object_unref (cancellable); return 0; }
int main (int argc, char **argv) { int c; char *config_dir = DEFAULT_CONFIG_DIR; char *seafile_dir = NULL; char *logfile = NULL; const char *debug_str = NULL; int daemon_mode = 1; int is_master = 0; CcnetClient *client; char *ccnet_debug_level_str = "info"; char *seafile_debug_level_str = "debug"; int cloud_mode = 0; #ifdef WIN32 LoadLibraryA ("exchndl.dll"); argv = get_argv_utf8 (&argc); #endif while ((c = getopt_long (argc, argv, short_options, long_options, NULL)) != EOF) { switch (c) { case 'h': exit (1); break; case 'v': exit (1); break; case 'c': config_dir = optarg; break; case 'd': seafile_dir = g_strdup(optarg); break; case 'f': daemon_mode = 0; break; case 'l': logfile = g_strdup(optarg); break; case 'D': debug_str = optarg; break; case 'g': ccnet_debug_level_str = optarg; break; case 'G': seafile_debug_level_str = optarg; break; case 'm': is_master = 1; case 'P': pidfile = optarg; break; case 'C': cloud_mode = 1; break; default: usage (); exit (1); } } argc -= optind; argv += optind; #ifndef WIN32 if (daemon_mode) daemon (1, 0); #endif cdc_init (); g_type_init (); #if !GLIB_CHECK_VERSION(2,32,0) g_thread_init (NULL); #endif if (!debug_str) debug_str = g_getenv("SEAFILE_DEBUG"); seafile_debug_set_flags_string (debug_str); if (seafile_dir == NULL) seafile_dir = g_build_filename (config_dir, "seafile", NULL); if (logfile == NULL) logfile = g_build_filename (seafile_dir, "seafile.log", NULL); if (seafile_log_init (logfile, ccnet_debug_level_str, seafile_debug_level_str) < 0) { seaf_warning ("Failed to init log.\n"); exit (1); } client = ccnet_init (config_dir); if (!client) exit (1); register_processors (client); start_rpc_service (client, cloud_mode); create_sync_rpc_clients (config_dir); create_async_rpc_clients (client); seaf = seafile_session_new (seafile_dir, client); if (!seaf) { seaf_warning ("Failed to create seafile session.\n"); exit (1); } seaf->is_master = is_master; seaf->ccnetrpc_client = ccnetrpc_client; seaf->async_ccnetrpc_client = async_ccnetrpc_client; seaf->ccnetrpc_client_t = ccnetrpc_client_t; seaf->async_ccnetrpc_client_t = async_ccnetrpc_client_t; seaf->client_pool = ccnet_client_pool_new (config_dir); seaf->cloud_mode = cloud_mode; load_history_config (); g_free (seafile_dir); g_free (logfile); set_signal_handlers (seaf); /* init seaf */ if (seafile_session_init (seaf) < 0) exit (1); if (seafile_session_start (seaf) < 0) exit (1); if (pidfile) { if (write_pidfile (pidfile) < 0) { ccnet_message ("Failed to write pidfile\n"); return -1; } } atexit (on_seaf_server_exit); ccnet_main (client); return 0; }
int main (int argc, char **argv) { #ifdef HAVE_BREAKPAD_SUPPORT #ifdef WIN32 #define DUMPS_DIR "~/ccnet/logs/dumps/" #else #define DUMPS_DIR "~/.ccnet/logs/dumps/" #endif const char *dump_dir = ccnet_expand_path(DUMPS_DIR); checkdir_with_mkdir(dump_dir); CBPWrapperExceptionHandler bp_exception_handler = newCBPWrapperExceptionHandler(dump_dir); #endif int c; char *config_dir = DEFAULT_CONFIG_DIR; char *seafile_dir = NULL; char *worktree_dir = NULL; char *logfile = NULL; const char *debug_str = NULL; int daemon_mode = 0; CcnetClient *client; char *ccnet_debug_level_str = "info"; char *seafile_debug_level_str = "debug"; #ifdef WIN32 LoadLibraryA ("exchndl.dll"); argv = get_argv_utf8 (&argc); #endif while ((c = getopt_long (argc, argv, short_options, long_options, NULL)) != EOF) { switch (c) { case 'h': usage(); exit (1); break; case 'v': exit (1); break; case 'c': config_dir = optarg; break; case 'd': seafile_dir = g_strdup(optarg); break; case 'b': daemon_mode = 1; break; case 'D': debug_str = optarg; break; case 'w': worktree_dir = g_strdup(optarg); break; case 'l': logfile = g_strdup(optarg); break; case 'g': ccnet_debug_level_str = optarg; break; case 'G': seafile_debug_level_str = optarg; break; default: usage (); exit (1); } } argc -= optind; argv += optind; #ifndef WIN32 if (daemon_mode) { #ifndef __APPLE__ daemon (1, 0); #else /* __APPLE */ /* daemon is deprecated under APPLE * use fork() instead * */ switch (fork ()) { case -1: seaf_warning ("Failed to daemonize"); exit (-1); break; case 0: /* all good*/ break; default: /* kill origin process */ exit (0); } #endif /* __APPLE */ } #endif /* !WIN32 */ cdc_init (); #if !GLIB_CHECK_VERSION(2, 35, 0) g_type_init(); #endif #if !GLIB_CHECK_VERSION(2, 31, 0) g_thread_init(NULL); #endif if (!debug_str) debug_str = g_getenv("SEAFILE_DEBUG"); seafile_debug_set_flags_string (debug_str); if (logfile == NULL) logfile = g_build_filename (config_dir, "logs", "seafile.log", NULL); if (seafile_log_init (logfile, ccnet_debug_level_str, seafile_debug_level_str) < 0) { seaf_warning ("Failed to init log.\n"); exit (1); } if (!bind_ccnet_service (config_dir)) { seaf_warning ("Failed to bind ccnet service\n"); exit (1); } /* init ccnet */ client = ccnet_init (NULL, config_dir); if (!client) exit (1); start_rpc_service (client); create_sync_rpc_clients (config_dir); appletrpc_client = ccnet_create_async_rpc_client (client, NULL, "applet-rpcserver"); /* init seafile */ if (seafile_dir == NULL) seafile_dir = g_build_filename (config_dir, "seafile-data", NULL); if (worktree_dir == NULL) worktree_dir = g_build_filename (g_get_home_dir(), "seafile", NULL); seaf = seafile_session_new (seafile_dir, worktree_dir, client); if (!seaf) { seaf_warning ("Failed to create seafile session.\n"); exit (1); } seaf->ccnetrpc_client = ccnetrpc_client; seaf->appletrpc_client = appletrpc_client; seaf_message ("starting seafile client "SEAFILE_CLIENT_VERSION"\n"); #if defined(SEAFILE_SOURCE_COMMIT_ID) seaf_message ("seafile source code version "SEAFILE_SOURCE_COMMIT_ID"\n"); #endif g_free (seafile_dir); g_free (worktree_dir); g_free (logfile); set_signal_handlers (seaf); #ifndef USE_GPL_CRYPTO seafile_curl_init(); #endif seafile_session_prepare (seaf); seafile_session_start (seaf); seafile_session_config_set_string (seaf, "wktree", seaf->worktree_dir); ccnet_main (client); #ifndef USE_GPL_CRYPTO seafile_curl_deinit(); #endif return 0; }
int main(int argc, char *argv[]) { // Check for big files #ifdef __USE_LARGEFILE #ifdef __USE_LARGEFILE64 printf("\n LARGE FILE AVAILABLE : %d offset\n", __USE_FILE_OFFSET64 ); #endif #endif /* Initialize Gettext if available */ #ifdef HAVE_DCGETTEXT setlocale (LC_ALL, ""); //#define ALOCALES "/usr/local/share/locale" bindtextdomain ("avidemux", ADMLOCALE); textdomain ("avidemux"); printf("Locales for %s appear to be in %s\n","avidemux", ADMLOCALE); printf("\nI18N : %s \n",dgettext("avidemux","_File")); #endif // thx smurf uk :) signal(11, sig_segfault_handler); // show stacktrace on default printf("\n*******************\n"); printf(" Avidemux 2, v " VERSION "\n"); printf("*******************\n"); printf(" http://fixounet.free.fr/avidemux\n"); printf(" Code : Mean & JSC \n"); printf(" GFX : Nestor Di , [email protected]\n"); printf(" Testing : Jakub Misak\n"); printf(" FreeBSD : Anish Mistry, [email protected]\n"); #if (defined( ARCH_X86) || defined(ARCH_X86_64)) printf("Arcc X86 X86_64 activated.\n"); #endif #ifdef USE_XX_XVID_CVS printf("Probing XvidCVS library....\n"); dloadXvidCVS( ); #endif VPInitLibrary(); register_Encoders( ); atexit(onexit); #ifndef CYG_MANGLING g_thread_init(NULL); #endif gtk_set_locale(); gtk_init(&argc, &argv); gdk_rgb_init(); #ifdef USE_XVID_4 xvid4_init(); #endif initFileSelector(); CpuCaps::init(); ADM_InitMemcpy(); // Load .avidemuxrc quotaInit(); prefs->load(); if(!initGUI()) { printf("\n Fatal : could not init GUI\n"); exit(-1); } video_body = new ADM_Composer; #ifdef HAVE_ENCODER registerVideoFilters( ); #endif #ifdef USE_FFMPEG avcodec_init(); avcodec_register_all(); mpegps_init(); #endif #ifdef HAVE_AUDIO AVDM_audioInit(); #endif buildDistMatrix(); initScaleTab(); loadEncoderConfig(); COL_init(); if (argc >= 2) { global_argc=argc; global_argv=argv; gtk_timeout_add( 300, (GtkFunction )automation, NULL ); //automation(); } #ifdef USE_SDL printf("Global SDL init...\n"); SDL_Init(0); //SDL_INIT_AUDIO+SDL_INIT_VIDEO); #endif oplug_mpegInit(); if(SpidermonkeyInit() == true) printf("Spidermonkey initialized.\n"); gtk_main(); SpidermonkeyDestroy(); return 0; }
int main (int argc, char *argv[]) { int i; char *pluginname = NULL; char *plugindir = NULL; char *configfile = NULL; char *objtype = NULL; OSyncError *error = NULL; if (argc < 2) usage (argv[0], 1); pluginname = argv[1]; for (i = 2; i < argc; i++) { char *arg = argv[i]; if (!strcmp (arg, "--config")) { configfile = argv[i + 1]; i++; if (!configfile) usage (argv[0], 1); } else if (!strcmp (arg, "--type")) { objtype = argv[i + 1]; i++; if (!objtype) usage (argv[0], 1); } else if (!strcmp (arg, "--plugindir")) { printf("plugindir %s\n", argv[i + 1]); plugindir = argv[i + 1]; i++; if (!plugindir) usage (argv[0], 1); } else if (!strcmp (arg, "--random")) { only_random = TRUE; } else if (!strcmp (arg, "--help")) { usage (argv[0], 0); } else { usage (argv[0], 1); } } OSyncEnv *env = osync_env_new(NULL); osync_env_set_option(env, "LOAD_GROUPS", "FALSE"); if (plugindir) osync_env_set_option(env, "PLUGINS_DIRECTORY", plugindir); if (!osync_env_initialize(env, &error)) { printf("Unable to initialize environment: %s\n", osync_error_print(&error)); osync_error_unref(&error); return 1; } char *testdir = g_strdup_printf("%s/plgtest.XXXXXX", g_get_tmp_dir()); char *result = mkdtemp(testdir); if (result == NULL) { osync_trace(TRACE_EXIT_ERROR, "unable to create temporary dir: %s", g_strerror(errno)); return 1; } OSyncGroup *group = osync_group_new(env); osync_group_set_name(group, osync_rand_str(8)); osync_group_set_configdir(group, testdir); OSyncMember *member = osync_member_new(group); char *config = NULL; int size = 0; if (configfile) { if (!osync_file_read(configfile, &config, &size, &error)) { fprintf(stderr, "Unable to read config: %s\n", osync_error_print(&error)); osync_error_unref(&error); return 1; } osync_member_set_config(member, config, size); } osync_member_set_pluginname(member, pluginname); OSyncMember *file = osync_member_new(group); localdir = g_strdup_printf("%s/plgtest.XXXXXX", g_get_tmp_dir()); result = mkdtemp(localdir); if (result == NULL) { osync_trace(TRACE_EXIT_ERROR, "unable to create temporary dir: %s", g_strerror(errno)); return 1; } config = g_strdup_printf("<config><path>%s</path><recursive>0</recursive></config>", localdir); osync_member_set_config(file, config, strlen(config) + 1); osync_member_set_pluginname(file, "file-sync"); if (!osync_group_save(group, &error)) { printf("Error while creating syncengine: %s\n", osync_error_print(&error)); osync_error_unref(&error); goto error_free_env; } if (!g_thread_supported ()) g_thread_init (NULL); OSyncEngine *engine = osengine_new(group, &error); if (!engine) { printf("Error while creating syncengine: %s\n", osync_error_print(&error)); osync_error_unref(&error); goto error_free_env; } if (!osengine_init(engine, &error)) { printf("Error while initializing syncengine: %s\n", osync_error_print(&error)); osync_error_unref(&error); goto error_free_engine; } int count = 0; if (only_random) { do { count++; printf("++++++++++++++++++++++++++++++\n"); printf("Initializing new round #%i!\n", count); if (g_random_int_range(0, 5) == 0) { int i; OSyncFormatEnv *env = osync_group_get_format_env(group); for (i = 0; i < osync_conv_num_objtypes(env); i++) { if (g_random_int_range(0, 5) == 0) { OSyncObjType *type = osync_conv_nth_objtype(env, i); osync_group_set_slow_sync(group, osync_objtype_get_name(type), TRUE); printf("Requesting slow-sync for: %s\n", osync_objtype_get_name(type)); } } osync_conv_env_free(env); } change_content(); check_sync(engine, "Random", 1); } while (g_random_int_range(0, 3) != 0); printf("Finalizing engine\n"); osengine_finalize(engine); osengine_free(engine); engine = osengine_new(group, &error); if (!engine) { printf("Error while creating syncengine: %s\n", osync_error_print(&error)); osync_error_unref(&error); goto error_free_env; } if (!osengine_init(engine, &error)) { printf("Error while initializing syncengine: %s\n", osync_error_print(&error)); osync_error_unref(&error); goto error_free_engine; } } else { register_tests(); run_all_tests(engine, file, member, objtype); } printf("\nCompleted successfully\n"); return 0; error_free_engine: osengine_free(engine); error_free_env: osync_group_free(group); osync_env_free(env); return 1; }
int main(int argc, char *argv[]) { gint result = SUCCESS; GeglRectangle rect1 = { 0, 0, 1, 1 }; GeglRectangle rect2 = { 1, 0, 1, 1 }; GeglRectangle rect3 = { 1, 1, 1, 1 }; GeglRectangle rect4 = { 0, 1, 1, 1 }; GeglColor *common_color = NULL; GeglNode *gegl = NULL; GeglNode *color = NULL; GeglNode *layer = NULL; GeglNode *text = NULL; GeglNode *sink = NULL; GeglProcessor *processor = NULL; /* Convenient line to keep around: g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL); */ g_thread_init (NULL); gegl_init (&argc, &argv); common_color = gegl_color_new ("rgb(1.0, 1.0, 1.0)"); gegl = gegl_node_new (); color = gegl_node_new_child (gegl, "operation", "gegl:color", "value", common_color, NULL); layer = gegl_node_new_child (gegl, "operation", "gegl:layer", "x", 0.0, "y", 0.0, NULL); text = gegl_node_new_child (gegl, "operation", "gegl:text", "color", common_color, "string", "█████████████████████████", "size", 200.0, NULL); sink = gegl_node_new_child (gegl, "operation", "gegl:buffer-sink", NULL); /* We build our graph for processing complexity, not for compositing * complexity */ gegl_node_link_many (color, layer, sink, NULL); gegl_node_connect_to (text, "output", layer, "aux"); /* Create a processor */ processor = gegl_node_new_processor (sink, NULL); /* Do the tests */ if (!test_change_processor_rect_do_test (processor, &rect1, sink)) { g_printerr ("test-change-processor-rect: First compare failed\n"); result = FAILURE; goto abort; } if (!test_change_processor_rect_do_test (processor, &rect2, sink)) { g_printerr ("test-change-processor-rect: Second compare failed\n"); result = FAILURE; goto abort; } if (!test_change_processor_rect_do_test (processor, &rect3, sink)) { g_printerr ("test-change-processor-rect: Third compare failed\n"); result = FAILURE; goto abort; } if (!test_change_processor_rect_do_test (processor, &rect4, sink)) { g_printerr ("test-change-processor-rect: Fourth compare failed\n"); result = FAILURE; goto abort; } /* Cleanup */ abort: g_object_unref (processor); g_object_unref (common_color); g_object_unref (gegl); gegl_exit (); return result; }
int main (int argc, char **argv) { static const GOptionEntry test_goptions[] = { { "videosink", '\0', 0, G_OPTION_ARG_STRING, &opt_videosink_str, "videosink to use (default: " DEFAULT_VIDEOSINK ")", NULL }, { "caps", '\0', 0, G_OPTION_ARG_STRING, &opt_filtercaps_str, "filter caps to narrow down formats to test", NULL }, { "with-ffmpegcolorspace", '\0', 0, G_OPTION_ARG_NONE, &opt_with_ffmpegcolorspace, "whether to add an ffmpegcolorspace element in front of the sink", NULL }, {NULL, '\0', 0, 0, NULL, NULL, NULL} }; GOptionContext *ctx; GError *opt_err = NULL; GstElement *pipeline, *src, *filter1, *crop, *scale, *filter2, *csp, *sink; GMainLoop *loop; GstCaps *filter_caps = NULL; GList *caps_list, *l; if (!g_thread_supported ()) g_thread_init (NULL); /* command line option parsing */ ctx = g_option_context_new (""); g_option_context_add_group (ctx, gst_init_get_option_group ()); g_option_context_add_main_entries (ctx, test_goptions, NULL); if (!g_option_context_parse (ctx, &argc, &argv, &opt_err)) { g_error ("Error parsing command line options: %s", opt_err->message); return -1; } GST_DEBUG_CATEGORY_INIT (videocrop_test_debug, "videocroptest", 0, "vctest"); loop = g_main_loop_new (NULL, FALSE); pipeline = gst_pipeline_new ("pipeline"); src = gst_element_factory_make ("videotestsrc", "videotestsrc"); g_assert (src != NULL); filter1 = gst_element_factory_make ("capsfilter", "capsfilter1"); g_assert (filter1 != NULL); crop = gst_element_factory_make ("videocrop", "videocrop"); g_assert (crop != NULL); scale = gst_element_factory_make ("videoscale", "videoscale"); g_assert (scale != NULL); filter2 = gst_element_factory_make ("capsfilter", "capsfilter2"); g_assert (filter2 != NULL); if (opt_with_ffmpegcolorspace) { g_print ("Adding ffmpegcolorspace\n"); csp = gst_element_factory_make ("ffmpegcolorspace", "colorspace"); } else { csp = gst_element_factory_make ("identity", "colorspace"); } g_assert (csp != NULL); if (opt_filtercaps_str) { filter_caps = gst_caps_from_string (opt_filtercaps_str); if (filter_caps == NULL) { g_error ("Invalid filter caps string '%s'", opt_filtercaps_str); } else { g_print ("Using filter caps '%s'\n", opt_filtercaps_str); } } if (opt_videosink_str) { g_print ("Trying videosink '%s' ...", opt_videosink_str); sink = gst_element_factory_make (opt_videosink_str, "sink"); g_print ("%s\n", (sink) ? "ok" : "element couldn't be created"); } else { sink = NULL; } if (sink == NULL) { g_print ("Trying videosink '%s' ...", DEFAULT_VIDEOSINK); sink = gst_element_factory_make (DEFAULT_VIDEOSINK, "sink"); g_print ("%s\n", (sink) ? "ok" : "element couldn't be created"); } if (sink == NULL) { g_print ("Trying videosink '%s' ...", "xvimagesink"); sink = gst_element_factory_make ("xvimagesink", "sink"); g_print ("%s\n", (sink) ? "ok" : "element couldn't be created"); } if (sink == NULL) { g_print ("Trying videosink '%s' ...", "ximagesink"); sink = gst_element_factory_make ("ximagesink", "sink"); g_print ("%s\n", (sink) ? "ok" : "element couldn't be created"); } g_assert (sink != NULL); gst_bin_add_many (GST_BIN (pipeline), src, filter1, crop, scale, filter2, csp, sink, NULL); if (!gst_element_link (src, filter1)) g_error ("Failed to link videotestsrc to capsfilter1"); if (!gst_element_link (filter1, crop)) g_error ("Failed to link capsfilter1 to videocrop"); if (!gst_element_link (crop, scale)) g_error ("Failed to link videocrop to videoscale"); if (!gst_element_link (scale, filter2)) g_error ("Failed to link videoscale to capsfilter2"); if (!gst_element_link (filter2, csp)) g_error ("Failed to link capsfilter2 to ffmpegcolorspace"); if (!gst_element_link (csp, sink)) g_error ("Failed to link ffmpegcolorspace to video sink"); caps_list = video_crop_get_test_caps (crop); for (l = caps_list; l != NULL; l = l->next) { GstStateChangeReturn ret; GstCaps *caps, *out_caps; gboolean skip = FALSE; gchar *s; if (filter_caps) { GstCaps *icaps; icaps = gst_caps_intersect (filter_caps, GST_CAPS (l->data)); skip = gst_caps_is_empty (icaps); gst_caps_unref (icaps); } /* this is the size of our window (stays fixed) */ out_caps = gst_caps_copy (GST_CAPS (l->data)); gst_structure_set (gst_caps_get_structure (out_caps, 0), "width", G_TYPE_INT, OUT_WIDTH, "height", G_TYPE_INT, OUT_HEIGHT, NULL); g_object_set (filter2, "caps", out_caps, NULL); /* filter1 gets these too to prevent videotestsrc from renegotiating */ g_object_set (filter1, "caps", out_caps, NULL); gst_caps_unref (out_caps); caps = gst_caps_copy (GST_CAPS (l->data)); GST_INFO ("testing format: %" GST_PTR_FORMAT, caps); s = gst_caps_to_string (caps); if (skip) { g_print ("Skipping format: %s\n", s); g_free (s); continue; } g_print ("Format: %s\n", s); caps = gst_caps_make_writable (caps); /* FIXME: check return values */ ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); if (ret != GST_STATE_CHANGE_FAILURE) { ret = gst_element_get_state (pipeline, NULL, NULL, -1); if (ret != GST_STATE_CHANGE_FAILURE) { test_with_caps (src, crop, caps); } else { g_print ("Format: %s not supported (failed to go to PLAYING)\n", s); } } else { g_print ("Format: %s not supported\n", s); } gst_element_set_state (pipeline, GST_STATE_NULL); gst_caps_unref (caps); g_free (s); } g_list_foreach (caps_list, (GFunc) gst_caps_unref, NULL); g_list_free (caps_list); gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (pipeline); return 0; }
int main (int argc, char *argv[]) { GOptionContext *context; GError *error = NULL; #ifdef G_OS_WIN32 if (fileno (stdout) != -1 && _get_osfhandle (fileno (stdout)) != -1) { /* stdout is fine, presumably redirected to a file or pipe */ } else { typedef BOOL (* WINAPI AttachConsole_t) (DWORD); AttachConsole_t p_AttachConsole = (AttachConsole_t) GetProcAddress (GetModuleHandle ("kernel32.dll"), "AttachConsole"); if (p_AttachConsole != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS)) { freopen ("CONOUT$", "w", stdout); dup2 (fileno (stdout), 1); freopen ("CONOUT$", "w", stderr); dup2 (fileno (stderr), 2); } } #endif #if !GLIB_CHECK_VERSION (2, 32, 0) /* Init glib threads asap */ if (!g_thread_supported ()) g_thread_init (NULL); #endif #ifdef ENABLE_NLS /* Initialize the i18n stuff */ bindtextdomain (GETTEXT_PACKAGE, ev_get_locale_dir()); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif context = g_option_context_new (N_("MATE Document Viewer")); g_option_context_set_translation_domain(context, GETTEXT_PACKAGE); g_option_context_add_main_entries (context, goption_options, GETTEXT_PACKAGE); #ifdef WITH_SMCLIENT g_option_context_add_group (context, egg_sm_client_get_option_group ()); #endif g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("Cannot parse arguments: %s\n", error->message); g_error_free (error); g_option_context_free (context); return 1; } g_option_context_free (context); if (preview_mode) { gboolean retval; retval = launch_previewer (); return retval ? 0 : 1; } if (!ev_init ()) return 1; ev_stock_icons_init (); #if defined(WITH_SMCLIENT) && defined(GDK_WINDOWING_X11) egg_set_desktop_file (MATEDATADIR "/applications/atril.desktop"); #else /* Manually set name and icon */ g_set_application_name (_("Document Viewer")); gtk_window_set_default_icon_name ("atril"); #endif /* WITH_SMCLIENT && GDK_WINDOWING_X11 */ ev_application_load_session (EV_APP); load_files (file_arguments); /* Change directory so we don't prevent unmounting in case the initial cwd * is on an external device (see bug #575436) */ g_chdir (g_get_home_dir ()); gtk_main (); ev_shutdown (); ev_stock_icons_shutdown (); return 0; }
emulator_context* emu_create_context( dword memsize, dword cachelines, dword cachelinesize ) { /* Check overridden default settings */ if(!memsize) memsize = VA_DEFAULT_MEMORY_SIZE; if(!cachelines) cachelines = VA_DEFAULT_CACHE_LINES; if(!cachelinesize) cachelinesize = VA_DEFAULT_CACHE_LINE_SIZE; /* Allocate contexts */ emulator_context* ectx = emalloc(sizeof(emulator_context)); ectx->cpu_context = emalloc(sizeof(cpu_context)); ectx->memory_context = emalloc(sizeof(memory_context)); ectx->statistic_context = emalloc(sizeof(statistic_context)); /* Set up memory context */ ectx->memory_context->memory = ecalloc(memsize,sizeof(byte)); ectx->memory_context->memory_size = memsize; ectx->memory_context->lines = ecalloc(cachelines, sizeof(cache_context)); ectx->memory_context->cache_lines = cachelines; ectx->memory_context->cache_line_size = cachelinesize; /* Set up statistic context */ ectx->statistic_context->cache_miss_count = 0; ectx->statistic_context->cache_hits = 0; ectx->statistic_context->interrupt_count = 0; ectx->statistic_context->instruction_count = 0; /* Initialize the ITT */ /* removed */ /* Set up cpu context */ ectx->cpu_context->pos = 0u; ectx->cpu_context->cregs = emalloc(sizeof(dword) * 16u); ectx->cpu_context->regs = emalloc(sizeof(dword) * 16u); ectx->cpu_context->regs[CPU_REG_SP] = VA_INIT_SP_LOCATION; ectx->cpu_context->cregs[CPU_CREG_SSP] = VA_INIT_SSP_LOCATION; ectx->cpu_context->cregs[CPU_CREG_CR1] = CR1_PRIV_MODE; ectx->cpu_context->cregs[CPU_CREG_MR2] = 0x00u; /* Thread init */ #if !GLIB_CHECK_VERSION(2,32,0) g_thread_init(NULL); //init glib's threads ectx->memory_context->bus_lock = g_mutex_new(); ectx->log_lock = g_mutex_new(); #else static GMutex bus_mutex; static GMutex log_mutex; ectx->memory_context->bus_lock = &bus_mutex; ectx->log_lock = &log_mutex; #endif /* Create cache lines */ for(int i = 0; i < cachelines; i++) { ectx->memory_context->lines[i].cache = ecalloc(cachelinesize, sizeof(byte)); ectx->memory_context->lines[i].cache_start = i * cachelinesize; ectx->memory_context->lines[i].hit_count = 0; ectx->memory_context->lines[i].wb_required = 0; } /* No interrupts yet, please */ ectx->cpu_context->ints = ecalloc(0, sizeof(byte)); ectx->cpu_context->int_present = 0; /* Set up dma context */ /* removed */ ectx->logbuffer = emalloc(sizeof(char) * 512); ectx->logbuffer_size = 512; ectx->log = &log_stdout; return ectx; }
int main(int argc, char *argv[]) #endif { gboolean opt_force_online = FALSE; gboolean opt_help = FALSE; gboolean opt_login = FALSE; gboolean opt_nologin = FALSE; gboolean opt_version = FALSE; gboolean opt_si = TRUE; /* Check for single instance? */ char *opt_config_dir_arg = NULL; char *opt_login_arg = NULL; char *opt_session_arg = NULL; char *search_path; GList *accounts; #ifdef HAVE_SIGNAL_H int sig_indx; /* for setting up signal catching */ sigset_t sigset; RETSIGTYPE (*prev_sig_disp)(int); char errmsg[BUFSIZ]; GIOChannel *signal_channel; GIOStatus signal_status; guint signal_channel_watcher; #ifndef DEBUG char *segfault_message_tmp; #endif GError *error; #endif int opt; gboolean gui_check; gboolean debug_enabled; gboolean migration_failed = FALSE; GList *active_accounts; struct stat st; struct option long_options[] = { {"config", required_argument, NULL, 'c'}, {"debug", no_argument, NULL, 'd'}, {"force-online", no_argument, NULL, 'f'}, {"help", no_argument, NULL, 'h'}, {"login", optional_argument, NULL, 'l'}, {"multiple", no_argument, NULL, 'm'}, {"nologin", no_argument, NULL, 'n'}, {"session", required_argument, NULL, 's'}, {"version", no_argument, NULL, 'v'}, {"display", required_argument, NULL, 'D'}, {"sync", no_argument, NULL, 'S'}, {0, 0, 0, 0} }; #ifdef DEBUG debug_enabled = TRUE; #else debug_enabled = FALSE; #endif /* Initialize GThread before calling any Glib or GTK+ functions. */ g_thread_init(NULL); g_set_prgname("Pidgin"); #ifdef ENABLE_NLS bindtextdomain(PACKAGE, LOCALEDIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); #endif #ifdef HAVE_SETLOCALE /* Locale initialization is not complete here. See gtk_init_check() */ setlocale(LC_ALL, ""); #endif #ifdef HAVE_SIGNAL_H #ifndef DEBUG /* We translate this here in case the crash breaks gettext. */ segfault_message_tmp = g_strdup_printf(_( "%s %s has segfaulted and attempted to dump a core file.\n" "This is a bug in the software and has happened through\n" "no fault of your own.\n\n" "If you can reproduce the crash, please notify the developers\n" "by reporting a bug at:\n" "%ssimpleticket/\n\n" "Please make sure to specify what you were doing at the time\n" "and post the backtrace from the core file. If you do not know\n" "how to get the backtrace, please read the instructions at\n" "%swiki/GetABacktrace\n"), PIDGIN_NAME, DISPLAY_VERSION, PURPLE_DEVEL_WEBSITE, PURPLE_DEVEL_WEBSITE ); /* we have to convert the message (UTF-8 to console charset) early because after a segmentation fault it's not a good practice to allocate memory */ error = NULL; segfault_message = g_locale_from_utf8(segfault_message_tmp, -1, NULL, NULL, &error); if (segfault_message != NULL) { g_free(segfault_message_tmp); } else { /* use 'segfault_message_tmp' (UTF-8) as a fallback */ g_warning("%s\n", error->message); g_error_free(error); segfault_message = segfault_message_tmp; } #else /* Don't mark this for translation. */ segfault_message = g_strdup( "Hi, user. We need to talk.\n" "I think something's gone wrong here. It's probably my fault.\n" "No, really, it's not you... it's me... no no no, I think we get along well\n" "it's just that.... well, I want to see other people. I... what?!? NO! I \n" "haven't been cheating on you!! How many times do you want me to tell you?! And\n" "for the last time, it's just a rash!\n" ); #endif /* * Create a socket pair for receiving unix signals from a signal * handler. */ if (socketpair(AF_UNIX, SOCK_STREAM, 0, signal_sockets) < 0) { perror("Failed to create sockets for GLib signal handling"); exit(1); } signal_channel = g_io_channel_unix_new(signal_sockets[1]); /* * Set the channel encoding to raw binary instead of the default of * UTF-8, because we'll be sending integers across instead of strings. */ error = NULL; signal_status = g_io_channel_set_encoding(signal_channel, NULL, &error); if (signal_status != G_IO_STATUS_NORMAL) { fprintf(stderr, "Failed to set the signal channel to raw " "binary: %s", error->message); exit(1); } signal_channel_watcher = g_io_add_watch(signal_channel, G_IO_IN, mainloop_sighandler, NULL); g_io_channel_unref(signal_channel); /* Let's not violate any PLA's!!!! */ /* jseymour: whatever the fsck that means */ /* Robot101: for some reason things like gdm like to block * * useful signals like SIGCHLD, so we unblock all the ones we * * declare a handler for. thanks JSeymour and Vann. */ if (sigemptyset(&sigset)) { snprintf(errmsg, sizeof(errmsg), "Warning: couldn't initialise empty signal set"); perror(errmsg); } for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) { if((prev_sig_disp = signal(catch_sig_list[sig_indx], sighandler)) == SIG_ERR) { snprintf(errmsg, sizeof(errmsg), "Warning: couldn't set signal %d for catching", catch_sig_list[sig_indx]); perror(errmsg); } if(sigaddset(&sigset, catch_sig_list[sig_indx])) { snprintf(errmsg, sizeof(errmsg), "Warning: couldn't include signal %d for unblocking", catch_sig_list[sig_indx]); perror(errmsg); } } for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) { if((prev_sig_disp = signal(ignore_sig_list[sig_indx], SIG_IGN)) == SIG_ERR) { snprintf(errmsg, sizeof(errmsg), "Warning: couldn't set signal %d to ignore", ignore_sig_list[sig_indx]); perror(errmsg); } } if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) { snprintf(errmsg, sizeof(errmsg), "Warning: couldn't unblock signals"); perror(errmsg); } #endif /* scan command-line options */ opterr = 1; while ((opt = getopt_long(argc, argv, #ifndef _WIN32 "c:dfhmnl::s:v", #else "c:dfhmnl::v", #endif long_options, NULL)) != -1) { switch (opt) { case 'c': /* config dir */ g_free(opt_config_dir_arg); opt_config_dir_arg = g_strdup(optarg); break; case 'd': /* debug */ debug_enabled = TRUE; break; case 'f': /* force-online */ opt_force_online = TRUE; break; case 'h': /* help */ opt_help = TRUE; break; case 'n': /* no autologin */ opt_nologin = TRUE; break; case 'l': /* login, option username */ opt_login = TRUE; g_free(opt_login_arg); if (optarg != NULL) opt_login_arg = g_strdup(optarg); break; case 's': /* use existing session ID */ g_free(opt_session_arg); opt_session_arg = g_strdup(optarg); break; case 'v': /* version */ opt_version = TRUE; break; case 'm': /* do not ensure single instance. */ opt_si = FALSE; break; case 'D': /* --display */ case 'S': /* --sync */ /* handled by gtk_init_check below */ break; case '?': /* show terse help */ default: show_usage(argv[0], TRUE); #ifdef HAVE_SIGNAL_H g_free(segfault_message); #endif return 0; break; } } /* show help message */ if (opt_help) { show_usage(argv[0], FALSE); #ifdef HAVE_SIGNAL_H g_free(segfault_message); #endif return 0; } /* show version message */ if (opt_version) { printf("%s %s (libpurple %s)\n", PIDGIN_NAME, DISPLAY_VERSION, purple_core_get_version()); #ifdef HAVE_SIGNAL_H g_free(segfault_message); #endif return 0; } /* set a user-specified config directory */ if (opt_config_dir_arg != NULL) { purple_util_set_user_dir(opt_config_dir_arg); } /* * We're done piddling around with command line arguments. * Fire up this baby. */ purple_debug_set_enabled(debug_enabled); /* If we're using a custom configuration directory, we * do NOT want to migrate, or weird things will happen. */ if (opt_config_dir_arg == NULL) { if (!purple_core_migrate()) { migration_failed = TRUE; } } search_path = g_build_filename(purple_user_dir(), "gtkrc-2.0", NULL); gtk_rc_add_default_file(search_path); g_free(search_path); gui_check = gtk_init_check(&argc, &argv); if (!gui_check) { char *display = gdk_get_display(); printf("%s %s\n", PIDGIN_NAME, DISPLAY_VERSION); g_warning("cannot open display: %s", display ? display : "unset"); g_free(display); #ifdef HAVE_SIGNAL_H g_free(segfault_message); #endif return 1; } g_set_application_name(PIDGIN_NAME); #ifdef _WIN32 winpidgin_init(hint); #endif if (migration_failed) { char *old = g_strconcat(purple_home_dir(), G_DIR_SEPARATOR_S ".gaim", NULL); const char *text = _( "%s encountered errors migrating your settings " "from %s to %s. Please investigate and complete the " "migration by hand. Please report this error at http://developer.pidgin.im"); GtkWidget *dialog; dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, text, PIDGIN_NAME, old, purple_user_dir()); g_free(old); g_signal_connect_swapped(dialog, "response", G_CALLBACK(gtk_main_quit), NULL); gtk_widget_show_all(dialog); gtk_main(); #ifdef HAVE_SIGNAL_H g_free(segfault_message); #endif return 0; } purple_core_set_ui_ops(pidgin_core_get_ui_ops()); purple_eventloop_set_ui_ops(pidgin_eventloop_get_ui_ops()); /* * Set plugin search directories. Give priority to the plugins * in user's home directory. */ search_path = g_build_filename(purple_user_dir(), "plugins", NULL); if (!g_stat(search_path, &st)) g_mkdir(search_path, S_IRUSR | S_IWUSR | S_IXUSR); purple_plugins_add_search_path(search_path); g_free(search_path); purple_plugins_add_search_path(LIBDIR); if (!purple_core_init(PIDGIN_UI)) { fprintf(stderr, "Initialization of the libpurple core failed. Dumping core.\n" "Please report this!\n"); #ifdef HAVE_SIGNAL_H g_free(segfault_message); #endif abort(); } if (opt_si && !purple_core_ensure_single_instance()) { #ifdef HAVE_DBUS DBusConnection *conn = purple_dbus_get_connection(); DBusMessage *message = dbus_message_new_method_call(DBUS_SERVICE_PURPLE, DBUS_PATH_PURPLE, DBUS_INTERFACE_PURPLE, "PurpleBlistSetVisible"); gboolean tr = TRUE; dbus_message_append_args(message, DBUS_TYPE_INT32, &tr, DBUS_TYPE_INVALID); dbus_connection_send_with_reply_and_block(conn, message, -1, NULL); dbus_message_unref(message); #endif gdk_notify_startup_complete(); purple_core_quit(); g_printerr(_("Exiting because another libpurple client is already running.\n")); #ifdef HAVE_SIGNAL_H g_free(segfault_message); #endif return 0; } /* TODO: Move blist loading into purple_blist_init() */ purple_set_blist(purple_blist_new()); purple_blist_load(); /* load plugins we had when we quit */ purple_plugins_load_saved(PIDGIN_PREFS_ROOT "/plugins/loaded"); /* TODO: Move pounces loading into purple_pounces_init() */ purple_pounces_load(); ui_main(); #ifdef USE_SM pidgin_session_init(argv[0], opt_session_arg, opt_config_dir_arg); #endif if (opt_session_arg != NULL) { g_free(opt_session_arg); opt_session_arg = NULL; } if (opt_config_dir_arg != NULL) { g_free(opt_config_dir_arg); opt_config_dir_arg = NULL; } /* This needs to be before purple_blist_show() so the * statusbox gets the forced online status. */ if (opt_force_online) purple_network_force_online(); /* * We want to show the blist early in the init process so the * user feels warm and fuzzy (not cold and prickley). */ purple_blist_show(); if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/enabled")) pidgin_debug_window_show(); if (opt_login) { /* disable all accounts */ for (accounts = purple_accounts_get_all(); accounts != NULL; accounts = accounts->next) { PurpleAccount *account = accounts->data; purple_account_set_enabled(account, PIDGIN_UI, FALSE); } /* honor the startup status preference */ if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status")) purple_savedstatus_activate(purple_savedstatus_get_startup()); /* now enable the requested ones */ dologin_named(opt_login_arg); if (opt_login_arg != NULL) { g_free(opt_login_arg); opt_login_arg = NULL; } } else if (opt_nologin) { /* Set all accounts to "offline" */ PurpleSavedStatus *saved_status; /* If we've used this type+message before, lookup the transient status */ saved_status = purple_savedstatus_find_transient_by_type_and_message( PURPLE_STATUS_OFFLINE, NULL); /* If this type+message is unique then create a new transient saved status */ if (saved_status == NULL) saved_status = purple_savedstatus_new(NULL, PURPLE_STATUS_OFFLINE); /* Set the status for each account */ purple_savedstatus_activate(saved_status); } else { /* Everything is good to go--sign on already */ if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status")) purple_savedstatus_activate(purple_savedstatus_get_startup()); purple_accounts_restore_current_statuses(); } if ((active_accounts = purple_accounts_get_all_active()) == NULL) { pidgin_accounts_window_show(); } else { g_list_free(active_accounts); } /* GTK clears the notification for us when opening the first window, * but we may have launched with only a status icon, so clear the it * just in case. */ gdk_notify_startup_complete(); #ifdef _WIN32 winpidgin_post_init(); #endif gtk_main(); #ifdef HAVE_SIGNAL_H g_free(segfault_message); g_source_remove(signal_channel_watcher); close(signal_sockets[0]); close(signal_sockets[1]); #endif #ifdef _WIN32 winpidgin_cleanup(); #endif return 0; }
static void run (const gchar *name, gint nparams, const GimpParam *param, gint *nreturn_vals, GimpParam **return_vals) { static GimpParam values[1]; GimpRunMode run_mode; GimpPDBStatusType status; //gint32 image_ID; gint32 drawable_ID; FblurParam *fblur_param; /* Get the specified values */ run_mode = param[0].data.d_int32; //image_ID = param[1].data.d_image; drawable_ID = param[2].data.d_drawable; #ifdef ENABLE_MP if (! g_thread_supported ()) g_thread_init (NULL); #endif INIT_I18N (); /* Check image type */ if (! gimp_drawable_is_rgb (drawable_ID) && ! gimp_drawable_is_gray (drawable_ID)) { status = GIMP_PDB_EXECUTION_ERROR; goto focusblur_exit; } /* Initialize parameters */ fblur_param = focusblur_param_new (drawable_ID); if (! fblur_param) { status = GIMP_PDB_EXECUTION_ERROR; goto focusblur_exit; } switch (run_mode) { case GIMP_RUN_INTERACTIVE: /* Possibly retrieve data */ focusblur_param_restore (fblur_param); /* Get information from the dialog */ if (! focusblur_dialog (fblur_param)) { status = GIMP_PDB_SUCCESS; goto focusblur_exit; } break; case GIMP_RUN_NONINTERACTIVE: /* Make sure all the arguments are present */ if (! focusblur_param_set (fblur_param, nparams, param)) { status = GIMP_PDB_CALLING_ERROR; goto focusblur_exit; } break; case GIMP_RUN_WITH_LAST_VALS: /* Possibly retrieve data */ if (! focusblur_param_restore (fblur_param)) { status = GIMP_PDB_CALLING_ERROR; goto focusblur_exit; } break; } if (focusblur_execute (fblur_param, NULL)) status = GIMP_PDB_SUCCESS; else status = GIMP_PDB_EXECUTION_ERROR; /* If run mode is interactive, flush displays */ if (run_mode != GIMP_RUN_NONINTERACTIVE) gimp_displays_flush (); /* Store data */ if (run_mode == GIMP_RUN_INTERACTIVE) focusblur_param_store (fblur_param); focusblur_exit: if (run_mode == GIMP_RUN_INTERACTIVE) focusblur_rc_save_preferences (&(fblur_param->pref)); focusblur_param_destroy (&fblur_param); values[0].type = GIMP_PDB_STATUS; values[0].data.d_status = status; *nreturn_vals = G_N_ELEMENTS (values); *return_vals = values; }
int main (int argc, char **argv) { GSThemeEngine *engine; GtkWidget *window; GError *error; gboolean ret; char *location = NULL; char *background_color = NULL; gboolean sort_images = FALSE; gboolean no_stretch = FALSE; GOptionEntry entries [] = { { "location", 0, 0, G_OPTION_ARG_STRING, &location, N_("Location to get images from"), N_("PATH") }, { "background-color", 0, 0, G_OPTION_ARG_STRING, &background_color, N_("Color to use for images background"), N_("\"#rrggbb\"") }, { "sort-images", 0, 0, G_OPTION_ARG_NONE, &sort_images, N_("Do not randomize pictures from location"), NULL }, { "no-stretch", 0, 0, G_OPTION_ARG_NONE, &no_stretch, N_("Do not try to stretch images on screen"), NULL }, { NULL } }; bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); error = NULL; g_thread_init (NULL); ret = gtk_init_with_args (&argc, &argv, NULL, entries, NULL, &error); if (! ret) { g_message ("%s", error->message); g_error_free (error); exit (1); } g_chdir (g_get_home_dir ()); g_set_prgname ("slideshow"); window = gs_theme_window_new (); g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (gtk_main_quit), NULL); engine = g_object_new (GSTE_TYPE_SLIDESHOW, NULL); if (location == NULL) { location = xdg_user_dir_lookup ("PICTURES"); if (location == NULL || strcmp (location, "/tmp") == 0 || strcmp (location, g_get_home_dir ()) == 0) { free (location); location = g_build_filename (g_get_home_dir (), "Pictures", NULL); } } if (location != NULL) { g_object_set (engine, "images-location", location, NULL); } if (sort_images) { g_object_set (engine, "sort-images", sort_images, NULL); } if (background_color != NULL) { g_object_set (engine, "background-color", background_color, NULL); } if (no_stretch) { g_object_set (engine, "no-stretch", no_stretch, NULL); } gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (engine)); gtk_widget_show (GTK_WIDGET (engine)); gtk_window_set_default_size (GTK_WINDOW (window), 640, 480); gtk_widget_show (window); gtk_main (); return 0; }
/* Rather than inline this one, we just declare it as a function, to prevent * GCC warning about inline failure. */ fluid_cond_t * new_fluid_cond (void) { if (!g_thread_supported ()) g_thread_init (NULL); return g_cond_new (); }
gint main (gint argc, gchar * argv[]) { GstElement *pipeline; GstElement *uload, *filter, *sink; GstElement *sourcebin; GstBus *bus; GError *error = NULL; GtkWidget *window; GtkWidget *screen; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *play, *pause, *null, *ready; gchar **source_desc_array = NULL; gchar *source_desc = NULL; GOptionContext *context; GOptionEntry options[] = { {"source-bin", 's', 0, G_OPTION_ARG_STRING_ARRAY, &source_desc_array, "Use a custom source bin description (gst-launch style)", NULL} , {"method", 'm', 0, G_OPTION_ARG_INT, &method, "1 for gstdifferencematte, 2 for gloverlay", "M"} , {"delay", 'd', 0, G_OPTION_ARG_INT, &delay, "Wait N seconds before to send the image to gstreamer (useful with differencematte)", "N"} , {NULL} }; g_thread_init (NULL); context = g_option_context_new (NULL); g_option_context_add_main_entries (context, options, NULL); g_option_context_add_group (context, gst_init_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_print ("Inizialization error: %s\n", GST_STR_NULL (error->message)); return -1; } g_option_context_free (context); if (source_desc_array != NULL) { source_desc = g_strjoinv (" ", source_desc_array); g_strfreev (source_desc_array); } if (source_desc == NULL) { source_desc = g_strdup ("videotestsrc ! video/x-raw-rgb, width=352, height=288 ! identity"); } sourcebin = gst_parse_bin_from_description (g_strdup (source_desc), TRUE, &error); g_free (source_desc); if (error) { g_print ("Error while parsing source bin description: %s\n", GST_STR_NULL (error->message)); return -1; } g_set_application_name ("gst-gl-effects test app"); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width (GTK_CONTAINER (window), 3); pipeline = gst_pipeline_new ("pipeline"); uload = gst_element_factory_make ("glupload", "glu"); if (method == 2) { filter = gst_element_factory_make ("gloverlay", "flt"); } else { filter = gst_element_factory_make ("gldifferencematte", "flt"); } sink = gst_element_factory_make ("glimagesink", "glsink"); gst_bin_add_many (GST_BIN (pipeline), sourcebin, uload, filter, sink, NULL); if (!gst_element_link_many (sourcebin, uload, filter, sink, NULL)) { g_print ("Failed to link one or more elements!\n"); return -1; } g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (destroy_cb), pipeline); g_signal_connect (G_OBJECT (window), "destroy-event", G_CALLBACK (destroy_cb), pipeline); screen = gtk_drawing_area_new (); gtk_widget_set_size_request (screen, 640, 480); // 500 x 376 vbox = gtk_vbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX (vbox), screen, TRUE, TRUE, 0); hbox = gtk_hbox_new (FALSE, 0); play = gtk_button_new_with_label ("PLAY"); g_signal_connect (G_OBJECT (play), "clicked", G_CALLBACK (play_cb), pipeline); pause = gtk_button_new_with_label ("PAUSE"); g_signal_connect (G_OBJECT (pause), "clicked", G_CALLBACK (pause_cb), pipeline); null = gtk_button_new_with_label ("NULL"); g_signal_connect (G_OBJECT (null), "clicked", G_CALLBACK (null_cb), pipeline); ready = gtk_button_new_with_label ("READY"); g_signal_connect (G_OBJECT (ready), "clicked", G_CALLBACK (ready_cb), pipeline); gtk_box_pack_start (GTK_BOX (hbox), null, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), ready, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), play, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), pause, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (window), vbox); bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, screen); gst_bus_add_signal_watch (bus); g_signal_connect (bus, "message::error", G_CALLBACK (message_cb), pipeline); g_signal_connect (bus, "message::warning", G_CALLBACK (message_cb), pipeline); g_signal_connect (bus, "message::eos", G_CALLBACK (message_cb), pipeline); gst_object_unref (bus); g_signal_connect (screen, "expose-event", G_CALLBACK (expose_cb), sink); g_signal_connect (screen, "realize", G_CALLBACK (realize_cb), pipeline); gtk_drag_dest_set (screen, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY); gtk_drag_dest_add_uri_targets (screen); g_signal_connect (screen, "drag-data-received", G_CALLBACK (on_drag_data_received), filter); gtk_widget_show_all (GTK_WIDGET (window)); gtk_main (); return 0; }