示例#1
0
/*
 * Creates the components needed to edit the extra properties of this widget.
 */
static void
gb_radio_tool_button_create_properties (GtkWidget * widget, GbWidgetCreateArgData * data)
{
  GtkWidget *combo;

  property_add_stock_item (StockButton, _("Stock Button:"),
			   _("The stock button to use"),
			   GTK_ICON_SIZE_LARGE_TOOLBAR);
  property_add_text (Label, _("Label:"), _("The text to display"), 2);
  property_add_icon (Icon, _("Icon:"),
		     _("The icon to display"),
		     GTK_ICON_SIZE_LARGE_TOOLBAR);

  property_add_combo (Group, _("Group:"),
		      _("The radio tool button group (the default is all radio tool buttons in the toolbar)"),
		      NULL);
  combo = property_get_value_widget (Group);
  gtk_editable_set_editable (GTK_EDITABLE (GTK_COMBO (combo)->entry), FALSE);

  property_add_bool (Active, _("Initially On:"),
		     _("If the radio button is initially on"));

  property_add_bool (VisibleHorz, _("Show Horizontal:"),
		     _("If the item is visible when the toolbar is horizontal"));
  property_add_bool (VisibleVert, _("Show Vertical:"),
		     _("If the item is visible when the toolbar is vertical"));
  property_add_bool (IsImportant, _("Is Important:"),
		     _("If the item's text should be shown when the toolbar's mode is GTK_TOOLBAR_BOTH_HORIZ"));
}
示例#2
0
文件: gbimage.c 项目: jubalh/deadbeef
static void
check_visible_sizes (const gchar *stock_id, gboolean show_all)
{
  GtkIconSet *icon_set;
  GtkIconSize *sizes;
  gint n_sizes, i, j;
  GtkWidget *option_menu, *menu;
  gboolean item_visible[G_N_ELEMENTS(GladeIconSizeValues)];
  GList *children;

  for (j = 0; j < GladeIconSizeChoicesSize; j++)
    item_visible[j] = show_all;

  if (!show_all)
    {
      icon_set = gtk_icon_factory_lookup_default (stock_id);
      if (icon_set)
	{
	  gtk_icon_set_get_sizes (icon_set, &sizes, &n_sizes);
	  /* Figure out which of our choices should be visible. */
	  for (i = 0; i < n_sizes; i++)
	    {
	      for (j = 0; j < GladeIconSizeChoicesSize; j++)
		{
		  if (sizes[i] == GladeIconSizeValues[j])
		    item_visible[j] = TRUE;
		}
	    }
	  g_free (sizes);
	}
    }

  /* Show or Hide the items as appropriate. */
  option_menu = property_get_value_widget (IconSize);
  g_return_if_fail (GTK_IS_OPTION_MENU (option_menu));

  menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (option_menu));
  g_return_if_fail (GTK_IS_MENU (menu));

  children = GTK_MENU_SHELL (menu)->children;
  for (j = 0; j < GladeIconSizeChoicesSize; j++)
    {
      GtkWidget *item;

      item = children->data;

      if (item_visible[j])
	gtk_widget_show (item);
      else
	gtk_widget_hide (item);

      children = children->next;
    }
}
示例#3
0
void
gb_label_create_standard_properties (GtkWidget * widget,
				     GbWidgetCreateArgData * 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)
{
  GtkWidget *combo;

  property_add_text (label_p, _("Label:"), _("The text to display"), 2);
  property_add_bool (use_underline_p, _("Use Underline:"),
		     _("If the text includes an underlined accelerator character"));
  property_add_bool (use_markup_p, _("Use Markup:"),
		     _("If the text includes pango markup"));
  property_add_choice (justify_p, _("Justify:"),
		       _("The justification of the lines of the label"),
		       GbJustifyChoices);
  property_add_bool (wrap_p, _("Wrap Text:"),
		     _("If the text is wrapped to fit within the width of the label"));
  property_add_bool (selectable_p, _("Selectable:"),
		     _("If the label text can be selected with the mouse"));
  property_add_float_range (xalign_p, _("X Align:"),
			    _("The horizontal alignment of the entire label"),
			    0, 1, 0.01, 0.1, 0.01, 2);
  property_add_float_range (yalign_p, _("Y Align:"),
			    _("The vertical alignment of the entire label"),
			    0, 1, 0.01, 0.1, 0.01, 2);
  property_add_int_range (xpad_p, _("X Pad:"), _("The horizontal padding"),
			  0, 1000, 1, 10, 1);
  property_add_int_range (ypad_p, _("Y Pad:"), _("The vertical padding"),
			  0, 1000, 1, 10, 1);
  property_add_combo (focus_target_p, _("Focus Target:"),
		      _("The widget to set the keyboard focus to when the underlined accelerator key is used"),
		      NULL);
  combo = property_get_value_widget (focus_target_p);
  gtk_editable_set_editable (GTK_EDITABLE (GTK_COMBO (combo)->entry), FALSE);
  gtk_combo_set_value_in_list (GTK_COMBO (combo), TRUE, TRUE);
}
示例#4
0
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);
	}
    }
}