pcb 4.1.1
An interactive printed circuit board layout editor.
|
#include <glib.h>
#include <glib-object.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "gtkhid.h"
#include "gui.h"
#include "pcb-printf.h"
#include "ghid-layer-selector.h"
#include "ghid-cell-renderer-visibility.h"
Go to the source code of this file.
Data Structures | |
struct | _GHidLayerSelector |
struct | _GHidLayerSelectorClass |
struct | _layer |
struct | layer_data |
Defines | |
#define | INITIAL_ACTION_MAX 40 |
Enumerations | |
enum | { SELECT_LAYER_SIGNAL, TOGGLE_LAYER_SIGNAL, RENAME_LAYER_SIGNAL, LAST_SIGNAL } |
Signals exposed by the widget. More... | |
enum | { STRUCT_COL, USER_ID_COL, VISIBLE_COL, COLOR_COL, TEXT_COL, FONT_COL, EDITABLE_COL, SELECTABLE_COL, SEPARATOR_COL, N_COLS } |
Columns used for internal data store. More... | |
Functions | |
static void | ghid_layer_selector_finalize (GObject *object) |
Clean up object before garbage collection. | |
static void | menu_pick_cb (GtkRadioAction *action, struct _layer *ldata) |
Callback for menu actions: sync layer selection list, emit signal. | |
static void | g_cclosure_user_marshal_VOID__INT_STRING (GClosure *closure, GValue *return_value G_GNUC_UNUSED, guint n_param_values, const GValue *param_values, gpointer invocation_hint G_GNUC_UNUSED, gpointer marshal_data) |
static void | free_ldata (GHidLayerSelector *ls, struct _layer *ldata) |
Deletes the action and accelerator from a layer. | |
static void | set_visibility (GHidLayerSelector *ls, GtkTreeIter *iter, struct _layer *ldata, gboolean state) |
internal set-visibility function -- emits no signals | |
static void | toggle_visibility (GHidLayerSelector *ls, GtkTreeIter *iter, gboolean emit) |
Flip the visibility state of a given layer. | |
static gboolean | tree_view_separator_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data) |
Decide if a GtkListStore entry is a layer or separator. | |
static gboolean | tree_selection_func (GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean selected, gpointer data) |
Decide if a GtkListStore entry may be selected. | |
static gboolean | button_press_cb (GHidLayerSelector *ls, GdkEventButton *event) |
Callback for mouse-click: toggle visibility. | |
static void | selection_changed_cb (GtkTreeSelection *selection, GHidLayerSelector *ls) |
Callback for layer selection change: sync menu, emit signal. | |
static void | layer_name_editing_started_cb (GtkCellRenderer *renderer, GtkCellEditable *editable, gchar *path, gpointer user_data) |
Callback for when a layer name has been edited. | |
static void | layer_name_editing_canceled_cb (GtkCellRenderer *renderer, gpointer user_data) |
Callback for when layer name editing has been canceled. | |
static void | layer_name_edited_cb (GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer user_data) |
Callback for when a layer name has been edited. | |
static void | menu_view_cb (GtkToggleAction *action, struct _layer *ldata) |
Callback for menu actions: sync layer selection list, emit signal. | |
static void | ghid_layer_selector_init (GHidLayerSelector *ls) |
static void | ghid_layer_selector_class_init (GHidLayerSelectorClass *klass) |
GType | ghid_layer_selector_get_type (void) |
GtkWidget * | ghid_layer_selector_new (void) |
Create a new GHidLayerSelector. | |
void | ghid_layer_selector_add_layer (GHidLayerSelector *ls, gint user_id, const gchar *name, const gchar *color_string, gboolean visible, gboolean selectable, gboolean renameable) |
Add a layer to a GHidLayerSelector. | |
gint | ghid_layer_selector_install_pick_items (GHidLayerSelector *ls, GtkMenuShell *shell, gint pos) |
Install the "Current Layer" menu items for a layer selector. | |
gint | ghid_layer_selector_install_view_items (GHidLayerSelector *ls, GtkMenuShell *shell, gint pos) |
Install the "Shown Layers" menu items for a layer selector. | |
GtkAccelGroup * | ghid_layer_selector_get_accel_group (GHidLayerSelector *ls) |
Returns the GtkAccelGroup of a layer selector. | |
static gboolean | toggle_foreach_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data) |
used internally | |
void | ghid_layer_selector_toggle_layer (GHidLayerSelector *ls, gint user_id) |
Toggle a layer's visibility. | |
static gboolean | select_foreach_func (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer user_data) |
used internally | |
void | ghid_layer_selector_select_layer (GHidLayerSelector *ls, gint user_id) |
Select a layer. | |
gboolean | ghid_layer_selector_select_next_visible (GHidLayerSelector *ls) |
Selects the next visible layer. | |
void | ghid_layer_selector_make_selected_visible (GHidLayerSelector *ls) |
Makes the selected layer visible. | |
void | ghid_layer_selector_update_colors (GHidLayerSelector *ls, const gchar *(*callback)(int user_id)) |
Sets the colors of all layers in a layer-selector. | |
void | ghid_layer_selector_delete_layers (GHidLayerSelector *ls, gboolean(*callback)(int user_id)) |
Deletes layers from a layer selector. | |
void | ghid_layer_selector_show_layers (GHidLayerSelector *ls, gboolean(*callback)(int user_id)) |
Sets the visibility toggle-state of all layers. | |
Variables | |
static GtkTreeView * | ghid_layer_selector_parent_class |
static guint | ghid_layer_selector_signals [LAST_SIGNAL] = { 0 } |
#define INITIAL_ACTION_MAX 40 |
Definition at line 21 of file ghid-layer-selector.c.
anonymous enum |
Signals exposed by the widget.
Definition at line 29 of file ghid-layer-selector.c.
anonymous enum |
Columns used for internal data store.
STRUCT_COL | |
USER_ID_COL | |
VISIBLE_COL | |
COLOR_COL | |
TEXT_COL | |
FONT_COL | |
EDITABLE_COL | |
SELECTABLE_COL | |
SEPARATOR_COL | |
N_COLS |
Definition at line 37 of file ghid-layer-selector.c.
static gboolean button_press_cb | ( | GHidLayerSelector * | ls, |
GdkEventButton * | event | ||
) | [static] |
Callback for mouse-click: toggle visibility.
Definition at line 226 of file ghid-layer-selector.c.
References FALSE, _GHidLayerSelector::list_store, SELECTABLE_COL, SEPARATOR_COL, toggle_visibility(), TRUE, and _GHidLayerSelector::visibility_column.
Referenced by ghid_layer_selector_init().
static void free_ldata | ( | GHidLayerSelector * | ls, |
struct _layer * | ldata | ||
) | [static] |
Deletes the action and accelerator from a layer.
Definition at line 129 of file ghid-layer-selector.c.
References _GHidLayerSelector::accel_available, _layer::accel_index, _GHidLayerSelector::action_group, _layer::pick_action, _layer::rref, TRUE, and _layer::view_action.
Referenced by ghid_layer_selector_add_layer(), ghid_layer_selector_delete_layers(), and ghid_layer_selector_finalize().
static void g_cclosure_user_marshal_VOID__INT_STRING | ( | GClosure * | closure, |
GValue *return_value | G_GNUC_UNUSED, | ||
guint | n_param_values, | ||
const GValue * | param_values, | ||
gpointer invocation_hint | G_GNUC_UNUSED, | ||
gpointer | marshal_data | ||
) | [static] |
Definition at line 92 of file ghid-layer-selector.c.
References callback().
Referenced by ghid_layer_selector_class_init().
void ghid_layer_selector_add_layer | ( | GHidLayerSelector * | ls, |
gint | user_id, | ||
const gchar * | name, | ||
const gchar * | color_string, | ||
gboolean | visible, | ||
gboolean | selectable, | ||
gboolean | renameable | ||
) |
Add a layer to a GHidLayerSelector.
If the user_id passed already exists in the layer selector, that layer will have its data overwritten with the new stuff.
[in] | ls | The selector to be acted on |
[in] | user_id | An ID used to identify the layer; will be passed to selection/visibility callbacks |
[in] | name | The name of the layer; will be used on selector and menus |
[in] | color_string | The color of the layer on selector |
[in] | visibile | Whether the layer is visible |
[in] | selectable | Whether the layer appears in menus and can be selected |
[in] | renameable | Whether the layer is renameable |
Definition at line 582 of file ghid-layer-selector.c.
References _GHidLayerSelector::accel_available, _GHidLayerSelector::accel_group, _layer::accel_index, action, _GHidLayerSelector::action_group, COLOR_COL, EDITABLE_COL, FALSE, FONT_COL, free_ldata(), _GHidLayerSelector::list_store, menu_pick_cb(), menu_view_cb(), _GHidLayerSelector::n_actions, _layer::pick_action, _layer::pick_item, _GHidLayerSelector::radio_group, _layer::rref, SELECTABLE_COL, SEPARATOR_COL, STRUCT_COL, TEXT_COL, TRUE, USER_ID_COL, _layer::view_action, _layer::view_item, and VISIBLE_COL.
Referenced by make_layer_buttons(), and make_virtual_layer_buttons().
static void ghid_layer_selector_class_init | ( | GHidLayerSelectorClass * | klass | ) | [static] |
Definition at line 467 of file ghid-layer-selector.c.
References g_cclosure_user_marshal_VOID__INT_STRING(), ghid_layer_selector_finalize(), ghid_layer_selector_signals, RENAME_LAYER_SIGNAL, SELECT_LAYER_SIGNAL, and TOGGLE_LAYER_SIGNAL.
Referenced by ghid_layer_selector_get_type().
void ghid_layer_selector_delete_layers | ( | GHidLayerSelector * | ls, |
gboolean(*)(int user_id) | callback | ||
) |
Deletes layers from a layer selector.
Separators will be deleted if the layer AFTER them is deleted.
[in] | ls | The selector to be acted on |
[in] | callback | Takes the user_id of the layer and returns a boolean |
Definition at line 1022 of file ghid-layer-selector.c.
References callback(), FALSE, free_ldata(), _GHidLayerSelector::list_store, SEPARATOR_COL, STRUCT_COL, and USER_ID_COL.
Referenced by ghid_layer_buttons_update().
static void ghid_layer_selector_finalize | ( | GObject * | object | ) | [static] |
Clean up object before garbage collection.
Definition at line 502 of file ghid-layer-selector.c.
References _GHidLayerSelector::accel_group, _GHidLayerSelector::action_group, free_ldata(), ghid_layer_selector_parent_class, _GHidLayerSelector::list_store, and STRUCT_COL.
Referenced by ghid_layer_selector_class_init().
GtkAccelGroup* ghid_layer_selector_get_accel_group | ( | GHidLayerSelector * | ls | ) |
Returns the GtkAccelGroup of a layer selector.
[in] | ls | The selector to be acted on |
Definition at line 820 of file ghid-layer-selector.c.
References _GHidLayerSelector::accel_group.
Referenced by ghid_install_accel_groups(), and ghid_remove_accel_groups().
GType ghid_layer_selector_get_type | ( | void | ) |
Definition at line 525 of file ghid-layer-selector.c.
References ghid_layer_selector_class_init(), and ghid_layer_selector_init().
static void ghid_layer_selector_init | ( | GHidLayerSelector * | ls | ) | [static] |
Definition at line 396 of file ghid-layer-selector.c.
References _GHidLayerSelector::accel_available, _GHidLayerSelector::accel_group, _GHidLayerSelector::action_group, button_press_cb(), COLOR_COL, EDITABLE_COL, FALSE, FONT_COL, ghid_cell_renderer_visibility_new(), layer_name_edited_cb(), layer_name_editing_canceled_cb(), layer_name_editing_started_cb(), _GHidLayerSelector::list_store, _GHidLayerSelector::n_actions, N_COLS, _GHidLayerSelector::selection, selection_changed_cb(), _GHidLayerSelector::selection_changed_sig_id, TEXT_COL, tree_selection_func(), tree_view_separator_func(), TRUE, _GHidLayerSelector::visibility_column, and VISIBLE_COL.
Referenced by ghid_layer_selector_get_type().
gint ghid_layer_selector_install_pick_items | ( | GHidLayerSelector * | ls, |
GtkMenuShell * | shell, | ||
gint | pos | ||
) |
Install the "Current Layer" menu items for a layer selector.
[in] | ls | The selector to be acted on |
[in] | shell | The menu to install the items in |
[in] | pos | The position in the menu to install items |
Definition at line 750 of file ghid-layer-selector.c.
References action, _GHidLayerSelector::list_store, n, _layer::pick_action, _layer::pick_item, and STRUCT_COL.
Referenced by ghid_main_menu_install_layer_selector().
gint ghid_layer_selector_install_view_items | ( | GHidLayerSelector * | ls, |
GtkMenuShell * | shell, | ||
gint | pos | ||
) |
Install the "Shown Layers" menu items for a layer selector.
[in] | ls | The selector to be acted on |
[in] | shell | The menu to install the items in |
[in] | pos | The position in the menu to install items |
Definition at line 787 of file ghid-layer-selector.c.
References action, _GHidLayerSelector::list_store, n, STRUCT_COL, _layer::view_action, and _layer::view_item.
Referenced by ghid_main_menu_install_layer_selector().
void ghid_layer_selector_make_selected_visible | ( | GHidLayerSelector * | ls | ) |
Makes the selected layer visible.
[in] | ls | The selector to be acted on |
Definition at line 967 of file ghid-layer-selector.c.
References FALSE, _GHidLayerSelector::list_store, _GHidLayerSelector::selection, toggle_visibility(), and VISIBLE_COL.
GtkWidget* ghid_layer_selector_new | ( | void | ) |
Create a new GHidLayerSelector.
Definition at line 558 of file ghid-layer-selector.c.
References GHID_LAYER_SELECTOR_TYPE.
Referenced by ghid_build_pcb_top_window().
void ghid_layer_selector_select_layer | ( | GHidLayerSelector * | ls, |
gint | user_id | ||
) |
Select a layer.
[in] | ls | The selector to be acted on |
[in] | user_id | The ID of the layer to be affected |
Definition at line 891 of file ghid-layer-selector.c.
References _GHidLayerSelector::list_store, layer_data::ls, select_foreach_func(), and layer_data::user_id.
Referenced by ghid_layer_buttons_update(), and SelectLayer().
gboolean ghid_layer_selector_select_next_visible | ( | GHidLayerSelector * | ls | ) |
Selects the next visible layer.
[in] | ls | The selector to be acted on |
Definition at line 914 of file ghid-layer-selector.c.
References FALSE, _GHidLayerSelector::list_store, SELECTABLE_COL, _GHidLayerSelector::selection, selection_changed_cb(), TRUE, and VISIBLE_COL.
Referenced by layer_selector_toggle_callback().
void ghid_layer_selector_show_layers | ( | GHidLayerSelector * | ls, |
gboolean(*)(int user_id) | callback | ||
) |
Sets the visibility toggle-state of all layers.
[in] | ls | The selector to be acted on |
[in] | callback | Takes the user_id of the layer and returns a boolean |
Definition at line 1075 of file ghid-layer-selector.c.
References callback(), _GHidLayerSelector::list_store, SEPARATOR_COL, set_visibility(), STRUCT_COL, and USER_ID_COL.
Referenced by LayersChanged().
void ghid_layer_selector_toggle_layer | ( | GHidLayerSelector * | ls, |
gint | user_id | ||
) |
Toggle a layer's visibility.
[in] | ls | The selector to be acted on |
[in] | user_id | The ID of the layer to be affected |
Definition at line 855 of file ghid-layer-selector.c.
References _GHidLayerSelector::list_store, layer_data::ls, toggle_foreach_func(), and layer_data::user_id.
Referenced by ToggleView().
void ghid_layer_selector_update_colors | ( | GHidLayerSelector * | ls, |
const gchar *(*)(int user_id) | callback | ||
) |
Sets the colors of all layers in a layer-selector.
[in] | ls | The selector to be acted on |
[in] | callback | Takes the user_id of the layer and returns a color string |
Definition at line 991 of file ghid-layer-selector.c.
References callback(), COLOR_COL, _GHidLayerSelector::list_store, layer_data::user_id, and USER_ID_COL.
Referenced by ghid_layer_buttons_color_update().
static void layer_name_edited_cb | ( | GtkCellRendererText * | renderer, |
gchar * | path, | ||
gchar * | new_text, | ||
gpointer | user_data | ||
) | [static] |
Callback for when a layer name has been edited.
Definition at line 319 of file ghid-layer-selector.c.
References ghid_install_accel_groups(), ghid_layer_selector_signals, ghidgui, gport, _GHidLayerSelector::list_store, RENAME_LAYER_SIGNAL, GHidPort::top_window, and USER_ID_COL.
Referenced by ghid_layer_selector_init().
static void layer_name_editing_canceled_cb | ( | GtkCellRenderer * | renderer, |
gpointer | user_data | ||
) | [static] |
Callback for when layer name editing has been canceled.
Definition at line 305 of file ghid-layer-selector.c.
References ghid_install_accel_groups(), ghidgui, gport, and GHidPort::top_window.
Referenced by ghid_layer_selector_init().
static void layer_name_editing_started_cb | ( | GtkCellRenderer * | renderer, |
GtkCellEditable * | editable, | ||
gchar * | path, | ||
gpointer | user_data | ||
) | [static] |
Callback for when a layer name has been edited.
Definition at line 287 of file ghid-layer-selector.c.
References ghid_remove_accel_groups(), ghidgui, gport, and GHidPort::top_window.
Referenced by ghid_layer_selector_init().
static void menu_pick_cb | ( | GtkRadioAction * | action, |
struct _layer * | ldata | ||
) | [static] |
Callback for menu actions: sync layer selection list, emit signal.
Definition at line 371 of file ghid-layer-selector.c.
References ghid_layer_selector_signals, _layer::rref, SELECT_LAYER_SIGNAL, _GHidLayerSelector::selection, _GHidLayerSelector::selection_changed_sig_id, and USER_ID_COL.
Referenced by ghid_layer_selector_add_layer().
static void menu_view_cb | ( | GtkToggleAction * | action, |
struct _layer * | ldata | ||
) | [static] |
Callback for menu actions: sync layer selection list, emit signal.
Definition at line 351 of file ghid-layer-selector.c.
References ghid_layer_selector_signals, _layer::rref, TOGGLE_LAYER_SIGNAL, USER_ID_COL, and VISIBLE_COL.
Referenced by ghid_layer_selector_add_layer().
static gboolean select_foreach_func | ( | GtkTreeModel * | model, |
GtkTreePath * | path, | ||
GtkTreeIter * | iter, | ||
gpointer | user_data | ||
) | [static] |
used internally
Definition at line 868 of file ghid-layer-selector.c.
References FALSE, layer_data::ls, _GHidLayerSelector::selection, TRUE, layer_data::user_id, and USER_ID_COL.
Referenced by ghid_layer_selector_select_layer().
static void selection_changed_cb | ( | GtkTreeSelection * | selection, |
GHidLayerSelector * | ls | ||
) | [static] |
Callback for layer selection change: sync menu, emit signal.
Definition at line 264 of file ghid-layer-selector.c.
References ghid_layer_selector_signals, _GHidLayerSelector::list_store, _layer::pick_action, SELECT_LAYER_SIGNAL, STRUCT_COL, and USER_ID_COL.
Referenced by ghid_layer_selector_init(), and ghid_layer_selector_select_next_visible().
static void set_visibility | ( | GHidLayerSelector * | ls, |
GtkTreeIter * | iter, | ||
struct _layer * | ldata, | ||
gboolean | state | ||
) | [static] |
internal set-visibility function -- emits no signals
Definition at line 158 of file ghid-layer-selector.c.
References _GHidLayerSelector::list_store, _layer::view_action, _layer::view_item, and VISIBLE_COL.
Referenced by ghid_layer_selector_show_layers(), and toggle_visibility().
static gboolean toggle_foreach_func | ( | GtkTreeModel * | model, |
GtkTreePath * | path, | ||
GtkTreeIter * | iter, | ||
gpointer | user_data | ||
) | [static] |
used internally
Definition at line 832 of file ghid-layer-selector.c.
References FALSE, layer_data::ls, toggle_visibility(), TRUE, layer_data::user_id, and USER_ID_COL.
Referenced by ghid_layer_selector_toggle_layer().
static void toggle_visibility | ( | GHidLayerSelector * | ls, |
GtkTreeIter * | iter, | ||
gboolean | emit | ||
) | [static] |
Flip the visibility state of a given layer.
[in] | ls | The selector to be acted on |
[in] | iter | A GtkTreeIter pointed at the relevant layer |
[in] | emit | Whether or not to emit a signal |
Definition at line 182 of file ghid-layer-selector.c.
References ghid_layer_selector_signals, _GHidLayerSelector::list_store, set_visibility(), STRUCT_COL, TOGGLE_LAYER_SIGNAL, USER_ID_COL, and VISIBLE_COL.
Referenced by button_press_cb(), ghid_layer_selector_make_selected_visible(), and toggle_foreach_func().
static gboolean tree_selection_func | ( | GtkTreeSelection * | selection, |
GtkTreeModel * | model, | ||
GtkTreePath * | path, | ||
gboolean | selected, | ||
gpointer | data | ||
) | [static] |
Decide if a GtkListStore entry may be selected.
Definition at line 208 of file ghid-layer-selector.c.
References FALSE, and SELECTABLE_COL.
Referenced by ghid_layer_selector_init().
static gboolean tree_view_separator_func | ( | GtkTreeModel * | model, |
GtkTreeIter * | iter, | ||
gpointer | data | ||
) | [static] |
Decide if a GtkListStore entry is a layer or separator.
Definition at line 198 of file ghid-layer-selector.c.
References SEPARATOR_COL.
Referenced by ghid_layer_selector_init().
GtkTreeView* ghid_layer_selector_parent_class [static] |
Definition at line 50 of file ghid-layer-selector.c.
Referenced by ghid_layer_selector_finalize().
guint ghid_layer_selector_signals[LAST_SIGNAL] = { 0 } [static] |
Definition at line 51 of file ghid-layer-selector.c.
Referenced by ghid_layer_selector_class_init(), layer_name_edited_cb(), menu_pick_cb(), menu_view_cb(), selection_changed_cb(), and toggle_visibility().