Beispiel #1
0
static void create_bus_layout_dialog (bus_layout_D *dialog)
  {
  GtkWidget *tblMain = NULL, *frm = NULL, *img = NULL, *tbl = NULL, *align = NULL, *bbox = NULL ;

  dialog->dialog = gtk_dialog_new () ;
  gtk_window_set_title (GTK_WINDOW (dialog->dialog), _("Bus Layout")) ;
  gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), TRUE) ;
  gtk_window_set_default_size (GTK_WINDOW (dialog->dialog), 300, 200) ;

  tblMain = gtk_table_new (1, 2, FALSE) ;
  gtk_widget_show (tblMain) ;
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->dialog)->vbox), tblMain, TRUE, TRUE, 0) ;
  gtk_container_set_border_width (GTK_CONTAINER (tblMain), 2) ;

  frm = gtk_frame_new (_("Cells And Buses")) ;
  gtk_widget_show (frm) ;
  gtk_table_attach (GTK_TABLE (tblMain), frm, 0, 1, 0, 1,
    (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
    (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 2, 2) ;
  gtk_container_set_border_width (GTK_CONTAINER (frm), 2) ;

  dialog->sw = gtk_scrolled_window_new (NULL, NULL) ;
  gtk_widget_show (dialog->sw) ;
  gtk_container_add (GTK_CONTAINER (frm), dialog->sw) ;
  gtk_container_set_border_width (GTK_CONTAINER (dialog->sw), 2) ;
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (dialog->sw), GTK_SHADOW_IN) ;
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (dialog->sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC) ;

  dialog->tview = create_bus_layout_tree_view (FALSE, NULL, GTK_SELECTION_MULTIPLE) ;
  gtk_widget_show (dialog->tview) ;
  gtk_container_add (GTK_CONTAINER (dialog->sw), dialog->tview) ;
  gtk_tree_selection_set_select_function (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tview)),
    (GtkTreeSelectionFunc)select_cell_row_p, NULL, NULL) ;

  align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0) ;
  gtk_widget_show (align) ;
  gtk_table_attach (GTK_TABLE (tblMain), align, 1, 2, 0, 1,
    (GtkAttachOptions)(GTK_FILL),
    (GtkAttachOptions)(GTK_FILL), 2, 2) ;
  gtk_container_set_border_width (GTK_CONTAINER (align), 2) ;

  tbl = gtk_table_new (3, 1, FALSE) ;
  gtk_widget_show (tbl) ;
  gtk_container_add (GTK_CONTAINER (align), tbl) ;
  gtk_container_set_border_width (GTK_CONTAINER (tbl), 2) ;

  bbox = gtk_vbutton_box_new () ;
  gtk_widget_show (bbox) ;
  gtk_table_attach (GTK_TABLE (tbl), bbox, 0, 1, 0, 1,
    (GtkAttachOptions)(0),
    (GtkAttachOptions)(0), 2, 2) ;
  gtk_container_set_border_width (GTK_CONTAINER (bbox), 2) ;
//  gtk_button_box_set_spacing (GTK_BUTTON_BOX (bbox), gtk_vbutton_box_get_spacing_default ()) ;

  dialog->btnCreateBus = create_pixmap_button (img = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON), _("Create Bus"), FALSE) ;
  gtk_widget_show (dialog->btnCreateBus) ;
  gtk_widget_show (img) ;
  gtk_box_pack_start (GTK_BOX (bbox), dialog->btnCreateBus, FALSE, TRUE, 0) ;

  dialog->btnDeleteBus = create_pixmap_button (img = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_BUTTON), _("Delete Bus"), FALSE) ;
  gtk_widget_show (dialog->btnDeleteBus) ;
  gtk_widget_show (img) ;
  gtk_box_pack_start (GTK_BOX (bbox), dialog->btnDeleteBus, FALSE, TRUE, 0) ;

  dialog->btnMoveBusUp = create_pixmap_button (img = gtk_image_new_from_stock (GTK_STOCK_GO_UP, GTK_ICON_SIZE_BUTTON), _("Move Bus Up"), FALSE) ;
  gtk_widget_show (dialog->btnMoveBusUp) ;
  gtk_widget_show (img) ;
  gtk_box_pack_start (GTK_BOX (bbox), dialog->btnMoveBusUp, FALSE, TRUE, 0) ;

  dialog->btnMoveBusDown = create_pixmap_button (img = gtk_image_new_from_stock (GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON), _("Move Bus Down"), FALSE) ;
  gtk_widget_show (dialog->btnMoveBusDown) ;
  gtk_widget_show (img) ;
  gtk_box_pack_start (GTK_BOX (bbox), dialog->btnMoveBusDown, FALSE, TRUE, 0) ;

  dialog->btnMoveCellsUp = create_pixmap_button (img = gtk_image_new_from_stock (GTK_STOCK_GO_UP, GTK_ICON_SIZE_BUTTON), _("Make Cell(s) More Significant"), FALSE) ;
  gtk_widget_show (dialog->btnMoveCellsUp) ;
  gtk_widget_show (img) ;
  gtk_box_pack_start (GTK_BOX (bbox), dialog->btnMoveCellsUp, FALSE, TRUE, 0) ;

  dialog->btnMoveCellsDown = create_pixmap_button (img = gtk_image_new_from_stock (GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON), _("Make Cell(s) Less Significant"), FALSE) ;
  gtk_widget_show (dialog->btnMoveCellsDown) ;
  gtk_widget_show (img) ;
  gtk_box_pack_start (GTK_BOX (bbox), dialog->btnMoveCellsDown, FALSE, TRUE, 0) ;

  dialog->lblBusName = gtk_label_new (_("Bus Name:")) ;
  gtk_widget_show (dialog->lblBusName) ;
  gtk_table_attach (GTK_TABLE (tbl), dialog->lblBusName, 0, 1, 1, 2,
    (GtkAttachOptions)(GTK_FILL),
    (GtkAttachOptions)(0), 2, 2) ;
  gtk_label_set_justify (GTK_LABEL (dialog->lblBusName), GTK_JUSTIFY_LEFT) ;
  gtk_misc_set_alignment (GTK_MISC (dialog->lblBusName), 0.0, 1.0) ;

  dialog->txtBusName = g_object_new (GTK_TYPE_ENTRY, "text", _("Untitled Bus"), NULL) ;
  gtk_widget_show (dialog->txtBusName) ;
  gtk_table_attach (GTK_TABLE (tbl), dialog->txtBusName, 0, 1, 2, 3,
    (GtkAttachOptions)(GTK_FILL),
    (GtkAttachOptions)(0), 2, 2) ;

  gtk_dialog_add_button (GTK_DIALOG (dialog->dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL) ;
  gtk_dialog_add_button (GTK_DIALOG (dialog->dialog), GTK_STOCK_OK, GTK_RESPONSE_OK) ;
  gtk_dialog_set_default_response (GTK_DIALOG (dialog->dialog), GTK_RESPONSE_OK) ;

  g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tview))), "changed", (GCallback)tree_view_selection_changed, dialog) ;
  g_signal_connect (G_OBJECT (dialog->btnCreateBus),     "clicked",     (GCallback)create_bus_button_clicked, dialog) ;
  g_signal_connect (G_OBJECT (dialog->btnDeleteBus),     "clicked",     (GCallback)delete_bus_button_clicked, dialog) ;
  g_signal_connect (G_OBJECT (dialog->btnMoveCellsUp),   "clicked",     (GCallback)raise_bus_cell_position,   dialog) ;
  g_signal_connect (G_OBJECT (dialog->btnMoveCellsDown), "clicked",     (GCallback)lower_bus_cell_position,   dialog) ;
  g_signal_connect (G_OBJECT (dialog->btnMoveBusUp),     "clicked",     (GCallback)raise_bus_position,        dialog) ;
  g_signal_connect (G_OBJECT (dialog->btnMoveBusDown),   "clicked",     (GCallback)lower_bus_position,        dialog) ;
  g_signal_connect (G_OBJECT (dialog->txtBusName),       "changed",     (GCallback)bus_name_changed,          dialog) ;
  g_signal_connect (G_OBJECT (dialog->txtBusName),       "insert-text", (GCallback)entry_insert_text,         dialog) ;
  g_signal_connect (G_OBJECT (dialog->txtBusName),       "delete-text", (GCallback)entry_delete_text,         dialog) ;
  }
void create_vector_table_options_dialog (vector_table_options_D *dialog)
  {
  GtkWidget *tbl = NULL, *toolbar = NULL, *btn = NULL, *btnBaseRadioSource = NULL ;
  GtkAccelGroup *accel_group = NULL ;
  GtkTreeViewColumn *col = NULL ;
  GtkCellRenderer *cr = NULL ;

  accel_group = gtk_accel_group_new () ;

  dialog->dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_modal (GTK_WINDOW (dialog->dialog), TRUE);
  gtk_window_set_title (GTK_WINDOW (dialog->dialog), _("Vector Table Setup"));
  gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), TRUE) ;
  g_object_set_data (G_OBJECT (dialog->dialog), "dialog", dialog) ;

  tbl = gtk_table_new (2, 1, FALSE) ;
  gtk_widget_show (tbl) ;
  gtk_container_add (GTK_CONTAINER (dialog->dialog), tbl) ;

  toolbar = gtk_toolbar_new () ;
  gtk_widget_show (toolbar) ;
  gtk_table_attach (GTK_TABLE (tbl), toolbar, 0, 1, 0, 1,
    (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
    (GtkAttachOptions)(GTK_FILL), 0, 0) ;
  gtk_toolbar_set_orientation (GTK_TOOLBAR (toolbar), GTK_ORIENTATION_HORIZONTAL) ;
  gtk_toolbar_set_tooltips (GTK_TOOLBAR (toolbar), TRUE) ;
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH) ;

  g_object_set_data (G_OBJECT (btn = gtk_toolbar_append_element (
    GTK_TOOLBAR (toolbar),
    GTK_TOOLBAR_CHILD_BUTTON,
    NULL,
    _("Close"),
    _("Close Window"),
    _("Close vector table editor."),
    gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_LARGE_TOOLBAR),
    (GCallback)vector_table_options_dialog_btnClose_clicked,
    NULL)),
  "dialog", dialog) ;
	gtk_widget_add_accelerator (btn, "clicked", accel_group, GDK_w, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE) ;

  gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)) ;

#ifdef STDIO_FILEIO
  dialog->btnOpen =
  btn = gtk_toolbar_append_element (
    GTK_TOOLBAR (toolbar),
    GTK_TOOLBAR_CHILD_BUTTON,
    NULL,
    _("Open"),
    _("Open Vector Table"),
    _("Open and display another vector table."),
    gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_LARGE_TOOLBAR),
    (GCallback)vector_table_options_dialog_btnOpen_clicked,
    dialog) ;
	gtk_widget_add_accelerator (btn, "clicked", accel_group, GDK_o, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE) ;

  dialog->btnSave =
  btn = gtk_toolbar_append_element (
    GTK_TOOLBAR (toolbar),
    GTK_TOOLBAR_CHILD_BUTTON,
    NULL,
    _("Save"),
    _("Save Vector Table"),
    _("Save the displayed vector table."),
    gtk_image_new_from_stock (GTK_STOCK_SAVE, GTK_ICON_SIZE_LARGE_TOOLBAR),
    (GCallback)vector_table_options_dialog_btnSave_clicked,
    dialog->dialog) ;
	gtk_widget_add_accelerator (btn, "clicked", accel_group, GDK_s, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE) ;
#endif /* def STDIO_FILEIO */

  gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)) ;

  g_object_set_data (G_OBJECT (
    dialog->tbtnExhaustive =
    btnBaseRadioSource = gtk_toolbar_append_element (
      GTK_TOOLBAR (toolbar),
      GTK_TOOLBAR_CHILD_RADIOBUTTON,
      NULL,
      _("Exhaustive"),
      _("Exhaustive Verification"),
      _("Attempt all possible inputs."),
      gtk_image_new_from_stock (GTK_STOCK_YES, GTK_ICON_SIZE_LARGE_TOOLBAR),
      (GCallback)vector_table_options_dialog_btnSimType_clicked,
      dialog)),
    "sim_type", (gpointer)EXHAUSTIVE_VERIFICATION) ;

  g_object_set_data (G_OBJECT (
    dialog->tbtnVT =
    gtk_toolbar_append_element (
      GTK_TOOLBAR (toolbar),
      GTK_TOOLBAR_CHILD_RADIOBUTTON,
      btnBaseRadioSource,
      _("Vector Table"),
      _("Vector Table Simulation"),
      _("Create a sequence of inputs."),
      gtk_image_new_from_stock (GTK_STOCK_NO, GTK_ICON_SIZE_LARGE_TOOLBAR),
      (GCallback)vector_table_options_dialog_btnSimType_clicked,
      dialog)),
    "sim_type", (gpointer)VECTOR_TABLE) ;

  dialog->tblVT = gtk_table_new (1, 2, FALSE) ;
  gtk_widget_show (dialog->tblVT) ;
  gtk_table_attach (GTK_TABLE (tbl), dialog->tblVT, 0, 1, 1, 2,
    (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
    (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0) ;

  toolbar = gtk_toolbar_new () ;
  gtk_widget_show (toolbar) ;
  gtk_table_attach (GTK_TABLE (dialog->tblVT), toolbar, 0, 1, 0, 1,
    (GtkAttachOptions)(GTK_FILL),
    (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0) ;
  gtk_toolbar_set_orientation (GTK_TOOLBAR (toolbar), GTK_ORIENTATION_VERTICAL) ;
  gtk_toolbar_set_tooltips (GTK_TOOLBAR (toolbar), TRUE) ;
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS) ;

  dialog->btnAdd =
  btn = gtk_toolbar_append_element (
    GTK_TOOLBAR (toolbar),
    GTK_TOOLBAR_CHILD_BUTTON,
    NULL,
    _("Add"),
    _("Add Vector"),
    _("Apend a vector to the end of the table."),
    gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_LARGE_TOOLBAR),
    (GCallback)vector_table_options_dialog_btnAdd_clicked,
    dialog->dialog) ;

  dialog->btnInsert =
  btn = gtk_toolbar_append_element (
    GTK_TOOLBAR (toolbar),
    GTK_TOOLBAR_CHILD_BUTTON,
    NULL,
    _("Insert Before"),
    _("Insert Vector Before"),
    _("Insert vector before the selected one."),
    gtk_image_new_from_stock (QCAD_STOCK_INSERT_COL_BEFORE, GTK_ICON_SIZE_LARGE_TOOLBAR),
    (GCallback)vector_table_options_dialog_btnAdd_clicked,
    dialog->dialog) ;

  dialog->btnDelete =
  btn = gtk_toolbar_append_element (
    GTK_TOOLBAR (toolbar),
    GTK_TOOLBAR_CHILD_BUTTON,
    NULL,
    _("Delete Vector"),
    _("Delete Vector"),
    _("Insert the selected vector."),
    gtk_image_new_from_stock (GTK_STOCK_DELETE, GTK_ICON_SIZE_LARGE_TOOLBAR),
    (GCallback)vector_table_options_dialog_btnDelete_clicked,
    dialog->dialog) ;

  dialog->sw = qcad_tree_view_container_new () ;
  gtk_widget_show (dialog->sw) ;
  gtk_table_attach (GTK_TABLE (dialog->tblVT), dialog->sw, 1, 2, 0, 1,
    (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
    (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 2, 2) ;
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (dialog->sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC) ;
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (dialog->sw), GTK_SHADOW_IN) ;

  dialog->tv = create_bus_layout_tree_view (TRUE, _("Inputs"), GTK_SELECTION_SINGLE) ;
  gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->tv), col = gtk_tree_view_column_new ()) ;
  gtk_tree_view_column_set_title (col, _("Active")) ;
  gtk_tree_view_column_pack_start (col, cr = dialog->crActive = gtk_cell_renderer_toggle_new (), TRUE) ;
  gtk_tree_view_column_add_attribute (col, cr, "active", VECTOR_TABLE_MODEL_COLUMN_ACTIVE) ;
  g_object_set (G_OBJECT (cr), "activatable", TRUE, NULL) ;
  gtk_cell_renderer_toggle_set_active (GTK_CELL_RENDERER_TOGGLE (cr), TRUE) ;
  gtk_widget_show (dialog->tv) ;
  gtk_container_add (GTK_CONTAINER (dialog->sw), dialog->tv) ;
  qcad_tree_view_container_freeze_columns (QCAD_TREE_VIEW_CONTAINER (dialog->sw), 2) ;

  g_signal_connect (G_OBJECT (dialog->tv),     "style-set",    (GCallback)tree_view_style_set,                          NULL) ;
  g_signal_connect (G_OBJECT (cr),             "toggled",      (GCallback)vt_model_active_toggled,                      dialog->tv) ;
  g_signal_connect (G_OBJECT (dialog->dialog), "delete-event", (GCallback)vector_table_options_dialog_btnClose_clicked, NULL) ;

  gtk_window_add_accel_group (GTK_WINDOW (dialog->dialog), accel_group) ;
  }