/*! \brief Initializes the stroke interface. * \par Function Description * This is the initialization function for the stroke interface. It * initializes the libstroke library and prepare an array of points * for the mouse footprints. * * This function has to be called only once at application * initialization before any use of the stroke interface. */ void x_stroke_init (void) { g_return_if_fail (stroke_points == NULL); stroke_init (); stroke_points = g_array_new (FALSE, FALSE, sizeof (StrokePoint)); }
void gul_gestures_start (GulGestures *as, GtkWidget *widget, guint button, gint x, gint y) { static GdkCursor *cursor = NULL; GulGesturesPrivate *p = as->priv; g_object_ref (as); p->widget = g_object_ref (widget); p->button = button; /* get a new cursor, if necessary */ if (!cursor) cursor = gdk_cursor_new (GDK_PENCIL); /* grab the pointer as soon as possible, we might miss button_release * otherwise */ gdk_pointer_grab (widget->window, FALSE, GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK, NULL, cursor, gtk_get_current_event_time ()); g_signal_connect (widget, "button_release_event", G_CALLBACK (gul_gestures_mouse_release_cb), as); /* init stroke */ stroke_init (); /* attach signals */ g_signal_connect (widget, "motion_notify_event", G_CALLBACK (gul_gestures_motion_cb), as); g_signal_connect (widget, "button_press_event", G_CALLBACK (gul_gestures_mouse_press_cb), as); g_signal_connect (widget, "key_press_event", G_CALLBACK (gul_gestures_key_press_cb), as); g_signal_connect (widget, "unmap-event", G_CALLBACK (gul_gestures_unmap_event_cb), as); gtk_grab_add (widget); gdk_keyboard_grab (widget->window, FALSE, gtk_get_current_event_time ()); p->start_x = x; p->start_y = y; p->started = TRUE; gul_gestures_start_autocancel (as); }
int main (int argc, char *argv[]) { int i; /* init application: * - make program name available for error handlers * - evaluate special options * - initialize toplevel shell and resources * - create an empty PCB with default symbols * - initialize all other widgets * - update screen and get size of drawing area * - evaluate command-line arguments * - register 'call on exit()' function */ setbuf (stdout, 0); InitPaths (argv[0]); #ifdef LOCALEDIR bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); textdomain(GETTEXT_PACKAGE); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); setlocale(LC_ALL,""); #endif srand ( time(NULL) ); /* Set seed for rand() */ initialize_units(); polygon_init (); hid_init (); hid_load_settings (); program_name = argv[0]; program_basename = strrchr (program_name, PCB_DIR_SEPARATOR_C); if (program_basename) { program_directory = strdup (program_name); *strrchr (program_directory, PCB_DIR_SEPARATOR_C) = 0; program_basename++; } else { program_directory = "."; program_basename = program_name; } Progname = program_basename; /* Print usage or version if requested. Then exit. */ if (argc > 1 && (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "-?") == 0 || strcmp (argv[1], "--help") == 0)) usage (); if (argc > 1 && strcmp (argv[1], "-V") == 0) print_version (); /* Export pcb from command line if requested. */ if (argc > 1 && strcmp (argv[1], "-p") == 0) { exporter = gui = hid_find_printer (); argc--; argv++; } else if (argc > 2 && strcmp (argv[1], "-x") == 0) { exporter = gui = hid_find_exporter (argv[2]); argc -= 2; argv += 2; } /* Otherwise start GUI. */ else if (argc > 2 && strcmp (argv[1], "--gui") == 0) { gui = hid_find_gui (argv[2]); if (gui == NULL) { Message("Can't find the gui requested.\n"); exit(1); } argc -= 2; argv += 2; } else { const char **g; gui = NULL; for(g = try_gui_hids; (*g != NULL) && (gui == NULL); g++) { gui = hid_find_gui (*g); } /* try anything */ if (gui == NULL) { Message("Warning: can't find any of the preferred GUIs, falling back to anything available...\n"); gui = hid_find_gui (NULL); } } /* Exit with error if GUI failed to start. */ if (!gui) exit (1); /* Initialize actions only when the gui is already known so only the right one is registered (there can be only one GUI). */ #include "action_list.h" /* Set up layers. */ for (i = 0; i < MAX_LAYER; i++) { char buf[20]; sprintf (buf, "signal%d", i + 1); Settings.DefaultLayerName[i] = strdup (buf); Settings.LayerColor[i] = "#c49350"; Settings.LayerSelectedColor[i] = "#00ffff"; } gui->parse_arguments (&argc, &argv); if (show_help || (argc > 1 && argv[1][0] == '-')) usage (); if (show_version) print_version (); if (show_defaults) print_defaults (); if (show_copyright) copyright (); settings_post_process (); if (show_actions) { print_actions (); exit (0); } if (do_dump_actions) { extern void dump_actions (void); dump_actions (); exit (0); } set_fontfile(); /* Create a new PCB object in memory */ PCB = CreateNewPCB (); if (PCB == NULL) { Message("Can't load the default pcb (%s) for creating an empty layout\n", Settings.DefaultPcbFile); exit(1); } /* Add silk layers to newly created PCB */ CreateNewPCBPost (PCB, 1); if (argc > 1) command_line_pcb = argv[1]; ResetStackAndVisibility (); if (gui->gui) InitCrosshair (); InitHandler (); InitBuffers (); SetMode (ARROW_MODE); if (command_line_pcb) { /* keep filename even if initial load command failed; * file might not exist */ if (LoadPCB (command_line_pcb)) PCB->Filename = strdup (command_line_pcb); } if (Settings.InitialLayerStack && Settings.InitialLayerStack[0]) { LayerStringToLayerStack (Settings.InitialLayerStack); } /* This must be called before any other atexit functions * are registered, as it configures an atexit function to * clean up and free various items of allocated memory, * and must be the last last atexit function to run. */ leaky_init (); /* Register a function to be called when the program terminates. * This makes sure that data is saved even if LEX/YACC routines * abort the program. * If the OS doesn't have at least one of them, * the critical sections will be handled by parse_l.l */ atexit (EmergencySave); /* read the library file and display it if it's not empty */ if (!ReadLibraryContents () && Library.MenuN) hid_action ("LibraryChanged"); #ifdef HAVE_LIBSTROKE stroke_init (); #endif if (Settings.ScriptFilename) { Message (_("Executing startup script file %s\n"), Settings.ScriptFilename); hid_actionl ("ExecuteFile", Settings.ScriptFilename, NULL); } if (Settings.ActionString) { Message (_("Executing startup action %s\n"), Settings.ActionString); hid_parse_actions (Settings.ActionString); } if (gui->printer || gui->exporter) { // Workaround to fix batch output for non-C locales setlocale(LC_NUMERIC,"C"); gui->do_export (0); exit (0); } #if HAVE_DBUS pcb_dbus_setup(); #endif EnableAutosave (); #ifdef DEBUG printf ("Settings.FontPath = \"%s\"\n", Settings.FontPath); printf ("Settings.ElementPath = \"%s\"\n", Settings.ElementPath); printf ("Settings.LibrarySearchPaths = \"%s\"\n", Settings.LibrarySearchPaths); printf ("Settings.LibraryShell = \"%s\"\n", Settings.LibraryShell); printf ("Settings.MakeProgram = \"%s\"\n", UNKNOWN (Settings.MakeProgram)); printf ("Settings.GnetlistProgram = \"%s\"\n", UNKNOWN (Settings.GnetlistProgram)); #endif buildin_init(); gui->do_export (0); #if HAVE_DBUS pcb_dbus_finish(); #endif return (0); }