svnno****@sourc*****
svnno****@sourc*****
Thu Apr 5 10:26:14 JST 2007
Revision: 3142 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3142 Author: kous Date: 2007-04-05 10:26:13 +0900 (Thu, 05 Apr 2007) Log Message: ----------- * src/prefs_ui/prefs_browser.[ch], src/prefs_ui/Makefile.am, src/kz-prefs-win.c: made layout engine selectable. * src/prefs_ui/prefs_history.c (set_search_engine): added NULL check. * src/kz-window.c (kz_window_create_embed): Use Global/layout_engine. * src/kz-embed.[ch] (kz_embed_engine_ids): added. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/src/kz-embed.c kazehakase/trunk/src/kz-embed.h kazehakase/trunk/src/kz-prefs-win.c kazehakase/trunk/src/kz-window.c kazehakase/trunk/src/prefs_ui/Makefile.am kazehakase/trunk/src/prefs_ui/prefs_history.c Added Paths: ----------- kazehakase/trunk/src/prefs_ui/prefs_browser.c kazehakase/trunk/src/prefs_ui/prefs_browser.h Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2007-04-04 08:14:36 UTC (rev 3141) +++ kazehakase/trunk/ChangeLog 2007-04-05 01:26:13 UTC (rev 3142) @@ -1,3 +1,14 @@ +2007-04-05 Kouhei Sutou <kou****@cozmi*****> + + * src/prefs_ui/prefs_browser.[ch], src/prefs_ui/Makefile.am, + src/kz-prefs-win.c: made layout engine selectable. + + * src/prefs_ui/prefs_history.c (set_search_engine): added NULL check. + + * src/kz-window.c (kz_window_create_embed): Use Global/layout_engine. + + * src/kz-embed.[ch] (kz_embed_engine_ids): added. + 2007-04-04 Takuro Ashie <ashie****@homa*****> * src/main.c: Remove needless checking return value of Modified: kazehakase/trunk/src/kz-embed.c =================================================================== --- kazehakase/trunk/src/kz-embed.c 2007-04-04 08:14:36 UTC (rev 3141) +++ kazehakase/trunk/src/kz-embed.c 2007-04-05 01:26:13 UTC (rev 3142) @@ -61,7 +61,7 @@ } GList * -kz_embed_engine_names(void) +kz_embed_engine_names (void) { GList *node; GList *result = NULL; @@ -76,6 +76,25 @@ return result; } +GList * +kz_embed_engine_ids (void) +{ + GList *node; + GList *result = NULL; + + if (!embeds) + kz_embed_load(NULL); + + for (node = embeds; node; node = g_list_next(node)) + { + KzModule *module = node->data; + result = g_list_append(result, + g_strdup(G_TYPE_MODULE(module)->name)); + } + + return result; +} + static GtkWidget * _kz_embed_new (KzModule *module, const gchar *name, const gchar *first_property, ...) Modified: kazehakase/trunk/src/kz-embed.h =================================================================== --- kazehakase/trunk/src/kz-embed.h 2007-04-04 08:14:36 UTC (rev 3141) +++ kazehakase/trunk/src/kz-embed.h 2007-04-05 01:26:13 UTC (rev 3142) @@ -300,6 +300,7 @@ void kz_embed_unload (void); void kz_embed_exit (void); GList *kz_embed_engine_names (void); +GList *kz_embed_engine_ids (void); GtkWidget *kz_embed_new (const gchar *name); void kz_embed_load_url (KzEmbed *kzembed, Modified: kazehakase/trunk/src/kz-prefs-win.c =================================================================== --- kazehakase/trunk/src/kz-prefs-win.c 2007-04-04 08:14:36 UTC (rev 3141) +++ kazehakase/trunk/src/kz-prefs-win.c 2007-04-05 01:26:13 UTC (rev 3142) @@ -41,6 +41,7 @@ #include "prefs_ui/prefs_external_program.h" #include "prefs_ui/prefs_history.h" #include "prefs_ui/prefs_bookmark.h" +#include "prefs_ui/prefs_browser.h" enum { @@ -124,6 +125,7 @@ widget_class->delete_event = delete_event; ADD_PAGE_ENTRY(prefs_general_get_entry); + ADD_PAGE_ENTRY(prefs_browser_get_entry); ADD_PAGE_ENTRY(prefs_lang_get_entry); ADD_PAGE_ENTRY(prefs_font_get_entry); ADD_PAGE_ENTRY(prefs_tab_get_entry); @@ -132,11 +134,11 @@ ADD_PAGE_ENTRY(prefs_key_accel_get_entry); ADD_PAGE_ENTRY(prefs_gesture_get_entry); ADD_PAGE_ENTRY(prefs_proxy_get_entry); - ADD_PAGE_ENTRY(prefs_privacy_get_entry); + ADD_PAGE_ENTRY(prefs_privacy_get_entry); /* ADD_PAGE_ENTRY(prefs_ui_editor_get_entry); */ ADD_PAGE_ENTRY(prefs_external_program_get_entry); ADD_PAGE_ENTRY(prefs_history_get_entry); - + g_type_class_add_private (object_class, sizeof(KzPrefsWinPrivate)); } Modified: kazehakase/trunk/src/kz-window.c =================================================================== --- kazehakase/trunk/src/kz-window.c 2007-04-04 08:14:36 UTC (rev 3141) +++ kazehakase/trunk/src/kz-window.c 2007-04-05 01:26:13 UTC (rev 3142) @@ -805,21 +805,10 @@ g_return_val_if_fail(KZ_IS_WINDOW(kz), NULL); - engine = KZ_CONF_GET_STR("Global", "layout_engine"); + engine = KZ_CONF_GET_STR("Browser", "layout_engine"); if (engine) { - if (!strcmp(engine, "gtk+-webcore")) - { - kz_embed = KZ_EMBED(kz_embed_new("gtk-webcore")); - } - else if (!strcmp(engine, "ie")) - { - kz_embed = KZ_EMBED(kz_embed_new("ie")); - } - else - { - kz_embed = KZ_EMBED(kz_embed_new("gecko")); - } + kz_embed = KZ_EMBED(kz_embed_new(engine)); g_free(engine); } @@ -827,6 +816,8 @@ kz_embed = KZ_EMBED(kz_embed_new("gecko")); if (!kz_embed) kz_embed = KZ_EMBED(kz_embed_new("gtk-webcore")); + if (!kz_embed) + kz_embed = KZ_EMBED(kz_embed_new("ie")); return kz_embed; } Modified: kazehakase/trunk/src/prefs_ui/Makefile.am =================================================================== --- kazehakase/trunk/src/prefs_ui/Makefile.am 2007-04-04 08:14:36 UTC (rev 3141) +++ kazehakase/trunk/src/prefs_ui/Makefile.am 2007-04-05 01:26:13 UTC (rev 3142) @@ -9,65 +9,61 @@ -I$(top_srcdir)/src/bookmarks \ -I$(top_srcdir)/src -AM_CPPFLAGS = \ - -DLOCALEDIR=\""$(localedir)"\" \ - -DSYSCONFDIR=\""$(sysconfdir)"\" \ - -DDATADIR=\""$(datadir)"\" \ - -DKZ_SYSCONFDIR=\""$(sysconfdir)/$(PACKAGE)"\" \ - -DKZ_DATADIR=\""$(datadir)/$(PACKAGE)"\" \ - -DKZ_SEARCH_MODULEDIR=\""$(searchdir)"\" \ - -DGTK_DISABLE_DEPRECATED=1 \ - -DGDK_DISABLE_DEPRECATED=1 \ - -DG_LOG_DOMAIN=\"Kazehakase-PrefsUI\" \ +AM_CPPFLAGS = \ + -DGTK_DISABLE_DEPRECATED=1 \ + -DGDK_DISABLE_DEPRECATED=1 \ + -DG_LOG_DOMAIN=\"Kazehakase-PrefsUI\" \ -DG_DISABLE_DEPRECATED=1 -libkzprefsui_public_h_sources = \ - prefs_entry.h \ - prefs_external_program.h \ - prefs_font.h \ - prefs_general.h \ - prefs_gesture.h \ - prefs_history.h \ - prefs_key_accel.h \ - prefs_lang.h \ - prefs_tab.h \ - prefs_privacy.h \ - prefs_proxy.h \ - prefs_ui_editor.h \ - prefs_bookmark.h +libkzprefsui_public_h_sources = \ + prefs_entry.h \ + prefs_external_program.h \ + prefs_font.h \ + prefs_general.h \ + prefs_gesture.h \ + prefs_history.h \ + prefs_key_accel.h \ + prefs_lang.h \ + prefs_tab.h \ + prefs_privacy.h \ + prefs_proxy.h \ + prefs_ui_editor.h \ + prefs_bookmark.h \ + prefs_browser.h enum_source_prefix = kz-prefsui-enum-types -enum_sources = \ +enum_sources = \ kz-prefsui-enum-types.c kz-prefsui-enum-types.h -enum_sources_h = \ +enum_sources_h = \ $(libkzprefsui_public_h_sources) -libkzprefsui_la_SOURCES = \ - prefs_entry.c \ - prefs_external_program.c \ - prefs_font.c \ - prefs_general.c \ - prefs_gesture.c \ - prefs_history.c \ - prefs_key_accel.c \ - prefs_lang.c \ - prefs_tab.c \ - prefs_privacy.c \ - prefs_proxy.c \ - prefs_ui_editor.c \ - prefs_bookmark.c \ - $(enum_types) \ +libkzprefsui_la_SOURCES = \ + prefs_entry.c \ + prefs_external_program.c \ + prefs_font.c \ + prefs_general.c \ + prefs_gesture.c \ + prefs_history.c \ + prefs_key_accel.c \ + prefs_lang.c \ + prefs_tab.c \ + prefs_privacy.c \ + prefs_proxy.c \ + prefs_ui_editor.c \ + prefs_bookmark.c \ + prefs_browser.c \ + $(enum_types) \ $(libkzprefsui_public_h_sources) libkzprefsui_la_LIBADD = \ $(GTK_LIBS) -BUILT_SOURCES = \ +BUILT_SOURCES = \ $(enum_sources) -CLEANFILES = \ +CLEANFILES = \ $(enum_sources) include $(top_srcdir)/src/enum-types.mk Added: kazehakase/trunk/src/prefs_ui/prefs_browser.c =================================================================== --- kazehakase/trunk/src/prefs_ui/prefs_browser.c 2007-04-04 08:14:36 UTC (rev 3141) +++ kazehakase/trunk/src/prefs_ui/prefs_browser.c 2007-04-05 01:26:13 UTC (rev 3142) @@ -0,0 +1,204 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* + * Copyright (C) 2007 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 "prefs_browser.h" + +#include <string.h> +#include <glib/gi18n.h> +#include "kazehakase.h" +#include "utils/gtk-utils.h" +#include "kz-embed.h" + +#define DATA_KEY "KzPrefsBrowser::info" + + +static GtkWidget *prefs_browser_create (void); +static void prefs_browser_response (GtkWidget *widget, + gint response); + + +static KzPrefsWinPageEntry prefs_entry = +{ + /* .path = */ N_("/Browser"), + /* .priority_hint = */ 0, + /* .ui_level = */ ~KZ_UI_LEVEL_BEGINNER, + /* .create = */ prefs_browser_create, + /* .response = */ prefs_browser_response, +}; + + +typedef struct _KzPrefsBrowser +{ + GtkWidget *main_vbox; + GtkWidget *layout_engine; + gboolean changed; +} KzPrefsBrowser; + + +static void +cb_changed (GtkWidget *widget, KzPrefsBrowser *prefsui) +{ + prefsui->changed = TRUE; +} + +static void +prefs_browser_destroy (gpointer data) +{ + KzPrefsBrowser *prefsui = data; + + g_free(prefsui); +} + +static void +set_layout_engine (GtkComboBox *combo) +{ + gchar *layout_engine_name; + gint i = 0, active = 0; + GList *node; + GList *layout_engine_ids = NULL; + + layout_engine_name = KZ_CONF_GET_STR("Browser", "layout_engine"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("None")); + + layout_engine_ids = kz_embed_engine_ids(); + for (node = layout_engine_ids; node; node = g_list_next(node)) + { + gchar *engine_id = node->data; + gtk_combo_box_append_text(combo, engine_id); + i++; + if (layout_engine_name && + strcmp(engine_id, layout_engine_name) == 0) + active = i; + g_free(engine_id); + } + g_list_free(layout_engine_ids); + + if (layout_engine_name) + g_free(layout_engine_name); + + gtk_combo_box_set_active(combo, active); +} + +static GtkWidget * +prefs_browser_create (void) +{ + KzPrefsBrowser *prefsui = g_new0(KzPrefsBrowser, 1); + GtkWidget *main_vbox, *vbox, *hbox, *frame; + GtkWidget *label, *combo; + + main_vbox = gtk_vbox_new(FALSE, 0); + prefsui->main_vbox = main_vbox; + g_object_set_data_full(G_OBJECT(main_vbox), DATA_KEY, + prefsui, prefs_browser_destroy); + + label = kz_prefs_ui_utils_create_title(_("Browser")); + gtk_box_pack_start(GTK_BOX(main_vbox), label, + FALSE, FALSE, 0); + gtk_widget_show(label); + + frame = gtk_frame_new(_("Layout engine")); + gtk_frame_set_label_align(GTK_FRAME(frame), 0.03, 0.5); + gtk_container_set_border_width(GTK_CONTAINER(frame), 5); + gtk_box_pack_start(GTK_BOX(main_vbox), frame, FALSE, FALSE, 2); + gtk_widget_show(frame); + + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); + gtk_container_add(GTK_CONTAINER(frame), vbox); + gtk_widget_show(vbox); + + hbox = gtk_hbox_new(FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); + gtk_container_add(GTK_CONTAINER(vbox), hbox); + gtk_widget_show(hbox); + label = gtk_label_new_with_mnemonic(_("Layout engine name")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2); + gtk_widget_show(label); + + prefsui->layout_engine = combo = gtk_combo_box_new_text(); + set_layout_engine(GTK_COMBO_BOX(combo)); + gtk_widget_show(combo); + gtk_box_pack_start (GTK_BOX(hbox), combo, TRUE, TRUE, 0); + g_signal_connect(combo, "changed", + G_CALLBACK(cb_changed), prefsui); + + prefsui->changed = FALSE; + + return main_vbox; +} + +static void +prefs_browser_response (GtkWidget *widget, gint response) +{ + KzPrefsBrowser *prefsui = g_object_get_data(G_OBJECT(widget), DATA_KEY); + + g_return_if_fail(prefsui); + + switch (response) { + case GTK_RESPONSE_ACCEPT: + case GTK_RESPONSE_APPLY: + { + GtkComboBox *combo; + + if (!prefsui->changed) + break; + + combo = GTK_COMBO_BOX(prefsui->layout_engine); + if (gtk_combo_box_get_active(combo) == 0) + { + KZ_CONF_SET_STR("Browser", "layout_engine", ""); + } + else + { + gchar *layout_engine; + layout_engine = gtk_combo_box_get_active_text(combo); + if (layout_engine) + { + KZ_CONF_SET_STR("Browser", "layout_engine", + layout_engine); + g_free(layout_engine); + } + } + + prefsui->changed = FALSE; + + break; + } + case GTK_RESPONSE_REJECT: + break; + case KZ_RESPONSE_UI_LEVEL_MEDIUM: + break; + case KZ_RESPONSE_UI_LEVEL_EXPERT: + break; + case KZ_RESPONSE_UI_LEVEL_CUSTOM: + break; + default: + break; + } +} + +KzPrefsWinPageEntry * +prefs_browser_get_entry (gint idx) +{ + if (idx == 0) + return &prefs_entry; + else + return NULL; +} Added: kazehakase/trunk/src/prefs_ui/prefs_browser.h =================================================================== --- kazehakase/trunk/src/prefs_ui/prefs_browser.h 2007-04-04 08:14:36 UTC (rev 3141) +++ kazehakase/trunk/src/prefs_ui/prefs_browser.h 2007-04-05 01:26:13 UTC (rev 3142) @@ -0,0 +1,32 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* + * Copyright (C) 2007 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. + */ + +#ifndef __PREFS_BROWSER_H__ +#define __PREFS_BROWSER_H__ + +#include "kz-prefs-win.h" + +G_BEGIN_DECLS + +KzPrefsWinPageEntry *prefs_browser_get_entry (gint idx); + +G_END_DECLS + +#endif /* __PREFS_BROWSER_H__ */ Modified: kazehakase/trunk/src/prefs_ui/prefs_history.c =================================================================== --- kazehakase/trunk/src/prefs_ui/prefs_history.c 2007-04-04 08:14:36 UTC (rev 3141) +++ kazehakase/trunk/src/prefs_ui/prefs_history.c 2007-04-05 01:26:13 UTC (rev 3142) @@ -124,7 +124,8 @@ gchar *engine_id = node->data; gtk_combo_box_append_text(combo, engine_id); i++; - if (strcmp(engine_id, search_engine_name) == 0) + if (search_engine_name && + strcmp(engine_id, search_engine_name) == 0) active = i; g_free(engine_id); } @@ -132,6 +133,7 @@ if (search_engine_name) g_free(search_engine_name); + gtk_combo_box_set_active(combo, active); }