int main(int argc, char* argv[]) { _debug_ = 0; samplecat_init(); gtk_init_check(&argc, &argv); type_init(); pixmaps_init(); icon_theme_init(); Window win; GLXContext ctx; GLboolean fullscreen = GL_FALSE; static int width = 400, height = 300; int i; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-verbose") == 0) { _debug_ = 1; } #if 0 else if (strcmp(argv[i], "-swap") == 0 && i + 1 < argc) { swap_interval = atoi( argv[i+1] ); do_swap_interval = GL_TRUE; i++; } else if (strcmp(argv[i], "-forcegetrate") == 0) { /* This option was put in because some DRI drivers don't support the * full GLX_OML_sync_control extension, but they do support * glXGetMscRateOML. */ force_get_rate = GL_TRUE; } #endif else if (strcmp(argv[i], "-fullscreen") == 0) { fullscreen = GL_TRUE; } else if (strcmp(argv[i], "-help") == 0) { printf("Usage:\n"); printf(" glx [options]\n"); printf("Options:\n"); printf(" -help Print this information\n"); printf(" -verbose Output info to stdout\n"); printf(" -swap N Swap no more than once per N vertical refreshes\n"); printf(" -forcegetrate Try to use glXGetMscRateOML function\n"); printf(" -fullscreen Full-screen window\n"); return 0; } } Display* dpy = XOpenDisplay(NULL); if(!dpy){ printf("Error: couldn't open display %s\n", XDisplayName(NULL)); return -1; } int screen = DefaultScreen(dpy); make_window(dpy, "Samplcecat", (XDisplayWidth(dpy, screen) - width) / 2, (XDisplayHeight(dpy, screen) - height) / 2, width, height, fullscreen, &win, &ctx); agl_get_extensions(); glx_init(dpy); g_main_loop_new(NULL, true); scene = (AGlRootActor*)agl_actor__new_root_(CONTEXT_TYPE_GLX); void scene_needs_redraw(AGlScene* scene, gpointer _){ need_draw = true; } scene->draw = scene_needs_redraw; gboolean add_content(gpointer _) { app->config_ctx.filename = g_strdup_printf("%s/.config/" PACKAGE "/" PACKAGE, g_get_home_dir()); config_load(&app->config_ctx, &app->config); if (app->config.database_backend && can_use(samplecat.model->backends, app->config.database_backend)) { #define list_clear(L) g_list_free(L); L = NULL; list_clear(samplecat.model->backends); samplecat_model_add_backend(app->config.database_backend); } db_init( #ifdef USE_MYSQL &app->config.mysql #else NULL #endif ); if (!db_connect()) { g_warning("cannot connect to any database.\n"); return EXIT_FAILURE; } samplecat_list_store_do_search((SamplecatListStore*)samplecat.store); Waveform* w = NULL; WaveformCanvas* wfc = wf_context_new(scene); agl_actor__add_child((AGlActor*)scene, actors.bg = background_actor(NULL)); actors.bg->region.x2 = 1; actors.bg->region.y2 = 1; agl_actor__add_child((AGlActor*)scene, actors.search = search_view(NULL)); agl_actor__add_child((AGlActor*)scene, actors.list = list_view(NULL)); agl_actor__add_child((AGlActor*)scene, actors.wave = (AGlActor*)wf_canvas_add_new_actor(wfc, w)); void scene_set_size(AGlActor* scene) { #define SPACING 2 int vspace = scene->region.y2 - 40; int y = 20; int h = search_view_height((SearchView*)actors.search); actors.search->region = (AGliRegion){20, y, scene->region.x2 - 20, y + h}; agl_actor__set_size(actors.search); vspace -= h + SPACING; y += h + SPACING; actors.list->region = (AGliRegion){20, y, scene->region.x2 - 20, y + vspace / 2}; vspace -= vspace / 2; y += vspace; agl_actor__set_size(actors.list); // clear cache actors.wave->region = (AGliRegion){ 20, y, scene->region.x2 - 20, y + vspace }; wf_actor_set_rect((WaveformActor*)actors.wave, &(WfRectangle){ 0.0, 0.0, agl_actor__width(actors.wave), agl_actor__height(actors.wave) }); need_draw = true; }
Application* application_construct (GType object_type) { Application* app = g_object_new (object_type, NULL); app->config_ctx.filename = g_strdup_printf("%s/.config/" PACKAGE "/" PACKAGE, g_get_home_dir()); //app->cache_dir = g_build_filename (g_get_home_dir(), ".config", PACKAGE, "cache", NULL); //app->configctx.dir = g_build_filename (g_get_home_dir(), ".config", PACKAGE, NULL); app->style = (Style){ .bg = 0x000000ff, .bg_alt = 0x181818ff, .bg_selected = 0x777777ff, .fg = 0x66aaffff, .text = 0xbbbbbbff, .selection = 0x6677ff77, .font = "Roboto" }; return app; } Application* application_new () { app = application_construct (TYPE_APPLICATION); samplecat_init(); { ConfigContext* ctx = &app->config_ctx; ctx->options = g_malloc0(CONFIG_MAX * sizeof(ConfigOption*)); void get_theme_name(ConfigOption* option) { g_value_set_string(&option->val, theme_name); } ctx->options[CONFIG_ICON_THEME] = config_option_new_string("icon_theme", get_theme_name); } void on_filter_changed(GObject* _filter, gpointer user_data) { application_search(); } GList* l = samplecat.model->filters_; for(;l;l=l->next){ g_signal_connect((SamplecatFilter*)l->data, "changed", G_CALLBACK(on_filter_changed), NULL); } /* void listmodel__sample_changed(SamplecatModel* m, Sample* sample, int prop, void* val, gpointer _app) { samplecat_list_store_on_sample_changed((SamplecatListStore*)samplecat.store, sample, prop, val); } g_signal_connect((gpointer)samplecat.model, "sample-changed", G_CALLBACK(listmodel__sample_changed), app); void log_message(GObject* o, char* message, gpointer _) { dbg(1, "---> %s", message); statusbar_print(1, PACKAGE_NAME". Version "PACKAGE_VERSION); } g_signal_connect(samplecat.logger, "message", G_CALLBACK(log_message), NULL); */ return app; }