Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
* libstetic/wrapper/objects.xml: bring back ThemedIcon images and
Browse files Browse the repository at this point in the history
	buttons. Add <itemgroup ref="Gtk.Widget"> to a few classes that
	were missing it.

	* libstetic/editor/ThemedIcon.cs: Fix to work under Gtk# 2.4

	* libstetic/wrapper/Button.cs: bring back ThemedIcon buttons

	* libstetic/wrapper/Image.cs: bring back ThemedIcon images.

	* libstetic/wrapper/Frame.cs: don't crash when importing a frame
	with no label widget. If the LabelWidget changes, create a new
	wrapper for it.

	* libstetic/wrapper/Container.cs (GladeImport): don't crash when
	importing a placeholder into a !AllowPlacerholders container.

svn path=/trunk/stetic/; revision=50798
  • Loading branch information
Dan Winship committed Sep 26, 2005
1 parent fe0b35e commit 87b22c7
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 63 deletions.
19 changes: 19 additions & 0 deletions ChangeLog
@@ -1,3 +1,22 @@
2005-09-26 Dan Winship <danw@novell.com>

* libstetic/wrapper/objects.xml: bring back ThemedIcon images and
buttons. Add <itemgroup ref="Gtk.Widget"> to a few classes that
were missing it.

* libstetic/editor/ThemedIcon.cs: Fix to work under Gtk# 2.4

* libstetic/wrapper/Button.cs: bring back ThemedIcon buttons

* libstetic/wrapper/Image.cs: bring back ThemedIcon images.

* libstetic/wrapper/Frame.cs: don't crash when importing a frame
with no label widget. If the LabelWidget changes, create a new
wrapper for it.

* libstetic/wrapper/Container.cs (GladeImport): don't crash when
importing a placeholder into a !AllowPlacerholders container.

2005-09-26 Dan Winship <danw@novell.com>

* libstetic/wrapper/Dialog.cs (Buttons): make this a number rather
Expand Down
8 changes: 6 additions & 2 deletions libstetic/editor/ThemedIcon.cs
Expand Up @@ -19,7 +19,7 @@ public ThemedIcon () : base (false, 6)
entry.Changed += entry_Changed;

button = new Gtk.Button ();
Gtk.Image icon = Gtk.Image.NewFromIconName ("stock_symbol-selection", Gtk.IconSize.Button);
Gtk.Image icon = new Gtk.Image (Gtk.IconTheme.Default.LoadIcon ("stock_symbol-selection", 16, 0));
button.Add (icon);
PackStart (button, false, false, 0);
button.Clicked += button_Clicked;
Expand Down Expand Up @@ -51,7 +51,11 @@ void button_Clicked (object obj, EventArgs args)
return;

icon = value;
image.SetFromIconName (icon, Gtk.IconSize.Button);
try {
image.Pixbuf = Gtk.IconTheme.Default.LoadIcon (icon, 16, 0);
} catch {
image.Stock = Gnome.Stock.Blank;
}

syncing = true;
entry.Text = icon;
Expand Down
43 changes: 16 additions & 27 deletions libstetic/wrapper/Button.cs
Expand Up @@ -66,17 +66,13 @@ void FixupGladeChildren ()
this.label = label.LabelProp;
button.UseUnderline = label.UseUnderline;

#if GTK_SHARP_2_6
if (iwrap.Type == Image.ImageType.ThemedIcon) {
themedIcon = iwrap.IconName;
Type = ButtonType.ThemedIcon;
} else {
#endif
applicationIcon = iwrap.Filename;
Type = ButtonType.ApplicationIcon;
#if GTK_SHARP_2_6
}
#endif
}

public override XmlElement GladeExport (XmlDocument doc)
Expand Down Expand Up @@ -114,9 +110,7 @@ public override XmlElement GladeExport (XmlDocument doc)
public enum ButtonType {
StockItem,
TextOnly,
#if GTK_SHARP_2_6
ThemedIcon,
#endif
ApplicationIcon,
Custom
};
Expand All @@ -137,20 +131,15 @@ public enum ButtonType {
case ButtonType.TextOnly:
labelWidget = null;
button.UseStock = false;
#if GTK_SHARP_2_6
button.Image = null;
#endif
Label = label;
UseUnderline = useUnderline;
break;
#if GTK_SHARP_2_6
case ButtonType.ThemedIcon:
button.UseStock = false;
Label = label;
UseUnderline = useUnderline;
ThemedIcon = themedIcon;
break;
#endif
case ButtonType.ApplicationIcon:
button.UseStock = false;
Label = label;
Expand All @@ -159,9 +148,6 @@ public enum ButtonType {
break;
case ButtonType.Custom:
button.UseStock = false;
#if GTK_SHARP_2_6
button.Image = null;
#endif
if (button.Child != null)
ReplaceChild (button.Child, CreatePlaceholder ());
break;
Expand All @@ -173,8 +159,6 @@ public enum ButtonType {

void ConstructContents ()
{
Gtk.Image iconWidget;

if (button.Child != null)
button.Remove (button.Child);

Expand All @@ -184,24 +168,31 @@ void ConstructContents ()
} else
labelWidget = Gtk.Label.New (label);

#if GTK_SHARP_2_6
if (type == ButtonType.ThemedIcon)
iconWidget = Gtk.Image.NewFromIconName (themedIcon, Gtk.IconSize.Button);
else
#endif
iconWidget = new Gtk.Image (applicationIcon);
Gtk.Image imageWidget = (Gtk.Image)Registry.NewInstance (typeof (Gtk.Image), proj);
Image imageWrapper = (Image)Widget.Lookup (imageWidget);
imageWrapper.Unselectable = true;
if (type == ButtonType.StockItem) {
imageWrapper.IconName = stockId;
imageWrapper.IconSize = Gtk.IconSize.Button;
imageWrapper.Type = Image.ImageType.ThemedIcon;
} else if (type == ButtonType.ThemedIcon) {
imageWrapper.IconName = themedIcon;
imageWrapper.IconSize = Gtk.IconSize.Button;
imageWrapper.Type = Image.ImageType.ThemedIcon;
} else {
imageWrapper.Filename = applicationIcon;
imageWrapper.Type = Image.ImageType.ApplicationImage;
}

Gtk.HBox box = new Gtk.HBox (false, 2);
box.PackStart (iconWidget, false, false, 0);
box.PackStart (imageWidget, false, false, 0);
box.PackEnd (labelWidget, false, false, 0);

Gtk.Alignment alignment = new Gtk.Alignment (button.Xalign, button.Yalign, 0.0f, 0.0f);
alignment.Add (box);

Widget wrapper = (Widget)ObjectWrapper.Create (proj, labelWidget);
wrapper.Unselectable = true;
wrapper = (Widget)ObjectWrapper.Create (proj, iconWidget);
wrapper.Unselectable = true;
wrapper = (Widget)ObjectWrapper.Create (proj, box);
wrapper.Unselectable = true;
wrapper = (Widget)ObjectWrapper.Create (proj, alignment);
Expand Down Expand Up @@ -246,7 +237,6 @@ void ConstructContents ()
}
}

#if GTK_SHARP_2_6
string themedIcon;
public string ThemedIcon {
get {
Expand All @@ -258,7 +248,6 @@ void ConstructContents ()
EmitNotify ("ThemedIcon");
}
}
#endif

string label;
public string Label {
Expand Down
2 changes: 1 addition & 1 deletion libstetic/wrapper/Container.cs
Expand Up @@ -80,7 +80,7 @@ public override void GladeImport (XmlElement elem)
try {
if (child_elem.HasAttribute ("internal-child"))
GladeSetInternalChild (child_elem);
else if (child_elem["widget"] == null && AllowPlaceholders)
else if (child_elem["widget"] == null)
AddPlaceholder ();
else
GladeImportChild (child_elem);
Expand Down
11 changes: 10 additions & 1 deletion libstetic/wrapper/Frame.cs
Expand Up @@ -19,7 +19,16 @@ public override void Wrap (object obj, bool initialized)
align_wrapper.AddPlaceholder ();
ReplaceChild (frame.Child, (Gtk.Widget)align_wrapper.Wrapped);
}
ObjectWrapper.Create (proj, frame.LabelWidget);

if (frame.LabelWidget != null)
ObjectWrapper.Create (proj, frame.LabelWidget);
frame.AddNotification ("label-widget", LabelWidgetChanged);
}

void LabelWidgetChanged (object obj, GLib.NotifyArgs args)
{
if (frame.LabelWidget != null)
ObjectWrapper.Create (proj, frame.LabelWidget);
}

Gtk.Frame frame {
Expand Down
71 changes: 49 additions & 22 deletions libstetic/wrapper/Image.cs
Expand Up @@ -13,21 +13,19 @@ public static new Gtk.Image CreateInstance ()
public override void Wrap (object obj, bool initialized)
{
base.Wrap (obj, initialized);

iconSize = (Gtk.IconSize)image.IconSize;

if (image.StorageType == Gtk.ImageType.Stock) {
type = ImageType.ThemedIcon;
iconName = image.Stock;
iconSize = (Gtk.IconSize)image.IconSize;
Type = ImageType.ThemedIcon;
#if GTK_SHARP_2_6
} else if (image.StorageType == Gtk.ImageType.IconName) {
type = ImageType.ThemedIcon;
iconName = image.IconName;
iconSize = (Gtk.IconSize)image.IconSize;
Type = ImageType.ThemedIcon;
#endif
} else {
type = ImageType.ApplicationImage;
if (filename == null)
Filename = null;
}
} else
Type = ImageType.ApplicationImage;
}

Gtk.Image image {
Expand All @@ -36,13 +34,18 @@ public override void Wrap (object obj, bool initialized)
}
}

void BreakImage ()
{
image.IconSize = (int)Gtk.IconSize.Button;
image.Stock = Gtk.Stock.MissingImage;
}

public enum ImageType {
ThemedIcon,
ApplicationImage,
}

ImageType type;

public ImageType Type {
get {
return type;
Expand All @@ -51,12 +54,10 @@ public enum ImageType {
type = value;
EmitNotify ("Type");

#if GTK_SHARP_2_6
if (type == ImageType.ThemedIcon) {
IconName = iconName;
IconSize = iconSize;
} else
#endif
Filename = filename;
}
}
Expand All @@ -68,18 +69,24 @@ public enum ImageType {
}
set {
iconName = value;
Gtk.StockItem item = Gtk.Stock.Lookup (value);
if (item.StockId == value)
EmitNotify ("IconName");

if (value == null) {
BreakImage ();
return;
}

if (type != ImageType.ThemedIcon)
type = ImageType.ThemedIcon;

Gtk.StockItem item = Gtk.Stock.Lookup (iconName);
if (item.StockId == iconName)
image.Stock = iconName;
#if GTK_SHARP_2_6
else
image.IconName = iconName;
#else
else
image.Stock = Gtk.Stock.MissingImage;
#endif

EmitNotify ("IconName");
IconSize = iconSize;
}
}

Expand All @@ -89,7 +96,28 @@ public enum ImageType {
return iconSize;
}
set {
image.IconSize = (int)(iconSize = value);
iconSize = value;
EmitNotify ("IconSize");

if (iconName == null)
return;

#if !GTK_SHARP_2_6
if (image.StorageType != Gtk.ImageType.Stock) {
bool ok = false;

try {
int w, h;
Gtk.Icon.SizeLookup (iconSize, out w, out h);
image.Pixbuf = Gtk.IconTheme.Default.LoadIcon (iconName, h, 0);
ok = true;
} catch {}

if (!ok)
BreakImage ();
} else
#endif
image.IconSize = (int)iconSize;
}
}

Expand All @@ -100,8 +128,7 @@ public enum ImageType {
}
set {
if (value == "" || value == null) {
image.Stock = Gtk.Stock.MissingImage;
image.IconSize = (int)Gtk.IconSize.Button;
BreakImage ();
filename = null;
} else
image.File = filename = value;
Expand Down

0 comments on commit 87b22c7

Please sign in to comment.