コード例 #1
0
static void BusLayoutToDialog (bus_layout_D *dialog, BUS_LAYOUT *bus_layout)
  {
  GtkTreeStore *ts = NULL ;

  ts = design_bus_layout_tree_store_new (bus_layout, ROW_TYPE_ANY, 0) ;

  gtk_widget_set_sensitive (dialog->btnCreateBus, FALSE) ;
  gtk_widget_set_sensitive (dialog->btnDeleteBus, FALSE) ;
  gtk_widget_set_sensitive (dialog->btnMoveBusUp, FALSE) ;
  gtk_widget_set_sensitive (dialog->btnMoveBusDown, FALSE) ;
  gtk_widget_set_sensitive (dialog->btnMoveCellsUp, FALSE) ;
  gtk_widget_set_sensitive (dialog->btnMoveCellsDown, FALSE) ;
  gtk_widget_set_sensitive (dialog->lblBusName, FALSE) ;
  gtk_widget_set_sensitive (dialog->txtBusName, FALSE) ;
  gtk_entry_set_text (GTK_ENTRY (dialog->txtBusName), "") ;

  gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->tview), GTK_TREE_MODEL (ts)) ;

  // Unref the tree store after giving it to the TreeView.  This way, the next time we give
  // a tree store to the tree view, the current tree store will be destroyed
  g_object_unref (ts) ;

  scrolled_window_set_size (GTK_SCROLLED_WINDOW (dialog->sw), dialog->tview, 0.8, 0.4) ;
  }
コード例 #2
0
void VectorTableToDialog (vector_table_options_D *dialog, BUS_LAYOUT *bus_layout, int *sim_type, VectorTable *pvt)
  {
  GList *llCols = NULL, *llItr = NULL ;
  int Nix ;
  GtkTreeModel *model = NULL ;
  GtkWidget *tbtn = NULL ;
  GtkTreeViewColumn *col = NULL ;

  if (NULL == dialog || NULL == sim_type || NULL == pvt) return ;

  g_object_set_data (G_OBJECT (dialog->dialog), "user_sim_type", sim_type) ;
  g_object_set_data (G_OBJECT (dialog->dialog), "user_pvt", pvt) ;
  g_object_set_data (G_OBJECT (dialog->dialog), "user_bus_layout", bus_layout) ;
  g_object_set_data (G_OBJECT (dialog->dialog), "idxVector", (gpointer)-1) ;

  if (0 == bus_layout->inputs->icUsed)
    (*sim_type) = EXHAUSTIVE_VERIFICATION ;

  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tbtn = (VECTOR_TABLE == (*sim_type) ? dialog->tbtnVT : dialog->tbtnExhaustive)), TRUE) ;

  g_object_set_data (G_OBJECT (dialog->crActive), "pvt", pvt) ;

  if (NULL != (model = GTK_TREE_MODEL (design_bus_layout_tree_store_new (bus_layout, ROW_TYPE_INPUT, 1, G_TYPE_BOOLEAN))))
    {
    gboolean bActive = FALSE ;
    GtkTreeIter itr, itrChild ;
    int row_type = -1, idx = -1 ;
    QCADCell *cell = NULL ;
    gboolean bBusActive = FALSE ;

    // First reflect the active_flag of current cell inputs
    if (gtk_tree_model_get_iter_first (model, &itr))
      while (TRUE)
        {
        gtk_tree_model_get (model, &itr, 
          BUS_LAYOUT_MODEL_COLUMN_TYPE, &row_type,
          BUS_LAYOUT_MODEL_COLUMN_CELL, &cell, -1) ;
        if (ROW_TYPE_CELL_INPUT == row_type && NULL != cell)
          if (-1 != (idx = VectorTable_find_input_idx (pvt, cell)))
            gtk_tree_store_set (GTK_TREE_STORE (model), &itr, 
              VECTOR_TABLE_MODEL_COLUMN_ACTIVE, exp_array_index_1d (pvt->inputs, VT_INPUT, idx).active_flag, -1) ;
        if (!gtk_tree_model_iter_next_dfs (model, &itr)) break ;
        }

    // For any given bus, if any of its cells are active, then the bus is active. Reflect this.
    if (gtk_tree_model_get_iter_first (model, &itr))
      while (TRUE)
        {
        bBusActive = FALSE ;
        if (gtk_tree_model_iter_children (model, &itrChild, &itr))
          {
          while (TRUE)
            {
            gtk_tree_model_get (model, &itrChild, VECTOR_TABLE_MODEL_COLUMN_ACTIVE, &bActive, -1) ;
            if ((bBusActive = bActive)) break ;
            if (!gtk_tree_model_iter_next (model, &itrChild)) break ;
            }
          gtk_tree_store_set (GTK_TREE_STORE (model), &itr, VECTOR_TABLE_MODEL_COLUMN_ACTIVE, bBusActive, -1) ;
          }
        if (!gtk_tree_model_iter_next (model, &itr)) break ;
        }

    llCols = gtk_tree_view_get_columns (GTK_TREE_VIEW (dialog->tv)) ;
    for (Nix = 0, llItr = llCols ; Nix < 2 && NULL != llItr ; Nix++, llItr = llItr->next) ;
    for (; llItr != NULL ; llItr = llItr->next)
      gtk_tree_view_remove_column (GTK_TREE_VIEW (dialog->tv), GTK_TREE_VIEW_COLUMN (llItr->data)) ;
    g_list_free (llCols) ;

    gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->tv), model) ;
    }

  gtk_tree_view_expand_all (GTK_TREE_VIEW (dialog->tv)) ;

  for (Nix = 0 ; Nix < pvt->vectors->icUsed ; Nix++)
    {
    if (NULL == col)
      col = add_vector_to_dialog (dialog, pvt, Nix) ;
    else
      add_vector_to_dialog (dialog, pvt, Nix) ;
    // Give the dialog a chance to update itself
    if (0 == Nix % 10)
      while (gtk_events_pending ())
        gtk_main_iteration () ;
    }

  if (NULL != col)
    gtk_tree_view_column_clicked (col) ;

  if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tbtn)))
    vector_table_options_dialog_btnSimType_clicked (tbtn, dialog) ;

  vector_table_options_dialog_reflect_state (dialog) ;
  }