コード例 #1
0
ファイル: interface.c プロジェクト: jbohren-forks/dia
static GtkWidget *
create_canvas (DDisplay *ddisp)
{
  GtkWidget *canvas = gtk_drawing_area_new();

  /* Dia's canvas does it's double buffering alone so switch off GTK's */
  gtk_widget_set_double_buffered (canvas, FALSE);

  gtk_widget_set_events (canvas,
			 GDK_EXPOSURE_MASK | 
			 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
			 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | 
			 GDK_STRUCTURE_MASK | GDK_ENTER_NOTIFY_MASK |
			 GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
  g_signal_connect (G_OBJECT (canvas), "configure-event",
		    G_CALLBACK (canvas_configure_event), ddisp);
  g_signal_connect (G_OBJECT (canvas), "expose-event",
		    G_CALLBACK (canvas_expose_event), ddisp);
#if GTK_CHECK_VERSION(2,18,0)
  gtk_widget_set_can_focus (canvas, TRUE);
#else
  GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS);
#endif
  g_signal_connect (G_OBJECT (canvas), "event",
                    G_CALLBACK(ddisplay_canvas_events),
                    ddisp);

  toolbox_setup_drag_dest (canvas);
  g_signal_connect (G_OBJECT (canvas), "drag_drop",
		    G_CALLBACK(display_drop_callback), NULL);
  g_signal_connect (G_OBJECT (canvas), "drag_data_received",
		    G_CALLBACK(display_data_received_callback), ddisp);
  g_object_set_data (G_OBJECT (canvas), "user_data", (gpointer) ddisp);

  return canvas;
}
コード例 #2
0
ファイル: interface.c プロジェクト: UIKit0/dia
/**
 * Create integrated user interface
 */
void 
create_integrated_ui (void)
{
  GtkWidget *window;
  GtkWidget *main_vbox;
  GtkWidget *hbox;
  GtkWidget *wrapbox;
  GtkWidget *menubar;
  GtkWidget *toolbar;
  GtkWidget *notebook;
  GtkWidget *statusbar;
  GtkAccelGroup *accel_group;

  GtkWidget *layer_view;
	
#ifdef HAVE_GNOME
  window = gnome_app_new ("Dia", _("Diagram Editor"));
#else
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_object_ref (window);
  gtk_window_set_title (GTK_WINDOW (window), "Dia v" VERSION);
#endif

  /* hint to window manager on X so the wm can put the window in the same  
     as it was when the application shut down                             */      
  gtk_window_set_role (GTK_WINDOW (window), DIA_MAIN_WINDOW);
  
  gtk_window_set_default_size (GTK_WINDOW (window), 146, 349);
 
  app_set_icon (GTK_WINDOW (window));

  g_signal_connect (G_OBJECT (window), "delete_event",
		    G_CALLBACK (toolbox_delete),
		      window);

  g_signal_connect (G_OBJECT (window), "destroy",
		    G_CALLBACK (toolbox_destroy),
		      window);

  main_vbox = gtk_vbox_new (FALSE, 1);
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 1);
#ifdef HAVE_GNOME
  gnome_app_set_contents (GNOME_APP(window), main_vbox);
#else
  gtk_container_add (GTK_CONTAINER (window), main_vbox);
#endif
  gtk_widget_show (main_vbox);

  /* Applicatioon Statusbar */
  statusbar = gtk_statusbar_new ();
  gtk_box_pack_end (GTK_BOX (main_vbox), statusbar, FALSE, TRUE, 0);
  /* HBox for everything below the menubar and toolbars */
  hbox = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_end (GTK_BOX (main_vbox), hbox, TRUE, TRUE, 0);
  gtk_widget_show (hbox);
  
  /* Layer View  */
  layer_view = create_layer_view_widget ();
  gtk_box_pack_end (GTK_BOX (hbox), layer_view, FALSE, FALSE, 0);
	 
  /* Diagram Notebook */
  notebook = gtk_notebook_new ();
  gtk_box_pack_end (GTK_BOX (hbox), notebook, TRUE, TRUE, 0);
  gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE); 
  gtk_widget_show (notebook);

  /* Toolbox widget */
  wrapbox = toolbox_create();
  gtk_box_pack_start (GTK_BOX (hbox), wrapbox, FALSE, TRUE, 0);

  g_signal_connect (G_OBJECT (wrapbox), "drag_data_received",
		    G_CALLBACK (dia_dnd_file_drag_data_received),
                    NULL); /* userdata == NULL here intentionally */
  /* setup the notebook to receive drops as well */
  toolbox_setup_drag_dest (notebook);
  g_signal_connect (G_OBJECT (notebook), "drag_data_received",
		    G_CALLBACK (dia_dnd_file_drag_data_received),
                    NULL); /* userdata == NULL here intentionally */

  /* menus -- initialised afterwards, because initing the display menus
   * uses the tool buttons*/
  menus_get_integrated_ui_menubar(&menubar, &toolbar, &accel_group);
  gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
#ifdef HAVE_GNOME
  gnome_app_set_menus (GNOME_APP (window), GTK_MENU_BAR (menubar));
#else
#  ifdef HAVE_MAC_INTEGRATION
  _create_mac_integration ();
#  else
  gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0);
  gtk_widget_show (menubar);
#  endif
#endif

  /* Toolbar */
  /* TODO: maybe delete set_style(toolbar,ICONS) */
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
  gtk_box_pack_start (GTK_BOX (main_vbox), toolbar, FALSE, TRUE, 0);
  gtk_widget_show (toolbar);

  persistence_register_window(GTK_WINDOW(window));

  ui.main_window      = GTK_WINDOW    (window);
  ui.toolbar          = GTK_TOOLBAR   (toolbar);
  ui.diagram_notebook = GTK_NOTEBOOK  (notebook);
  ui.statusbar        = GTK_STATUSBAR (statusbar);
  ui.layer_view       =                layer_view;

  /* NOTE: These functions use ui.xxx assignments above and so must come after
   *       the user interface components are set.                              */
  integrated_ui_toolbar_show (TRUE);
  integrated_ui_statusbar_show (TRUE);

  /* For access outside here: */
  g_object_set_data (G_OBJECT (ui.main_window), DIA_MAIN_NOTEBOOK, notebook);

  /* TODO: Figure out what to do about toolbox_shell for integrated UI */
  toolbox_shell = window;
}