Kouhei Sutou
kous****@users*****
Sun Dec 31 22:59:19 JST 2006
Index: kazehakase/ext/ruby/Makefile.am diff -u kazehakase/ext/ruby/Makefile.am:1.11 kazehakase/ext/ruby/Makefile.am:1.12 --- kazehakase/ext/ruby/Makefile.am:1.11 Mon Sep 18 12:09:33 2006 +++ kazehakase/ext/ruby/Makefile.am Sun Dec 31 22:59:19 2006 @@ -44,6 +44,7 @@ libkzext_la_SOURCES = \ kz-rb-ext.c kz-rb-ext.h \ + kz-rb-app.c \ kz-rb-window.c \ kz-rb-statusbar.c \ kz-rb-embed.c \ Index: kazehakase/ext/ruby/kz-rb-app.c diff -u /dev/null kazehakase/ext/ruby/kz-rb-app.c:1.1 --- /dev/null Sun Dec 31 22:59:19 2006 +++ kazehakase/ext/ruby/kz-rb-app.c Sun Dec 31 22:59:19 2006 @@ -0,0 +1,43 @@ +/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */ + +/* + * Copyright (C) 2006 Kouhei Sutou <kou****@cozmi*****> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "kz-rb-ext.h" + +#define _SELF(obj) (KZ_APP(RVAL2GOBJ(obj))) + +static VALUE +rb_kz_app_get_window_list(VALUE self) +{ + GList *list; + list = (GList *)kz_app_get_window_list(_SELF(self)); + return GLIST2ARY(list); +} + +void +Init_kz_rb_app(VALUE mKz) +{ + VALUE cKzApp; + + cKzApp = G_DEF_CLASS(KZ_TYPE_APP, "App", mKz); + + rb_define_method(cKzApp, "window_list", rb_kz_app_get_window_list, 0); + + G_DEF_SETTERS(cKzApp); +} Index: kazehakase/ext/ruby/kz-rb-ext.c diff -u kazehakase/ext/ruby/kz-rb-ext.c:1.20 kazehakase/ext/ruby/kz-rb-ext.c:1.21 --- kazehakase/ext/ruby/kz-rb-ext.c:1.20 Mon Sep 18 12:09:33 2006 +++ kazehakase/ext/ruby/kz-rb-ext.c Sun Dec 31 22:59:19 2006 @@ -22,6 +22,8 @@ #include <glib/gi18n.h> #include "kz-rb-ext.h" +#include "kz-ext-impl.h" + #ifdef POSIX_SIGNAL #define ruby_signal(sig, handle) posix_signal((sig), (handle)) #else @@ -124,7 +126,7 @@ } void -kz_ext_init () +KZ_EXT_IMPL_INIT (KzApp *app) { VALUE stack_start; gchar *dirname; @@ -150,6 +152,7 @@ rb_funcall(Qnil, rb_intern("require"), 1, rb_str_new2(INIT_PRE_RB)); if (RTEST(rb_const_get(mKz, rb_intern("ENABLE")))) { + Init_kz_rb_app(mKz); Init_kz_rb_window(mKz); Init_kz_rb_statusbar(mKz); Init_kz_rb_embed(mKz); @@ -160,12 +163,14 @@ Init_kz_rb_bookmark(mKz); Init_kz_rb_sidebar(mKz); + /* FIXME */ + rb_define_const(mKz, "APP", GOBJ2RVAL(app)); rb_funcall(Qnil, rb_intern("require"), 1, rb_str_new2(INIT_RB)); } } void -kz_ext_setup (KzWindow *kz) +KZ_EXT_IMPL_SETUP (KzWindow *kz) { if (RTEST(rb_const_get(mKz, rb_intern("ENABLE")))) { rb_funcall(mKz, rb_intern("setup"), 1, GOBJ2RVAL(kz)); @@ -174,7 +179,7 @@ } void -kz_ext_exit (gboolean success) +KZ_EXT_IMPL_EXIT (gboolean success) { rb_funcall(mKz, rb_intern("exit"), 0); ruby_cleanup(0); Index: kazehakase/ext/ruby/kz-rb-ext.h diff -u kazehakase/ext/ruby/kz-rb-ext.h:1.12 kazehakase/ext/ruby/kz-rb-ext.h:1.13 --- kazehakase/ext/ruby/kz-rb-ext.h:1.12 Sat Aug 26 00:06:38 2006 +++ kazehakase/ext/ruby/kz-rb-ext.h Sun Dec 31 22:59:19 2006 @@ -10,6 +10,7 @@ #undef PACKAGE_STRING #undef PACKAGE_VERSION +#include "kz-app.h" #include "kz-window.h" #include "kz-statusbar.h" #include "kz-downloader.h" @@ -31,10 +32,7 @@ # define RVAL2CSTR2(v) (NIL_P(v) ? NULL : StringValuePtr(v)) #endif -extern void kz_ext_init(void); -extern void kz_ext_setup(KzWindow *kz); -extern void kz_ext_exit(gboolean success); - +extern void Init_kz_rb_app(VALUE mKz); extern void Init_kz_rb_window(VALUE mKz); extern void Init_kz_rb_statusbar(VALUE mKz); extern void Init_kz_rb_embed(VALUE mKz); Index: kazehakase/ext/ruby/kz-rb-window.c diff -u kazehakase/ext/ruby/kz-rb-window.c:1.13 kazehakase/ext/ruby/kz-rb-window.c:1.14 --- kazehakase/ext/ruby/kz-rb-window.c:1.13 Fri Aug 25 21:42:56 2006 +++ kazehakase/ext/ruby/kz-rb-window.c Sun Dec 31 22:59:19 2006 @@ -41,14 +41,6 @@ } static VALUE -rb_kz_window_get_window_list(VALUE self) -{ - GList *list; - list = (GList *)kz_window_get_window_list(); - return GLIST2ARY(list); -} - -static VALUE rb_kz_window_set_default(VALUE self, VALUE window) { rb_cvar_set(self, id_default, window, Qfalse); @@ -306,9 +298,6 @@ rb_define_singleton_method(cKzWindow, "default", rb_kz_window_get_default, 0); - rb_define_singleton_method(cKzWindow, "list", - rb_kz_window_get_window_list, 0); - rb_define_method(cKzWindow, "initialize", rb_kz_window_new, -1); rb_define_method(cKzWindow, "open_new_tab",