Index: trunk/src_plugins/lib_gtk_common/dlg_route_style.c =================================================================== --- trunk/src_plugins/lib_gtk_common/dlg_route_style.c (revision 6732) +++ trunk/src_plugins/lib_gtk_common/dlg_route_style.c (revision 6733) @@ -37,6 +37,7 @@ #include "compat.h" #include "board.h" #include "conf_core.h" +#include "error.h" #include "dlg_route_style.h" #include "wt_coord_entry.h" @@ -429,8 +430,8 @@ rst_modify(changed, rst->Clearance, pcb_gtk_coord_entry_get_value(GHID_COORD_ENTRY(dialog_data.clearance_entry))); #undef rst_modify save = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_box)); - if (style == NULL){ - style = ghid_route_style_real_add_route_style(rss, rst, 0); + if (style == NULL) { + style = pcb_gtk_route_style_add_route_style(rss, rst, 0); } else { gtk_action_set_label(GTK_ACTION(style->action), rst->name); @@ -442,7 +443,7 @@ gtk_list_store_remove(rss->model, &rss->new_iter); /* Emit change signals */ pcb_gtk_route_style_select_style(rss, rst); - g_signal_emit(rss, ghid_route_style_signals[STYLE_EDITED_SIGNAL], 0, save); + g_signal_emit(rss, pcb_gtk_route_style_signals_id[STYLE_EDITED_SIGNAL], 0, save); if (changed) { pcb_board_set_changed_flag(pcb_true); Index: trunk/src_plugins/lib_gtk_common/dlg_route_style.h =================================================================== --- trunk/src_plugins/lib_gtk_common/dlg_route_style.h (revision 6732) +++ trunk/src_plugins/lib_gtk_common/dlg_route_style.h (revision 6733) @@ -18,8 +18,10 @@ int attr_editing; /* set to 1 when an attribute key or value text is being edited */ }; -/** Builds and runs the "edit route style" dialog */ +/** Builds and runs the "edit route style" dialog. + \param rss the route style selector widget linked to this dialog. + */ void pcb_gtk_route_style_edit_dialog(pcb_gtk_route_style_t * rss); /* Temporary: hid_gtk call back */ -extern void ghid_window_set_name_label(gchar *name); +extern void ghid_window_set_name_label(gchar * name); Index: trunk/src_plugins/lib_gtk_common/wt_route_style.c =================================================================== --- trunk/src_plugins/lib_gtk_common/wt_route_style.c (revision 6732) +++ trunk/src_plugins/lib_gtk_common/wt_route_style.c (revision 6733) @@ -38,12 +38,11 @@ #include "bu_status_line.h" - /** Global action creation counter */ static gint action_count; static GtkVBox *pcb_gtk_route_style_parent_class; -guint ghid_route_style_signals[STYLE_LAST_SIGNAL] = { 0 }; +guint pcb_gtk_route_style_signals_id[STYLE_LAST_SIGNAL] = { 0 }; #warning TODO: this should be in core @@ -61,17 +60,19 @@ } /** Launches the Edit dialog */ -static void edit_button_cb(GtkButton * btn, pcb_gtk_route_style_t * rss) +static void edit_button_cb(GtkButton * btn, gpointer rss) { - pcb_gtk_route_style_edit_dialog(rss); + pcb_gtk_route_style_edit_dialog((pcb_gtk_route_style_t *) rss); } /** Callback for user selection of a route style */ -static void radio_select_cb(GtkToggleAction * action, pcb_gtk_route_style_t * rss) +static void radio_select_cb(GtkToggleAction * action, gpointer data) { + pcb_gtk_route_style_t *rss = (pcb_gtk_route_style_t *) data; + rss->active_style = g_object_get_data(G_OBJECT(action), "route-style"); if (gtk_toggle_action_get_active(action)) - g_signal_emit(rss, ghid_route_style_signals[SELECT_STYLE_SIGNAL], 0, rss->active_style->rst); + g_signal_emit(rss, pcb_gtk_route_style_signals_id[SELECT_STYLE_SIGNAL], 0, rss->active_style->rst); } /* CONSTRUCTOR */ @@ -98,13 +99,13 @@ pcb_gtk_route_style_parent_class = g_type_class_peek_parent(klass); - ghid_route_style_signals[SELECT_STYLE_SIGNAL] = + pcb_gtk_route_style_signals_id[SELECT_STYLE_SIGNAL] = g_signal_new("select-style", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, G_STRUCT_OFFSET(pcb_gtk_route_style_class_t, select_style), NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); - ghid_route_style_signals[STYLE_EDITED_SIGNAL] = + pcb_gtk_route_style_signals_id[STYLE_EDITED_SIGNAL] = g_signal_new("style-edited", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, @@ -116,6 +117,7 @@ /* PUBLIC FUNCTIONS */ + GType pcb_gtk_route_style_get_type(void) { static GType rss_type = 0; @@ -159,12 +161,7 @@ return GTK_WIDGET(rss); } -/** FIXME: Remove comments ? Create a new pcb_gtk_route_style_t - - \param [in] rss The selector to be acted on - \param [in] data PCB's route style object that will be edited - */ -pcb_gtk_dlg_route_style_t *ghid_route_style_real_add_route_style(pcb_gtk_route_style_t * rss, pcb_route_style_t * data, int hide) +pcb_gtk_obj_route_style_t *pcb_gtk_route_style_add_route_style(pcb_gtk_route_style_t * rss, pcb_route_style_t * data, int hide) { GtkTreeIter iter; GtkTreePath *path; @@ -209,7 +206,14 @@ return new_style; } -void pcb_gtk_route_style_add_route_style(pcb_gtk_route_style_t * rss, pcb_route_style_t * data) +/** Adds a PCB route style to a \ref pcb_gtk_route_style_t object. + Note that the route style object passed to this function will be + updated directly. + + \param rss The widget to be acted on + \param data PCB's route style object describing the style + */ +static void add_route_style_with_hidden_check(pcb_gtk_route_style_t * rss, pcb_route_style_t * data) { if (!rss->hidden_button) { if (*pcb_custom_route_style.name == '\0') { @@ -217,11 +221,11 @@ strcpy(pcb_custom_route_style.name, ""); pcb_gtk_route_style_copy(0); } - ghid_route_style_real_add_route_style(rss, &pcb_custom_route_style, 1); + pcb_gtk_route_style_add_route_style(rss, &pcb_custom_route_style, 1); rss->hidden_button = 1; } if (data != NULL) - ghid_route_style_real_add_route_style(rss, data, 0); + pcb_gtk_route_style_add_route_style(rss, data, 0); } gint pcb_gtk_route_style_install_items(pcb_gtk_route_style_t * rss, GtkMenuShell * shell, gint pos) @@ -262,7 +266,7 @@ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(style->action), TRUE); g_signal_handler_unblock(G_OBJECT(style->action), style->sig_id); rss->active_style = style; - g_signal_emit(rss, ghid_route_style_signals[SELECT_STYLE_SIGNAL], 0, rss->active_style->rst); + g_signal_emit(rss, pcb_gtk_route_style_signals_id[SELECT_STYLE_SIGNAL], 0, rss->active_style->rst); return TRUE; } } @@ -346,7 +350,7 @@ rss->hidden_button = 0; } -/** Called when a route style is selected */ +/** Called when a route style is selected. */ static void route_style_changed_cb(pcb_gtk_route_style_t * rss, pcb_route_style_t * rst, gpointer data) { pcb_use_route_style(rst); @@ -353,15 +357,15 @@ ghid_set_status_line_label(); } -void make_route_style_buttons(pcb_gtk_route_style_t *rss) +void make_route_style_buttons(pcb_gtk_route_style_t * rss) { int i; /* Make sure the item is added */ - pcb_gtk_route_style_add_route_style(rss, NULL); + add_route_style_with_hidden_check(rss, NULL); for (i = 0; i < vtroutestyle_len(&PCB->RouteStyle); ++i) - pcb_gtk_route_style_add_route_style(rss, &PCB->RouteStyle.array[i]); + add_route_style_with_hidden_check(rss, &PCB->RouteStyle.array[i]); g_signal_connect(G_OBJECT(rss), "select_style", G_CALLBACK(route_style_changed_cb), NULL); g_signal_connect(G_OBJECT(rss), "style_edited", G_CALLBACK(route_styles_edited_cb), NULL); } Index: trunk/src_plugins/lib_gtk_common/wt_route_style.h =================================================================== --- trunk/src_plugins/lib_gtk_common/wt_route_style.h (revision 6732) +++ trunk/src_plugins/lib_gtk_common/wt_route_style.h (revision 6733) @@ -3,7 +3,6 @@ #include -#include "config.h" #include "route_style.h" G_BEGIN_DECLS /* keep c++ happy */ @@ -12,8 +11,15 @@ #define GHID_ROUTE_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GHID_ROUTE_STYLE_TYPE, pcb_gtk_route_style_class_t)) #define IS_GHID_ROUTE_STYLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GHID_ROUTE_STYLE_TYPE)) #define IS_GHID_ROUTE_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GHID_ROUTE_STYLE_TYPE)) -/** The widget Object */ - struct pcb_gtk_route_style_s { +/** Structure for "Edit Route Style" Dialog */ +typedef struct pcb_gtk_dlg_route_style_s pcb_gtk_dlg_route_style_t; + +/** The route style selector widget object data. */ +struct pcb_gtk_route_style_s { + /* GTK3 incompatibility : GTK3 prefers a GtkGrid with "orientation" property + set to GTK_ORIENTATION_VERTICAL, and packed children from + the start, using gtk_container_add(GTK_CONTAINER(grid), w); + */ GtkVBox parent; GSList *button_radio_group; @@ -20,6 +26,9 @@ GSList *action_radio_group; GtkWidget *edit_button; + /* GTK3 deprecated since version 3.10 Use GAction instead, and associate actions + with GtkActionable widgets. Use GMenuModel for creating menus with gtk_menu_new_from_model(). + */ GtkActionGroup *action_group; GtkAccelGroup *accel_group; @@ -34,7 +43,7 @@ typedef struct pcb_gtk_route_style_s pcb_gtk_route_style_t; -/** The widget Class */ +/** The route style selector widget Class. */ struct pcb_gtk_route_style_class_s { GtkVBoxClass parent_class; @@ -44,7 +53,7 @@ typedef struct pcb_gtk_route_style_class_s pcb_gtk_route_style_class_t; -/** Signals exposed by the widget */ +/** Signals exposed by the widget. */ enum { SELECT_STYLE_SIGNAL, STYLE_EDITED_SIGNAL, @@ -51,10 +60,11 @@ STYLE_LAST_SIGNAL }; -extern guint ghid_route_style_signals[STYLE_LAST_SIGNAL]; +/** All available GObject signals IDs. */ +extern guint pcb_gtk_route_style_signals_id[STYLE_LAST_SIGNAL]; -/** Columns used for internal data store */ +/** Columns used for internal data store. */ enum { STYLE_TEXT_COL, STYLE_DATA_COL, @@ -61,7 +71,7 @@ STYLE_N_COLS }; -/** Structure for a single Route Style object */ +/** Structure for a single Route Style object. */ struct pcb_gtk_obj_route_style_s { GtkRadioAction *action; GtkWidget *button; @@ -71,17 +81,15 @@ gulong sig_id; int hidden; }; + typedef struct pcb_gtk_obj_route_style_s pcb_gtk_obj_route_style_t; -/** Structure for "Edit Route Style" Dialog */ -typedef struct pcb_gtk_dlg_route_style_s pcb_gtk_dlg_route_style_t; - /* API */ -/** GObject type for this widget */ +/** GObject type for this widget. */ GType pcb_gtk_route_style_get_type(void); -/** Creates and returns a new freshly-allocated pcb_gtk_route_style_t object */ +/** Creates and returns a new freshly-allocated \ref pcb_gtk_route_style_t object. */ GtkWidget *pcb_gtk_route_style_new(void); /** Installs the "Route Style" menu items. @@ -90,68 +98,65 @@ the ordering of these items, since our internal data structure is a hash table. This shouldn't be a problem. - \param [in] rss The selector to be acted on - \param [in] shell The menu to install the items in - \param [in] pos The position in the menu to install items + \param rss The widget to be acted on + \param shell The menu to install the items in + \param pos The position in the menu to install items \return the number of items installed */ gint pcb_gtk_route_style_install_items(pcb_gtk_route_style_t * rss, GtkMenuShell * shell, gint pos); -/** Adds a route style to a pcb_gtk_route_style_t. +/** Adds a PCB route style to a \ref pcb_gtk_route_style_t object. Note that the route style object passed to this function will be - updated directly. + updated directly. (TODO: AV: Check and complete) - \param [in] rss The selector to be acted on - \param [in] data PCB's route style object describing the style + \param rss The widget to be acted on + \param data PCB's route style object describing the style + \param hide if TRUE ... (TODO: explain) */ -void pcb_gtk_route_style_add_route_style(pcb_gtk_route_style_t * rss, pcb_route_style_t * data); +pcb_gtk_obj_route_style_t *pcb_gtk_route_style_add_route_style(pcb_gtk_route_style_t * rss, pcb_route_style_t * data, int hide); -/** Selects a route style and emits a select-style signal - \param [in] rss The selector to be acted on - \param [in] rst The style to select +/** Selects a route style and emits a select-style signal. + \param rss The widget to be acted on + \param rst The style to select \return TRUE if a style was selected, FALSE otherwise */ gboolean pcb_gtk_route_style_select_style(pcb_gtk_route_style_t * rss, pcb_route_style_t * rst); -/** Returns the GtkAccelGroup of a route style selector - \param [in] rss The selector to be acted on - - \return the accel group of the selector +/** Returns the GtkAccelGroup of a route style selector widget. + \param rss The widget to be acted on */ GtkAccelGroup *pcb_gtk_route_style_get_accel_group(pcb_gtk_route_style_t * rss); -/** Sets a pcb_gtk_route_style_t selection to given values - \par Function Description +/** Sets a \ref pcb_gtk_route_style_t selection to given values. Given the line thickness, via size and clearance values of a route style, this function selects a route style with the given values. If there is no such style registered with the selector, nothing will happen. This function does not emit any signals. - \param [in] rss The selector to be acted on - \param [in] Thick pcb_coord_t to match selection to - \param [in] Hole pcb_coord_t to match selection to - \param [in] Diameter pcb_coord_t to match selection to - \param [in] Clearance pcb_coord_t to match selection to + \param rss The widget to be acted on + \param Thick \ref pcb_coord_t to match selection to + \param Hole \ref pcb_coord_t to match selection to + \param Diameter \ref pcb_coord_t to match selection to + \param Clearance \ref pcb_coord_t to match selection to */ void pcb_gtk_route_style_sync(pcb_gtk_route_style_t * rss, pcb_coord_t Thick, pcb_coord_t Hole, pcb_coord_t Diameter, pcb_coord_t Clearance); +/** What represents idx ? */ void pcb_gtk_route_style_copy(int idx); - -/** Removes all styles from a route style selector */ +/** Removes all styles from a route style widget. */ void pcb_gtk_route_style_empty(pcb_gtk_route_style_t * rss); -/** Configure the route style selector */ -void make_route_style_buttons(pcb_gtk_route_style_t *rss); +/*TODO: rename this function */ +/** Configures the route style selector. */ +void make_route_style_buttons(pcb_gtk_route_style_t * rss); -pcb_gtk_dlg_route_style_t *ghid_route_style_real_add_route_style(pcb_gtk_route_style_t * rss, pcb_route_style_t * data, int hide); - /* Temporary: call back to hid_gtk */ -extern void route_styles_edited_cb(pcb_gtk_route_style_t *rss, gboolean save, gpointer data); +extern void route_styles_edited_cb(pcb_gtk_route_style_t * rss, gboolean save, gpointer data); G_END_DECLS /* keep c++ happy */