pcb 4.1.1
An interactive printed circuit board layout editor.

ghid-route-style-selector.c

Go to the documentation of this file.
00001 
00007 #include <glib.h>
00008 #include <glib-object.h>
00009 #include <gdk/gdkkeysyms.h>
00010 #include <gtk/gtk.h>
00011 
00012 #include "global.h"
00013 #include "gtkhid.h"
00014 #include "gui.h"
00015 #include "pcb-printf.h"
00016 
00017 #include "ghid-route-style-selector.h"
00018 
00019 /* Forward dec'ls */
00020 struct _route_style;
00021 struct _route_style *ghid_route_style_selector_real_add_route_style
00022   (GHidRouteStyleSelector *, RouteStyleType *, gboolean temp);
00023 static void ghid_route_style_selector_finalize (GObject *object);
00024 
00026 static gint action_count;
00027 
00029 enum {
00030   SELECT_STYLE_SIGNAL,
00031   STYLE_EDITED_SIGNAL,
00032   LAST_SIGNAL
00033 };
00034 
00036 enum {
00037   TEXT_COL,
00038   DATA_COL,
00039   N_COLS
00040 };
00041 
00042 static GtkVBox *ghid_route_style_selector_parent_class;
00043 static guint ghid_route_style_selector_signals[LAST_SIGNAL] = { 0 };
00044 
00045 struct _GHidRouteStyleSelector
00046 {
00047   GtkVBox parent;
00048 
00049   GSList *button_radio_group;
00050   GSList *action_radio_group;
00051   GtkWidget *edit_button;
00052 
00053   GtkActionGroup *action_group;
00054   GtkAccelGroup *accel_group;
00055   GtkRadioAction *null_action;
00056   GtkWidget *null_button;
00057   gint shortcut_key_idx;
00058 
00059   GtkListStore *model;
00060   struct _route_style *active_style;
00061 };
00062 
00063 struct _GHidRouteStyleSelectorClass
00064 {
00065   GtkVBoxClass parent_class;
00066 
00067   void (* select_style) (GHidRouteStyleSelector *, RouteStyleType *);
00068   void (* style_edited) (GHidRouteStyleSelector *, gboolean);
00069 };
00070 
00071 struct _route_style
00072 {
00073   gboolean temporary;
00074   GtkRadioAction *action;
00075   GtkWidget *button;
00076   GtkWidget *menu_item;
00077   GtkTreeRowReference *rref;
00078   RouteStyleType *rst;
00079   gulong sig_id;
00080 };
00081 
00082 static void
00083 init_radio_groups (GHidRouteStyleSelector *rss)
00084 {
00085   gtk_radio_action_set_group (rss->null_action, rss->action_radio_group);
00086   rss->action_radio_group = gtk_radio_action_get_group (rss->null_action);
00087   gtk_radio_button_set_group (GTK_RADIO_BUTTON (rss->null_button),
00088                               rss->button_radio_group);
00089   rss->button_radio_group = gtk_radio_button_get_group
00090                               (GTK_RADIO_BUTTON (rss->null_button));
00091 }
00092 
00093 /* SIGNAL HANDLERS */
00095 static void
00096 radio_select_cb (GtkToggleAction *action, GHidRouteStyleSelector *rss)
00097 {
00098   rss->active_style = g_object_get_data (G_OBJECT (action), "route-style");
00099   if (gtk_toggle_action_get_active (action))
00100     g_signal_emit (rss, ghid_route_style_selector_signals[SELECT_STYLE_SIGNAL],
00101                    0, rss->active_style->rst);
00102 }
00103 
00104 /* EDIT DIALOG */
00105 struct _dialog
00106 {
00107   GHidRouteStyleSelector *rss;
00108   GtkWidget *name_entry;
00109   GtkWidget *line_entry;
00110   GtkWidget *via_hole_entry;
00111   GtkWidget *via_size_entry;
00112   GtkWidget *clearance_entry;
00113 };
00114 
00125 static void
00126 dialog_style_changed_cb (GtkComboBox *combo, struct _dialog *dialog)
00127 {
00128   struct _route_style *style;
00129   GtkTreeIter iter;
00130   gtk_combo_box_get_active_iter (combo, &iter);
00131   gtk_tree_model_get (GTK_TREE_MODEL (dialog->rss->model),
00132                       &iter, DATA_COL, &style, -1);
00133 
00134   if (style == NULL)
00135     {
00136       gtk_entry_set_text (GTK_ENTRY (dialog->name_entry),
00137                           _("New Style"));
00138       return;
00139     }
00140 
00141   gtk_entry_set_text (GTK_ENTRY (dialog->name_entry), style->rst->Name);
00142   ghid_coord_entry_set_value (GHID_COORD_ENTRY (dialog->line_entry),
00143                               style->rst->Thick);
00144   ghid_coord_entry_set_value (GHID_COORD_ENTRY (dialog->via_hole_entry),
00145                               style->rst->Hole);
00146   ghid_coord_entry_set_value (GHID_COORD_ENTRY (dialog->via_size_entry),
00147                               style->rst->Diameter);
00148   ghid_coord_entry_set_value (GHID_COORD_ENTRY (dialog->clearance_entry),
00149                               style->rst->Keepaway);
00150 
00151 }
00152 
00153 /* \brief Helper for edit_button_cb */
00154 static void
00155 _table_attach (GtkWidget *table, gint row, const gchar *label,
00156                GtkWidget **entry, Coord min, Coord max)
00157 {
00158   GtkWidget *label_w = gtk_label_new (label);
00159   gtk_misc_set_alignment (GTK_MISC (label_w), 1.0, 0.5);
00160 
00161   *entry = ghid_coord_entry_new (min, max, 0, Settings.grid_unit, CE_SMALL);
00162   gtk_table_attach (GTK_TABLE (table), label_w, 0, 1, row, row + 1,
00163                     GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
00164   gtk_table_attach (GTK_TABLE (table), *entry, 1, 2, row, row + 1,
00165                     GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
00166 }
00167 
00168 /* \brief Builds and runs the "edit route styles" dialog */
00169 void
00170 ghid_route_style_selector_edit_dialog (GHidRouteStyleSelector *rss)
00171 {
00172   GtkTreePath *path;
00173   GtkTreeIter iter, tmp_iter;
00174   struct _dialog dialog_data;
00175   GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
00176   GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (rss));
00177   GtkWidget *dialog;
00178   GtkWidget *content_area;
00179   GtkWidget *vbox, *hbox, *sub_vbox, *table;
00180   GtkWidget *label, *select_box, *check_box;
00181 
00182   /* Build dialog */
00183   dialog = gtk_dialog_new_with_buttons (_("Edit Route Styles"),
00184                                         GTK_WINDOW (window),
00185                                         GTK_DIALOG_DESTROY_WITH_PARENT,
00186                                         GTK_STOCK_CANCEL, GTK_RESPONSE_NONE,
00187                                         GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
00188 
00189   label = gtk_label_new (_("Edit Style:"));
00190   gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
00191 
00192   select_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (rss->model));
00193   gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (select_box), renderer, TRUE);
00194   gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT(select_box), renderer,
00195                                   "text", TEXT_COL, NULL);
00196 
00197   content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
00198 
00199   hbox = gtk_hbox_new (FALSE, 4);
00200   gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 4);
00201   vbox = gtk_vbox_new (FALSE, 4);
00202   gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 4);
00203 
00204   hbox = gtk_hbox_new (FALSE, 4);
00205   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
00206   gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
00207   gtk_box_pack_start (GTK_BOX (hbox), select_box, TRUE, TRUE, 0);
00208 
00209   sub_vbox = ghid_category_vbox (vbox, _("Route Style Data"),
00210                                  4, 2, TRUE, TRUE);
00211   table = gtk_table_new (5, 2, FALSE);
00212   gtk_box_pack_start (GTK_BOX (sub_vbox), table, TRUE, TRUE, 4);
00213   label = gtk_label_new (_("Name:"));
00214   gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
00215   dialog_data.name_entry = gtk_entry_new ();
00216   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
00217                     GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
00218   gtk_table_attach (GTK_TABLE (table), dialog_data.name_entry, 1, 2, 0, 1,
00219                     GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
00220 
00221   _table_attach (table, 1, _("Line width:"),
00222                  &dialog_data.line_entry,
00223                  MIN_LINESIZE, MAX_LINESIZE);
00224   _table_attach (table, 2, _("Via hole size:"),
00225                  &dialog_data.via_hole_entry,
00226                  MIN_PINORVIAHOLE, MAX_PINORVIASIZE - MIN_PINORVIACOPPER);
00227   _table_attach (table, 3, _("Via ring size:"),
00228                  &dialog_data.via_size_entry,
00229                  MIN_PINORVIAHOLE + MIN_PINORVIACOPPER, MAX_PINORVIASIZE);
00230   _table_attach (table, 4, _("Clearance:"),
00231                  &dialog_data.clearance_entry,
00232                  MIN_LINESIZE, MAX_LINESIZE);
00233 
00234   sub_vbox = ghid_category_vbox (vbox, _("Set as Default"),
00235                                  4, 2, TRUE, TRUE);
00236   check_box = gtk_check_button_new_with_label
00237                 (_("Save route style settings as default"));
00238   gtk_box_pack_start (GTK_BOX (sub_vbox), check_box, TRUE, TRUE, 0);
00239 
00240   /* Add "new style" option to list */
00241   gtk_list_store_append (rss->model, &tmp_iter);
00242   gtk_list_store_set (rss->model, &tmp_iter, TEXT_COL,
00243                       _("New (this session only)"), DATA_COL, NULL, -1);
00244 
00245   /* Display dialog */
00246   dialog_data.rss = rss;
00247   path = gtk_tree_row_reference_get_path (rss->active_style->rref);
00248   gtk_tree_model_get_iter (GTK_TREE_MODEL (rss->model), &iter, path);
00249   g_signal_connect (G_OBJECT (select_box), "changed",
00250                     G_CALLBACK (dialog_style_changed_cb), &dialog_data);
00251   gtk_combo_box_set_active_iter (GTK_COMBO_BOX (select_box), &iter);
00252   gtk_widget_show_all (dialog);
00253   if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
00254     {
00255       RouteStyleType *rst;
00256       struct _route_style *style;
00257       gboolean save;
00258       gtk_combo_box_get_active_iter (GTK_COMBO_BOX (select_box), &iter);
00259       gtk_tree_model_get (GTK_TREE_MODEL (rss->model),
00260                           &iter, DATA_COL, &style, -1);
00261       if (style == NULL)
00262         rst = g_malloc (sizeof *rst);
00263       else
00264         {
00265           rst = style->rst;
00266           free (rst->Name);
00267         }
00268 
00269       rst->Name = StripWhiteSpaceAndDup
00270                     (gtk_entry_get_text (GTK_ENTRY (dialog_data.name_entry)));
00271       rst->Thick = ghid_coord_entry_get_value
00272                      (GHID_COORD_ENTRY (dialog_data.line_entry));
00273       rst->Hole = ghid_coord_entry_get_value
00274                     (GHID_COORD_ENTRY (dialog_data.via_hole_entry));
00275       rst->Diameter = ghid_coord_entry_get_value
00276                         (GHID_COORD_ENTRY (dialog_data.via_size_entry));
00277       rst->Keepaway = ghid_coord_entry_get_value
00278                         (GHID_COORD_ENTRY (dialog_data.clearance_entry));
00279       save = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_box));
00280 
00281       if (style == NULL)
00282         style = ghid_route_style_selector_real_add_route_style
00283                   (rss, rst, TRUE);
00284       else
00285         {
00286           gtk_action_set_label (GTK_ACTION (style->action), rst->Name); 
00287           gtk_list_store_set (rss->model, &iter, TEXT_COL, rst->Name, -1);
00288         }
00289 
00290       /* Cleanup */
00291       gtk_widget_destroy (dialog);
00292       gtk_list_store_remove (rss->model, &tmp_iter);
00293       /* Emit change signals */
00294       ghid_route_style_selector_select_style (rss, rst);
00295       g_signal_emit
00296         (rss, ghid_route_style_selector_signals[STYLE_EDITED_SIGNAL],
00297          0, save);
00298     }
00299   else
00300     {
00301       gtk_widget_destroy (dialog);
00302       gtk_list_store_remove (rss->model, &tmp_iter);
00303     }
00304 }
00305 /* end EDIT DIALOG */
00306 
00307 static void
00308 edit_button_cb (GtkButton *btn, GHidRouteStyleSelector *rss)
00309 {
00310   ghid_route_style_selector_edit_dialog (rss);
00311 }
00312 
00313 /* CONSTRUCTOR */
00314 static void
00315 ghid_route_style_selector_init (GHidRouteStyleSelector *rss)
00316 {
00317 }
00318 
00319 static void
00320 ghid_route_style_selector_class_init (GHidRouteStyleSelectorClass *klass)
00321 {
00322   GObjectClass *object_class = (GObjectClass *) klass;
00323 
00324   ghid_route_style_selector_parent_class = g_type_class_peek_parent (klass);
00325 
00326   ghid_route_style_selector_signals[SELECT_STYLE_SIGNAL] =
00327     g_signal_new ("select-style",
00328                   G_TYPE_FROM_CLASS (klass),
00329                   G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
00330                   G_STRUCT_OFFSET (GHidRouteStyleSelectorClass, select_style),
00331                   NULL, NULL,
00332                   g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE,
00333                   1, G_TYPE_POINTER);
00334   ghid_route_style_selector_signals[STYLE_EDITED_SIGNAL] =
00335     g_signal_new ("style-edited",
00336                   G_TYPE_FROM_CLASS (klass),
00337                   G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
00338                   G_STRUCT_OFFSET (GHidRouteStyleSelectorClass, style_edited),
00339                   NULL, NULL,
00340                   g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE,
00341                   1, G_TYPE_BOOLEAN);
00342 
00343   object_class->finalize = ghid_route_style_selector_finalize;
00344 }
00345 
00348 static void
00349 ghid_route_style_selector_finalize (GObject *object)
00350 {
00351   GHidRouteStyleSelector *rss = (GHidRouteStyleSelector *) object;
00352 
00353   ghid_route_style_selector_empty (rss);
00354 
00355   g_object_unref (rss->accel_group);
00356   g_object_unref (rss->action_group);
00357 
00358   G_OBJECT_CLASS (ghid_route_style_selector_parent_class)->finalize (object);
00359 }
00360 
00361 /* PUBLIC FUNCTIONS */
00362 GType
00363 ghid_route_style_selector_get_type (void)
00364 {
00365   static GType rss_type = 0;
00366 
00367   if (!rss_type)
00368     {
00369       const GTypeInfo rss_info =
00370       {
00371         sizeof (GHidRouteStyleSelectorClass),
00372         NULL, /* base_init */
00373         NULL, /* base_finalize */
00374         (GClassInitFunc) ghid_route_style_selector_class_init,
00375         NULL, /* class_finalize */
00376         NULL, /* class_data */
00377         sizeof (GHidRouteStyleSelector),
00378         0,    /* n_preallocs */
00379         (GInstanceInitFunc) ghid_route_style_selector_init,
00380       };
00381 
00382       rss_type = g_type_register_static (GTK_TYPE_VBOX,
00383                                          "GHidRouteStyleSelector",
00384                                          &rss_info,
00385                                          0);
00386     }
00387 
00388   return rss_type;
00389 }
00390 
00395 GtkWidget *
00396 ghid_route_style_selector_new ()
00397 {
00398   GHidRouteStyleSelector *rss =
00399     g_object_new (GHID_ROUTE_STYLE_SELECTOR_TYPE, NULL);
00400 
00401   rss->active_style = NULL;
00402   rss->action_radio_group = NULL;
00403   rss->button_radio_group = NULL;
00404   rss->model = gtk_list_store_new (N_COLS, G_TYPE_STRING, G_TYPE_POINTER);
00405 
00406   rss->accel_group = gtk_accel_group_new ();
00407   rss->action_group = gtk_action_group_new ("RouteStyleSelector");
00408   rss->null_action = gtk_radio_action_new ("RouteStyleXX", "",
00409                                            NULL, NULL, -1);
00410   rss->null_button = gtk_radio_button_new (rss->button_radio_group);
00411   init_radio_groups (rss);
00412   gtk_activatable_set_related_action (GTK_ACTIVATABLE (rss->null_button),
00413                                       GTK_ACTION (rss->null_action));
00414   rss->shortcut_key_idx = 1;
00415 
00416   /* Create edit button */
00417   rss->edit_button = gtk_button_new_with_label (_("Route Styles"));
00418   g_signal_connect (G_OBJECT (rss->edit_button), "clicked",
00419                     G_CALLBACK (edit_button_cb), rss);
00420   gtk_box_pack_start (GTK_BOX (rss), rss->edit_button, FALSE, FALSE, 0);
00421 
00422   return GTK_WIDGET (rss);
00423 }
00424 
00431 struct _route_style *
00432 ghid_route_style_selector_real_add_route_style (GHidRouteStyleSelector *rss,
00433                                                 RouteStyleType *data,
00434                                                 gboolean temp)
00435 {
00436   GtkTreeIter iter;
00437   GtkTreePath *path;
00438   gchar *action_name = g_strdup_printf ("RouteStyle%d", action_count);
00439   struct _route_style *new_style = g_malloc (sizeof (*new_style));
00440 
00441   /* Key the route style data with the RouteStyleType it controls */
00442   new_style->rst = data;
00443   new_style->temporary = temp;
00444   new_style->action = gtk_radio_action_new (action_name, data->Name,
00445                                             NULL, NULL, action_count);
00446   gtk_radio_action_set_group (new_style->action, rss->action_radio_group);
00447   rss->action_radio_group = gtk_radio_action_get_group (new_style->action);
00448   new_style->button = gtk_radio_button_new (rss->button_radio_group);
00449   rss->button_radio_group = gtk_radio_button_get_group
00450                               (GTK_RADIO_BUTTON (new_style->button));
00451   gtk_activatable_set_related_action (GTK_ACTIVATABLE (new_style->button),
00452                                       GTK_ACTION (new_style->action));
00453 
00454   gtk_list_store_append (rss->model, &iter);
00455   gtk_list_store_set (rss->model, &iter, TEXT_COL, data->Name,
00456                       DATA_COL, new_style, -1);
00457   path = gtk_tree_model_get_path (GTK_TREE_MODEL (rss->model), &iter);
00458   new_style->rref = gtk_tree_row_reference_new (GTK_TREE_MODEL (rss->model),
00459                                                 path);
00460   gtk_tree_path_free (path);
00461 
00462   /* Setup accelerator */
00463   if (rss->shortcut_key_idx < 12)
00464     {
00465       gchar *accel = g_strdup_printf ("<Ctrl>F%d", rss->shortcut_key_idx);
00466       gtk_action_set_accel_group (GTK_ACTION (new_style->action),
00467                                   rss->accel_group);
00468       gtk_action_group_add_action_with_accel (rss->action_group,
00469                                               GTK_ACTION (new_style->action),
00470                                               accel);
00471       g_free (accel);
00472       ++rss->shortcut_key_idx;
00473     }
00474 
00475   /* Hookup and install radio button */
00476   g_object_set_data (G_OBJECT (new_style->action), "route-style", new_style);
00477   new_style->sig_id = g_signal_connect (G_OBJECT (new_style->action),
00478                                         "activate",
00479                                         G_CALLBACK (radio_select_cb), rss);
00480   gtk_box_pack_start (GTK_BOX (rss), new_style->button, FALSE, FALSE, 0);
00481 
00482   g_free (action_name);
00483   ++action_count;
00484   return new_style;
00485 }
00486 
00496 void
00497 ghid_route_style_selector_add_route_style (GHidRouteStyleSelector *rss,
00498                                            RouteStyleType *data)
00499 {
00500   ghid_route_style_selector_real_add_route_style (rss, data, FALSE);
00501 }
00502 
00503 
00517 gint
00518 ghid_route_style_selector_install_items (GHidRouteStyleSelector *rss,
00519                                          GtkMenuShell *shell, gint pos)
00520 {
00521   gint n = 0;
00522   GtkTreeIter iter;
00523 
00524   gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rss->model), &iter);
00525   do
00526     {
00527       GtkAction *action;
00528       struct _route_style *style;
00529 
00530       gtk_tree_model_get (GTK_TREE_MODEL (rss->model),
00531                           &iter, DATA_COL, &style, -1);
00532       action = GTK_ACTION (style->action);
00533       style->menu_item = gtk_action_create_menu_item (action);
00534       gtk_menu_shell_insert (shell, style->menu_item, pos + n);
00535       ++n;
00536     }
00537   while (gtk_tree_model_iter_next (GTK_TREE_MODEL (rss->model), &iter));
00538 
00539   return n;
00540 }
00541 
00549 gboolean
00550 ghid_route_style_selector_select_style (GHidRouteStyleSelector *rss,
00551                                         RouteStyleType *rst)
00552 {
00553   GtkTreeIter iter;
00554   gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rss->model), &iter);
00555   do
00556     {
00557       struct _route_style *style;
00558       gtk_tree_model_get (GTK_TREE_MODEL (rss->model),
00559                           &iter, DATA_COL, &style, -1);
00560       if (style->rst == rst)
00561         {
00562           g_signal_handler_block (G_OBJECT (style->action), style->sig_id);
00563           gtk_toggle_action_set_active
00564             (GTK_TOGGLE_ACTION (style->action), TRUE);
00565           g_signal_handler_unblock (G_OBJECT (style->action), style->sig_id);
00566           rss->active_style = style;
00567           g_signal_emit
00568             (rss, ghid_route_style_selector_signals[SELECT_STYLE_SIGNAL],
00569              0, rss->active_style->rst);
00570           return TRUE;
00571         }
00572     }
00573   while (gtk_tree_model_iter_next (GTK_TREE_MODEL (rss->model), &iter));
00574 
00575   return FALSE;
00576 }
00577 
00585 GtkAccelGroup *
00586 ghid_route_style_selector_get_accel_group (GHidRouteStyleSelector *rss)
00587 {
00588   return rss->accel_group;
00589 }
00590 
00604 void
00605 ghid_route_style_selector_sync (GHidRouteStyleSelector *rss,
00606                                 Coord Thick, Coord Hole,
00607                                 Coord Diameter, Coord Keepaway)
00608 {
00609   gboolean found_match = FALSE;
00610   GtkTreeIter iter;
00611   gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rss->model), &iter);
00612   do
00613     {
00614       struct _route_style *style;
00615       gtk_tree_model_get (GTK_TREE_MODEL (rss->model),
00616                           &iter, DATA_COL, &style, -1);
00617       if (style->rst->Thick == Thick &&
00618           style->rst->Hole == Hole &&
00619           style->rst->Diameter == Diameter &&
00620           style->rst->Keepaway == Keepaway)
00621         {
00622           g_signal_handler_block (G_OBJECT (style->action), style->sig_id);
00623           gtk_toggle_action_set_active
00624             (GTK_TOGGLE_ACTION (style->action), TRUE);
00625           g_signal_handler_unblock (G_OBJECT (style->action), style->sig_id);
00626           rss->active_style = style;
00627           found_match = TRUE;
00628         }
00629     }
00630   while (gtk_tree_model_iter_next (GTK_TREE_MODEL (rss->model), &iter));
00631 
00632   if (!found_match)
00633     gtk_radio_action_set_current_value (rss->null_action, -1);
00634 }
00635 
00637 void
00638 ghid_route_style_selector_empty (GHidRouteStyleSelector *rss)
00639 {
00640   GtkTreeIter iter;
00641   gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rss->model), &iter);
00642   do
00643     {
00644       struct _route_style *rsdata;
00645       gtk_tree_model_get (GTK_TREE_MODEL (rss->model),
00646                           &iter, DATA_COL, &rsdata, -1);
00647       if (rsdata->action)
00648         {
00649           gtk_action_group_remove_action (rss->action_group,
00650                                 GTK_ACTION (rsdata->action));
00651           g_object_unref (G_OBJECT (rsdata->action));
00652         }
00653       if (rsdata->button)
00654         gtk_widget_destroy (GTK_WIDGET (rsdata->button));
00655       if (rsdata->menu_item)
00656         gtk_widget_destroy (GTK_WIDGET (rsdata->menu_item));
00657       if (rsdata->temporary)
00658         {
00659           free (rsdata->rst->Name);
00660           g_free (rsdata->rst);
00661         }
00662       gtk_tree_row_reference_free (rsdata->rref);
00663       free (rsdata);
00664     }
00665   while (gtk_list_store_remove (rss->model, &iter));
00666   rss->action_radio_group = NULL;
00667   rss->button_radio_group = NULL;
00668   rss->shortcut_key_idx = 1;
00669   init_radio_groups (rss);
00670 }
00671