Example #1
0
/**
 * Print the current value of a spin button.
 * @param spin spin button to print information about
 */
void mk_print_GtkSpinButton_info(GtkSpinButton* spin)
{
    if (gtk_spin_button_get_digits(spin) == 0) {
        gint value = gtk_spin_button_get_value_as_int(spin);
        g_printf("\t%d", value);
    } else {
        gdouble value = gtk_spin_button_get_value(spin);
        g_printf("\t%f", value);
    }
}
Example #2
0
static gboolean
unit_spin_button_output(GtkSpinButton *spin)
{
  GtkAdjustment *adj;
  gchar *text;
  double value;
  int digits;
  adj = gtk_spin_button_get_adjustment (spin);
  digits = gtk_spin_button_get_digits(spin);
  value = gtk_adjustment_get_value (adj);
  text = g_strdup_printf ("%.*lf %s", digits, value, UNIT_SPIN_BUTTON(spin)->unit);
  gtk_entry_set_text (GTK_ENTRY (spin), text);
  g_free (text);
  return TRUE;
}
Example #3
0
int
clip_GTK_SPINBUTTONGETDIGITS(ClipMachine * ClipMachineMemory)
{
   C_widget *cspb = _fetch_cw_arg(ClipMachineMemory);

   guint     ret;

   CHECKCWID(cspb, GTK_IS_SPIN_BUTTON);

   ret = gtk_spin_button_get_digits(GTK_SPIN_BUTTON(cspb->widget));
   _clip_retni(ClipMachineMemory, ret);
   return 0;
 err:
   return 1;
}
static gboolean
on_output (GtkSpinButton *spin) /*@ \label{spinbuttonformatc:output} @*/

{
  GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin);
  gdouble value = gtk_adjustment_get_value (adjustment);
  gint digits = gtk_spin_button_get_digits (spin);
  gchar *buf = g_strdup_printf ("%0.*f", digits, value); /*@ \label{spinbuttonformatc:outputformat} @*/

  if (strcmp (buf, gtk_entry_get_text (GTK_ENTRY (spin)))) /*@ \label{spinbuttonformatc:outputcompare} @*/
    gtk_entry_set_text (GTK_ENTRY (spin), buf); /*@ \label{spinbuttonformatc:outputset} @*/

  g_free (buf);

  return TRUE; /*@ \label{spinbuttonformatc:outputreturn} @*/
}
Example #5
0
void
entry_print_result (void)
{
  if (options.entry_data.numeric)
    {
      guint prec = gtk_spin_button_get_digits (GTK_SPIN_BUTTON (entry));
      g_print ("%.*f\n", prec, gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)));
    }
  else if (is_combo)
    {
      if (options.common_data.num_output)
        g_print ("%d\n", gtk_combo_box_get_active (GTK_COMBO_BOX (entry)) + 1);
      else
        {
#if GTK_CHECK_VERSION(2,24,0)
          g_print ("%s\n", gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry)));
#else
          g_print ("%s\n", gtk_combo_box_get_active_text (GTK_COMBO_BOX (entry)));
#endif
        }
    }
  else
    g_print ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry)));
}
Example #6
0
unsigned wxSpinCtrlDouble::GetDigits() const
{
    wxCHECK_MSG( m_widget, 0, "invalid spin button" );

    return gtk_spin_button_get_digits( GTK_SPIN_BUTTON(m_widget) );
}
Example #7
0
static Tcl_Obj *getObjValue( GtkSpinButton *spinButton )
{
   if( gtk_spin_button_get_digits( spinButton ) == 0 )
      return Tcl_NewIntObj( gtk_spin_button_get_value_as_int( spinButton ) );
   return Tcl_NewDoubleObj( gtk_spin_button_get_value( spinButton ) );
}