Commit 45c66277 authored by Scott Lembcke's avatar Scott Lembcke

ChangeLogNew

parent a08c4f97
2006-08-04 Scott Lembcke <lemb0029@gnome.org>
* ext/rbgimpdialog.c: Added a list and multiline text widget. Some
minor simplifications to other parts of the code.
* gimp-lib/rubyfu.rb: Added new ParamDef types for new widgets.
* plug-ins/test.rb: Added new widgets to the test dialogs.
2006-08-04 Scott Lembcke <lemb0029@gnome.org>
* Added the GPL notification to all source files.
......
......@@ -42,6 +42,22 @@ get_entry_text (gpointer ptr)
return rb_str_new2(gtk_entry_get_text(entry));
}
static VALUE
get_text_buffer_string (gpointer ptr)
{
GtkTextBuffer *text_buffer = ptr;
GtkTextIter start, end;
gtk_text_buffer_get_start_iter(text_buffer, &start);
gtk_text_buffer_get_end_iter(text_buffer, &end);
gchar *str = gtk_text_buffer_get_text(text_buffer, &start, &end, TRUE);
VALUE rbstr = rb_str_new2(str);
g_free(str);
return rbstr;
}
static VALUE
get_spinner_int (gpointer ptr)
{
......@@ -90,6 +106,17 @@ get_combo_box_int (gpointer ptr)
return INT2NUM(value);
}
static VALUE
get_combo_box_string (gpointer ptr)
{
gchar *str = gtk_combo_box_get_active_text(GTK_COMBO_BOX(ptr));
VALUE rbstr = rb_str_new2(str);
g_free(str);
return rbstr;
}
static VALUE
get_font_name (gpointer ptr)
{
......@@ -245,7 +272,44 @@ make_int_combo_box (GimpPDBArgType type)
default:
return NULL;
}
}
}
static GtkWidget *
make_list_combo_box (VALUE list)
{
GtkWidget *widget = gtk_combo_box_new_text();
GtkComboBox *cbox = GTK_COMBO_BOX(widget);
list = rb_check_array_type(list);
int num = RARRAY(list)->len;
VALUE *ary = RARRAY(list)->ptr;
int i;
for (i=0; i<num; i++)
gtk_combo_box_append_text(cbox, StringValuePtr(ary[i]));
gtk_combo_box_set_active(cbox, 0);
return widget;
}
static GtkWidget *
make_text_box (gchar *deflt, gpointer *buffer)
{
GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
GtkTextBuffer *text_buffer = gtk_text_buffer_new(NULL);
gtk_text_buffer_set_text(text_buffer, deflt, -1);
*buffer = text_buffer;
GtkWidget *text_view = gtk_text_view_new_with_buffer(text_buffer);
gtk_container_add(GTK_CONTAINER(scrolled_window), text_view);
return scrolled_window;
}
static gchar **
......@@ -265,7 +329,7 @@ handle_string_types (VALUE param,
GtkWidget *widget;
gpointer data;
char *defstr;
gchar *defstr;
if (deflt == Qnil)
defstr = "";
else
......@@ -283,7 +347,12 @@ handle_string_types (VALUE param,
}
ID subtypeid = SYM2ID(subtype);
if (subtypeid == rb_intern("font"))
if (subtypeid == rb_intern("text"))
{
widget = make_text_box(defstr, &result->ptr);
result->func = &get_text_buffer_string;
}
else if (subtypeid == rb_intern("font"))
{
widget = gimp_font_select_button_new("Ruby-Fu", defstr);
......@@ -306,41 +375,45 @@ handle_string_types (VALUE param,
}
else if (subtypeid == rb_intern("palette"))
{
data = wrap_string(defstr);
widget = gimp_palette_select_widget_new("Ruby-Fu", defstr,
&palette_select, data);
result->ptr = data;
result->ptr = wrap_string(defstr);
result->func = &get_string_from_pointer;
}
else if (subtypeid == rb_intern("gradient"))
{
data = wrap_string(defstr);
widget = gimp_gradient_select_widget_new("Ruby-Fu", defstr,
&gradient_select, data);
result->ptr = data;
result->func = &get_string_from_pointer;
result->ptr = wrap_string(defstr);
result->func = &get_string_from_pointer;
}
else if (subtypeid == rb_intern("pattern"))
{
data = wrap_string(defstr);
widget = gimp_pattern_select_widget_new("Ruby-Fu", defstr,
&pattern_select, data);
result->ptr = data;
result->ptr = wrap_string(defstr);
result->func = &get_string_from_pointer;
}
else if (subtypeid == rb_intern("brush"))
{
data = wrap_string(defstr);
widget = gimp_brush_select_widget_new("Ruby-Fu", defstr,
100, -1, GIMP_NORMAL_MODE,
&brush_select, data);
result->ptr = data;
result->ptr = wrap_string(defstr);
result->func = &get_string_from_pointer;
}
else if (subtypeid == rb_intern("list"))
{
VALUE list = rb_iv_get(param, "@list");
widget = make_list_combo_box(list);
result->ptr = widget;
result->func = &get_combo_box_string;
}
else
{
widget = NULL;
......@@ -459,7 +532,7 @@ handle_float_types (VALUE param,
}
else
{
widget = gtk_label_new("poo");
widget = NULL;
rb_raise(rb_eTypeError, "Bad RubyFu::ParamDef float subtype.");
}
......@@ -604,7 +677,8 @@ show_dialog (VALUE self,
{
GtkWidget *dialog, *table;
gchar *procname = StringValuePtr(rbprocname);
gchar *title = g_strdup_printf("Ruby Fu: %s", gettext(StringValuePtr(rbtitle)));
gchar *title = g_strdup_printf("Ruby Fu: %s",
gettext(StringValuePtr(rbtitle)));
int num_results;
Result *results;
......
......@@ -99,7 +99,7 @@ module RubyFu
value.instance_variable_set(:@range, range)
value.instance_variable_set(:@step, step)
return value
end
end
def self.SLIDER(name, desc, default, range, step)
value = FLOAT(name, desc, default)
......@@ -107,14 +107,27 @@ module RubyFu
value.instance_variable_set(:@range, range)
value.instance_variable_set(:@step, step)
return value
end
end
def self.ENUM(name, desc, default, enum)
value = INT32(name, desc, default)
value.instance_variable_set(:@subtype, :enum)
value.instance_variable_set(:@enum, enum)
return value
end
end
def self.LIST(name, desc, list)
value = STRING(name, desc, list[0])
value.instance_variable_set(:@subtype, :list)
value.instance_variable_set(:@list, list)
return value
end
def self.TEXT(*args)
value = STRING(*args)
value.instance_variable_set(:@subtype, :text)
return value
end
end
class Procedure
......
......@@ -303,6 +303,7 @@ RubyFu.register(
RubyFu::ParamDef.SPINNER('spinner', 'SPINNER', 6, (1.5..9.1), 0.01),
RubyFu::ParamDef.SLIDER('slider', 'SLIDER', 6, (1.5..9.1), 0.01),
RubyFu::ParamDef.STRING('string', 'STRING', 'string'),
RubyFu::ParamDef.TEXT('text', 'TEXT', "multi\nline\nstring"),
RubyFu::ParamDef.COLOR('color', 'COLOR', Gimp::Rgb.new(1.0, 0.0, 0.0, 0.0)),
RubyFu::ParamDef.ENUM('enum', 'ENUM', 0, 'GimpBlendMode')
], #params
......@@ -324,6 +325,7 @@ RubyFu.register(
'<Toolbox>/Xtns/Languages/Ruby-Fu/Test/more dialog', #menupath
nil, #image types
[
RubyFu::ParamDef.LIST('list', 'LIST', ['a', 'two', '3', 'IV']),
RubyFu::ParamDef.IMAGE('image', 'IMAGE'),
RubyFu::ParamDef.DRAWABLE('drawable', 'DRAWABLE'),
RubyFu::ParamDef.CHANNEL('channel', 'CHANNEL'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment