Exemple #1
0
/* ---------------------------------------------------------------------------
 * output of status line
 */
void
ghid_set_status_line_label (void)
{
  gchar *flag = TEST_FLAG (ALLDIRECTIONFLAG, PCB)
                ? "all"
                : (PCB->Clipping == 0
                    ? "45"
                    : (PCB->Clipping == 1
                      ? "45_/"
                      : "45\\_"));
  gchar *text = pcb_g_strdup_printf (
        _("%m+<b>view</b>=%s  "
          "<b>grid</b>=%$mS  "
          "%s%s  "
          "<b>line</b>=%mS  "
          "<b>via</b>=%mS (%mS)  %s"
          "<b>clearance</b>=%mS  "
          "<b>text</b>=%i%%  "
          "<b>buffer</b>=#%i"),
      Settings.grid_unit->allow,
      Settings.ShowBottomSide ? C_("status", "bottom") : C_("status", "top"),
      PCB->Grid,
      flag, TEST_FLAG (RUBBERBANDFLAG, PCB) ? ",R  " : "  ",
      Settings.LineThickness,
      Settings.ViaThickness,
      Settings.ViaDrillingHole,
      ghidgui->compact_horizontal ? "\n" : "",
      Settings.Keepaway,
      Settings.TextScale, Settings.BufferNumber + 1);

  ghid_status_line_set_text (text);
  g_free (text);
}
Exemple #2
0
  /* Run a glib GMainLoop which intercepts key and mouse button events from
     |  the top level loop.  When a mouse or key is hit in the Output drawing
     |  area, quit the loop so the top level loop can continue and use the
     |  the mouse pointer coordinates at the time of the mouse button event.
   */
static gboolean
run_get_location_loop (const gchar * message)
{
  GMainLoop *loop;
  gulong button_handler, key_handler;
  gint oldObjState, oldLineState, oldBoxState;

  ghid_status_line_set_text (message);

  oldObjState = Crosshair.AttachedObject.State;
  oldLineState = Crosshair.AttachedLine.State;
  oldBoxState = Crosshair.AttachedBox.State;
  HideCrosshair (true);
  Crosshair.AttachedObject.State = STATE_FIRST;
  Crosshair.AttachedLine.State = STATE_FIRST;
  Crosshair.AttachedBox.State = STATE_FIRST;
  ghid_hand_cursor ();
  RestoreCrosshair (true);

  /* Stop the top level GMainLoop from getting user input from keyboard
     |  and mouse so we can install our own handlers here.  Also set the
     |  control interface insensitive so all the user can do is hit a key
     |  or mouse button in the Output drawing area.
   */
  ghid_interface_input_signals_disconnect ();
  ghid_interface_set_sensitive (FALSE);

  got_location = TRUE;		/* Will be unset by hitting most keys */
  button_handler =
    g_signal_connect (G_OBJECT (gport->drawing_area),
		      "button_press_event",
		      G_CALLBACK (loop_button_press_cb), &loop);
  key_handler =
    g_signal_connect (G_OBJECT (gport->top_window),
		      "key_press_event",
		      G_CALLBACK (loop_key_press_cb), &loop);

  loop = g_main_loop_new (NULL, FALSE);
  g_main_loop_run (loop);

  g_main_loop_unref (loop);

  g_signal_handler_disconnect (gport->drawing_area, button_handler);
  g_signal_handler_disconnect (gport->top_window, key_handler);

  ghid_interface_input_signals_connect ();	/* return to normal */
  ghid_interface_set_sensitive (TRUE);

  HideCrosshair (true);
  Crosshair.AttachedObject.State = oldObjState;
  Crosshair.AttachedLine.State = oldLineState;
  Crosshair.AttachedBox.State = oldBoxState;
  RestoreCrosshair (true);
  ghid_restore_cursor ();

  ghid_set_status_line_label ();

  return got_location;
}
Exemple #3
0
/* ---------------------------------------------------------------------------
 * output of status line
 */
void
ghid_set_status_line_label (void)
{
  gchar text[512];

  if (!Settings.grid_units_mm)
    snprintf (text, sizeof (text),
	      _("<b>%c  view</b>=%s  "
		"<b>grid</b>=%.1f:%i  "
		"%s%s  "
		"<b>line</b>=%.1f  "
		"<b>via</b>=%.1f(%.1f)  %s"
		"<b>clearance</b>=%.1f  "
		"<b>text</b>=%i%%  "
		"<b>buffer</b>=#%i"),
	      PCB->Changed ? '*' : ' ',
	      Settings.ShowSolderSide ? _("solder") : _("component"),
	      PCB->Grid / 100.0,
	      (int) Settings.GridFactor,
	      TEST_FLAG (ALLDIRECTIONFLAG, PCB) ? "all" :
	      (PCB->Clipping == 0 ? "45" :
	       (PCB->Clipping == 1 ? "45_/" : "45\\_")),
	      TEST_FLAG (RUBBERBANDFLAG, PCB) ? ",R  " : "  ",
	      Settings.LineThickness / 100.0,
	      Settings.ViaThickness / 100.0,
	      Settings.ViaDrillingHole / 100.0,
	      ghidgui->compact_horizontal ? "\n" : "",
	      Settings.Keepaway / 100.0,
	      Settings.TextScale, Settings.BufferNumber + 1);
  else
    snprintf (text, sizeof (text),
	      _("<b>%c  view</b>=%s  "
		"<b>grid</b>=%5.3f:%i  "
		"%s%s  "
		"<b>line</b>=%5.3f  "
		"<b>via</b>=%5.3f(%5.3f)  %s"
		"<b>clearance</b>=%5.3f  "
		"<b>text</b>=%i%%  "
		"<b>buffer</b>=#%i"),
	      PCB->Changed ? '*' : ' ',
	      Settings.ShowSolderSide ? _("solder") : _("component"),
	      PCB->Grid * COOR_TO_MM, (int) Settings.GridFactor,
	      TEST_FLAG (ALLDIRECTIONFLAG, PCB) ? "all" :
	      (PCB->Clipping == 0 ? "45" :
	       (PCB->Clipping == 1 ? "45_/" : "45\\_")),
	      TEST_FLAG (RUBBERBANDFLAG, PCB) ? ",R  " : "  ",
	      Settings.LineThickness * COOR_TO_MM,
	      Settings.ViaThickness * COOR_TO_MM,
	      Settings.ViaDrillingHole * COOR_TO_MM,
	      ghidgui->compact_horizontal ? "\n" : "",
	      Settings.Keepaway * COOR_TO_MM,
	      Settings.TextScale, Settings.BufferNumber + 1);

  ghid_status_line_set_text (text);
}
Exemple #4
0
  /* Run a glib GMainLoop which intercepts key and mouse button events from
     |  the top level loop.  When a mouse or key is hit in the Output drawing
     |  area, quit the loop so the top level loop can continue and use the
     |  the mouse pointer coordinates at the time of the mouse button event.
   */
static gboolean
run_get_location_loop (const gchar * message)
{
  GMainLoop *loop;
  gulong button_handler, key_handler;
  gint oldObjState, oldLineState, oldBoxState;

  /* Make the text cue bold so it hides less and looks like command prompt  */
  GString *bold_message = g_string_new (message);
  g_string_prepend (bold_message, "<b>");
  g_string_append (bold_message, "</b>");

  ghid_status_line_set_text (bold_message->str);

  g_string_free (bold_message, TRUE);

  oldObjState = Crosshair.AttachedObject.State;
  oldLineState = Crosshair.AttachedLine.State;
  oldBoxState = Crosshair.AttachedBox.State;
  notify_crosshair_change (false);
  Crosshair.AttachedObject.State = STATE_FIRST;
  Crosshair.AttachedLine.State = STATE_FIRST;
  Crosshair.AttachedBox.State = STATE_FIRST;
  ghid_hand_cursor ();
  notify_crosshair_change (true);

  /* Stop the top level GMainLoop from getting user input from keyboard
     |  and mouse so we can install our own handlers here.  Also set the
     |  control interface insensitive so all the user can do is hit a key
     |  or mouse button in the Output drawing area.
   */
  ghid_interface_input_signals_disconnect ();
  ghid_interface_set_sensitive (FALSE);

  got_location = TRUE;		/* Will be unset by hitting most keys */
  button_handler =
    g_signal_connect (G_OBJECT (gport->drawing_area),
		      "button_press_event",
		      G_CALLBACK (loop_button_press_cb), &loop);
  key_handler =
    g_signal_connect (G_OBJECT (gport->top_window),
		      "key_press_event",
		      G_CALLBACK (loop_key_press_cb), &loop);

  loop = g_main_loop_new (NULL, FALSE);

  GDK_THREADS_LEAVE ();
  g_main_loop_run (loop);
  GDK_THREADS_ENTER ();

  g_main_loop_unref (loop);

  g_signal_handler_disconnect (gport->drawing_area, button_handler);
  g_signal_handler_disconnect (gport->top_window, key_handler);

  ghid_interface_input_signals_connect ();	/* return to normal */
  ghid_interface_set_sensitive (TRUE);

  notify_crosshair_change (false);
  Crosshair.AttachedObject.State = oldObjState;
  Crosshair.AttachedLine.State = oldLineState;
  Crosshair.AttachedBox.State = oldBoxState;
  notify_crosshair_change (true);
  ghid_restore_cursor ();

  ghid_set_status_line_label ();

  return got_location;
}
  /* This is the command entry function called from ActionCommand() when
     |  ghidgui->use_command_window is FALSE.  The command_combo_box is already
     |  packed into the status line label hbox in this case.
   */
gchar *
ghid_command_entry_get (gchar * prompt, gchar * command)
{
  gchar *s;
  gint escape_sig_id;
  GHidPort *out = &ghid_port;

  /* If this is the first user command entry, we have to create the
     |  command_combo_box and pack it into the status_line_hbox.
   */
  if (!ghidgui->command_combo_box)
    {
      command_combo_box_entry_create ();
      gtk_box_pack_start (GTK_BOX (ghidgui->status_line_hbox),
			  ghidgui->command_combo_box, FALSE, FALSE, 0);
    }

  /* Make the prompt bold and set the label before showing the combo to
     |  avoid window resizing wider.
   */
  s = g_strdup_printf ("<b>%s</b>", prompt ? prompt : "");
  ghid_status_line_set_text (s);
  g_free (s);

  /* Flag so output drawing area won't try to get focus away from us and
     |  so resetting the status line label can be blocked when resize
     |  callbacks are invokded from the resize caused by showing the combo box.
   */
  ghidgui->command_entry_status_line_active = TRUE;

  gtk_entry_set_text (ghidgui->command_entry, command ? command : "");
  gtk_widget_show_all (ghidgui->command_combo_box);

  /* Remove the top window accel group so keys intended for the entry
     |  don't get intercepted by the menu system.  Set the interface
     |  insensitive so all the user can do is enter a command, grab focus
     |  and connect a handler to look for the escape key.
   */
  ghid_remove_accel_groups (GTK_WINDOW (gport->top_window), ghidgui);
  ghid_interface_input_signals_disconnect ();
  ghid_interface_set_sensitive (FALSE);
  gtk_widget_grab_focus (GTK_WIDGET (ghidgui->command_entry));
  escape_sig_id = g_signal_connect (G_OBJECT (ghidgui->command_entry),
				    "key_press_event",
				    G_CALLBACK (command_escape_cb), NULL);

  loop = g_main_loop_new (NULL, FALSE);
  g_main_loop_run (loop);

  g_main_loop_unref (loop);
  loop = NULL;

  ghidgui->command_entry_status_line_active = FALSE;

  /* Restore the damage we did before entering the loop.
   */
  g_signal_handler_disconnect (ghidgui->command_entry, escape_sig_id);
  ghid_interface_input_signals_connect ();
  ghid_interface_set_sensitive (TRUE);
  ghid_install_accel_groups (GTK_WINDOW (gport->top_window), ghidgui);

  /* Restore the status line label and give focus back to the drawing area
   */
  gtk_widget_hide (ghidgui->command_combo_box);
  gtk_widget_grab_focus (out->drawing_area);

  return command_entered;
}