Ejemplo n.º 1
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_handle_box_set_properties(GtkWidget *widget, GbWidgetSetArgData *data)
{
  gchar *shadow, *position, *snap_edge;
  gint i;

  shadow = gb_widget_input_choice (data, Shadow);
  if (data->apply)
    {
      for (i = 0; i < sizeof (GbShadowValues) / sizeof (GbShadowValues[0]);
	   i++)
	{
	  if (!strcmp (shadow, GbShadowChoices[i])
	      || !strcmp (shadow, GbShadowSymbols[i]))
	    {
	      gtk_handle_box_set_shadow_type (GTK_HANDLE_BOX (widget),
					      GbShadowValues[i]);
	      break;
	    }
	}
    }

  position = gb_widget_input_choice (data, Position);
  if (data->apply)
    {
      for (i = 0; i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]);
	   i++)
	{
	  if (!strcmp (position, GbPositionChoices[i])
	      || !strcmp (position, GbPositionSymbols[i]))
	    {
	      gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (widget),
						  GbPositionValues[i]);
	      break;
	    }
	}
    }

  snap_edge = gb_widget_input_choice (data, SnapEdge);
  if (data->apply)
    {
      for (i = 0; i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]);
	   i++)
	{
	  if (!strcmp (snap_edge, GbPositionChoices[i])
	      || !strcmp (snap_edge, GbPositionSymbols[i]))
	    {
	      gtk_handle_box_set_snap_edge (GTK_HANDLE_BOX (widget),
					    GbPositionValues[i]);
	      break;
	    }
	}
    }
}
Ejemplo n.º 2
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_viewport_set_properties (GtkWidget * widget, GbWidgetSetArgData * data)
{
  gint i;
  gchar *shadow;

  shadow = gb_widget_input_choice (data, Shadow);
  if (data->apply)
    {
      for (i = 0; i < sizeof (GbShadowValues) / sizeof (GbShadowValues[0]); i
	   ++)
	{
	  if (!strcmp (shadow, GbShadowChoices[i])
	      || !strcmp (shadow, GbShadowSymbols[i]))
	    {
	      gtk_viewport_set_shadow_type (GTK_VIEWPORT (widget), GbShadowValues
					    [i]);
	      break;
	    }
	}
    }

  /*
     if (gb_widget_input_adjustment(data, HValues,
     GTK_VIEWPORT(widget)->hadjustment))
     gtk_signal_emit_by_name (GTK_OBJECT (GTK_VIEWPORT(widget)->hadjustment),
     "value_changed");
     if (gb_widget_input_adjustment(data, VValues,
     GTK_VIEWPORT(widget)->vadjustment))
     gtk_signal_emit_by_name (GTK_OBJECT (GTK_VIEWPORT(widget)->vadjustment),
     "value_changed");
   */
}
Ejemplo n.º 3
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_spin_button_set_properties (GtkWidget * widget, GbWidgetSetArgData * data)
{
  gfloat climb_rate;
  gint digits, policy_value = GTK_UPDATE_ALWAYS, i;
  gchar *policy;
  gboolean numeric, snap, wrap;
  GtkAdjustment *adj;

  climb_rate = gb_widget_input_float (data, ClimbRate);
  /* No set function for this */
  if (data->apply)
    GTK_SPIN_BUTTON (widget)->climb_rate = climb_rate;

  digits = gb_widget_input_int (data, Digits);
  if (data->apply)
    gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), digits);

  numeric = gb_widget_input_bool (data, Numeric);
  if (data->apply)
    gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (widget), numeric);

  snap = gb_widget_input_bool (data, Snap);
  if (data->apply)
    gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (widget), snap);

  policy = gb_widget_input_choice (data, Policy);
  for (i = 0; i < sizeof (GbPolicyValues) / sizeof (GbPolicyValues[0]); i++)
    {
      if (!strcmp (policy, GbPolicyChoices[i])
	  || !strcmp (policy, GbPolicySymbols[i]))
	{
	  policy_value = GbPolicyValues[i];
	  break;
	}
    }
  if (data->apply)
    gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (widget), policy_value);

  wrap = gb_widget_input_bool (data, Wrap);
  if (data->apply)
    gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (widget), wrap);

  adj = GTK_SPIN_BUTTON (widget)->adjustment;
  if (gb_widget_input_adjustment (data, Values, adj, "adjustment"))
    {
      gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed");
    }
}
Ejemplo n.º 4
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_hbutton_box_set_properties (GtkWidget * widget, GbWidgetSetArgData * data)
{
    gint size, i, spacing;
    gchar *layout;
    gboolean queue_resize = FALSE;

    if (data->action != GB_LOADING)
    {
        size = gb_widget_input_int (data, Size);
        if (data->apply)
            gb_box_set_size (widget, size);
    }

    layout = gb_widget_input_choice (data, Layout);
    if (data->apply)
    {
        for (i = 0; i < sizeof (GbLayoutValues) / sizeof (GbLayoutValues[0]);
                i++)
        {
            if (!strcmp (layout, GbLayoutChoices[i])
                    || !strcmp (layout, GbLayoutSymbols[i]))
            {
                gtk_button_box_set_layout (GTK_BUTTON_BOX (widget), GbLayoutValues
                                           [i]);
                queue_resize = TRUE;
                break;
            }
        }
    }

    if (!gb_hbutton_box_is_dialog_action_area (widget))
    {
        spacing = gb_widget_input_int (data, Spacing);
        if (data->apply)
        {
            gtk_box_set_spacing (GTK_BOX (widget), spacing);
            queue_resize = TRUE;
        }
    }

    if (queue_resize)
        gtk_widget_queue_resize (widget);
}
Ejemplo n.º 5
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_file_chooser_button_set_properties (GtkWidget * widget, GbWidgetSetArgData * data)
{
  gchar *title, *action;
  gboolean local_only, show_hidden, confirm;
  gint i, width_chars;

  title = gb_widget_input_string (data, Title);
  if (data->apply)
    g_object_set (widget, "title", title, NULL);

  action = gb_widget_input_choice (data, Action);
  if (data->apply)
    {
      for (i = 0; i < sizeof (GbActionValues) / sizeof (GbActionValues[0]);
	   i++)
	{
	  if (!strcmp (action, GbActionChoices[i])
	      || !strcmp (action, GbActionSymbols[i]))
	    {
	      g_object_set (widget, "action", GbActionValues[i], NULL);
	      break;
	    }
	}
    }

  local_only = gb_widget_input_bool (data, LocalOnly);
  if (data->apply)
    g_object_set (widget, "local_only", local_only, NULL);

  show_hidden = gb_widget_input_bool (data, ShowHidden);
  if (data->apply)
    g_object_set (widget, "show_hidden", show_hidden, NULL);

  confirm = gb_widget_input_bool (data, Confirm);
  if (data->apply)
    g_object_set (widget, "do_overwrite_confirmation", confirm, NULL);

  width_chars = gb_widget_input_int (data, WidthChars);
  if (data->apply)
    g_object_set (widget, "width_chars", width_chars, NULL);
}
Ejemplo n.º 6
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_gnome_message_box_set_properties (GtkWidget * widget, GbWidgetSetArgData * data)
{
  GtkWidget *pixmap, *label;
  gchar *message, *type_name;
  gboolean auto_close, hide_on_close;

  get_message_box_widgets (widget, &pixmap, &label);
  g_return_if_fail (pixmap != NULL);
  g_return_if_fail (label != NULL);

  type_name = gb_widget_input_choice (data, MessageBoxType);
  if (data->apply)
    {
      set_message_box_type (widget, pixmap, type_name);
    }

  message = gb_widget_input_text (data, Message);
  if (data->apply)
    {
      gtk_label_set_text (GTK_LABEL (label), message);
    }
  if (data->action == GB_APPLYING)
    g_free (message);

  gb_window_set_standard_properties (widget, data,
				     Title, NULL, Position, Modal,
				     DefaultWidth, DefaultHeight,
				     Shrink, Grow, AutoShrink,
				     WMName, WMClass);

  auto_close = gb_widget_input_bool (data, AutoClose);
  if (data->apply)
    gnome_dialog_set_close (GNOME_DIALOG (widget), auto_close);

  hide_on_close = gb_widget_input_bool (data, HideOnClose);
  if (data->apply)
    gnome_dialog_close_hides (GNOME_DIALOG (widget), hide_on_close);
}
Ejemplo n.º 7
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_scrolled_window_set_properties (GtkWidget * widget, GbWidgetSetArgData * data)
{
  gint i;
  gchar *hpolicy, *vpolicy, *hupdate_policy, *vupdate_policy;
  gboolean set_policy = FALSE;
  GtkPolicyType hpolicy_value = GTK_POLICY_AUTOMATIC;
  GtkPolicyType vpolicy_value = GTK_POLICY_AUTOMATIC;
  GtkUpdateType hupdate_policy_value = GTK_UPDATE_CONTINUOUS;
  GtkUpdateType vupdate_policy_value = GTK_UPDATE_CONTINUOUS;
  gchar *shadow, *placement;

  hpolicy = gb_widget_input_choice (data, HPolicy);
  if (data->apply)
    {
      set_policy = TRUE;
      for (i = 0; i < sizeof (GbPolicyValues) / sizeof (GbPolicyValues[0]);
	   i++)
	{
	  if (!strcmp (hpolicy, GbPolicyChoices[i])
	      || !strcmp (hpolicy, GbPolicySymbols[i]))
	    hpolicy_value = GbPolicyValues[i];
	}
    }
  else
    hpolicy_value = GTK_SCROLLED_WINDOW (widget)->hscrollbar_policy;

  vpolicy = gb_widget_input_choice (data, VPolicy);
  if (data->apply)
    {
      set_policy = TRUE;
      for (i = 0; i < sizeof (GbPolicyValues) / sizeof (GbPolicyValues[0]);
	   i++)
	{
	  if (!strcmp (vpolicy, GbPolicyChoices[i])
	      || !strcmp (vpolicy, GbPolicySymbols[i]))
	    vpolicy_value = GbPolicyValues[i];
	}
    }
  else
    vpolicy_value = GTK_SCROLLED_WINDOW (widget)->vscrollbar_policy;

  if (set_policy)
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget),
				    hpolicy_value, vpolicy_value);

  shadow = gb_widget_input_choice (data, ShadowType);
  if (data->apply)
    {
      for (i = 0; i < GladeShadowChoicesSize; i++)
	{
	  if (!strcmp (shadow, GladeShadowChoices[i])
	      || !strcmp (shadow, GladeShadowSymbols[i]))
	    {
	      gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget), GladeShadowValues[i]);
	      break;
	    }
	}
    }

  placement = gb_widget_input_choice (data, WindowPlacement);
  if (data->apply)
    {
      for (i = 0; i < GladeCornerChoicesSize; i++)
	{
	  if (!strcmp (placement, GladeCornerChoices[i])
	      || !strcmp (placement, GladeCornerSymbols[i]))
	    {
	      gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW (widget),
						 GladeCornerValues[i]);
	      break;
	    }
	}
    }
}
Ejemplo n.º 8
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_tclist_set_properties (GtkWidget * widget, GtkWidget *child, GbWidgetSetArgData * data)
{
  gchar *widths, *pos, *mode;
  gchar *shadow;
  gboolean titles;
  gint col, w, i;
#ifndef GTK_HAVE_FEATURES_1_1_4
  gboolean myApply;
  gchar *hpolicy, *vpolicy;
  GtkPolicyType hpolicy_value = GTK_POLICY_AUTOMATIC;
  GtkPolicyType vpolicy_value = GTK_POLICY_AUTOMATIC;
#endif

  if (data->action == GB_LOADING)
    {
      widths = gb_widget_input_string (data, ColumnWidths);
      if (data->apply)
	{
	  pos = widths;
	  for (col = 0; col < GTK_CLIST (widget)->columns; col++)
	    {
	      w = atoi (pos);
	      gtk_clist_set_column_width (GTK_CLIST (widget), col, w);
	      pos = strchr (pos, ',');
	      if (!pos)
		break;
	      pos++;
	    }
	}
    }

  mode = gb_widget_input_choice (data, Mode);
  if (data->apply)
    {
      for (i = 0; i < sizeof (GbModeValues) / sizeof (GbModeValues[0]); i++)
	{
	  if (!strcmp (mode, GbModeChoices[i])
	      || !strcmp (mode, GbModeSymbols[i]))
	    {
	      gtk_clist_set_selection_mode (GTK_CLIST (widget), GbModeValues[i]);
	      break;
	    }
	}
    }

  titles = gb_widget_input_bool (data, Titles);
  if (data->apply)
    {
      if (titles)
	gtk_clist_column_titles_show (GTK_CLIST (widget));
      else
	gtk_clist_column_titles_hide (GTK_CLIST (widget));
    }

  shadow = gb_widget_input_choice (data, Shadow);
  if (data->apply)
    {
      for (i = 0; i < sizeof (GbShadowValues) / sizeof (GbShadowValues[0]); i
	   ++)
	{
	  if (!strcmp (shadow, GbShadowChoices[i])
	      || !strcmp (shadow, GbShadowSymbols[i]))
	    {
#ifdef GTK_HAVE_FEATURES_1_1_4
	      gtk_clist_set_shadow_type (GTK_CLIST (widget),
					 GbShadowValues[i]);
#else
	      gtk_clist_set_border (GTK_CLIST (widget), GbShadowValues[i]);
#endif
	      break;
	    }
	}
    }

#ifndef GTK_HAVE_FEATURES_1_1_4
  hpolicy = gb_widget_input_choice (data, HPolicy);
  myApply = data->apply;
  vpolicy = gb_widget_input_choice (data, VPolicy);
  if (data->apply || myApply)
    {
      for (i = 0; i < sizeof (GbPolicyValues) / sizeof (GbPolicyValues[0]); i
	   ++)
	{
	  if (!strcmp (hpolicy, GbPolicyChoices[i])
	      || !strcmp (hpolicy, GbPolicySymbols[i]))
	    hpolicy_value = GbPolicyValues[i];
	  if (!strcmp (vpolicy, GbPolicyChoices[i])
	      || !strcmp (vpolicy, GbPolicySymbols[i]))
	    vpolicy_value = GbPolicyValues[i];
	}
      gtk_clist_set_policy (GTK_CLIST (widget), vpolicy_value, hpolicy_value);
    }
#endif
}
Ejemplo n.º 9
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
void
gb_label_set_standard_properties (GtkWidget * widget,
				  GbWidgetSetArgData * 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)
{
  gchar *label, *justify, *accel_target;
  const gchar *label_text;
  gfloat xalign, yalign;
  gint xpad, ypad, i;
  gboolean wrap, selectable, set_alignment = FALSE, set_padding = FALSE;
  gboolean use_underline, use_markup;
  gboolean set_label = FALSE;

  use_underline = gb_widget_input_bool (data, use_underline_p);
  if (data->apply)
    gtk_label_set_use_underline (GTK_LABEL (widget), use_underline);

  use_markup = gb_widget_input_bool (data, use_markup_p);
  if (data->apply)
    {
      set_label = TRUE;
      gtk_object_set_data (GTK_OBJECT (widget), use_markup_p,
			   GINT_TO_POINTER (use_markup));
    }

  label = gb_widget_input_text (data, label_p);
  if (data->apply)
    {
      set_label = TRUE;
      label_text = label;
    }
  else
    {
      label_text = gtk_label_get_label (GTK_LABEL (widget));
    }

  if (set_label)
    {
      gboolean prev_use_markup;

      use_markup = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget),
							 use_markup_p));

      /* We try to parse the markup here, and if it isn't valid, we will
	 turn use_markup off and show it as plain text. */
      if (use_markup)
	{
	  GError *error = NULL;
	  gunichar accel_marker = 0;
	  PangoAttrList *attrs = NULL;
	  gunichar accel_char = 0;
	  gchar *text = NULL;

	  if (gtk_label_get_use_underline (GTK_LABEL (widget)))
	    accel_marker = '_';

	  /* We check it is valid markup. If it isn't we will set "use_markup"
	     to FALSE. Note that we don't need attrs, text, or accel_char but
	     it seems to crash otherwise. */
	  if (!pango_parse_markup (label_text, -1, accel_marker, &attrs, &text,
				   &accel_char, &error))
	    {
	      use_markup = FALSE;
	      g_error_free (error);
	    }
	  else
	    {
	      if (attrs)
		pango_attr_list_unref (attrs);
	      g_free (text);
	    }
	}

      /* If we are turning use_markup off, we want to do that before setting
	 the text. If we are turning it on, we want to do it after. */
      prev_use_markup = gtk_label_get_use_markup (GTK_LABEL (widget));
      if (!use_markup && prev_use_markup)
	gtk_label_set_use_markup (GTK_LABEL (widget), use_markup);

      gtk_label_set_label (GTK_LABEL (widget), label_text);

      if (use_markup && !prev_use_markup)
	gtk_label_set_use_markup (GTK_LABEL (widget), use_markup);
    }

  if (data->action == GB_APPLYING)
    g_free (label);

  justify = gb_widget_input_choice (data, justify_p);
  if (data->apply)
    {
      for (i = 0; i < sizeof (GbJustifyValues) / sizeof (GbJustifyValues[0]);
	   i++)
	{
	  if (!strcmp (justify, GbJustifyChoices[i])
	      || !strcmp (justify, GbJustifySymbols[i]))
	    {
	      gtk_label_set_justify (GTK_LABEL (widget), GbJustifyValues[i]);
	      break;
	    }
	}
    }

  wrap = gb_widget_input_bool (data, wrap_p);
  if (data->apply)
    gtk_label_set_line_wrap (GTK_LABEL (widget), wrap);

  selectable = gb_widget_input_bool (data, selectable_p);
  if (data->apply)
    gtk_label_set_selectable (GTK_LABEL (widget), selectable);

  xalign = gb_widget_input_float (data, xalign_p);
  if (data->apply)
    set_alignment = TRUE;
  else
    xalign = GTK_MISC (widget)->xalign;

  yalign = gb_widget_input_float (data, yalign_p);
  if (data->apply)
    set_alignment = TRUE;
  else
    yalign = GTK_MISC (widget)->yalign;

  if (set_alignment)
    gtk_misc_set_alignment (GTK_MISC (widget), xalign, yalign);

  xpad = gb_widget_input_int (data, xpad_p);
  if (data->apply)
    set_padding = TRUE;
  else
    xpad = GTK_MISC (widget)->xpad;

  ypad = gb_widget_input_int (data, ypad_p);
  if (data->apply)
    set_padding = TRUE;
  else
    ypad = GTK_MISC (widget)->ypad;

  if (set_padding)
    gtk_misc_set_padding (GTK_MISC (widget), xpad, ypad);

  /* Labels not in buttons may have a focus target widget. */
  accel_target = gb_widget_input_combo (data, focus_target_p);
  if (data->apply)
    {
      if (!gb_label_find_mnemonic_widget (widget))
	{
	  if (!strcmp (accel_target, _("Auto")))
	    accel_target = NULL;

	  gtk_object_set_data_full (GTK_OBJECT (widget), focus_target_p,
				    g_strdup (accel_target),
				    accel_target ? g_free : NULL);
	}
    }
}
Ejemplo n.º 10
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_vbutton_box_set_properties (GtkWidget * widget, GbWidgetSetArgData * data)
{
  gint size, i, spacing, min_width, min_height, ipad_x, ipad_y;
  gchar *layout;
  gboolean set_child_size = FALSE, set_child_padding = FALSE;
  gboolean queue_resize = FALSE;

  size = gb_widget_input_int (data, Size);
  if (data->apply)
    gb_box_set_size (widget, size);

  layout = gb_widget_input_choice (data, Layout);
  if (data->apply)
    {
      for (i = 0; i < sizeof (GbLayoutValues) / sizeof (GbLayoutValues[0]); i
	   ++)
	{
	  if (!strcmp (layout, GbLayoutChoices[i])
	      || !strcmp (layout, GbLayoutSymbols[i]))
	    {
	      gtk_button_box_set_layout (GTK_BUTTON_BOX (widget), GbLayoutValues
					 [i]);
	      queue_resize = TRUE;
	      break;
	    }
	}
    }

  spacing = gb_widget_input_int (data, Spacing);
  if (data->apply)
    {
      gtk_button_box_set_spacing (GTK_BUTTON_BOX (widget), spacing);
      queue_resize = TRUE;
    }

  min_width = gb_widget_input_int (data, Width);
  if (data->apply)
    set_child_size = TRUE;
  else
    min_width = GTK_BUTTON_BOX (widget)->child_min_width;

  min_height = gb_widget_input_int (data, Height);
  if (data->apply)
    set_child_size = TRUE;
  else
    min_height = GTK_BUTTON_BOX (widget)->child_min_height;

  if (set_child_size)
    {
      gtk_button_box_set_child_size (GTK_BUTTON_BOX (widget),
				     min_width, min_height);
      queue_resize = TRUE;
    }

  ipad_x = gb_widget_input_int (data, XPad);
  if (data->apply)
    set_child_padding = TRUE;
  else
    ipad_x = GTK_BUTTON_BOX (widget)->child_ipad_x;

  ipad_y = gb_widget_input_int (data, YPad);
  if (data->apply)
    set_child_padding = TRUE;
  else
    ipad_y = GTK_BUTTON_BOX (widget)->child_ipad_y;

  if (set_child_padding)
    {
      gtk_button_box_set_child_ipadding (GTK_BUTTON_BOX (widget),
					 ipad_x, ipad_y);
      queue_resize = TRUE;
    }

  if (queue_resize)
    gtk_widget_queue_resize (widget);
}
Ejemplo n.º 11
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_image_set_properties (GtkWidget * widget, GbWidgetSetArgData * data)
{
  gfloat xalign, yalign;
  gint xpad, ypad, i, pixel_size;
  gboolean set_alignment = FALSE, set_padding = FALSE, apply_icon_size;
  GtkIconSize icon_size = GTK_ICON_SIZE_BUTTON;
  gchar *icon_size_string, *icon, *icon_name;

  icon_size = GTK_IMAGE (widget)->icon_size;

  if (data->action == GB_APPLYING)
    {
      icon_size_string = gb_widget_input_choice (data, IconSize);
      apply_icon_size = data->apply;
      if (data->apply)
	{
	  for (i = 0; i < GladeIconSizeChoicesSize; i++)
	    {
	      if (!strcmp (icon_size_string, GladeIconSizeChoices[i])
		  || !strcmp (icon_size_string, GladeIconSizeSymbols[i]))
		{
		  icon_size = GladeIconSizeValues[i];
		  break;
		}
	    }
	}
    }
  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.*/
      int new_size = gb_widget_input_int (data, IconSize);
      apply_icon_size = data->apply;
      if (data->apply)
	icon_size = new_size;
    }

  /* When loading we use different names. */
  if (data->action == GB_LOADING)
    {
      icon = gb_widget_input_icon (data, "stock");
      if (!data->apply)
	icon = gb_widget_input_icon (data, "pixbuf");
    }
  else
    {
      icon = gb_widget_input_icon (data, Icon);
    }

  if (data->apply)
    {
      gboolean is_stock_icon = glade_util_check_is_stock_id (icon);

      /* Remove the old icon stored in the widget data, and remove the
	 pixmap from the project, if necessary. */
      gb_image_clear_pixmap (widget, data->project);

      gtk_object_set_data_full (GTK_OBJECT (widget), GladeIconKey,
				g_strdup (icon), icon ? g_free : NULL);

      if (is_stock_icon)
	{
	  GtkIconSize new_icon_size;

	  new_icon_size = check_icon_size (icon, icon_size);

	  /* If we are showing this widget's properties, we need to update
	     the sizes option menu. */
	  if (property_get_widget () == widget)
	    {
	      /* We set it sensitive before changing the value, so the child
		 menu item is changed from insensitive to sensitive if needed.
		 Otherwise it may remain insensitive. */
	      property_set_sensitive (IconSize, TRUE);
	      property_set_sensitive (PixelSize, FALSE);

	      property_set_auto_apply (FALSE);

	      check_visible_sizes (icon, FALSE);

	      /* Check the icon size is valid for the stock item, and if not
		 pick the first valid size. */
	      for (i = 0; i < GladeIconSizeChoicesSize; i++)
		{
		  if (GladeIconSizeValues[i] == new_icon_size)
		    {
		      property_set_choice (IconSize, i);
		    }
		}

	      property_set_named_icon (IconName, NULL);

	      property_set_auto_apply (TRUE);
	    }

	  gtk_image_set_from_stock (GTK_IMAGE (widget), icon,
				    new_icon_size);
	}
      else
	{
	  /* If an icon filename is set, use that, otherwise use the icon
	     we use for the palette. */
	  if (icon)
	    {
	      gtk_image_set_from_file (GTK_IMAGE (widget), icon);
	      glade_project_add_pixmap (data->project, icon);
	    }
	  else
	    {
	      gtk_image_set_from_pixmap (GTK_IMAGE (widget),
					 gbwidget.gdkpixmap, gbwidget.mask);
	    }

	  if (property_get_widget () == widget)
	    {
	      /* The icon size isn't relevant to non-stock icons. */
	      property_set_sensitive (IconSize, FALSE);
	      property_set_sensitive (PixelSize, FALSE);

	      property_set_auto_apply (FALSE);
	      property_set_named_icon (IconName, NULL);
	      property_set_auto_apply (TRUE);
	    }
	}

      /* We've recreated the icon with the new size above, so we don't need
	 to apply the size again. */
      apply_icon_size = FALSE;
    }

  /* This is for the named/themed icon. */
  icon_name = gb_widget_input_named_icon (data, IconName);
  if (data->apply)
    {
      /* Clear any stock icon or icon from a file. */
      gb_image_clear_pixmap (widget, data->project);

      gtk_image_set_from_icon_name (GTK_IMAGE (widget), icon_name,
				    icon_size);

      if (property_get_widget () == widget)
	{
	  property_set_sensitive (IconSize, TRUE);
	  property_set_sensitive (PixelSize, TRUE);

	  /* Clear the Icon property. */
	  property_set_auto_apply (FALSE);
	  property_set_icon (Icon, NULL);
	  property_set_auto_apply (TRUE);
	}

      /* We've recreated the icon with the new size above, so we don't need
	 to apply the size again. */
      apply_icon_size = FALSE;
    }

  /* When we set the icon size, we reset the pixel size to -1, otherwise it
     overrides the icon size. */
  if (apply_icon_size)
    {
      gtk_image_set_pixel_size (GTK_IMAGE (widget), -1);
      g_object_set (widget, "icon_size", icon_size, NULL);

      if (property_get_widget () == widget)
	{
	  property_set_auto_apply (FALSE);
	  property_set_int (PixelSize, -1);
	  property_set_auto_apply (TRUE);
	}
    }

  /* GtkImage doesn't like a pixel size of 0 so we just skip that. */
  pixel_size = gb_widget_input_int (data, PixelSize);
  if (data->apply && pixel_size != 0)
    gtk_image_set_pixel_size (GTK_IMAGE (widget), pixel_size);

  xalign = gb_widget_input_float (data, XAlign);
  if (data->apply)
    set_alignment = TRUE;
  else
    xalign = GTK_MISC (widget)->xalign;

  yalign = gb_widget_input_float (data, YAlign);
  if (data->apply)
    set_alignment = TRUE;
  else
    yalign = GTK_MISC (widget)->yalign;

  if (set_alignment)
    gtk_misc_set_alignment (GTK_MISC (widget), xalign, yalign);

  xpad = gb_widget_input_int (data, XPad);
  if (data->apply)
    set_padding = TRUE;
  else
    xpad = GTK_MISC (widget)->xpad;

  ypad = gb_widget_input_int (data, YPad);
  if (data->apply)
    set_padding = TRUE;
  else
    ypad = GTK_MISC (widget)->ypad;

  if (set_padding)
    gtk_misc_set_padding (GTK_MISC (widget), xpad, ypad);
}
Ejemplo n.º 12
0
void
gb_window_set_standard_properties (GtkWidget * widget,
				   GbWidgetSetArgData * data,
				   gchar *title_p,
				   gchar *type_p,
				   gchar *position_p,
				   gchar *modal_p,
				   gchar *default_width_p,
				   gchar *default_height_p,
				   gchar *shrink_p,
				   gchar *grow_p,
				   gchar *auto_shrink_p,
				   gchar *wmname_p,
				   gchar *wmclass_p,
				   gchar *resizable_p,
				   gchar *destroy_with_parent_p,
				   gchar *icon_p)
{
  gchar *title, *type, *position;
  gint default_width, default_height, i;
  gboolean modal, apply_default_width, apply_default_height;
  gboolean resizable, destroy_with_parent;
#if 0
  gchar *wmname, *wmclass;
#endif

  if (title_p)
    {
      title = gb_widget_input_string (data, title_p);
      if (data->apply)
	gtk_window_set_title (GTK_WINDOW (widget), title);
    }

  if (type_p)
    {
      type = gb_widget_input_choice (data, type_p);
      if (data->apply)
	{
	  for (i = 0; i < sizeof (GbTypeValues) / sizeof (GbTypeValues[0]);
	       i++)
	    {
	      if (!strcmp (type, GbTypeChoices[i])
		  || !strcmp (type, GbTypeSymbols[i]))
		{
		  gtk_object_set_data (GTK_OBJECT (widget), type_p,
				       GINT_TO_POINTER (i));
		  break;
		}
	    }
	}
    }

  if (position_p)
    {
      position = gb_widget_input_choice (data, position_p);
      if (data->apply)
	{
	  for (i = 0;
	       i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]);
	       i++)
	    {
	      if (!strcmp (position, GbPositionChoices[i])
		  || !strcmp (position, GbPositionSymbols[i]))
		{
		  gtk_object_set_data (GTK_OBJECT (widget), position_p,
				       GINT_TO_POINTER (i));
		  break;
		}
	    }
	}
    }

  if (modal_p)
    {
      modal = gb_widget_input_bool (data, modal_p);
      if (data->apply)
	{
	  gtk_object_set_data (GTK_OBJECT (widget), modal_p,
			       modal ? "TRUE" : NULL);
	}
    }

  if (default_width_p && default_height_p)
    {
      default_width = gb_widget_input_int (data, default_width_p);
      apply_default_width = data->apply;
      if (apply_default_width)
	{
	  gtk_object_set_data (GTK_OBJECT (widget), DefaultWidth,
			       GINT_TO_POINTER (default_width));
	}

      default_height = gb_widget_input_int (data, default_height_p);
      apply_default_height = data->apply;
      if (apply_default_height)
	{
	  gtk_object_set_data (GTK_OBJECT (widget), DefaultHeight,
			       GINT_TO_POINTER (default_height));
	}

      if (apply_default_width || apply_default_height)
	{
	  if (!apply_default_width)
	    default_width = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget),
								  DefaultWidth));
	  if (!apply_default_height)
	    default_height = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget),
								   DefaultHeight));
	  gtk_window_set_default_size (GTK_WINDOW (widget),
				       default_width ? default_width : -1,
				       default_height ? default_height : -1);
	}
    }

#if 0
  /* These are deprecated. */
  if (shrink_p && grow_p)
    {
      shrink = gb_widget_input_bool (data, shrink_p);
      if (data->apply)
	set_policy = TRUE;
      else
	shrink = GTK_WINDOW (widget)->allow_shrink;

      grow = gb_widget_input_bool (data, grow_p);
      if (data->apply)
	set_policy = TRUE;
      else
	grow = GTK_WINDOW (widget)->allow_grow;

      if (set_policy)
	gtk_window_set_policy (GTK_WINDOW (widget), shrink, grow, FALSE);
    }
#endif

#if 0
  /* These aren't necessary, and have been used incorrectly for ages. */
  if (wmname_p)
    {
      wmname = gb_widget_input_string (data, wmname_p);
      if (wmname && wmname[0] == '\0')
	wmname = NULL;
      if (data->apply)
	{
	  gtk_object_set_data_full (GTK_OBJECT (widget), wmname_p,
				    g_strdup (wmname), wmname ? g_free : NULL);
	}
    }

  if (wmclass_p)
    {
      wmclass = gb_widget_input_string (data, wmclass_p);
      if (wmclass && wmclass[0] == '\0')
	wmclass = NULL;
      if (data->apply)
	{
	  gtk_object_set_data_full (GTK_OBJECT (widget), wmclass_p,
				    g_strdup (wmclass),
				    wmclass ? g_free : NULL);
	}
    }
#endif

  if (resizable_p)
    {
      resizable = gb_widget_input_bool (data, resizable_p);
      if (data->apply)
	gtk_window_set_resizable (GTK_WINDOW (widget), resizable);
    }

  if (destroy_with_parent_p)
    {
      destroy_with_parent = gb_widget_input_bool (data, destroy_with_parent_p);
      if (data->apply)
	gtk_window_set_destroy_with_parent (GTK_WINDOW (widget),
					    destroy_with_parent);
    }

  if (icon_p)
    {
      char *filename = gb_widget_input_pixmap_filename (data, icon_p);
      if (data->apply)
	{
	  char *old_filename;

	  if (filename && filename[0] == '\0')
	    filename = NULL;

	  /* Remove the old pixmap from the project. */
	  old_filename = gtk_object_get_data (GTK_OBJECT (widget), icon_p);
	  glade_project_remove_pixmap (data->project, old_filename);

	  gtk_object_set_data_full (GTK_OBJECT (widget), icon_p,
				    g_strdup (filename),
				    filename ? g_free : NULL);

	  glade_project_add_pixmap (data->project, filename);

	  if (filename)
	    {
	      GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
	      gtk_window_set_icon (GTK_WINDOW (widget), pixbuf);
	      if (pixbuf)
		gdk_pixbuf_unref (pixbuf);
	    }
	}
      if (data->action == GB_LOADING)
	g_free (filename);
    }
}
Ejemplo n.º 13
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_bonobo_dock_item_set_properties (GtkWidget * widget, GbWidgetSetArgData * data)
{
  gboolean locked, exclusive, never_floating, never_vertical, never_horizontal;
  gchar *shadow, *orientation;
  BonoboDockItemBehavior behavior;
  gint i;

  /* This is a bit of a hack, as some of the properties are now saved as
     packing properties instead of normal properties. */
  if (data->action == GB_LOADING)
    {
      gchar *behavior_string;

      data->loading_type = GB_CHILD_PROPERTIES;

      behavior_string = load_string (data, Behavior);
      behavior = glade_util_flags_from_string (BONOBO_TYPE_DOCK_ITEM_BEHAVIOR,
					       behavior_string);

      data->loading_type = GB_STANDARD_PROPERTIES;
    }
  else
    {
      behavior = BONOBO_DOCK_ITEM (widget)->behavior;

      locked = gb_widget_input_bool (data, Locked);
      if (data->apply)
	{
	  if (locked)
	    behavior |= BONOBO_DOCK_ITEM_BEH_LOCKED;
	  else
	    behavior &= ~BONOBO_DOCK_ITEM_BEH_LOCKED;

	  /* This avoids any problems with redrawing the selection. */
	  if (data->action == GB_APPLYING)
	    editor_clear_selection (NULL);

	  gtk_widget_queue_resize (widget);
	}

      exclusive = gb_widget_input_bool (data, Exclusive);
      if (data->apply)
	{
	  if (exclusive)
	    behavior |= BONOBO_DOCK_ITEM_BEH_EXCLUSIVE;
	  else
	    behavior &= ~BONOBO_DOCK_ITEM_BEH_EXCLUSIVE;
	}

      never_floating = gb_widget_input_bool (data, NeverFloating);
      if (data->apply)
	{
	  if (never_floating)
	    behavior |= BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING;
	  else
	    behavior &= ~BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING;
	}

      never_vertical = gb_widget_input_bool (data, NeverVertical);
      if (data->apply)
	{
	  if (never_vertical)
	    behavior |= BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL;
	  else
	    behavior &= ~BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL;
	}

      never_horizontal = gb_widget_input_bool (data, NeverHorizontal);
      if (data->apply)
	{
	  if (never_horizontal)
	    behavior |= BONOBO_DOCK_ITEM_BEH_NEVER_HORIZONTAL;
	  else
	    behavior &= ~BONOBO_DOCK_ITEM_BEH_NEVER_HORIZONTAL;
	}
    }

  /* BonoboDockItem has no method for setting the behavior. */
  BONOBO_DOCK_ITEM (widget)->behavior = behavior;


  shadow = gb_widget_input_choice (data, ShadowType);
  if (data->apply)
    {
      for (i = 0; i < sizeof (GbShadowValues) / sizeof (GbShadowValues[0]);
	   i++)
	{
	  if (!strcmp (shadow, GbShadowChoices[i])
	      || !strcmp (shadow, GbShadowSymbols[i]))
	    {
	      bonobo_dock_item_set_shadow_type (BONOBO_DOCK_ITEM (widget),
					       GbShadowValues[i]);
	      break;
	    }
	}
    }

  orientation = gb_widget_input_choice (data, Orientation);
  if (data->apply)
    {
      for (i = 0; i < GladeOrientationSize; i++)
	{
	  if (!strcmp (orientation, GladeOrientationChoices[i])
	      || !strcmp (orientation, GladeOrientationSymbols[i]))
	    {
	      bonobo_dock_item_set_orientation (BONOBO_DOCK_ITEM (widget),
					       GladeOrientationValues[i]);

	      /* This avoids any problems with redrawing the selection. */
	      if (data->action == GB_APPLYING)
		editor_clear_selection (NULL);

	      /* FIXME: A test to see if changing orientation works. */
	      if (BONOBO_DOCK_ITEM (widget)->bin.child)
		gtk_widget_queue_resize (BONOBO_DOCK_ITEM (widget)->bin.child);

	      break;
	    }
	}
    }
}