Exemplo n.º 1
0
/*! \todo Finish function documentation!!!
 *  \brief
 *  \par Function Description
 *
 */
void pagesel_update (Pagesel *pagesel)
{
    GtkTreeModel *model;
    TOPLEVEL *toplevel;
    PAGE *p_current;
    GList *iter;

    g_assert (IS_PAGESEL (pagesel));

    g_return_if_fail (GSCHEM_DIALOG (pagesel)->w_current);

    toplevel = GSCHEM_DIALOG (pagesel)->w_current->toplevel;
    model    = gtk_tree_view_get_model (pagesel->treeview);

    /* wipe out every thing in the store */
    gtk_tree_store_clear (GTK_TREE_STORE (model));
    /* now rebuild */
    for ( iter = geda_list_get_glist( toplevel->pages );
            iter != NULL;
            iter = g_list_next( iter ) ) {

        p_current = (PAGE *)iter->data;
        /* find every page that is not a hierarchy-down of another page */
        if (p_current->up < 0 ||
                s_page_search_by_page_id (toplevel->pages,
                                          p_current->up) == NULL) {
            add_page (model, NULL, toplevel->pages, p_current);
        }
    }

    /* select the current page in the treeview */
    select_page (pagesel->treeview, NULL, toplevel->page_current);
}
Exemplo n.º 2
0
/*! \brief Internal GTK function modified from GTK+-2.4.14 gtkdialog.c
 *  to support gschem_dialog_new_with_buttons(...)
 *
 *  \par Function Description
 *  Convenience function which creates a blank GschemDialog with various options.
 *
 *  \param [in]  title              The title text of the dialog
 *  \param [in]  parent             The GtkWindow which will parent this dialog
 *  \param [in]  flags              The GtkDialogFlags to use when setting up the dialog
 *  \param [in]  settings_name      The name gschem should use to store this dialog's settings
 *  \param [in]  w_current          The GschemToplevel object this dialog is associated with
 *
 *  \return  The GschemDialog created.
 */
static GtkWidget* gschem_dialog_new_empty (const gchar     *title,
                                           GtkWindow       *parent,
                                           GtkDialogFlags   flags,
                                           const gchar *settings_name,
                                           GschemToplevel *w_current)
{
  GschemDialog *dialog;

  dialog = GSCHEM_DIALOG (g_object_new (GSCHEM_TYPE_DIALOG,
                                        "settings-name", settings_name,
                                        "gschem-toplevel", w_current,
                                        NULL));

  if (title)
    gtk_window_set_title (GTK_WINDOW (dialog), title);

  if (parent)
    gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);

  if (flags & GTK_DIALOG_MODAL)
    gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);

  if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
    gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);

  if (flags & GTK_DIALOG_NO_SEPARATOR)
    gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);

  return GTK_WIDGET (dialog);
}
Exemplo n.º 3
0
/*! \todo Finish function documentation!!!
 *  \brief
 *  \par Function Description
 *
 */
static void pagesel_callback_selection_changed (GtkTreeSelection *selection,
        gpointer user_data)
{
    GtkTreeModel *model;
    GtkTreeIter iter;
    Pagesel *pagesel = (Pagesel*)user_data;
    GSCHEM_TOPLEVEL *w_current;
    PAGE *page;

    if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
        return;
    }

    w_current = GSCHEM_DIALOG (pagesel)->w_current;
    gtk_tree_model_get (model, &iter,
                        COLUMN_PAGE, &page,
                        -1);

    /* temp */
    s_page_goto (w_current->toplevel, page);
    i_set_filename (w_current, w_current->toplevel->page_current->page_filename);
    x_scrollbars_update (w_current);
    o_invalidate_all (w_current);

    /* We would like to use the following call, but since it calls
     * x_pagesel_update() it would cause an infinite loop.
     */
    /*  x_window_set_current_page (toplevel, page); */

}
Exemplo n.º 4
0
/*! \brief GObject finalise handler
 *
 *  \par Function Description
 *  Just before the GschemDialog GObject is finalized, free our
 *  allocated data, and then chain up to the parent's finalize handler.
 *
 *  \param [in] object The GObject being finalized.
 */
static void gschem_dialog_finalize (GObject *object)
{
  GschemDialog *dialog = GSCHEM_DIALOG (object);

  g_free (dialog->settings_name);

  G_OBJECT_CLASS (gschem_dialog_parent_class)->finalize (object);
}
Exemplo n.º 5
0
/*! \brief GObject property getter function
 *
 *  \par Function Description
 *  Getter function for GschemDialog's GObject properties,
 *  "settings-name" and "toplevel".
 *
 *  \param [in]  object       The GObject whose properties we are getting
 *  \param [in]  property_id  The numeric id. under which the property was
 *                            registered with g_object_class_install_property()
 *  \param [out] value        The GValue in which to return the value of the property
 *  \param [in]  pspec        A GParamSpec describing the property being got
 */
static void gschem_dialog_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
{
  GschemDialog *dialog = GSCHEM_DIALOG (object);

  switch(property_id) {
      case PROP_SETTINGS_NAME:
        g_value_set_string (value, dialog->settings_name);
        break;
      case PROP_GSCHEM_TOPLEVEL:
        g_value_set_pointer (value, (gpointer)dialog->w_current);
        break;
      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
  }

}
Exemplo n.º 6
0
/*! \brief GTK function modified from GTK+-2.4.14 gtkdialog.c
 *  to provide a GschemDialog equivelant of the convenience function
 *  gtk_dialog_new_with_buttons(...)
 *
 *  \par Function Description
 *  Convenience function which creates a GschemDialog with buttons and options.
 *
 *  \param [in]  title              The title text of the dialog
 *  \param [in]  parent             The GtkWindow which will parent this dialog
 *  \param [in]  flags              The GtkDialogFlags to use when setting up the dialog
 *  \param [in]  settings_name      The name gschem should use to store this dialog's settings
 *  \param [in]  w_current          The GschemToplevel object this dialog is associated with
 *  \param [in]  first_button_text  The text string for the first button
 *  \param [in]  ...                A variable number of arguments with the remaining button strings
 *
 *  \return  The GschemDialog created.
 */
GtkWidget* gschem_dialog_new_with_buttons (const gchar *title, GtkWindow *parent, GtkDialogFlags flags,
                                           const gchar *settings_name, GschemToplevel *w_current,
                                           const gchar *first_button_text, ...)
{
  GschemDialog *dialog;
  va_list args;

  dialog = GSCHEM_DIALOG (gschem_dialog_new_empty (title, parent, flags, settings_name, w_current));

  va_start (args, first_button_text);

  gschem_dialog_add_buttons_valist (GTK_DIALOG (dialog),
                                    first_button_text,
                                    args);

  va_end (args);

  return GTK_WIDGET (dialog);
}
Exemplo n.º 7
0
/*! \brief GtkWidget unmap signal handler
 *
 *  \par Function Description
 *  Just before the dialog widget is unmapped, call the hook
 *  to save its current position and size.
 *
 *  This typically happens when you call gtk_widget_destroy().
 *
 *  \param [in] widget  The GtkWidget being unmapped.
 */
static void unmap_handler (GtkWidget *widget)
{
  gchar *group_name;
  EdaConfig *cfg = eda_config_get_cache_context ();
  GschemDialog *dialog = GSCHEM_DIALOG (widget);

  if (dialog->settings_name != NULL) {
    group_name = g_strdup_printf ("gschem.dialog-geometry.%s",
                                  dialog->settings_name);

    g_assert (cfg != NULL);
    g_signal_emit (dialog, gschem_dialog_signals[ GEOMETRY_SAVE ], 0,
                   cfg, group_name);

    g_free (group_name);
  }

  /* Let GTK unmap the window */
  GTK_WIDGET_CLASS (gschem_dialog_parent_class)->unmap (widget);
}
Exemplo n.º 8
0
/*! \todo Finish function documentation!!!
 *  \brief
 *  \par Function Description
 *
 */
static void pagesel_callback_selection_changed (GtkTreeSelection *selection,
						gpointer user_data)
{
  GtkTreeModel *model;
  GtkTreeIter iter;
  Pagesel *pagesel = (Pagesel*)user_data;
  GSCHEM_TOPLEVEL *w_current;
  PAGE *page;

  if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
    return;
  }

  w_current = GSCHEM_DIALOG (pagesel)->w_current;
  gtk_tree_model_get (model, &iter,
                      COLUMN_PAGE, &page,
                      -1);

  /* Since setting the current page may call x_pagesel_update(), which
   * might change the current page selection, make sure we do nothing
   * if the newly-selected page is already the current page. */
  if (page == w_current->toplevel->page_current) return;
  x_window_set_current_page (w_current, page);
}