Ejemplo n.º 1
0
/*
 * 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_radio_tool_button_get_properties (GtkWidget *widget, GbWidgetGetArgData * data)
{
  GladeFindGroupData find_data;

  gb_tool_button_get_standard_properties (widget, data,
					  StockButton, Label, Icon,
					  VisibleHorz, VisibleVert,
					  IsImportant);

  gb_widget_output_bool (data, Active,
			 data->widget_data->flags & GLADE_ACTIVE);

  /* If we're showing we need to display the list of groups to choose from.
     We walk the tree of widgets in this component, and if a widget is
     a radio button, we see if it has a group and if it is already in the
     list and if not we add it. */
  if (data->action == GB_SHOWING)
    {
      GladeFindGroupsData find_groups_data;

      find_groups_data.groups_found = NULL;
      find_groups_data.group_names = NULL;
      gb_widget_children_foreach (widget->parent,
				  (GtkCallback) get_radio_button_groups,
				  &find_groups_data);

      find_groups_data.group_names = g_list_prepend (find_groups_data.group_names,
						     _("New Group"));
      property_set_combo_strings (Group, find_groups_data.group_names);

      g_list_free (find_groups_data.groups_found);
      g_list_free (find_groups_data.group_names);
    }

  find_data.group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (widget));
  find_data.found_widget = NULL;
  gb_widget_children_foreach (widget->parent,
			      (GtkCallback) find_radio_group,
			      &find_data);

  if (find_data.found_widget)
    {
      /* If we are saving, we don't output the group if this widget is the
	 first widget in the group. */
      if (data->action == GB_SHOWING || find_data.found_widget != widget)
	{
	  const char *name;
	  name = gtk_widget_get_name (find_data.found_widget);
	  gb_widget_output_combo (data, Group, name);
	}
    }
  else
    {
      g_warning ("Radiotoolbutton has no group");
      gb_widget_output_combo (data, Group, "");
    }
}
Ejemplo n.º 2
0
/*
 * 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_radio_button_get_properties (GtkWidget * widget, GbWidgetGetArgData * data)
{
  gboolean is_toolbar_button;

  is_toolbar_button = gb_toolbar_is_toolbar_button (widget);

  if (is_toolbar_button)
    {
      gb_toolbar_output_child_label (widget, data, Label);
      gb_toolbar_output_child_icon (widget, data, Icon);
    }
  else
    {
      gb_widget_output_child_label (widget, data, Label);
    }

  gb_widget_output_bool (data, State, data->widget_data->flags & GLADE_ACTIVE);

  if (!is_toolbar_button)
    {
      gb_widget_output_bool (data, Indicator,
			     GTK_TOGGLE_BUTTON (widget)->draw_indicator);
    }

  /* If we're showing we need to display the list of groups to choose from.
     We walk the tree of widgets in this component, and if a widget is
     a radio button, we see if it has a group and if it is already in the
     list and if not we add it. */
  if (data->action == GB_SHOWING)
    {
      GList *groups = NULL;
      get_radio_button_groups (gtk_widget_get_toplevel (widget), &groups);
      property_set_combo_strings (Group, groups);
      g_list_free (groups);

      property_set_visible (Icon, is_toolbar_button);
      property_set_visible (Indicator, !is_toolbar_button);
    }

  gb_widget_output_combo (data, Group,
			  gtk_object_get_data (GTK_OBJECT (widget), Group));
}
Ejemplo n.º 3
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);
	}
    }
}