コード例 #1
0
ファイル: gbspinbutton.c プロジェクト: AriaAsuka/deadbeef
/*
 * Gets the properties of the widget. This is used for both displaying the
 * properties in the property editor, and also for saving the properties.
 */
static void
gb_spin_button_get_properties (GtkWidget * widget, GbWidgetGetArgData * data)
{
  gint i, update_policy;
  gb_widget_output_float (data, ClimbRate, GTK_SPIN_BUTTON (widget)->climb_rate);
  gb_widget_output_int (data, Digits, GTK_SPIN_BUTTON (widget)->digits);
  gb_widget_output_bool (data, Numeric, GTK_SPIN_BUTTON (widget)->numeric);

  /* This is a slight kludge since the spin_button's update policy is
     a set of flags rather than integer values */
  update_policy = GTK_SPIN_BUTTON (widget)->update_policy
    & (GTK_UPDATE_ALWAYS | GTK_UPDATE_IF_VALID);
  for (i = 0; i < sizeof (GbPolicyValues) / sizeof (GbPolicyValues[0]); i++)
    {
      if (GbPolicyValues[i] == update_policy)
	gb_widget_output_choice (data, Policy, i, GbPolicySymbols[i]);
    }
  /* In GTK 1.1 snap_to_ticks is given its own variable. */
  gb_widget_output_bool (data, Snap, GTK_SPIN_BUTTON (widget)->snap_to_ticks);

  gb_widget_output_bool (data, Wrap, GTK_SPIN_BUTTON (widget)->wrap);
  gb_widget_output_adjustment (data, Values,
			       GTK_SPIN_BUTTON (widget)->adjustment,
			       "adjustment");
}
コード例 #2
0
ファイル: gnomecontrol.c プロジェクト: AriaAsuka/deadbeef
/*
 * Gets the properties of the widget. This is used for both displaying the
 * properties in the property editor, and also for saving the properties.
 */
static void
gb_bonobo_control_get_properties (GtkWidget * widget, GbWidgetGetArgData * data)
{
  Bonobo_PropertyBag pb = control_get_pb (widget);
  char *moniker = gtk_object_get_data (GTK_OBJECT (widget), Moniker);
  GList *key_list, *names;

  g_assert (moniker);

  if (!pb)
    return;

  /* We save the moniker in the XML, though we don't show it in the property
     editor. */
  if (data->action == GB_SAVING) 
    {
      save_string (data, Moniker, moniker);
    }

  key_list = bonobo_pbclient_get_keys (pb, NULL);
  for (names = key_list; names; names = names->next) {
    CORBA_TypeCode tc;
    char          *prop = create_prop_name (moniker, names->data);

    tc  = bonobo_pbclient_get_type (pb, names->data, NULL);
    switch (tc->kind) {
    case CORBA_tk_boolean:
      gb_widget_output_bool (data, prop,
			     bonobo_pbclient_get_boolean (pb, names->data, NULL));
      break;
    case CORBA_tk_string:
    {
      char *str = bonobo_pbclient_get_string (pb, names->data, NULL);

      gb_widget_output_translatable_string (data, prop, str);

      g_free (str);
      break;
    }
    case CORBA_tk_ulong:
      gb_widget_output_int (data, prop,
			    bonobo_pbclient_get_ulong (pb, names->data, NULL));
      break;
    case CORBA_tk_long:
      gb_widget_output_int (data, prop,
			    bonobo_pbclient_get_long (pb, names->data, NULL));
      break;
    case CORBA_tk_short:
      gb_widget_output_int (data, prop,
			    bonobo_pbclient_get_short (pb, names->data, NULL));
      break;
    case CORBA_tk_ushort:
      gb_widget_output_int (data, prop,
			    bonobo_pbclient_get_ushort (pb, names->data, NULL));
      break;
    case CORBA_tk_float:
      gb_widget_output_float (data, prop,
			      bonobo_pbclient_get_float (pb, names->data, NULL));
      break;
    case CORBA_tk_double:
      gb_widget_output_float (data, prop,
			      bonobo_pbclient_get_double (pb, names->data, NULL));
      break;
    default:
      g_warning ("Unhandled type %d", tc->kind);
      break;
    }
    g_free (prop);
  }
  bonobo_pbclient_free_keys (key_list);
}
コード例 #3
0
ファイル: gblabel.c プロジェクト: cooljeanius/glade-1.1.3
void
gb_label_get_standard_properties (GtkWidget * widget,
				  GbWidgetGetArgData * data,
				  const char *label_p,
				  const char *use_underline_p,
				  const char *use_markup_p,
				  const char *justify_p,
				  const char *wrap_p,
				  const char *selectable_p,
				  const char *xalign_p,
				  const char *yalign_p,
				  const char *xpad_p,
				  const char *ypad_p,
				  const char *focus_target_p)
{
  const gchar *label_text;
  gint i;

  label_text = gtk_label_get_label (GTK_LABEL (widget));
  gb_widget_output_translatable_text (data, label_p, label_text);

  gb_widget_output_bool (data, use_underline_p,
			 gtk_label_get_use_underline (GTK_LABEL (widget)));
  gb_widget_output_bool (data, use_markup_p,
			 GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), use_markup_p)));

  for (i = 0; i < sizeof (GbJustifyValues) / sizeof (GbJustifyValues[0]); i++)
    {
      if (GbJustifyValues[i] == GTK_LABEL (widget)->jtype)
	gb_widget_output_choice (data, justify_p, i, GbJustifySymbols[i]);
    }
  gb_widget_output_bool (data, wrap_p, GTK_LABEL (widget)->wrap);
  gb_widget_output_bool (data, selectable_p,
			 gtk_label_get_selectable (GTK_LABEL (widget)));
  gb_widget_output_float (data, xalign_p, GTK_MISC (widget)->xalign);
  gb_widget_output_float (data, yalign_p, GTK_MISC (widget)->yalign);
  gb_widget_output_int (data, xpad_p, GTK_MISC (widget)->xpad);
  gb_widget_output_int (data, ypad_p, GTK_MISC (widget)->ypad);

  /* Labels not in buttons may have a focus target widget. */
  if (!gb_label_find_mnemonic_widget (widget))
    {
      gchar *accel_target;

      accel_target = gtk_object_get_data (GTK_OBJECT (widget), focus_target_p);

      /* If we're showing we need to display the list of possible focus target
	 widgets. We walk the tree of widgets in this component, and if a
	 widget has CAN_FOCUS set, we add it to the list. */
      if (data->action == GB_SHOWING)
	{
	  GList *focus_targets = NULL, *standard_items = NULL;
	  GtkWidget *item, *combo;

	  property_set_visible (focus_target_p, TRUE);

	  gb_label_get_focus_targets (gtk_widget_get_toplevel (widget),
				      &focus_targets);
	  property_set_combo_strings (focus_target_p, focus_targets);
	  g_list_free (focus_targets);

	  combo = property_get_value_widget (focus_target_p);

	  item = gtk_list_item_new_with_label (_("Auto"));
	  gtk_widget_show (item);
	  standard_items = g_list_append (standard_items, item);

	  item = gtk_list_item_new ();
	  gtk_widget_set_sensitive (item, FALSE);
	  gtk_widget_show (item);
	  standard_items = g_list_append (standard_items, item);
	  gtk_combo_set_item_string (GTK_COMBO (combo), GTK_ITEM (item), "");

	  gtk_list_prepend_items (GTK_LIST (GTK_COMBO (combo)->list),
				  standard_items);

	  if (!accel_target)
	    {
	      accel_target = _("Auto");
	    }
	  gb_widget_output_combo (data, focus_target_p, accel_target);
	}
      else
	{
	  /* When saving, we only save the property if it has been set. */
	  if (accel_target)
	    {
	      /* First check that the widget is still there, and if it isn't
		 just skip it. */
	      if (glade_util_find_widget (gtk_widget_get_toplevel (widget),
					  accel_target))
		{
		  gb_widget_output_combo (data, focus_target_p, accel_target);
		}
	    }
	  else
	    {
	      /* If no target has been set, and the label has an underlined
		 key, we try to find a default target and save that. */
	      if (gtk_label_get_use_underline (GTK_LABEL (widget)))
		{
		  GtkWidget *accel_target;

		  accel_target = glade_util_find_default_accelerator_target (widget);
		  if (accel_target)
		    {
		      gb_widget_output_string (data, focus_target_p, gtk_widget_get_name (accel_target));
		    }
		}
	    }
	}
    }
  else
    {
      if (data->action == GB_SHOWING)
	{
	  property_set_visible (focus_target_p, FALSE);
	}
    }
}
コード例 #4
0
ファイル: gbimage.c プロジェクト: jubalh/deadbeef
/*
 * Gets the properties of the widget. This is used for both displaying the
 * properties in the property editor, and also for saving the properties.
 */
static void
gb_image_get_properties (GtkWidget * widget, GbWidgetGetArgData * data)
{
  gchar *icon = gtk_object_get_data (GTK_OBJECT (widget), GladeIconKey);
  gchar *icon_name = NULL;
  gboolean is_stock_icon, is_named_icon = FALSE;
  gint i, pixel_size;
  GtkImageType storage_type;

  storage_type = gtk_image_get_storage_type (GTK_IMAGE (widget));
  pixel_size = gtk_image_get_pixel_size (GTK_IMAGE (widget));

  is_stock_icon = glade_util_check_is_stock_id (icon);

  if (storage_type == GTK_IMAGE_ICON_NAME)
    {
      g_object_get (widget,
		    "icon_name", &icon_name,
		    NULL);
      if (icon_name && *icon_name)
	is_named_icon = TRUE;
    }

  if (data->action == GB_SAVING)
    {
      /* When saving we want to use "stock" or "pixbuf", depending on whether
	 it is a stock icon or an oridinary pixmap file. */
      if (is_stock_icon)
	gb_widget_output_icon (data, "stock", icon);
      else
	gb_widget_output_icon (data, "pixbuf", icon);
    }
  else
    {
      gb_widget_output_icon (data, Icon, icon);
    }

  if (is_stock_icon || is_named_icon)
    {
      if (data->action == GB_SHOWING)
	{
	  for (i = 0; i < GladeIconSizeChoicesSize; i++)
	    {
	      if (GladeIconSizeValues[i] == GTK_IMAGE (widget)->icon_size)
		gb_widget_output_choice (data, IconSize, i,
					 GladeIconSizeSymbols[i]);
	    }

	  check_visible_sizes (icon, is_named_icon);
	}
      else
	{
	  /* We have to save the size as an integer, which sucks a bit.
	     The integer is the GtkIconSize enum value, not the actual size.*/
	  if (is_stock_icon || pixel_size == -1)
	    gb_widget_output_int (data, IconSize,
				  GTK_IMAGE (widget)->icon_size);
	}
    }

  gb_widget_output_named_icon (data, IconName, icon_name);

  /* The icon size only applies to stock icons or named icons.
     The pixel size only applies to named icons. */
  if (data->action == GB_SHOWING)
    {
      property_set_sensitive (IconSize, is_stock_icon || is_named_icon);
      property_set_sensitive (PixelSize, is_named_icon);
    }

  /* We only want to save the pixel size for named icons, and only if it is
     not -1. */
  if (data->action == GB_SHOWING
      || (storage_type == GTK_IMAGE_ICON_NAME && pixel_size != -1))
    gb_widget_output_int (data, PixelSize, pixel_size);

  gb_widget_output_float (data, XAlign, GTK_MISC (widget)->xalign);
  gb_widget_output_float (data, YAlign, GTK_MISC (widget)->yalign);
  gb_widget_output_int (data, XPad, GTK_MISC (widget)->xpad);
  gb_widget_output_int (data, YPad, GTK_MISC (widget)->ypad);
}