示例#1
0
int 
ui_init( int *argc, char ***argv )
{
  int error;

  if( ui_widget_init() ) return 1;

/* Comment out to Work around a bug in OS X 10.1 related to OpenGL in windowed
   mode */
  atexit(atexit_proc);

  error = SDL_Init( SDL_INIT_VIDEO );
  if ( error )
    return error;

#ifndef __MORPHOS__
  SDL_EnableUNICODE( 1 );
#endif				/* #ifndef __MORPHOS__ */

  sdlkeyboard_init();

  ui_mouse_present = 1;

  return 0;
}
示例#2
0
int
ui_init( int *argc, char ***argv )
{
  struct sigaction handler;
  int error;

  if( ui_widget_init() ) return 1;

  error = atexit( fb_end );
  if( error ) {
    ui_error( UI_ERROR_ERROR, "ui_init: couldn't set atexit function" );
    return 1;
  }
  
  handler.sa_handler = end_handler;

  error = sigaction( SIGTERM, &handler, NULL );
  if( error ) {
    ui_error( UI_ERROR_ERROR, "ui_init: couldn't set SIGTERM handler: %s",
	      strerror( errno ) );
    return 1;
  }

  error = sigaction( SIGHUP, &handler, NULL );
  if( error ) {
    ui_error( UI_ERROR_ERROR, "ui_init: couldn't set SIGHUP handler: %s",
	      strerror( errno ) );
    return 1;
  }

  error = fbkeyboard_init();
  if( error ) return error;

  error = fbmouse_init();
  if( error ) return error;

  error = fbdisplay_init();
  if( error ) return error;

  return 0;
}
示例#3
0
文件: wiiui.c 项目: twinaphex/sdcell
int
ui_init( int *argc, char ***argv )
{
  int error;

#ifdef USE_WIDGET
  if( ui_widget_init() ) return 1;
#endif				/* #ifdef USE_WIDGET */

  error = atexit( wii_end );
  if( error ) {
    ui_error( UI_ERROR_ERROR, "%s: couldn't set atexit function", __func__ );
    return 1;
  }
  
  error = wiidisplay_init();
  if( error ) return error;
  error = wiikeyboard_init();
  if( error ) return error;
  error = wiimouse_init();
  if( error ) return error;

  return 0;
}
示例#4
0
文件: xui.c 项目: twinaphex/sdcell
int
ui_init( int *argc, char ***argv )
{
  char *displayName=NULL;	/* Use default display */
  XWMHints *wmHints;
  XSizeHints *sizeHints;
  XClassHint *classHint;
  char *windowNameList="Fuse",*iconNameList="Fuse";
  XTextProperty windowName, iconName;
  unsigned long windowFlags;
  XSetWindowAttributes windowAttributes;

  /* Allocate memory for various things */

  if( ui_widget_init() ) return 1;

  if(!(wmHints = XAllocWMHints())) {
    fprintf(stderr,"%s: failure allocating memory\n", fuse_progname);
    return 1;
  }

  if(!(sizeHints = XAllocSizeHints())) {
    fprintf(stderr,"%s: failure allocating memory\n", fuse_progname);
    return 1;
  }

  if(!(classHint = XAllocClassHint())) {
    fprintf(stderr,"%s: failure allocating memory\n", fuse_progname);
    return 1;
  }

  if(XStringListToTextProperty(&windowNameList,1,&windowName) == 0 ) {
    fprintf(stderr,"%s: structure allocation for windowName failed\n",
	    fuse_progname);
    return 1;
  }

  if(XStringListToTextProperty(&iconNameList,1,&iconName) == 0 ) {
    fprintf(stderr,"%s: structure allocation for iconName failed\n",
	    fuse_progname);
    return 1;
  }

  /* Open a connection to the X server */

  if ( ( display=XOpenDisplay(displayName)) == NULL ) {
    fprintf(stderr,"%s: cannot connect to X server %s\n", fuse_progname,
	    XDisplayName(displayName));
    return 1;
  }

  /* Set up our error handler */
  xerror_expecting = xerror_error = 0;
  XSetErrorHandler( xerror_handler );

  xui_screenNum = DefaultScreen(display);

  /* Create the main window */

  xui_mainWindow = XCreateSimpleWindow(
    display, RootWindow( display, xui_screenNum ), 0, 0,
    DISPLAY_ASPECT_WIDTH, DISPLAY_SCREEN_HEIGHT, 0,
    BlackPixel( display, xui_screenNum ), WhitePixel( display, xui_screenNum )
  );

  /* Set standard window properties */

  sizeHints->flags = PBaseSize | PResizeInc | PMaxSize | PMinSize;

  sizeHints->base_width = 0;
  sizeHints->base_height = 0;

  sizeHints->min_width    =     DISPLAY_ASPECT_WIDTH;
  sizeHints->min_height   =     DISPLAY_SCREEN_HEIGHT;
  sizeHints->width_inc    =     DISPLAY_ASPECT_WIDTH;
  sizeHints->height_inc   =     DISPLAY_SCREEN_HEIGHT;
  sizeHints->max_width    = 3 * DISPLAY_ASPECT_WIDTH;
  sizeHints->max_height   = 3 * DISPLAY_SCREEN_HEIGHT;

  if( settings_current.aspect_hint ) {
    sizeHints->flags |= PAspect;
    sizeHints->min_aspect.x = 4;
    sizeHints->min_aspect.y = 3;
    sizeHints->max_aspect.x = 4;
    sizeHints->max_aspect.y = 3;
  }

  wmHints->flags=StateHint | InputHint;
  wmHints->initial_state=NormalState;
  wmHints->input=True;

  classHint->res_name=fuse_progname;
  classHint->res_class="Fuse";

  XSetWMProperties(display, xui_mainWindow, &windowName, &iconName,
		   *argv, *argc, sizeHints, wmHints, classHint);

  /* Ask the server to use its backing store for this window */

  windowFlags=CWBackingStore;
  windowAttributes.backing_store=WhenMapped;

  XChangeWindowAttributes(display, xui_mainWindow, windowFlags,
			  &windowAttributes);

  /* Select which types of event we want to receive */

  XSelectInput(display, xui_mainWindow, ExposureMask | KeyPressMask |
	       KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
	       StructureNotifyMask | FocusChangeMask | PointerMotionMask );

  {
    static XColor dummy = { 0, 0, 0, 0, 4, 0 };
    XGCValues xgc;
    GC gc;

    Pixmap mask =
      XCreatePixmap( display, RootWindow( display, xui_screenNum ), 1, 1, 1 );

    xgc.function = GXclear;
    gc = XCreateGC( display, mask, GCFunction, &xgc );
    XFillRectangle( display, mask, gc, 0, 0, 1, 1 );
    nullpointer = XCreatePixmapCursor( display, mask,mask, &dummy,&dummy, 0,0 );
    XFreePixmap( display, mask );
    XFreeGC( display, gc );
  }

  /* Ask to be notified of window close requests */

  delete_window_atom = XInternAtom( display, "WM_DELETE_WINDOW", 0 );
  XSetWMProtocols( display, xui_mainWindow, &delete_window_atom, 1 );

  if( xdisplay_init() ) return 1;

  /* And finally display the window */
  XMapWindow(display,xui_mainWindow);

  ui_mouse_present = 1;

  return 0;
}
示例#5
0
文件: window.c 项目: MiKom/clipt
sys_result_t
ui_window_init(ui_widget_t** widget)
{
    ui_widget_t *ui_widget = ui_widget_defaults(*widget,
                             "Application Window",
                             800, 600);
    ui_window = ui_widget->widget;
    GError *error = NULL;

    if(!ui_window)
        ui_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    gtk_window_set_title(GTK_WINDOW(ui_window), ui_widget->title);
    gtk_window_set_default_size(GTK_WINDOW(ui_window),
                                ui_widget->width,
                                ui_widget->height);

    g_signal_connect(ui_window, "delete-event", G_CALLBACK(ui_window_delete_event_cb), NULL);

    //setting up app vbox
    ui_vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(ui_window), ui_vbox);
    //gtk_widget_show(ui_vbox);
    ui_manager = gtk_ui_manager_new();
    ui_action_group = gtk_action_group_new("Actions");
    gtk_action_group_add_actions(ui_action_group, entries, n_entries, NULL);

    gtk_ui_manager_add_ui_from_string(ui_manager, ui_definition,-1, &error);

    //Populating menus with operations
    ui_histogram_add_action_entries(ui_action_group, ui_window);
    if( ui_histogram_add_ui_string(ui_manager) != CLIPT_OK ) {
        g_warning("Adding histogram menus failed");
    }

    ui_curves_add_action_entries(ui_action_group, ui_window);
    if( ui_curves_add_ui_string(ui_manager) != CLIPT_OK ) {
        g_warning("Adding curves menus failed");
    }

    ui_convolutions_add_action_entries(ui_action_group, ui_window);
    if( ui_convolutions_add_ui_string(ui_manager) != CLIPT_OK ) {
        g_warning("Adding convolutions menu failed");
    }

    ui_binarization_add_action_entries(ui_action_group, ui_window);
    if( ui_binarization_add_ui_string(ui_manager) != CLIPT_OK ) {
        g_warning("Adding binarization menu failed");
    }

    ui_colorspaces_add_action_entries(ui_action_group, ui_window);
    if( ui_colorspaces_add_ui_string(ui_manager) != CLIPT_OK ) {
        g_warning("Adding colorspaces menu entries failed");
    }

    ui_morphology_add_action_entries(ui_action_group, ui_window);
    if( ui_morphology_add_ui_string(ui_manager) != CLIPT_OK ) {
        g_warning("Adding morphology menu entry failed");
    }

    gtk_ui_manager_insert_action_group(ui_manager, ui_action_group, 0);
    if(error) {
        g_error("Building menus failed: %s", error->message);
        g_error_free(error);
        return CLIPT_ERROR;
    }
    ui_menu_bar = gtk_ui_manager_get_widget(ui_manager,"/MainMenu");
    gtk_box_pack_start(GTK_BOX(ui_vbox), ui_menu_bar, FALSE, FALSE, 2);

    ui_toolbar = gtk_ui_manager_get_widget(ui_manager, "/MainToolbar");
    GtkStyleContext* style_ctx = gtk_widget_get_style_context(ui_toolbar);
    gtk_style_context_add_class(style_ctx, GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
    gtk_box_pack_start(GTK_BOX(ui_vbox), ui_toolbar, FALSE, FALSE, 2);

    gtk_window_add_accel_group(GTK_WINDOW(ui_window),
                               gtk_ui_manager_get_accel_group(ui_manager));
    //Drawing area
    ui_drawing_area = ui_widget_init(NULL, "Drawing area", 100, 100);
    ui_drawing_area->widget = gtk_drawing_area_new();
    g_signal_connect_after(ui_drawing_area->widget, "realize",
                           G_CALLBACK(ui_drawing_area_after_realize_cb), ui_drawing_area);
    g_signal_connect_after(ui_drawing_area->widget, "draw",
                           G_CALLBACK(ui_drawing_area_draw_cb), ui_drawing_area);
    gtk_box_pack_end(GTK_BOX(ui_vbox), ui_drawing_area->widget, TRUE, TRUE, 0);
    gtk_widget_set_double_buffered(ui_drawing_area->widget, FALSE);
    //gtk_widget_show(ui_drawing_area->widget);

    //signal emitted when image gets changed somehow
    ui_new_image_signal = g_signal_new("image-changed",
                                       G_TYPE_OBJECT, G_SIGNAL_RUN_FIRST,
                                       0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
                                       G_TYPE_NONE, 0);

    g_signal_connect(G_OBJECT(ui_window), "image-changed",
                     G_CALLBACK(ui_window_image_changed_cb), NULL);

    gtk_widget_show_all(ui_window);
    ui_widget->widget = ui_window;
    return CLIPT_OK;
}