Commit e2d11fd0 authored by Scott Lembcke's avatar Scott Lembcke Committed by Scott Lembcke

Now sets $KCODE to UTF8. Removed rubyfu.rb from list of loaded modules.

2006-08-03  Scott Lembcke <lemb0029@gnome.org>

        * gimp-lib/gimp.rb: Now sets $KCODE to UTF8. Removed rubyfu.rb from list
          of loaded modules.

        * gimp-lib/rubyfu.rb: Now loads gimp.rb as a dependency. Creates and END
          block to automatically call RubyFu.main. Added conversion to object
          types for procedure arguments.

        * gimp-lib/gimp_oo.rb: Added a Gimp::Param#transform method to convert
          parameters to object types if possible.

        * gimp-lib/pdb.rb: Added a call to Gimp::Param#transform on return
          values if possible.

        * plug-ins/*.rb: Updated to reflect changes in gimp-lib.

        * ext/Makefile.am: Added DLOCALEDIR to AM_CFLAGS.

        * ext/rbgimpdialog.c: Added gettext() calls.

        * ext/rbgimpmain.c: Added Gettext initialization calls.
parent 7d8a0318
2006-08-03 Scott Lembcke <lemb0029@gnome.org>
* gimp-lib/gimp.rb: Now sets $KCODE to UTF8. Removed rubyfu.rb from list
of loaded modules.
* gimp-lib/rubyfu.rb: Now loads gimp.rb as a dependency. Creates and END
block to automatically call RubyFu.main. Added conversion to object
types for procedure arguments.
* gimp-lib/gimp_oo.rb: Added a Gimp::Param#transform method to convert
parameters to object types if possible.
* gimp-lib/pdb.rb: Added a call to Gimp::Param#transform on return
values if possible.
* plug-ins/*.rb: Updated to reflect changes in gimp-lib.
* ext/Makefile.am: Added DLOCALEDIR to AM_CFLAGS.
* ext/rbgimpdialog.c: Added gettext() calls.
* ext/rbgimpmain.c: Added Gettext initialization calls.
2006-07-28 Scott Lembcke <lemb0029@gnome.org>
* Added plug-ins/irbconsole.rb.
......
......@@ -9,7 +9,8 @@ endif
libdir = $(GIMP_LIBDIR)/ruby
AM_CFLAGS = $(RUBY_CFLAGS) $(GIMP_CFLAGS)
AM_CFLAGS = $(RUBY_CFLAGS) $(GIMP_CFLAGS) \
-DLOCALEDIR=\""$(GIMP_LOCALEDIR)"\"
lib_LTLIBRARIES = gimpext.la
......
......@@ -4,6 +4,8 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include <libintl.h>
#include "rbgimp.h"
VALUE mRubyFu;
......@@ -535,7 +537,7 @@ make_table (VALUE params,
rb_raise(rb_eArgError, "Parameters must be of type Gimp::ParamDef");
VALUE rbdscr = rb_struct_aref(param, ID2SYM(id_dscr));
gchar *dscr = g_strdup_printf("%s:", StringValuePtr(rbdscr));
gchar *dscr = g_strdup_printf("%s:", gettext(StringValuePtr(rbdscr)));
GtkWidget *label = gtk_label_new(dscr);
g_free(dscr);
......@@ -583,7 +585,7 @@ show_dialog (VALUE self,
{
GtkWidget *dialog, *table;
gchar *procname = StringValuePtr(rbprocname);
gchar *title = g_strdup_printf("Ruby Fu: %s", StringValuePtr(rbtitle));
gchar *title = g_strdup_printf("Ruby Fu: %s", gettext(StringValuePtr(rbtitle)));
int num_results;
Result *results;
......
......@@ -4,6 +4,14 @@
#include <ruby.h>
#include <libgimp/gimp.h>
#undef PACKAGE_NAME
#undef PACKAGE_STRING
#undef PACKAGE_TARNAME
#undef PACKAGE_VERSION
#include <libintl.h>
#include "../config.h"
#include "rbgimp.h"
static VALUE gc_array;
......@@ -155,36 +163,36 @@ run_callback (const gchar *name,
}
GimpPlugInInfo PLUG_IN_INFO = {
init_callback,
quit_callback,
query_callback,
run_callback
init_callback,
quit_callback,
query_callback,
run_callback
};
static VALUE
rb_gimp_main (VALUE self,
VALUE plug_in_info)
{
plug_in_callbacks[0] = rb_struct_aref(plug_in_info, ID2SYM(id_init_proc));
plug_in_callbacks[1] = rb_struct_aref(plug_in_info, ID2SYM(id_quit_proc));
plug_in_callbacks[2] = rb_struct_aref(plug_in_info, ID2SYM(id_query_proc));
plug_in_callbacks[3] = rb_struct_aref(plug_in_info, ID2SYM(id_run_proc));
/*build argv*/
VALUE *arr = RARRAY(rb_argv)->ptr;
gint argc = RARRAY(rb_argv)->len;
gchar *argv[argc + 1];
VALUE name = rb_gv_get("$0");
argv[0] = StringValuePtr(name);
int i;
for (i=0; i<argc; i++)
argv[i + 1] = StringValuePtr(arr[i]);
/*call gimp_main*/
gint rstatus = gimp_main(&PLUG_IN_INFO, argc + 1, argv);
return INT2NUM(rstatus);
plug_in_callbacks[0] = rb_struct_aref(plug_in_info, ID2SYM(id_init_proc));
plug_in_callbacks[1] = rb_struct_aref(plug_in_info, ID2SYM(id_quit_proc));
plug_in_callbacks[2] = rb_struct_aref(plug_in_info, ID2SYM(id_query_proc));
plug_in_callbacks[3] = rb_struct_aref(plug_in_info, ID2SYM(id_run_proc));
/*build argv*/
VALUE *arr = RARRAY(rb_argv)->ptr;
gint argc = RARRAY(rb_argv)->len;
gchar *argv[argc + 1];
VALUE name = rb_gv_get("$0");
argv[0] = StringValuePtr(name);
int i;
for (i=0; i<argc; i++)
argv[i + 1] = StringValuePtr(arr[i]);
/*call gimp_main*/
gint rstatus = gimp_main(&PLUG_IN_INFO, argc + 1, argv);
return INT2NUM(rstatus);
}
static VALUE
......@@ -216,24 +224,24 @@ rb_gimp_install_procedure (VALUE self,
GimpParamDef *returndefs;
returndefs = rb2GimpParamDefs(return_vals, &n_return_vals);
gimp_install_procedure((gchar *)StringValuePtr(name),
(gchar *)StringValuePtr(blurb),
(gchar *)StringValuePtr(help),
(gchar *)StringValuePtr(author),
(gchar *)StringValuePtr(copyright),
(gchar *)StringValuePtr(date),
(gchar *)StringValuePtr(menu_label),
(gchar *)StringValuePtr(image_types),
(GimpPDBProcType)NUM2INT(type),
n_params,
n_return_vals,
paramdefs,
returndefs);
g_free(paramdefs);
g_free(returndefs);
return Qnil;
gimp_install_procedure((gchar *)StringValuePtr(name),
(gchar *)StringValuePtr(blurb),
(gchar *)StringValuePtr(help),
(gchar *)StringValuePtr(author),
(gchar *)StringValuePtr(copyright),
(gchar *)StringValuePtr(date),
(gchar *)StringValuePtr(menu_label),
(gchar *)StringValuePtr(image_types),
(GimpPDBProcType)NUM2INT(type),
n_params,
n_return_vals,
paramdefs,
returndefs);
g_free(paramdefs);
g_free(returndefs);
return Qnil;
}
/*TODO temp proc functions
......@@ -269,8 +277,16 @@ Init_gimpmain (void)
gc_array = rb_ary_new();
rb_gc_register_address(&gc_array);
rb_define_module_function(mGimp, "main", rb_gimp_main, 1);
rb_define_module_function(mGimp, "quit", rb_gimp_quit, 0);
rb_define_module_function(mGimp, "install_procedure", rb_gimp_install_procedure, 11);
rb_define_module_function(mGimp, "run_procedure", rb_gimp_run_procedure, 2);
/* setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
textdomain(GETTEXT_PACKAGE); */
bindtextdomain(GETTEXT_PACKAGE, gimp_locale_directory());
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
rb_define_module_function(mGimp, "main", rb_gimp_main, 1);
rb_define_module_function(mGimp, "quit", rb_gimp_quit, 0);
rb_define_module_function(mGimp, "install_procedure", rb_gimp_install_procedure, 11);
rb_define_module_function(mGimp, "run_procedure", rb_gimp_run_procedure, 2);
}
$KCODE = "UTF8"
require 'gimpext'
require 'pdb'
require 'rubyfu.rb'
module Gimp
def message(*messages)
......
......@@ -21,7 +21,7 @@ module Gimp
def add_constructor(name, proc_name)
class_eval """
def self.#{name}(*args)
create PDB['#{proc_name}'].call(*args)
PDB['#{proc_name}'].call(*args)
end
"""
end
......@@ -159,3 +159,23 @@ module Gimp
end #module
end #module
module Gimp
class Param
def transform
case type
when PDB_DISPLAY
Display.create(data)
when PDB_IMAGE
Image.create(data)
when PDB_LAYER
Layer.create(data)
when PDB_CHANNEL
Channel.create(data)
when PDB_VECTORS
Vectors.create(data)
else
self.data
end
end
end
end
......@@ -83,7 +83,13 @@ module PDB
when Gimp::PDB_EXECUTION_ERROR: raise(ExecutionError, @name)
end
return *values.collect{|param| param.data}
return *values.collect do|param|
if param.respond_to? :transform
param.transform
else
param.data
end
end
end
def to_s
......
require 'gimp.rb'
module RubyFu
class CallError < Exception
end
......@@ -204,9 +206,10 @@ module RubyFu
runMode = Gimp::RUN_NONINTERACTIVE
end
require 'gimp_oo.rb'
args = args.zip(@fullparams).collect do|arg, param|
raise(CallError, "Bad argument") unless arg.type == param.type
next arg.data
next arg.transform
end
values = case runMode
......@@ -308,4 +311,8 @@ module RubyFu
Gimp.main(PLUG_IN_INFO)
end
module_function :main
end
\ No newline at end of file
end
END {
RubyFu.main
}
\ No newline at end of file
#!/usr/bin/env ruby
require "gimp"
require "rubyfu"
include Gimp
include RubyFu
......@@ -188,5 +188,3 @@ RubyFu.register(
],
&method(:ruby_fu_cool_metal_logo)
)
RubyFu.main
require 'gimp'
require 'rubyfu'
RubyFu.register(
'ruby-fu-console', #procedure name
......@@ -13,7 +13,6 @@ RubyFu.register(
nil #results
) do
require 'irb'
require 'gimp_oo'
include Gimp
include PDB::Access
......@@ -35,5 +34,3 @@ RubyFu.register(
nil
end
RubyFu.main
......@@ -15,7 +15,7 @@ Parameters:
shadow: whather to create a shadow as well'
=end
require "gimp"
require "rubyfu"
include Gimp
include RubyFu
......@@ -41,8 +41,6 @@ RubyFu.register(
],
[ParamDef.IMAGE('image', 'Result Image')]
) do |run_mode, radius, light, shadow, bg_color, sphere_color|
require 'gimp_oo'
shadow = (shadow == 1)
width = radius * 3.75
......@@ -98,5 +96,3 @@ RubyFu.register(
img
end
main
#!/usr/bin/env ruby
require 'gimp'
require 'rubyfu'
RubyFu.register(
'ruby-fu-test1', #procedure name
......@@ -252,8 +252,6 @@ RubyFu.register(
[Gimp::ParamDef.IMAGE('image', 'Image')] #results
) do|run_mode|
PDB.verbose = true
require 'gimp_oo'
#constructor call
img = Gimp::Image.new(100, 100, Gimp::RGB)
......@@ -327,5 +325,3 @@ RubyFu.register(
nil
end
RubyFu.main
\ No newline at end of file
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