예제 #1
0
void
    glade_gtk_sheet_remove_child(GladeWidgetAdaptor *adaptor, GObject *object, GObject *child)
{
    gint col;
    GtkSheet *sheet;
    GtkSheetColumn *oldcol;

#ifdef GTK_SHEET_DEBUG
    g_debug("glade_gtk_sheet_remove_child: called");
#endif

    g_return_if_fail (GTK_IS_SHEET (object));
    g_return_if_fail (GTK_IS_WIDGET (child));

    sheet = GTK_SHEET(object);
    oldcol = GTK_SHEET_COLUMN(child);

    for (col=0; col<=sheet->maxcol; col++)
    {
        if (oldcol == sheet->column[col])
        {
            gtk_sheet_delete_columns(sheet, col, 1);
            return;
        }
    }
    g_warning("glade_gtk_sheet_remove_child: couldn't remove child %p", child);
}
예제 #2
0
/*! \brief Delete an attribute column
 *
 *  This function gets called when the user has selected a single attrib
 *  column, selected the edit->delete attrib item from the pull-down
 *  menu, and then said "yes" to the confirm dialog.
 */
void s_toplevel_delete_attrib_col() {
    gint cur_page;  /* current page in notbook  */
    gint mincol, maxcol;
    GtkSheet *sheet;
    gchar *attrib_name;

    /* Repeat previous checks  */
    cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
    sheet = GTK_SHEET(sheets[cur_page]);
    if (sheet == NULL) {
        return;
    }
    mincol = x_gtksheet_get_min_col(sheet);
    maxcol =  x_gtksheet_get_max_col(sheet);
    if ( (mincol != maxcol) || (mincol == -1) || (maxcol == -1) ) {
        return;
    }

#ifdef DEBUG
    printf("In s_toplevel_delete_attrib_col, checks were OK, now do real work\n");
#endif

    /*  Rebuild the gattrib-specific data structures  */
    switch (cur_page) {

    case 0:  /* component attribute  */

        /*  Eventually, I want to just resize the table after deleting the
         *  attrib.  However, that is difficult.  Therefore, I will just
         *  destroy the old table and recreate it for now. */

        s_table_destroy(sheet_head->component_table,
                        sheet_head->comp_count, sheet_head->comp_attrib_count);

        /*  Get name (label) of the col to delete from the gtk sheet */
        attrib_name = g_strdup( gtk_sheet_column_button_get_label(sheet, mincol) );

        if (attrib_name != NULL) {
#ifdef DEBUG
            printf("In s_toplevel_delete_attrib_col, attrib to delete = %s\n", attrib_name);
#endif
        } else {
            fprintf(stderr, "In s_toplevel_delete_attrib_col, can't get attrib name\n");
            return;
        }

#ifdef DEBUG
        printf("In s_toplevel_delete_attrib_col, before deleting comp attrib.\n");
        printf("                           comp_attrib_count = %d\n", sheet_head->comp_attrib_count);
#endif
        s_string_list_delete_item(&(sheet_head->master_comp_attrib_list_head),
                                  &(sheet_head->comp_attrib_count),
                                  attrib_name);
        s_string_list_sort_master_comp_attrib_list(); /* this renumbers list also */
        g_free(attrib_name);

#ifdef DEBUG
        printf("In s_toplevel_delete_attrib_col, just updated comp_attrib string list.\n");
        printf("                             new comp_attrib_count = %d\n", sheet_head->comp_attrib_count);
#endif

        /* Now create new table with new attrib count*/
        sheet_head->component_table = s_table_new(sheet_head->comp_count,
                                      sheet_head->comp_attrib_count);


#ifdef DEBUG
        printf("In s_toplevel_delete_attrib_col, just updated SHEET_DATA info.\n");
#endif
        break;

    case 1:  /* net attribute  */
        /* insert into net attribute list  */
        break;

    case 2:  /* pin attribute  */
        /* insert into pin attribute list  */
        break;
    }  /* switch  */


    /* Delete col on gtksheet  */
#ifdef DEBUG
    printf("In s_toplevel_delete_attrib_col, about to delete col in gtksheet.\n");
#endif
    gtk_sheet_delete_columns (sheet, mincol, 1);
#ifdef DEBUG
    printf("In s_toplevel_delete_attrib_col, done deleting col in gtksheet.\n");
#endif

    sheet_head->CHANGED = TRUE;  /* Set changed flag so user is prompted when exiting */

    return;
}