[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: pcb.git: branch: master updated (39c0925401ecb3862967faf852059e159ddf9c0a)



The branch, master has been updated
       via  39c0925401ecb3862967faf852059e159ddf9c0a (commit)
      from  2029c9de01e48335a6c4649642748307293979bd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 src/hid/gtk/gui-top-window.c |  302 +-----------------------------------------
 1 files changed, 4 insertions(+), 298 deletions(-)


=================
 Commit Messages
=================

commit 39c0925401ecb3862967faf852059e159ddf9c0a
Author: Andrew Poelstra <asp11@xxxxxx>
Commit: Andrew Poelstra <asp11@xxxxxx>

    Remove special grid-change handling from Gtk

:100644 100644 44ad43a... b5caff9... M	src/hid/gtk/gui-top-window.c

=========
 Changes
=========

commit 39c0925401ecb3862967faf852059e159ddf9c0a
Author: Andrew Poelstra <asp11@xxxxxx>
Commit: Andrew Poelstra <asp11@xxxxxx>

    Remove special grid-change handling from Gtk

diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index 44ad43a..b5caff9 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -407,60 +407,6 @@ ghid_update_toggle_flags ()
 
 }
 
-#define	N_GRID_SETTINGS		11
-
-static gdouble grid_mil_values[N_GRID_SETTINGS] = {
-  MIL_TO_COORD (0.10),
-  MIL_TO_COORD (0.20),
-  MIL_TO_COORD (0.50),
-  MIL_TO_COORD (1.00),
-  MIL_TO_COORD (2.00),
-  MIL_TO_COORD (5.00),
-  MIL_TO_COORD (10.0),
-  MIL_TO_COORD (20.0),
-  MIL_TO_COORD (25.0),
-  MIL_TO_COORD (50.0),
-  MIL_TO_COORD (100)
-};
-
-static gdouble grid_mm_values[N_GRID_SETTINGS] = {
-  MM_TO_COORD (0.002),
-  MM_TO_COORD (0.005),
-  MM_TO_COORD (0.01),
-  MM_TO_COORD (0.02),
-  MM_TO_COORD (0.05),
-  MM_TO_COORD (0.1),
-  MM_TO_COORD (0.2),
-  MM_TO_COORD (0.25),
-  MM_TO_COORD (0.5),
-  MM_TO_COORD (1.0),
-  MM_TO_COORD (2.0)
-};
-
-  /* When the user toggles grid units mil<->mm, call this to get an
-     |  index into the grid values table of the current grid setting.  Then a
-     |  grid in the new units may be selected that is closest to what we had.
-     |
-     |  May want this call to fail if user has altered grid with 'g' key
-     |  and so current grid does not match any of the presets.  In that
-     |  case we want no item in the grid setting radio group to get set.
-   */
-static gint
-get_grid_value_index (gboolean allow_fail)
-{
-  gdouble *value;
-  gint i;
-
-  value = Settings.grid_units_mm ? &grid_mm_values[0] : &grid_mil_values[0];
-  for (i = 0; i < N_GRID_SETTINGS; ++i, ++value)
-    if (PCB->Grid < *value + 1.0 && PCB->Grid > *value - 1.0)
-      break;
-  if (i >= N_GRID_SETTINGS)
-    i = allow_fail ? -1 : N_GRID_SETTINGS - 1;
-
-  return i;
-}
-
 static void
 h_adjustment_changed_cb (GtkAdjustment * adj, GhidGui * g)
 {
@@ -672,162 +618,6 @@ void ghid_hotkey_cb (int which)
 
 
 /* ============== ViewMenu callbacks =============== */
-
-
-  /* Do grid units handling common to a grid units change from the menu or
-     |  the grid units button.
-   */
-static void
-handle_grid_units_change (gboolean active)
-{
-  gchar *grid;
-  gint i;
-
-  i = get_grid_value_index (FALSE);
-  Settings.grid_units_mm = active;
-  PCB->Grid = Settings.grid_units_mm ? grid_mm_values[i] : grid_mil_values[i];
-
-  ghid_grid_setting_update_menu_actions ();
-
-  grid = pcb_g_strdup_printf ("%$ms", (BDimension) PCB->Grid);
-  hid_actionl ("SetValue", "Grid", grid, "", NULL);
-  g_free (grid);
-
-  ghid_config_handle_units_changed ();
-
-  ghid_set_status_line_label ();
-}
-
-static void
-radio_grid_mil_setting_cb (GtkAction * action, GtkRadioAction * current)
-{
-  BDimension value;
-  gchar *grid;
-  gint index;
-
-  printf ("radio_grid_mil_setting_cb()\n");
-  if (ghidgui->toggle_holdoff)
-    return;
-  index = gtk_radio_action_get_current_value (current);
-  value = grid_mil_values[index];
-  grid = pcb_g_strdup_printf ("%$ms", value);
-  hid_actionl ("SetValue", "Grid", grid, "", NULL);
-  g_free (grid);
-  ghid_set_status_line_label ();
-}
-
-static void
-radio_grid_mm_setting_cb (GtkAction * action, GtkRadioAction * current)
-{
-  BDimension value;
-  gchar *grid;
-  gint index;
-
-  printf ("radio_grid_mm_setting_cb()\n");
-  if (ghidgui->toggle_holdoff)
-    return;
-  index = gtk_radio_action_get_current_value (current);
-  value = grid_mm_values[index];
-  grid = pcb_g_strdup_printf ("%$ms", value);
-  hid_actionl ("SetValue", "Grid", grid, "", NULL);
-  g_free (grid);
-  ghid_set_status_line_label ();
-}
-
-
-static GtkRadioActionEntry radio_grid_mil_setting_entries[] = {
-  /* name, stock_id, label, accelerator, tooltip, value */
-  {"grid-user", NULL, "user value", NULL, NULL, 0},
-  {"grid0", NULL, "0.1 mil", NULL, NULL, 0},
-  {"grid1", NULL, "0.2 mil", NULL, NULL, 1},
-  {"grid2", NULL, "0.5 mil", NULL, NULL, 2},
-  {"grid3", NULL, "1 mil", NULL, NULL, 3},
-  {"grid4", NULL, "2 mil", NULL, NULL, 4},
-  {"grid5", NULL, "5 mil", NULL, NULL, 5},
-  {"grid6", NULL, "10 mil", NULL, NULL, 6},
-  {"grid7", NULL, "20 mil", NULL, NULL, 7},
-  {"grid8", NULL, "25 mil", NULL, NULL, 8},
-  {"grid9", NULL, "50 mil", NULL, NULL, 9},
-  {"grid10", NULL, "100 mil", NULL, NULL, 10}
-};
-
-static gint n_radio_grid_mil_setting_entries
-  = G_N_ELEMENTS (radio_grid_mil_setting_entries);
-
-
-static GtkRadioActionEntry radio_grid_mm_setting_entries[] = {
-  /* name, stock_id, label, accelerator, tooltip, value */
-  {"grid-user", NULL, "user value", NULL, NULL, 0},
-  {"grid0", NULL, "0.002 mm", NULL, NULL, 0},
-  {"grid1", NULL, "0.005 mm", NULL, NULL, 1},
-  {"grid2", NULL, "0.01 mm", NULL, NULL, 2},
-  {"grid3", NULL, "0.02 mm", NULL, NULL, 3},
-  {"grid4", NULL, "0.05 mm", NULL, NULL, 4},
-  {"grid5", NULL, "0.1 mm", NULL, NULL, 5},
-  {"grid6", NULL, "0.2 mm", NULL, NULL, 6},
-  {"grid7", NULL, "0.25 mm", NULL, NULL, 7},
-  {"grid8", NULL, "0.5 mm", NULL, NULL, 8},
-  {"grid9", NULL, "1 mm", NULL, NULL, 9},
-  {"grid10", NULL, "2 mm", NULL, NULL, 10},
-};
-
-static gint n_radio_grid_mm_setting_entries
-  = G_N_ELEMENTS (radio_grid_mm_setting_entries);
-
-
-
-  /* Grid setting labels must also match user and new layout unit changes.
-   */
-void
-ghid_grid_setting_update_menu_actions (void)
-{
-  GtkAction *action;
-  gint i;
-
-  if (ghidgui->grid_actions)
-    {
-      /* Remove the existing radio grid actions from the menu.
-       */
-      gtk_ui_manager_remove_action_group (ghidgui->ui_manager,
-					  ghidgui->grid_actions);
-      g_object_unref (ghidgui->grid_actions);
-    }
-
-  /* And add back actions appropriate for mil or mm grid settings.
-   */
-  ghidgui->grid_actions = gtk_action_group_new ("GridActions");
-  gtk_action_group_set_translation_domain (ghidgui->grid_actions, NULL);
-  gtk_ui_manager_insert_action_group (ghidgui->ui_manager,
-				      ghidgui->grid_actions, 0);
-
-  /* Get the index of the radio button to set depending on current
-     |  PCB Grid value.  But if user hits 'g' key and no grid index matches,
-     |  'i' will be -1 and no button will be set active.  At least Gtk docs
-     |  say so, but I see different.
-   */
-  i = get_grid_value_index (TRUE);
-
-  if (Settings.grid_units_mm)
-    gtk_action_group_add_radio_actions (ghidgui->grid_actions,
-					radio_grid_mm_setting_entries,
-					n_radio_grid_mm_setting_entries,
-					i,
-					G_CALLBACK (radio_grid_mm_setting_cb),
-					NULL);
-  else
-    gtk_action_group_add_radio_actions (ghidgui->grid_actions,
-					radio_grid_mil_setting_entries,
-					n_radio_grid_mil_setting_entries,
-					i,
-					G_CALLBACK
-					(radio_grid_mil_setting_cb), NULL);
-  action = gtk_action_group_get_action (ghidgui->grid_actions, "grid-user");
-  if (action)
-    g_object_set (action, "sensitive", FALSE, NULL);
-}
-
-
-
 void
 ghid_set_menu_toggle_button (GtkActionGroup * ag, gchar * name,
 			     gboolean state)
@@ -871,89 +661,6 @@ ghid_sync_with_new_layout (void)
   ghid_set_status_line_label ();
 }
 
-/*
- * Sync toggle states in the menus at startup to Settings values loaded
- * in the config.
- */
-void
-ghid_init_toggle_states (void)
-{
-  GtkAction *action;
-  gboolean old_holdoff;
-
-  /* Just want to update the state of the menus without calling the
-     |  action functions at this time because causing a toggle action can
-     |  undo the initial condition set we want here.
-   */
-  old_holdoff = ghidgui->toggle_holdoff;
-  ghidgui->toggle_holdoff = TRUE;
-
-  action =
-    gtk_action_group_get_action (ghidgui->main_actions, "ToggleDrawGrid");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-				Settings.DrawGrid);
-
-  action = gtk_action_group_get_action (ghidgui->main_actions,
-					"ToggleGridUnitsMm");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-				Settings.grid_units_mm);
-
-  action = gtk_action_group_get_action (ghidgui->main_actions,
-					"TogglePinoutShowsNumber");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-				Settings.ShowNumber);
-
-  action = gtk_action_group_get_action (ghidgui->main_actions,
-					"Toggle45degree");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-				Settings.AllDirectionLines);
-
-  action = gtk_action_group_get_action (ghidgui->main_actions,
-					"ToggleRubberBand");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-				Settings.RubberBandMode);
-
-  action = gtk_action_group_get_action (ghidgui->main_actions,
-					"ToggleStartDirection");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-				Settings.SwapStartDirection);
-
-  action = gtk_action_group_get_action (ghidgui->main_actions,
-					"ToggleUniqueNames");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-				Settings.UniqueNames);
-
-  action = gtk_action_group_get_action (ghidgui->main_actions,
-					"ToggleSnapPin");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), Settings.SnapPin);
-
-  action = gtk_action_group_get_action (ghidgui->main_actions,
-					"ToggleClearLine");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-				Settings.ClearLine);
-
-  action = gtk_action_group_get_action (ghidgui->main_actions,
-					"ToggleOrthogonalMoves");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-				Settings.OrthogonalMoves);
-
-  action = gtk_action_group_get_action (ghidgui->main_actions,
-					"ToggleLiveRoute");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
-				Settings.liveRouting);
-
-  action = gtk_action_group_get_action (ghidgui->main_actions,
-					"ToggleShowDRC");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), Settings.ShowDRC);
-
-  action = gtk_action_group_get_action (ghidgui->main_actions,
-					"ToggleAutoDrC");
-  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), Settings.AutoDRC);
-
-  ghidgui->toggle_holdoff = old_holdoff;
-  ghid_set_status_line_label ();
-}
-
 /* ---------------------------------------------------------------------------
  *
  * layer_process()
@@ -1241,11 +948,10 @@ ghid_window_set_name_label (gchar * name)
 static void
 grid_units_button_cb (GtkWidget * widget, gpointer data)
 {
-
-  /* Do handling common to when units are changed from the menu.
-   */
-  handle_grid_units_change (!Settings.grid_units_mm);
-
+  if (Settings.grid_units_mm)
+    hid_actionl ("SetUnits", "mil", NULL);
+  else
+    hid_actionl ("SetUnits", "mm", NULL);
 }
 
 /*




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs