[gimp-perl] Use GIMP font selector, not Gtk one. Bug 502558
- From: Kevin Cozens <kcozens src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp-perl] Use GIMP font selector, not Gtk one. Bug 502558
- Date: Wed, 26 Mar 2014 19:49:57 +0000 (UTC)
commit ad59470f87a3d8d2cba81eb2bfe9452c33468b88
Author: Ed J <m8r-35s8eo mailinator com>
Date: Thu Mar 20 04:05:16 2014 +0000
Use GIMP font selector, not Gtk one. Bug 502558
UI/UI.pm | 45 ++++++++++++++++++++++++++++++++-------------
UI/UI.xs | 16 +++++++++++++---
UI/typemap | 2 ++
extra.h | 1 +
typemap | 1 +
5 files changed, 49 insertions(+), 16 deletions(-)
---
diff --git a/UI/UI.pm b/UI/UI.pm
index d692f34..8261fde 100644
--- a/UI/UI.pm
+++ b/UI/UI.pm
@@ -420,6 +420,25 @@ sub help_window(\$$$) {
$$helpwin->show_all;
}
+
+sub _instrument {
+ return unless $Gimp::verbose;
+ my $obj = shift;
+ $class = ref $obj;
+ my %sig2done;
+ map {
+ my $c = $_;
+ map {
+#warn "$c:$_->{signal_name}\n";
+ my $s = $_->{signal_name};
+ $obj->signal_connect(
+ $s => sub { warn "SIG:$s(@_)\n";0 }
+ ) unless $sig2done{$s};
+ $sig2done{$s} = 1;
+ } Glib::Type->list_signals($c);
+ } Glib::Type->list_ancestors($class);
+}
+
sub interact($$$$@) {
my $function = shift;
my $blurb = shift;
@@ -499,41 +518,45 @@ sub interact($$$$@) {
&new_PF_STRING;
} elsif ($type == PF_FONT) {
+ $a = new Gtk2::HBox 0,5;
+ $default = 'Arial' unless defined $default;
+ my $b = new Gimp::UI::FontSelectButton $desc, $default;
+ $a->pack_start ($b, 1, 1, 0);
+ push @setvals, sub { $b->set_font($_[0]) };
+ push @getvals, sub { $b->get_font };
+ set_tip $t $b,$desc;
+ _instrument($b);
+
+if (0) {
my $fs = new Gtk2::FontSelectionDialog sprintf __"Font Selection Dialog (%s)", $desc;
my $def = __"Helvetica 34";
my $val;
-
my $l = new Gtk2::Label "!error!";
my $setval = sub {
my($words);
$val = $_[0];
-
#Append a size to font name string if no size is given so
#sample text will be displayed properly in font requester.
@words = split(/ /, $val);
if (@words == 0 || $words[ words - 1] <= 0) {
$val .= " 24";
};
-
unless (defined $val && $fs->set_font_name ($val)) {
warn sprintf __"Illegal default font description for $function: %s\n", $val
if defined $val;
$val = $def;
$fs->set_font_name ($val);
}
-
$l->set (label => " $val ");
};
-
$fs->ok_button->signal_connect (clicked => sub {$setval->($fs->get_font_name); $fs->hide});
$fs->cancel_button->signal_connect (clicked => sub {$fs->hide});
-
push @setvals, $setval;
push @getvals, sub { $val };
-
$a = new Gtk2::Button;
$a->add ($l);
$a->signal_connect (clicked => sub { show $fs });
+}
} elsif ($type == PF_SPINNER) {
my $adj = _new_adjustment ($value, $extra);
@@ -553,18 +576,14 @@ sub interact($$$$@) {
} elsif ($type == PF_COLOR) {
$a = new Gtk2::HBox 0,5;
-
$default = [0.8,0.6,0.1] unless defined $default;
-
$default = &Gimp::canonicalize_color($default);
-
- my $b = new Gimp::UI::ColorButton $name, 90, 14, $default, 'small-checks';
-
+ my $b = new Gimp::UI::ColorButton $desc, 90, 14, $default, 'small-checks';
$a->pack_start ($b, 1, 1, 0);
-
push @setvals, sub { $b->set_color (defined $_[0] ? Gimp::canonicalize_color $_[0] :
[0.8,0.6,0.1]) };
push @getvals, sub { $b->get_color };
set_tip $t $b,$desc;
+ _instrument($b);
# my $c = new Gtk2::Button __"FG";
# signal_connect $c clicked => sub {
diff --git a/UI/UI.xs b/UI/UI.xs
index 8519888..1728682 100644
--- a/UI/UI.xs
+++ b/UI/UI.xs
@@ -1,8 +1,5 @@
#include "config.h"
-/* dunno where this comes from */
-#undef VOIDUSED
-
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
@@ -34,6 +31,7 @@ typedef GtkWidget GimpColorSelect_own;
typedef GtkWidget GimpColorSelector_own;
typedef GtkWidget GimpDialog_own;
typedef GtkWidget GimpFileEntry_own;
+typedef GtkWidget GimpFontSelectButton_own;
typedef GtkWidget GimpOffsetArea_own;
typedef GtkWidget GimpPathEditor_own;
typedef GtkWidget GimpPickButton_own;
@@ -282,6 +280,18 @@ utf8_str gimp_file_entry_get_filename (GimpFileEntry *entry)
void gimp_file_entry_set_filename (GimpFileEntry *entry, utf8_str filename)
+MODULE = Gimp::UI PACKAGE = Gimp::UI::FontSelectButton PREFIX = gimp_font_select_button_
+
+BOOT:
+ gperl_register_object (GIMP_TYPE_FONT_SELECT_BUTTON, "Gimp::UI::FontSelectButton");
+
+GimpFontSelectButton_own * gimp_font_select_button_new (SV *unused_class, utf8_str title, utf8_str font_name)
+ C_ARGS: title, font_name
+
+utf8_str_const gimp_font_select_button_get_font (GimpFontSelectButton *button)
+
+void gimp_font_select_button_set_font (GimpFontSelectButton *button, utf8_str font_name)
+
MODULE = Gimp::UI PACKAGE = Gimp::UI::OffsetArea PREFIX = gimp_offset_area_
BOOT:
diff --git a/UI/typemap b/UI/typemap
index 7d868f2..5380fdc 100644
--- a/UI/typemap
+++ b/UI/typemap
@@ -24,6 +24,8 @@ GimpDialog * GOBJECT
GimpDialog_own * GOBJECT_OWN
GimpFileEntry * GOBJECT
GimpFileEntry_own * GOBJECT_OWN
+GimpFontSelectButton * GOBJECT
+GimpFontSelectButton_own * GOBJECT_OWN
GimpOffsetArea * GOBJECT
GimpOffsetArea_own * GOBJECT_OWN
GimpPathEditor * GOBJECT
diff --git a/extra.h b/extra.h
index 27e7be6..0e05a70 100644
--- a/extra.h
+++ b/extra.h
@@ -13,6 +13,7 @@
#define TRACE_ALL 0xff
typedef char *utf8_str;
+typedef const char *utf8_str_const;
#endif
diff --git a/typemap b/typemap
index 4d07109..dcf4f6d 100644
--- a/typemap
+++ b/typemap
@@ -11,6 +11,7 @@ gint * T_PTROBJ
guchar * T_PV
utf8_str T_UTF8
+utf8_str_const T_UTF8
GimpDrawable * T_GDRAWABLE
GimpTile * T_TILE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]