/** * gtk_gl_init: * @argc: (inout): Address of the <parameter>argc</parameter> parameter of your * <function>main()</function> function. Changed if any arguments * were handled. * @argv: (array length=argc) (inout) (allow-none): Address of the <parameter>argv</parameter> parameter of * <function>main()</function>. Any parameters understood by * gtk_gl_init() are stripped before return. * * Call this function before using any other GtkGLExt functions in your * applications. It will initialize everything needed to operate the library * and parses some standard command line options. @argc and * @argv are adjusted accordingly so your own code will * never see those standard arguments. * * <note><para> * This function will terminate your program if it was unable to initialize * the library for some reason. If you want your program to fall back to a * textual interface you want to call gtk_gl_init_check() instead. * </para></note> **/ void gtk_gl_init (int *argc, char ***argv) { if (!gtk_gl_init_check (argc, argv)) g_error ("GdkGLExt library initialization fails."); }
native_handle _chisel_native_openglview_create( ) { static int glsetup = 0; if ( !glsetup ) { gtk_gl_init_check( NULL, NULL ); glsetup = 1; } GtkWidget *widget = gtk_drawing_area_new( ); gtk_widget_set_size_request (widget, 120, 120); _chisel_gtk_setup_events( widget ); //g_signal_connect( G_OBJECT(widget), "size_allocate", G_CALLBACK(_chisel_native_openglview_resize_event), NULL ); //g_signal_connect_after( G_OBJECT(widget), "configure-event", G_CALLBACK(_chisel_native_openglview_configure_event), NULL ); // gtk_widget_set_events( widget, GDK_EXPOSURE_MASK ); GdkGLConfigMode glcmode = (GdkGLConfigMode)(GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE); GdkGLConfig *glconfig = gdk_gl_config_new_by_mode( glcmode ); assert( glconfig != NULL ); assert( gtk_widget_set_gl_capability( widget, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE ) ); g_signal_connect( G_OBJECT(widget), "expose-event", G_CALLBACK(_chisel_native_openglview_expose_event), NULL ); return widget; }
int main(int argc, char* argv[]) { IBusComponent *component; IBusEngineDesc * desc; GError * err = NULL; gboolean have_ibus=FALSE; const gchar * language="zh"; const gchar * icon_dir = NULL; const gchar * locale_dir = NULL; setlocale(LC_ALL, ""); gtk_set_locale(); textdomain(GETTEXT_PACKAGE); GOptionEntry args[] = { {"ibus",'\0',0,G_OPTION_ARG_NONE,&have_ibus}, {"icondir",'\0',0,G_OPTION_ARG_STRING,&icon_dir,_("the icon file"),N_("icon file")}, {"table",'\0',0,G_OPTION_ARG_STRING,&tablefile,_("set table file path"),N_("tablefile")}, {"locale",'\0',0,G_OPTION_ARG_STRING,&locale_dir,_("set locale path"),N_("locale")}, #ifdef WITH_ZINNIA {"lang",'\0',0,G_OPTION_ARG_STRING,&language,_("set languate, accept zh and jp"),N_("lang")}, #endif {0} }; gtk_init_with_args(&argc,&argv,PACKAGE_NAME,args,PACKAGE_NAME,&err); if(G_UNLIKELY(!gtk_gl_init_check(&argc, &argv))) { g_warning("GLX extension not available, use slow soft cairo rendering instead"); } #ifdef WITH_ZINNIA if(strcmp(language,"zh")==0 ||strcmp(language,"zh_CN") ==0 ) { }else if( strcmp(language,"jp") ==0 || strcmp(language,"ja")==0 ) { g_strlcpy(lang,"ja",20); }else { g_error("pass jp or zh to --lang!"); } #endif if(locale_dir) { bindtextdomain(GETTEXT_PACKAGE,locale_dir); } gchar * engine_name = g_strdup_printf("handwrite-%s",lang); gchar * dbus_name = g_strdup_printf("org.freedesktop.IBus.handwrite-%s",lang); ibus_init(); if(icon_dir) realpath(icon_dir, icondir); bus = ibus_bus_new(); g_signal_connect (bus, "disconnected", G_CALLBACK (gtk_main_quit), NULL); factory = ibus_factory_new(ibus_bus_get_connection(bus)); ibus_bus_request_name(bus, dbus_name, 0); // g_free(dbus_name); if (!have_ibus) { char * exefile ; exefile = realpath(argv[0],NULL); component = ibus_component_new(dbus_name, "handwrite", PACKAGE_VERSION, "GPL", MICROCAI_WITHEMAIL, PACKAGE_BUGREPORT, exefile, GETTEXT_PACKAGE); gchar * iconfile = g_strdup_printf("%s/ibus-handwrite.svg",icondir); desc = ibus_engine_desc_new(engine_name, "handwrite", _("hand write recognizer"), lang, "GPL", MICROCAI_WITHEMAIL, iconfile, "us"); ibus_component_add_engine(component, desc); free(exefile); g_free(iconfile); }else { component = ibus_component_new(dbus_name, "handwrite", PACKAGE_VERSION, "GPL", MICROCAI_WITHEMAIL, PACKAGE_BUGREPORT, PKGDATADIR, GETTEXT_PACKAGE); } g_free(dbus_name); ibus_bus_register_component(bus, component); ibus_factory_add_engine(factory, engine_name, IBUS_TYPE_HANDWRITE_ENGINE); g_free(engine_name); g_object_unref(component); GdkScreen * screen = gdk_screen_get_default(); GdkColormap * map = gdk_screen_get_rgba_colormap(screen); if(map) gtk_widget_set_default_colormap(map); printf(_("ibus-handwrite Version %s Start Up\n"), PACKAGE_VERSION); gtk_main(); return 0; }
/*! \brief main() is the typical main function in a C program, it performs all core initialization, loading of all main parameters, initializing handlers and entering gtk_main to process events until program close \param argc is the count of command line arguments \param argv is the array of command line args \returns TRUE */ gint main(gint argc, gchar ** argv) { Serial_Params *serial_params = NULL; GAsyncQueue *queue = NULL; GCond *cond = NULL; GMutex *mutex = NULL; gint id = 0; setlocale(LC_ALL,""); #ifdef __WIN32__ bindtextdomain(PACKAGE, "C:\\Program Files\\MegaTunix\\dist\\locale"); #else bindtextdomain(PACKAGE, LOCALEDIR); #endif textdomain (PACKAGE); #ifdef DEBUG printf("This is a debug release, Git hash: %s\n",MTX_GIT_HASH); #endif if(!g_thread_supported()) g_thread_init(NULL); gdk_threads_init(); gtk_init(&argc, &argv); glade_init(); gdk_gl_init_check(&argc, &argv); gl_ability = gtk_gl_init_check(&argc, &argv); global_data = g_new0(gconstpointer, 1); /* Condition variables */ cond = g_cond_new(); DATA_SET(global_data,"statuscounts_cond",cond); cond = g_cond_new(); DATA_SET(global_data,"io_dispatch_cond",cond); cond = g_cond_new(); DATA_SET(global_data,"gui_dispatch_cond",cond); cond = g_cond_new(); DATA_SET(global_data,"pf_dispatch_cond",cond); cond = g_cond_new(); DATA_SET(global_data,"rtv_thread_cond",cond); /* Mutexes */ mutex = g_mutex_new(); DATA_SET(global_data,"serio_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"rtt_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"rtv_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"dash_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"statuscounts_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"io_dispatch_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"gui_dispatch_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"pf_dispatch_mutex",mutex); mutex = g_mutex_new(); DATA_SET(global_data,"rtv_thread_mutex",mutex); /* For testing if gettext works printf(_("Hello World!\n")); */ /* Build table of strings to enum values */ build_string_2_enum_table(); serial_params = (Serial_Params *)g_malloc0(sizeof(Serial_Params)); DATA_SET(global_data,"serial_params",serial_params); handle_args(argc,argv); /* handle CLI arguments */ /* This will exit mtx if the locking fails! */ create_mtx_lock(); open_debug(); /* Open debug log */ /* Allocate memory */ init(); /* Initialize global vars */ make_mtx_dirs(); /* Create config file dirs if missing */ /* Create Message passing queues */ queue = g_async_queue_new(); DATA_SET_FULL(global_data,"io_data_queue",queue,g_async_queue_unref); queue = g_async_queue_new(); DATA_SET_FULL(global_data,"slave_msg_queue",queue,g_async_queue_unref); queue = g_async_queue_new(); DATA_SET_FULL(global_data,"pf_dispatch_queue",queue,g_async_queue_unref); queue = g_async_queue_new(); DATA_SET_FULL(global_data,"gui_dispatch_queue",queue,g_async_queue_unref); queue = g_async_queue_new(); DATA_SET_FULL(global_data,"io_repair_queue",queue,g_async_queue_unref); read_config(); setup_gui(); gtk_rc_parse_string("style \"override\"\n{\n\tGtkTreeView::horizontal-separator = 0\n\tGtkTreeView::vertical-separator = 0\n}\nwidget_class \"*\" style \"override\""); id = g_timeout_add_full(-50,16,(GSourceFunc)pf_dispatcher,NULL,NULL); DATA_SET(global_data,"pf_dispatcher_id",GINT_TO_POINTER(id)); id = g_timeout_add_full(-35,35,(GSourceFunc)gui_dispatcher,NULL,NULL); DATA_SET(global_data,"gui_dispatcher_id",GINT_TO_POINTER(id)); id = g_timeout_add(1000,(GSourceFunc)flush_binary_logs,NULL); DATA_SET(global_data,"binlog_flush_id",GINT_TO_POINTER(id)); sleep_calib(); /* Check for first_time flag, if so, run first tiem wizard, otherwise load personality choice */ gdk_threads_add_timeout(500,(GSourceFunc)check_for_first_time,NULL); DATA_SET(global_data,"ready",GINT_TO_POINTER(TRUE)); gdk_threads_enter(); gtk_main(); gdk_threads_leave(); return (0) ; }