Removing old minimo gtk based application. http://weblogs.mozillazine.org/dougt/archives/009349.html. Bug=322266, r=bsmedberg

This commit is contained in:
dougt%meer.net 2006-01-17 17:48:07 +00:00
Родитель 879544f3e3
Коммит 253e471671
42 изменённых файлов: 0 добавлений и 8363 удалений

Просмотреть файл

@ -820,9 +820,6 @@ embedding/tests/mfcembed/components/Makefile
"
MAKEFILES_minimo="
embedding/minimo/Makefile
embedding/minimo/app/Makefile
embedding/minimo/popuplite/Makefile
minimo/Makefile
minimo/base/Makefile
minimo/base/wince/Makefile

Просмотреть файл

@ -1,50 +0,0 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Minimo.
#
# The Initial Developer of the Original Code is
# Doug Turner <dougt@meer.net>.
# Portions created by the Initial Developer are Copyright (C) 2003
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
ifeq (,$(filter windows,$(MOZ_WIDGET_TOOLKIT)))
DIRS += popuplite ../browser/gtk/src app
endif
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,200 +0,0 @@
pref("browser.active_color", "#EE0000");
pref("browser.anchor_color", "#0000EE");
pref("browser.blink_allowed", true);
pref("browser.block.target_new_window", false);
pref("browser.cache.check_doc_frequency", 3);
pref("browser.cache.memory.capacity", 256);
pref("browser.cache.memory.enable", true);
pref("browser.display.background_color", "#FFFFFF");
pref("browser.display.focus_background_color", "#117722");
pref("browser.display.focus_ring_on_anything", false);
pref("browser.display.focus_ring_width", 1);
pref("browser.display.focus_text_color", "#ffffff");
pref("browser.display.force_inline_alttext", false);
pref("browser.display.foreground_color", "#000000");
pref("browser.display.normal_lineheight_calc_control", 2);
pref("browser.display.show_image_placeholders", true);
pref("browser.display.use_document_colors", true);
pref("browser.display.use_document_fonts", 1);
pref("browser.display.use_focus_colors", false);
pref("browser.display.use_system_colors", false);
pref("browser.enable_automatic_image_resizing", false);
pref("browser.fixup.alternate.enabled", true);
pref("browser.fixup.alternate.prefix", "www.");
pref("browser.fixup.alternate.suffix", ".com");
pref("browser.fixup.hide_user_pass", true);
pref("browser.forms.submit.backwards_compatible", true);
pref("browser.frames.enabled", true);
pref("browser.sessionhistory.max_entries", 0);
pref("browser.throbber.url","chrome://navigator-region/locale/region.properties");
pref("browser.underline_anchors", true);
pref("browser.visited_color", "#551A8B");
pref("clipboard.autocopy", false);
pref("dom.allow_scripts_to_close_windows", false);
pref("dom.disable_image_src_set", false);
pref("dom.disable_open_during_load", false);
pref("dom.disable_window_flip", false);
pref("dom.disable_window_move_resize", false);
pref("dom.disable_window_open_feature.close", false);
pref("dom.disable_window_open_feature.directories", false);
pref("dom.disable_window_open_feature.location", false);
pref("dom.disable_window_open_feature.menubar", false);
pref("dom.disable_window_open_feature.minimizable", false);
pref("dom.disable_window_open_feature.personalbar", false);
pref("dom.disable_window_open_feature.resizable", false);
pref("dom.disable_window_open_feature.scrollbars", false);
pref("dom.disable_window_open_feature.status", false);
pref("dom.disable_window_open_feature.titlebar", false);
pref("dom.disable_window_open_feature.toolbar", false);
pref("dom.disable_window_status_change", false);
pref("fonts.xft.enabled", true);
pref("font.language.group", "chrome://navigator/locale/navigator.properties");
pref("font.size.fixed.ar", 9);
pref("font.size.fixed.el", 9);
pref("font.size.fixed.he", 9);
pref("font.size.fixed.ja", 9);
pref("font.size.fixed.ko", 9);
pref("font.size.fixed.th", 9);
pref("font.size.fixed.tr", 9);
pref("font.size.fixed.x-baltic", 9);
pref("font.size.fixed.x-central-euro", 9);
pref("font.size.fixed.x-cyrillic", 9);
pref("font.size.fixed.x-devanagari", 9);
pref("font.size.fixed.x-tamil", 9);
pref("font.size.fixed.x-armn", 9);
pref("font.size.fixed.x-beng", 9);
pref("font.size.fixed.x-cans", 9);
pref("font.size.fixed.x-ethi", 9);
pref("font.size.fixed.x-geor", 9);
pref("font.size.fixed.x-gujr", 9);
pref("font.size.fixed.x-guru", 9);
pref("font.size.fixed.x-khmr", 9);
pref("font.size.fixed.x-mlym", 9);
pref("font.size.fixed.x-unicode", 9);
pref("font.size.fixed.x-western", 9);
pref("font.size.fixed.zh-CN", 9);
pref("font.size.fixed.zh-HK", 9);
pref("font.size.fixed.zh-TW", 9);
pref("font.size.unit", "pt");
pref("font.size.variable.ar", 8);
pref("font.size.variable.el", 8);
pref("font.size.variable.he", 8);
pref("font.size.variable.ja", 8);
pref("font.size.variable.ko", 8);
pref("font.size.variable.th", 8);
pref("font.size.variable.tr", 8);
pref("font.size.variable.x-baltic", 8);
pref("font.size.variable.x-central-euro", 8);
pref("font.size.variable.x-cyrillic", 8);
pref("font.size.variable.x-devanagari", 8);
pref("font.size.variable.x-tamil", 8);
pref("font.size.variable.x-armn", 8);
pref("font.size.variable.x-beng", 8);
pref("font.size.variable.x-cans", 8);
pref("font.size.variable.x-ethi", 8);
pref("font.size.variable.x-geor", 8);
pref("font.size.variable.x-gujr", 8);
pref("font.size.variable.x-guru", 8);
pref("font.size.variable.x-khmr", 8);
pref("font.size.variable.x-mlym", 8);
pref("font.size.variable.x-unicode", 8);
pref("font.size.variable.x-western", 8);
pref("font.size.variable.zh-CN", 8);
pref("font.size.variable.zh-HK", 8);
pref("font.size.variable.zh-TW", 8);
pref("general.useragent.override", "Mozilla/5.0 (X11; U; Familiar 0.72; en-US; rv:1.7a) Gecko/20040218 Minimo/0.1");
pref("image.animation_mode", "normal");
pref("images.dither", "auto");
pref("intl.accept_charsets", "iso-8859-1,*,utf-8");
pref("intl.accept_languages", "chrome://navigator/locale/navigator.properties");
pref("intl.accept_languages", "chrome://navigator/locale/navigator.properties");
pref("intl.charset.default", "chrome://navigator-platform/locale/navigator.properties");
pref("intl.charset.detector", "chrome://navigator/locale/navigator.properties");
pref("intl.collationOption", "chrome://navigator-platform/locale/navigator.properties");
pref("intl.content.langcode", "chrome://communicator-region/locale/region.properties");
pref("intl.fallbackCharsetList.ISO-8859-1", "windows-1252");
pref("intl.locale.matchOS", false);
pref("intl.menuitems.alwaysappendaccesskeys","chrome://navigator/locale/navigator.properties");
pref("intl.menuitems.insertseparatorbeforeaccesskeys","chrome://navigator/locale/navigator.properties");
pref("javascript.allow.mailnews", false);
pref("javascript.enabled", true);
pref("javascript.options.showInConsole", true);
pref("javascript.options.strict", false);
pref("keyword.enabled", true);
pref("layout.frames.force_resizability", false);
pref("layout.word_select.eat_space_to_next_word", false);
pref("layout.word_select.stop_at_punctuation", true);
pref("network.cookie.cookieBehavior", 0);
pref("network.cookie.disableCookieForMailNews", true);
pref("network.cookie.lifetime.behavior", 0);
pref("network.cookie.lifetime.days", 90);
pref("network.cookie.lifetime.enabled", false);
pref("network.cookie.warnAboutCookies", false);
pref("network.enableIDN", false);
pref("network.http.accept-encoding" ,"gzip,deflate");
pref("network.http.accept.default", "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1");
pref("network.http.default-socket-type", "");
pref("network.http.keep-alive", false);
pref("network.http.keep-alive.timeout", 300);
pref("network.http.max-connections", 2);
pref("network.http.max-connections-per-server", 2);
pref("network.http.max-persistent-connections-per-proxy", 2);
pref("network.http.max-persistent-connections-per-server", 2);
pref("network.http.pipelining" , false);
pref("network.http.pipelining.firstrequest", false);
pref("network.http.pipelining.maxrequests" , 4);
pref("network.http.proxy.keep-alive", true);
pref("network.http.proxy.pipelining", false);
pref("network.http.proxy.version", "1.1");
pref("network.http.redirection-limit", 20);
pref("network.http.request.max-start-delay", 10);
pref("network.http.sendRefererHeader", 2);
pref("network.http.sendSecureXSiteReferrer", true);
pref("network.http.use-cache", false);
pref("network.http.version", "1.1");
pref("network.image.imageBehavior", 0);
pref("network.image.warnAboutImages", false);
pref("network.online", true);
pref("network.prefetch-next", false);
pref("network.protocol-handler.expose-all", true);
pref("network.protocol-handler.external-default", true);
pref("network.protocol-handler.external.data", false);
pref("network.protocol-handler.external.disk", false);
pref("network.protocol-handler.external.hcp", false);
pref("network.protocol-handler.external.help", false);
pref("network.protocol-handler.external.javascript", false);
pref("network.protocol-handler.external.ms-help", false);
pref("network.protocol-handler.external.vbscript", false);
pref("network.protocol-handler.external.vnd.ms.radio", false);
pref("network.protocol-handler.warn-external-default", true);
pref("network.proxy.autoconfig_url", "");
pref("network.proxy.ftp", "");
pref("network.proxy.ftp_port", 0);
pref("network.proxy.gopher", "");
pref("network.proxy.gopher_port", 0);
pref("network.proxy.http", "");
pref("network.proxy.http_port", 0);
pref("network.proxy.no_proxies_on", "localhost, 127.0.0.1");
pref("network.proxy.socks", "");
pref("network.proxy.socks_port", 0);
pref("network.proxy.socks_version", 5);
pref("network.proxy.ssl", "");
pref("network.proxy.ssl_port", 0);
pref("network.proxy.type", 0);
pref("network.standard-url.escape-utf8", true);
pref("nglayout.debug.enable_xbl_forms", false);
pref("nglayout.events.dispatchLeftClickOnly", true);
pref("prefs.converted-to-utf8",false);
pref("security.checkloaduri", true);
pref("security.enable_java", false);
pref("security.xpconnect.plugin.unrestricted", true);
pref("signed.applets.codebase_principal_support", false);
pref("slider.snapMultiplier", 0);
pref("ui.key.accelKey", 17);
pref("ui.key.generalAccessKey", 18);
pref("ui.key.menuAccessKey", 18);
pref("ui.key.menuAccessKeyFocuses", false);
pref("ui.key.saveLink.shift", true);
pref("viewmanager.do_doublebuffering", true);

Просмотреть файл

@ -1,124 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Mozilla browser.
#
# The Initial Developer of the Original Code is
# Christopher Blizzard.
# Portions created by the Initial Developer are Copyright (C) 1999
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MOZILLA_INTERNAL_API = 1
MODULE = minimo
REQUIRES = gtkembedmoz \
xpcom \
string \
dom \
chrome \
locale \
webbrowserpersist \
find \
docshell \
webshell \
widget \
content \
browser \
necko \
pref \
history \
gfx \
webbrowserpersist \
layout \
webbrwsr \
history \
txtsvc \
windowwatcher \
appcomps \
xpcom \
nspr \
xpcom_obsolete \
$(NULL)
ifdef NS_TRACE_MALLOC
REQUIRES += tracemalloc
endif
CPPSRCS = Minimo.cpp \
minimo_support.cpp \
minimo_bookmark.cpp \
minimo_history.cpp \
minimo_callbacks.cpp \
minimo_context.cpp \
minimo_preference.cpp \
mozilla_api.cpp
PROGRAM = Minimo
LIBS += \
-lgtkembedmoz \
$(XLDFLAGS) \
$(XLIBS) \
$(NULL)
include $(topsrcdir)/config/config.mk
ifdef BUILD_STATIC_LIBS
FINAL_LINK_COMPS=$(topsrcdir)/minimo/base/linux/minimo-link-comps
FINAL_LINK_COMP_NAMES=$(topsrcdir)/minimo/base/linux/minimo-link-names
FINAL_LINK_LIBS=$(topsrcdir)/minimo/base/linux/minimo-link-libs
include $(topsrcdir)/config/static-config.mk
EXTRA_DEPS += $(STATIC_EXTRA_DEPS)
EXTRA_DSO_LIBS += $(STATIC_EXTRA_DSO_LIBS)
endif
EXTRA_LIBS += -L$(DEPTH)/dist/lib/components \
$(EXTRA_DSO_LIBS) \
$(STATIC_EXTRA_LIBS) \
$(MOZ_JS_LIBS) \
$(MOZ_COMPONENT_LIBS) \
-lSM -lICE \
$(TK_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk
CXXFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_GTK2_CFLAGS)

Просмотреть файл

@ -1,458 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "Minimo.h"
/* History */
#include "minimo_history.h"
/* Minimo's callbacks */
#include "minimo_callbacks.h"
/* Minimo's support functions */
#include "minimo_support.h"
/* Global variables */
MinimoBrowser *gMinimoBrowser; /* Global Minimo Variable */
gint gMinimoNumBrowsers = 0; /* Number of browsers */
gchar *gMinimoProfilePath = NULL; /* Minimo's PATH - probably "~/home/current_user/.Minimo" */
gchar *gMinimoLastFind = NULL; /* store the last expression on find dialog */
gchar *gMinimoUserHomePath = NULL; /* */
gchar *gMinimoLinkMessageURL; /* Last clicked URL */
GList *gMinimoBrowserList = g_list_alloc(); /* the list of browser windows currently open */
static GtkWidget *populate_menu_button(MinimoBrowser* );
static void switch_page_cb (GtkNotebook *, GtkNotebookPage *, guint , MinimoBrowser *);
/* callbacks from the singleton object */
static void new_window_orphan_cb(GtkMozEmbedSingle *, GtkMozEmbed **, guint , gpointer );
int
main(int argc, char **argv) {
#ifdef NS_TRACE_MALLOC
argc = NS_TraceMallocStartupArgs(argc, argv);
#endif
gtk_set_locale();
gtk_init(&argc, &argv);
gMinimoUserHomePath = PR_GetEnv("HOME");
if (!gMinimoUserHomePath) {
fprintf(stderr, "Failed to get HOME\n");
exit(1);
}
gchar *dir = g_strconcat(gMinimoUserHomePath,"/.Minimo",NULL);
/* this is fine, as it will silently error if it already exists*/
mkdir(dir,0755);
g_free(dir);
/* Minimo's config folder - hidden */
gMinimoProfilePath = g_strdup_printf("%s/%s", gMinimoUserHomePath, ".Minimo");
gtk_moz_embed_set_profile_path(gMinimoProfilePath, "Minimo");
gMinimoBrowser = new_gtk_browser(GTK_MOZ_EMBED_FLAG_DEFAULTCHROME);
/* set our minimum size */
gtk_widget_set_usize(gMinimoBrowser->mozEmbed, 250, 320);
/* Load the configuration files */
preferences_read_config ();
set_browser_visibility(gMinimoBrowser, TRUE);
bookmark_moz_embed_initialize (gMinimoBrowser->mozEmbed);
context_initialize_timer ();
support_init_remote();
support_init_autocomplete();
if (argc > 1)
gtk_moz_embed_load_url(GTK_MOZ_EMBED(gMinimoBrowser->mozEmbed), argv[1]);
// get the singleton object and hook up to its new window callback
// so we can create orphaned windows.
GtkMozEmbedSingle *single;
single = gtk_moz_embed_single_get();
if (!single) {
fprintf(stderr, "Failed to get singleton embed object!\n");
exit(1);
}
g_signal_connect(GTK_OBJECT(single), "new_window_orphan", G_CALLBACK(new_window_orphan_cb), NULL);
gtk_main ();
support_cleanup_remote ();
support_cleanup_autocomplete ();
}
/* Build the Minimo Window */
MinimoBrowser * new_gtk_browser(guint32 chromeMask) {
//MinimoBrowser *browser = 0;
gMinimoNumBrowsers++;
gMinimoBrowser = g_new0(MinimoBrowser, 1);
gMinimoBrowserList = g_list_prepend(gMinimoBrowserList, gMinimoBrowser);
// create our new toplevel window
gMinimoBrowser->topLevelWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_resizable (GTK_WINDOW(gMinimoBrowser->topLevelWindow),TRUE);
gtk_window_set_title (GTK_WINDOW (gMinimoBrowser->topLevelWindow), "MINIMO - Embedded Mozilla");
// new vbox
gMinimoBrowser->topLevelVBox = gtk_vbox_new(FALSE, 0);
gtk_widget_show (gMinimoBrowser->topLevelVBox);
// add it to the toplevel window
gtk_container_add(GTK_CONTAINER(gMinimoBrowser->topLevelWindow), gMinimoBrowser->topLevelVBox);
setup_toolbar(gMinimoBrowser);
gtk_box_pack_start(GTK_BOX(gMinimoBrowser->topLevelVBox),
gMinimoBrowser->toolbar.toolbar,
FALSE, // expand
FALSE, // fill
0); // padding
gMinimoBrowser->notebook = gtk_notebook_new ();
gtk_box_pack_start (GTK_BOX (gMinimoBrowser->topLevelVBox), gMinimoBrowser->notebook, TRUE, TRUE, 0);
gMinimoBrowser->show_tabs = FALSE;
gtk_notebook_set_show_tabs (GTK_NOTEBOOK(gMinimoBrowser->notebook), gMinimoBrowser->show_tabs);
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (gMinimoBrowser->notebook), GTK_POS_LEFT);
gtk_widget_show (gMinimoBrowser->notebook);
open_new_tab_cb (NULL, gMinimoBrowser);
// catch the destruction of the toplevel window
g_signal_connect(GTK_OBJECT(gMinimoBrowser->topLevelWindow), "delete_event",
G_CALLBACK(delete_cb), gMinimoBrowser);
// hookup to when the window is destroyed
g_signal_connect(GTK_OBJECT(gMinimoBrowser->topLevelWindow), "destroy", G_CALLBACK(destroy_cb), gMinimoBrowser);
g_signal_connect (GTK_OBJECT (gMinimoBrowser->notebook), "switch_page",
G_CALLBACK (switch_page_cb), gMinimoBrowser);
// set the chrome type so it's stored in the object
// commented for scrollbars fixing
//gtk_moz_embed_set_chrome_mask(GTK_MOZ_EMBED(gMinimoBrowser->mozEmbed), chromeMask);
gMinimoBrowser->active_page = get_active_tab (gMinimoBrowser);
return gMinimoBrowser;
}
void setup_toolbar(MinimoBrowser* browser) {
MinimoToolbar* toolbar = &browser->toolbar;
GtkWidget *menu;
#ifdef MOZ_WIDGET_GTK
toolbar->toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
#endif
#ifdef MOZ_WIDGET_GTK2
toolbar->toolbar = gtk_toolbar_new();
gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar->toolbar),GTK_ORIENTATION_HORIZONTAL);
gtk_toolbar_set_style(GTK_TOOLBAR(toolbar->toolbar),GTK_TOOLBAR_ICONS);
#endif /* MOZ_WIDGET_GTK2 */
gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar->toolbar), GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_widget_show(toolbar->toolbar);
toolbar->OpenButton =(GtkWidget*) gtk_tool_button_new_from_stock ("gtk-open");
gtk_widget_show(toolbar->OpenButton);
gtk_container_add(GTK_CONTAINER (toolbar->toolbar), toolbar->OpenButton);
g_signal_connect(GTK_OBJECT(toolbar->OpenButton), "clicked", G_CALLBACK(open_url_dialog_input_cb), browser);
toolbar->BackButton = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-go-back");
gtk_widget_show(toolbar->BackButton);
gtk_container_add(GTK_CONTAINER (toolbar->toolbar), toolbar->BackButton);
g_signal_connect(GTK_OBJECT(toolbar->BackButton), "clicked", G_CALLBACK(back_clicked_cb), browser);
toolbar->ReloadButton = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-refresh");
gtk_widget_show(toolbar->ReloadButton);
gtk_container_add(GTK_CONTAINER (toolbar->toolbar), toolbar->ReloadButton);
g_signal_connect(GTK_OBJECT(toolbar->ReloadButton), "clicked", G_CALLBACK(reload_clicked_cb), browser);
toolbar->ForwardButton = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-go-forward");
gtk_widget_show(toolbar->ForwardButton);
gtk_container_add(GTK_CONTAINER (toolbar->toolbar), toolbar->ForwardButton);
g_signal_connect(GTK_OBJECT(toolbar->ForwardButton), "clicked", G_CALLBACK(forward_clicked_cb), browser);
toolbar->StopButton =(GtkWidget*) gtk_tool_button_new_from_stock ("gtk-stop");
gtk_widget_show (toolbar->StopButton);
gtk_container_add(GTK_CONTAINER (toolbar->toolbar), toolbar->StopButton);
g_signal_connect(GTK_OBJECT(toolbar->StopButton), "clicked", G_CALLBACK(stop_clicked_cb), browser);
toolbar->PrefsButton = (GtkWidget*) gtk_menu_tool_button_new_from_stock("gtk-preferences");
gtk_widget_show (toolbar->PrefsButton);
gtk_container_add(GTK_CONTAINER (toolbar->toolbar), toolbar->PrefsButton);
g_signal_connect(GTK_OBJECT(toolbar->PrefsButton), "clicked", G_CALLBACK(pref_clicked_cb), browser);
menu = populate_menu_button (browser);
gtk_menu_tool_button_set_menu ((GtkMenuToolButton *) toolbar->PrefsButton, menu);
toolbar->InfoButton = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-dialog-info");
gtk_widget_show(toolbar->InfoButton);
gtk_container_add(GTK_CONTAINER (toolbar->toolbar), toolbar->InfoButton);
g_signal_connect(GTK_OBJECT(toolbar->InfoButton), "clicked", G_CALLBACK(info_clicked_cb), browser);
toolbar->QuitButton = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-quit");
gtk_widget_show(toolbar->QuitButton);
gtk_container_add(GTK_CONTAINER (toolbar->toolbar), toolbar->QuitButton);
g_signal_connect(GTK_OBJECT(toolbar->QuitButton), "clicked", G_CALLBACK(destroy_cb), browser);
}
static GtkWidget *populate_menu_button(MinimoBrowser* browser){
GtkWidget *menu, *menu_item;
GtkWidget *image;
menu = gtk_menu_new();
menu_item = gtk_image_menu_item_new_with_label ("Show/Hide Tabs");
gtk_menu_shell_append ((GtkMenuShell *)(menu),menu_item);
g_signal_connect(GTK_OBJECT(menu_item), "activate", G_CALLBACK(show_hide_tabs_cb), browser);
image = gtk_image_new_from_stock(GTK_STOCK_DND_MULTIPLE, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
menu_item = gtk_image_menu_item_new_with_label ("Add Tab");
gtk_menu_shell_append ((GtkMenuShell *)(menu),menu_item);
g_signal_connect(GTK_OBJECT(menu_item), "activate", G_CALLBACK(open_new_tab_cb), browser);
image = gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
menu_item = gtk_image_menu_item_new_with_label ("Close Tab");
gtk_menu_shell_append ((GtkMenuShell *)(menu),menu_item);
g_signal_connect(GTK_OBJECT(menu_item), "activate", G_CALLBACK(close_current_tab_cb), browser);
image = gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
menu_item = gtk_image_menu_item_new_with_label ("Open Bookmark Window");
gtk_menu_shell_append ((GtkMenuShell *)(menu),menu_item);
g_signal_connect(GTK_OBJECT(menu_item), "activate", G_CALLBACK(open_bookmark_window_cb), browser);
image = gtk_image_new_from_stock(GTK_STOCK_HARDDISK, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
menu_item = gtk_image_menu_item_new_with_label ("Add Bookmark");
gtk_menu_shell_append ((GtkMenuShell *)(menu),menu_item);
g_signal_connect(GTK_OBJECT(menu_item), "activate", G_CALLBACK(bookmark_add_url_directly_cb), browser);
image = gtk_image_new_from_stock(GTK_STOCK_YES, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
menu_item = gtk_image_menu_item_new_with_label ("Find");
gtk_menu_shell_append ((GtkMenuShell *)(menu),menu_item);
g_signal_connect(GTK_OBJECT(menu_item), "activate", G_CALLBACK(create_find_dialog), browser);
image = gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
menu_item = gtk_image_menu_item_new_with_label ("Save As");
gtk_menu_shell_append ((GtkMenuShell *)(menu),menu_item);
g_signal_connect(GTK_OBJECT(menu_item), "activate", G_CALLBACK(create_save_document_dialog), browser);
image = gtk_image_new_from_stock(GTK_STOCK_SAVE_AS, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
menu_item = gtk_image_menu_item_new_with_label ("Open From File");
gtk_menu_shell_append ((GtkMenuShell *)(menu),menu_item);
g_signal_connect(GTK_OBJECT(menu_item), "activate", G_CALLBACK(create_open_document_from_file), browser);
image = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
menu_item = gtk_image_menu_item_new_with_label ("Increase Font Size");
gtk_menu_shell_append ((GtkMenuShell *)(menu),menu_item);
g_signal_connect(GTK_OBJECT(menu_item), "activate", G_CALLBACK(increase_font_size_cb), browser);
image = gtk_image_new_from_stock(GTK_STOCK_ZOOM_IN, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
menu_item = gtk_image_menu_item_new_with_label ("Decrease Font Size");
gtk_menu_shell_append ((GtkMenuShell *)(menu),menu_item);
g_signal_connect(GTK_OBJECT(menu_item), "activate", G_CALLBACK(decrease_font_size_cb), browser);
image = gtk_image_new_from_stock(GTK_STOCK_ZOOM_OUT, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
menu_item = gtk_image_menu_item_new_with_label ("Full Screen");
gtk_menu_shell_append ((GtkMenuShell *)(menu),menu_item);
g_signal_connect(GTK_OBJECT(menu_item), "activate", G_CALLBACK(full_screen_cb), browser);
image = gtk_image_new_from_stock(GTK_STOCK_ZOOM_FIT, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
menu_item = gtk_image_menu_item_new_with_label ("History");
gtk_menu_shell_append ((GtkMenuShell *)(menu),menu_item);
g_signal_connect(GTK_OBJECT(menu_item), "activate", G_CALLBACK(open_history_window), browser);
gtk_widget_show_all(menu);
return (menu);
}
GtkWidget* create_minimo_progress (MinimoBrowser* browser) {
GtkWidget *Minimo_Progress;
GtkWidget *dialog_vbox4;
GtkWidget *vbox3;
GtkWidget *hbox2;
GtkWidget *LoadingLabel;
GtkWidget *URLLable;
GtkWidget *progressbar1;
GtkWidget *Minimo_Progress_Status;
Minimo_Progress = gtk_vbox_new(FALSE, 0);
dialog_vbox4 = Minimo_Progress;
vbox3 = gtk_vbox_new(FALSE, 0);
gtk_widget_show(vbox3);
gtk_box_pack_start(GTK_BOX (dialog_vbox4), vbox3, FALSE, FALSE, 0);
hbox2 = gtk_hbox_new(FALSE, 0);
gtk_widget_show(hbox2);
gtk_box_pack_start(GTK_BOX (vbox3), hbox2, FALSE, TRUE, 0);
LoadingLabel = gtk_label_new("Loading:");
gtk_widget_modify_font(LoadingLabel, getOrCreateDefaultMinimoFont());
gtk_widget_show(LoadingLabel);
gtk_box_pack_start(GTK_BOX (hbox2), LoadingLabel, FALSE, FALSE, 0);
URLLable = gtk_label_new("...");
gtk_widget_modify_font(URLLable, getOrCreateDefaultMinimoFont());
gtk_widget_show(URLLable);
gtk_box_pack_start(GTK_BOX (hbox2), URLLable, FALSE, FALSE, 0);
gtk_label_set_justify(GTK_LABEL (URLLable), GTK_JUSTIFY_CENTER);
progressbar1 = gtk_progress_bar_new ();
gtk_widget_show(progressbar1);
gtk_box_pack_start(GTK_BOX (vbox3), progressbar1, FALSE, FALSE, 0);
gtk_widget_set_usize(progressbar1, 240, 20);
Minimo_Progress_Status = gtk_label_new ("");
gtk_widget_modify_font(Minimo_Progress_Status, getOrCreateDefaultMinimoFont());
gtk_widget_show(Minimo_Progress_Status);
gtk_box_pack_start(GTK_BOX (vbox3), Minimo_Progress_Status, TRUE, FALSE, 0);
browser->progressBar = progressbar1;
g_signal_connect(GTK_OBJECT(browser->mozEmbed), "net_state", G_CALLBACK(net_state_change_cb), Minimo_Progress_Status);
g_signal_connect(GTK_OBJECT(browser->mozEmbed), "progress", G_CALLBACK(progress_change_cb), browser);
g_signal_connect(GTK_OBJECT(browser->mozEmbed), "location", G_CALLBACK(location_changed_cb), URLLable);
return Minimo_Progress;
}
static void new_window_orphan_cb(GtkMozEmbedSingle *embed,
GtkMozEmbed **retval, guint chromemask,
gpointer data)
{
MinimoBrowser *newBrowser = new_gtk_browser(chromemask);
*retval = GTK_MOZ_EMBED(newBrowser->mozEmbed);
}
/* METHODS TO MANIPULATE TABS */
GtkWidget *get_active_tab (MinimoBrowser *browser)
{
GtkWidget *active_page;
gint current_page;
current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (browser->notebook));
active_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), current_page);
return active_page;
}
/* CALLBACKS METHODS ... */
void
destroy_cb(GtkWidget *widget, MinimoBrowser *browser)
{
GList *tmp_list;
gMinimoNumBrowsers--;
tmp_list = g_list_find(gMinimoBrowserList, browser);
gMinimoBrowserList = g_list_remove_link(gMinimoBrowserList, tmp_list);
// if (gMinimoNumBrowsers == 0)
gtk_main_quit();
}
/* OTHERS METHODS */
void update_ui (MinimoBrowser *browser)
{
gchar *tmp;
int x=0;
char *url;
tmp = gtk_moz_embed_get_title (GTK_MOZ_EMBED (browser->active_page));
if (tmp)
x = strlen (tmp);
if (x == 0)
tmp = "Minimo";
gtk_window_set_title (GTK_WINDOW(browser->topLevelWindow), tmp);
url = gtk_moz_embed_get_location (GTK_MOZ_EMBED (browser->active_page));
browser->progressPopup = create_minimo_progress(browser);
}
static void switch_page_cb (GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, MinimoBrowser *browser)
{
browser->active_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), page_num);
browser->mozEmbed = browser->active_page;
update_ui (browser);
bookmark_moz_embed_initialize (browser->mozEmbed);
}
gboolean delete_cb(GtkWidget *widget, GdkEventAny *event, MinimoBrowser *browser)
{
gtk_widget_destroy(widget);
return TRUE;
}

Просмотреть файл

@ -1,66 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* METHODS HEADERS */
/* Minimo's global types */
#include "minimo_types.h"
GtkWidget* create_minimo_progress (MinimoBrowser* browser);
/* Building the Minimo Browser */
MinimoBrowser *new_gtk_browser(guint32 chromeMask);
//void new_window_cb(GtkMozEmbed *embed, GtkMozEmbed **retval, guint chromemask, MinimoBrowser *browser);
void setup_toolbar(MinimoBrowser* browser);
GtkWidget *get_active_tab (MinimoBrowser *browser);
/* callbacks from the widget */
void update_ui (MinimoBrowser *browser);
void destroy_cb(GtkWidget *widget, MinimoBrowser *browser);

Просмотреть файл

@ -1,628 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "history.h"
/* Callbacks from the UI */
void initialize_bookmark(GtkWidget *embed);
void open_bookmark(void);
void show_bookmark(void);
void read_bookmark(void);
void generate_bookmark_ctree(GNode *node, BookmarkCTreeData *ctree_data);
void add_bookmark_cb(GtkWidget *menu_item,GtkWidget *min);
void on_bookmark_add_button_clicked(GtkWidget *button,BookmarkWindow *bwin);
void on_bookmark_edit_button_clicked(GtkWidget *button,BookmarkWindow *bwin);
void on_bookmark_ok_button_clicked(GtkWidget *button,BookmarkWindow *bwin);
void on_bookmark_cancel_button_clicked(GtkWidget *button,BookmarkWindow *bwin);
void on_bookmark_go_button_clicked(GtkButton *button,BookmarkWindow *bwin);
void on_bookmark_remove_button_clicked(GtkWidget *button,BookmarkWindow *bwin);
void export_bookmarks(GtkButton *button,BookmarkWindow *bwin);
/* Callbacks from widgets*/
void on_bookmark_ctree_select_row(GtkWidget *ctree,GtkCTreeNode *node,gint col,BookmarkWindow *bwin);
void on_bookmark_ctree_unselect_row(GtkWidget *ctree,GtkCTreeNode *node,gint col,BookmarkWindow *bwin);
void on_bookmark_ctree_move(GtkWidget *ctree,GtkCTreeNode *node,GtkCTreeNode *parent,GtkCTreeNode *sibling,BookmarkWindow *bwin);
void move_folder(GNode *old_node, GNode *new_parent_node);
void print_bookmarks ();
void print_node_data (GNode *node,FILE *file);
void clear_entries(BookmarkWindow *bwin);
void close_bookmark_window(BookmarkWindow *bwin);
gboolean url_exists(BookmarkData *data);
/* Bookmarks Functions*/
void initialize_bookmark(GtkWidget *embed)
{
minEmbed= GTK_MOZ_EMBED(embed);
}
/* verify if there is a bookmark file */
void open_bookmark()
{
gchar* file = g_strconcat(g_get_home_dir(),"/.Minimo/bookmarks",NULL);
if (!(g_file_test(file,G_FILE_TEST_EXISTS)))
{
bookmark_file = fopen(file,"w+");
fprintf(bookmark_file, "Bookmarks\n");
fclose(bookmark_file);
open_bookmark();
}
else
{
bookmark_file = fopen(file,"r");
show_bookmark();
}
}
/* Create bookmarks manager window */
void show_bookmark()
{
BookmarkWindow *bwin;
bwin = g_new0(BookmarkWindow,1);
// minEmbed= GTK_MOZ_EMBED(embed);
bwin->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_object_set_data(G_OBJECT(bwin->window),"window",bwin->window);
gtk_window_set_title(GTK_WINDOW(bwin->window),"Bookmarks");
gtk_widget_set_usize(bwin->window,230,350);
gtk_window_set_resizable(GTK_WINDOW(bwin->window),FALSE);
gtk_window_set_position (GTK_WINDOW(bwin->window),GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_set_modal (GTK_WINDOW (bwin->window), TRUE);
gtk_window_set_keep_above(GTK_WINDOW (bwin->window), TRUE);
bwin->vbox1 = gtk_vbox_new(FALSE,0);
gtk_widget_show(bwin->vbox1);
gtk_container_add(GTK_CONTAINER(bwin->window),bwin->vbox1);
bwin->scrolled_window = gtk_scrolled_window_new(NULL,NULL);
gtk_widget_show(bwin->scrolled_window);
gtk_box_pack_start(GTK_BOX(bwin->vbox1),bwin->scrolled_window,TRUE,TRUE,0);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(bwin->scrolled_window),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
gchar *titles[] = {("Name"),("URL")};
gchar *menur[] = {"Bookmarks",""};
bwin->menu_node_data = g_new0(BookmarkData,1);
bwin->menu_node_data->label = g_strdup("Bookmarks");
bwin->menu_node_data->url = NULL;
bookmarks= g_node_new(bwin->menu_node_data);
bwin->parent_node= bookmarks;
read_bookmark();
/* mount the bookmark ctree */
bwin->ctree = gtk_ctree_new_with_titles(2,0,titles);
gtk_container_add(GTK_CONTAINER(bwin->scrolled_window),bwin->ctree);
gtk_clist_set_column_width(GTK_CLIST(bwin->ctree),0,150);
gtk_clist_set_column_width(GTK_CLIST(bwin->ctree),1,150);
gtk_clist_column_titles_show(GTK_CLIST(bwin->ctree));
gtk_clist_set_reorderable(GTK_CLIST(bwin->ctree),TRUE);
gtk_clist_set_auto_sort(GTK_CLIST(bwin->ctree),TRUE);
bwin->menu_node = gtk_ctree_insert_node(GTK_CTREE(bwin->ctree),NULL,NULL,menur,0,NULL,NULL,NULL,NULL,FALSE,TRUE);
gtk_ctree_node_set_row_data(GTK_CTREE(bwin->ctree),bwin->menu_node,bwin->menu_node_data);
gtk_ctree_node_set_selectable(GTK_CTREE(bwin->ctree),bwin->menu_node,FALSE);
bwin->ctree_data.ctree = bwin->ctree;
/* show bookmark ctree */
if (bookmarks != NULL)
{
bwin->ctree_data.parent = bwin->menu_node;
g_node_children_foreach(bookmarks,G_TRAVERSE_ALL,(GNodeForeachFunc)generate_bookmark_ctree,&bwin->ctree_data);
}
gtk_widget_show(bwin->ctree);
g_signal_connect(G_OBJECT(bwin->ctree),"tree_select_row",G_CALLBACK(on_bookmark_ctree_select_row),bwin);
g_signal_connect(G_OBJECT(bwin->ctree),"tree_unselect_row",G_CALLBACK(on_bookmark_ctree_unselect_row),bwin);
g_signal_connect(G_OBJECT(bwin->ctree),"tree_move",G_CALLBACK(on_bookmark_ctree_move),bwin);
/* hbox1: name label, name entry, url label, url entry and add button */
bwin->hbox1 = gtk_hbox_new(FALSE,0);
gtk_widget_show(bwin->hbox1);
gtk_box_pack_start(GTK_BOX(bwin->vbox1),bwin->hbox1,FALSE,FALSE,0);
/* name label */
bwin->text_label = gtk_label_new("Name ");
gtk_widget_show(bwin->text_label);
gtk_box_pack_start(GTK_BOX(bwin->hbox1),bwin->text_label,FALSE,FALSE,0);
/* name entry */
bwin->text_entry = gtk_entry_new();
gtk_widget_show(bwin->text_entry);
gtk_box_pack_start(GTK_BOX(bwin->hbox1),bwin->text_entry,TRUE,TRUE,0);
/* url label */
bwin->url_label = gtk_label_new(" URL ");
gtk_widget_show(bwin->url_label);
gtk_box_pack_start(GTK_BOX(bwin->hbox1),bwin->url_label,FALSE,FALSE,2);
/* url entry */
bwin->url_entry = gtk_entry_new();
gtk_widget_show(bwin->url_entry);
gtk_box_pack_start(GTK_BOX(bwin->hbox1),bwin->url_entry,TRUE,TRUE,0);
gtk_entry_set_text(GTK_ENTRY(bwin->url_entry)," ");
/* hbox 2: add folder button and folder name entry */
bwin->hbox2 = gtk_hbox_new(FALSE,0);
gtk_widget_show(bwin->hbox2);
gtk_box_pack_start(GTK_BOX(bwin->vbox1),bwin->hbox2,FALSE,FALSE,0);
/* folder name label */
bwin->text_label = gtk_label_new("Folder ");
gtk_widget_show(bwin->text_label);
gtk_box_pack_start(GTK_BOX(bwin->hbox2),bwin->text_label,FALSE,FALSE,0);
/* folder name entry */
bwin->folder_entry = gtk_entry_new();
gtk_widget_show(bwin->folder_entry);
gtk_box_pack_start(GTK_BOX(bwin->hbox2),bwin->folder_entry,TRUE,TRUE,0);
/* add button */
bwin->add_button = gtk_button_new_with_label("Add");
gtk_widget_show(bwin->add_button);
gtk_box_pack_start(GTK_BOX(bwin->hbox2),bwin->add_button,FALSE,FALSE,0);
g_signal_connect(G_OBJECT(bwin->add_button),"clicked",G_CALLBACK(on_bookmark_add_button_clicked),bwin);
/* edit button */
bwin->edit_button = gtk_button_new_with_label("Edit");
gtk_widget_show(bwin->edit_button);
gtk_box_pack_start(GTK_BOX(bwin->hbox2),bwin->edit_button,FALSE,FALSE,0);
g_signal_connect(G_OBJECT(bwin->edit_button),"clicked",G_CALLBACK(on_bookmark_edit_button_clicked),bwin);
/* hbox 3: go, ok, remove buttons */
bwin->hbox3 = gtk_hbox_new(FALSE,0);
gtk_widget_show(bwin->hbox3);
gtk_box_pack_start(GTK_BOX(bwin->vbox1),bwin->hbox3,FALSE,FALSE,0);
/* go button */
bwin->go_button = gtk_button_new_with_label("Go");
gtk_widget_show(bwin->go_button);
gtk_box_pack_start(GTK_BOX(bwin->hbox3),bwin->go_button,FALSE,FALSE,0);
g_signal_connect(G_OBJECT(bwin->go_button),"clicked",G_CALLBACK(on_bookmark_go_button_clicked),bwin);
/* ok button */
bwin->ok_button = gtk_button_new_with_label("Ok");
gtk_widget_show(bwin->ok_button);
gtk_box_pack_start(GTK_BOX(bwin->hbox3),bwin->ok_button,FALSE,FALSE,0);
g_signal_connect(G_OBJECT(bwin->ok_button),"clicked",G_CALLBACK(on_bookmark_ok_button_clicked),bwin);
/* remove button */
bwin->remove_button = gtk_button_new_with_label("Remove");
gtk_widget_show(bwin->remove_button);
gtk_box_pack_start(GTK_BOX(bwin->hbox3),bwin->remove_button,FALSE,FALSE,0);
g_signal_connect(G_OBJECT(bwin->remove_button),"clicked",G_CALLBACK(on_bookmark_remove_button_clicked),bwin);
/* cancel button*/
bwin->cancel_button = gtk_button_new_with_label("Cancel");
gtk_widget_show(bwin->cancel_button);
gtk_box_pack_start(GTK_BOX(bwin->hbox3),bwin->cancel_button,FALSE,FALSE,0);
g_signal_connect(G_OBJECT(bwin->cancel_button),"clicked",G_CALLBACK(on_bookmark_cancel_button_clicked),bwin);
gtk_widget_show(bwin->window);
}
/* read bookmarks */
void read_bookmark()
{
gchar *line;
BookmarkData *data;
GNode *parent;
line = (gchar *)g_malloc(1024);
parent= bookmarks;
while(fgets(line,1023,bookmark_file)!= NULL)
{
line = g_strstrip(line);
if (g_strncasecmp(line,"folder",6) == 0)
{
data = g_new0(BookmarkData,1);
data->label = g_strdup(line+7);
data->url = " ";
parent= g_node_append_data(parent, data);
continue;
}
if (g_strncasecmp(line,"url",3) == 0)
{
gchar **temp;
data = g_new0(BookmarkData,1);
temp = g_strsplit(line+4," ",2);
data->url = g_strdup(temp[0]);
if (temp[1] != NULL)
data->label = g_strdup(temp[1]);
else
data->label = g_strdup(temp[0]);
g_strfreev(temp);
g_node_append_data(parent,data);
continue;
}
if (g_strncasecmp(line,"/folder",7) == 0)
{
parent= parent->parent;
continue;
}
}
g_free(line);
}
/* generate bookmark ctree */
void generate_bookmark_ctree(GNode *node, BookmarkCTreeData *ctree_data)
{
BookmarkData *data;
gchar *ctree_entry[2];
GtkCTreeNode *ctree_node;
data= (BookmarkData*) node->data;
ctree_entry[0] = data->label;
ctree_entry[1] = data->url;
/* it's a folder */
if (g_ascii_strcasecmp(data->url," ") == 0)
{
BookmarkCTreeData new_ctree_data;
ctree_node = gtk_ctree_insert_node(GTK_CTREE(ctree_data->ctree),ctree_data->parent,NULL,ctree_entry,0,NULL,NULL,NULL,NULL,FALSE,TRUE);
new_ctree_data.ctree = ctree_data->ctree;
new_ctree_data.parent = ctree_node;
g_node_children_foreach(node,G_TRAVERSE_ALL,(GNodeForeachFunc)generate_bookmark_ctree,&new_ctree_data);
}/* it's a url */
else
ctree_node = gtk_ctree_insert_node(GTK_CTREE(ctree_data->ctree),ctree_data->parent,NULL,ctree_entry,0,NULL,NULL,NULL,NULL,TRUE,TRUE);
gtk_ctree_node_set_row_data(GTK_CTREE(ctree_data->ctree),ctree_node,data);
}
/* get selected data */
void on_bookmark_ctree_select_row(GtkWidget *ctree,GtkCTreeNode *node,gint col,BookmarkWindow *bwin)
{
BookmarkData *bmark;
bmark = (BookmarkData*) gtk_ctree_node_get_row_data(GTK_CTREE(bwin->ctree), node);
if (g_ascii_strcasecmp(bmark->url," ") == 0)
gtk_entry_set_text(GTK_ENTRY(bwin->folder_entry), bmark->label);
else
{
gtk_entry_set_text(GTK_ENTRY(bwin->text_entry), bmark->label);
gtk_entry_set_text(GTK_ENTRY(bwin->url_entry), bmark->url);
}
bwin->temp_node= g_node_find(bookmarks,G_IN_ORDER,G_TRAVERSE_ALL,bmark);
if (G_NODE_IS_LEAF(bwin->temp_node))
{
bwin->parent_node= bwin->temp_node->parent;
bwin->menu_node= node;
}
else
{
bwin->parent_node= bwin->temp_node;
bwin->menu_node= node;
}
}
/* there isn't a selected raw on ctree */
void on_bookmark_ctree_unselect_row(GtkWidget *ctree,GtkCTreeNode *node,gint col,BookmarkWindow *bwin)
{
bwin->menu_node= gtk_ctree_node_nth(GTK_CTREE(bwin->ctree),0);
gtk_ctree_unselect_recursive(GTK_CTREE(bwin->ctree),gtk_ctree_node_nth (GTK_CTREE(bwin->ctree),0));
gtk_entry_set_text(GTK_ENTRY(bwin->text_entry),"");
gtk_entry_set_text(GTK_ENTRY(bwin->url_entry)," ");
gtk_entry_set_text(GTK_ENTRY(bwin->folder_entry),"");
}
/* move a node */
void on_bookmark_ctree_move(GtkWidget *ctree,GtkCTreeNode *node,GtkCTreeNode *parent,GtkCTreeNode *sibling,BookmarkWindow *bwin)
{
BookmarkData *data, *parent_data;
GNode *menu_node, *old_node;
data= (BookmarkData *) gtk_ctree_node_get_row_data(GTK_CTREE(ctree),node);
if (parent== NULL) return;
old_node= g_node_find(bookmarks,G_IN_ORDER,G_TRAVERSE_ALL,data);
parent_data= (BookmarkData *) gtk_ctree_node_get_row_data(GTK_CTREE(ctree),parent);
menu_node= g_node_find(bookmarks, G_IN_ORDER, G_TRAVERSE_ALL, parent_data);
if (old_node->children!= NULL)
move_folder(old_node,menu_node);
else
g_node_append_data(menu_node,old_node->data);
g_node_destroy(old_node);
}
/* move a folder and its contents */
void move_folder(GNode *old_node, GNode *new_parent_node)
{
if (old_node== NULL) return;
else if (old_node->children!= NULL)
{
new_parent_node= g_node_append_data(new_parent_node,old_node->data);
move_folder(old_node->children,new_parent_node);
}
else if (old_node->children== NULL)
{
g_node_append_data(new_parent_node,old_node->data);
move_folder(old_node->next,new_parent_node);
}
}
/* add a bookmark */
void on_bookmark_add_button_clicked(GtkWidget *button,BookmarkWindow *bwin)
{
BookmarkData *data;
gchar *ctree_entry[2];
GtkCTreeNode *node;
data = g_new0(BookmarkData,1);
node= NULL;
data->url = ctree_entry[1] = g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->url_entry)));
if (((GtkCTreeRow *)(((GList *)(bwin->menu_node))->data))->is_leaf)
bwin->menu_node= ((GtkCTreeRow *)(((GList *)(bwin->menu_node))->data))->parent;
/* it's a url */
if (g_ascii_strcasecmp(data->url," ")!=0)
{
data->label = ctree_entry[0] = g_strstrip(g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->text_entry))));
node = gtk_ctree_insert_node(GTK_CTREE(bwin->ctree),bwin->menu_node,NULL,ctree_entry,0,NULL,NULL,NULL,NULL,TRUE,FALSE);
}
else /* it's a folder */
{
data->label = ctree_entry[0] = g_strstrip(g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->folder_entry))));
if (g_ascii_strcasecmp(data->label,"")==0)
data->label = ctree_entry[0] = g_strstrip(g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->text_entry))));
node = gtk_ctree_insert_node(GTK_CTREE(bwin->ctree),bwin->menu_node,NULL,ctree_entry,0,NULL,NULL,NULL,NULL,FALSE,TRUE);
}
gtk_ctree_node_set_row_data(GTK_CTREE(bwin->ctree),node,data);
g_node_append_data(bwin->parent_node,data);
clear_entries(bwin);
}
/* add a folder */
void on_bookmark_edit_button_clicked(GtkWidget *button,BookmarkWindow *bwin)
{
BookmarkData *data;
gchar *ctree_entry[2];
GNode *parent;
data = g_new0(BookmarkData,1);
data->label = g_strstrip(g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->text_entry))));
data->url = ctree_entry[1]= g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->url_entry)));
/* it's a folder */
if (g_ascii_strcasecmp(data->url," ")==0)
{
data->label = ctree_entry[0] = g_strstrip(g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->folder_entry))));
if (g_ascii_strcasecmp(data->label,"")==0)
data->label = ctree_entry[0] = g_strstrip(g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->text_entry))));
gtk_ctree_set_node_info(GTK_CTREE(bwin->ctree),bwin->menu_node,ctree_entry[0],0,NULL,NULL,NULL,NULL,FALSE,TRUE);
}
else /* it's a url */
{
data->label = ctree_entry[0] = g_strstrip(g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->text_entry))));
gtk_ctree_set_node_info(GTK_CTREE(bwin->ctree),bwin->menu_node,ctree_entry[0],0,NULL,NULL,NULL,NULL,TRUE,FALSE);
}
gtk_ctree_node_set_row_data(GTK_CTREE(bwin->ctree),bwin->menu_node,data);
parent= g_node_append_data(bwin->temp_node->parent,data);
if (bwin->temp_node->children!= NULL)
move_folder(bwin->temp_node->children,parent);
g_node_destroy(bwin->temp_node);
clear_entries(bwin);
}
/* a button to go to a selected url */
void on_bookmark_go_button_clicked(GtkButton *button,BookmarkWindow *bwin)
{
GList *selection;
gchar *url;
/* case there isn't a selected url */
if (!(selection = GTK_CLIST(bwin->ctree)->selection)) return;
url= g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->url_entry)));
/* it isn't a folder */
if (g_ascii_strcasecmp(url," ") != 0)
{
gtk_moz_embed_stop_load(GTK_MOZ_EMBED(minEmbed));
gtk_moz_embed_load_url(GTK_MOZ_EMBED(minEmbed), url);
}
clear_entries(bwin);
}
/* accept new edit configurations and update bookmark menu */
void on_bookmark_ok_button_clicked(GtkWidget *button,BookmarkWindow *bwin)
{
print_bookmarks();
close_bookmark_window(bwin);
}
/* cancel user's operations */
void on_bookmark_cancel_button_clicked(GtkWidget *button,BookmarkWindow *bwin)
{
close_bookmark_window(bwin);
}
/* remove a selected bookmark */
void on_bookmark_remove_button_clicked(GtkWidget *button,BookmarkWindow *bwin)
{
GList *selection;
GtkCTreeNode *node;
BookmarkData *data;
GNode *menu_node;
/* case there isn't a selected folder, url or separator to be removed */
if (!(selection = GTK_CLIST(bwin->ctree)->selection)) {
return;
}
node = (GtkCTreeNode*) g_list_nth_data(selection,0);
data = g_new0(BookmarkData,1);
data= (BookmarkData*) gtk_ctree_node_get_row_data(GTK_CTREE(bwin->ctree),node);
gtk_ctree_remove_node(GTK_CTREE(bwin->ctree),node);
menu_node= g_node_find(bookmarks, G_IN_ORDER, G_TRAVERSE_ALL, data);
g_node_destroy(menu_node);
clear_entries(bwin);
}
/* write bookmarks on file */
void print_bookmarks ()
{
char* file = g_strconcat(g_get_home_dir(),"/.Minimo/bookmarks",NULL);
fclose(bookmark_file);
bookmark_file = fopen(file,"w");
if (bookmarks != NULL)
g_node_children_foreach(bookmarks,G_TRAVERSE_ALL,(GNodeForeachFunc)print_node_data,bookmark_file);
}
/* print node data on file */
void print_node_data (GNode *node,FILE *bookmark_file)
{
BookmarkData *data;
data = (BookmarkData*) node->data;
/* it's a url */
if (g_ascii_strcasecmp(data->url," ") != 0)
fprintf(bookmark_file,"url %s %s\n",data->url,data->label);
else /* it's a folder */
{
fprintf(bookmark_file,"folder %s\n",data->label);
g_node_children_foreach(node,G_TRAVERSE_ALL,(GNodeForeachFunc)print_node_data,bookmark_file);
fprintf(bookmark_file,"/folder\n");
}
}
/* clear all the bookmarks entries */
void clear_entries(BookmarkWindow *bwin)
{
bwin->menu_node= gtk_ctree_node_nth(GTK_CTREE(bwin->ctree),0);
bwin->parent_node= g_node_get_root(bookmarks);
gtk_ctree_unselect_recursive(GTK_CTREE(bwin->ctree),gtk_ctree_node_nth (GTK_CTREE(bwin->ctree),0));
gtk_entry_set_text(GTK_ENTRY(bwin->url_entry)," ");
gtk_editable_delete_text(GTK_EDITABLE(bwin->text_entry),0 ,-1);
gtk_editable_delete_text(GTK_EDITABLE(bwin->folder_entry),0 ,-1);
}
/* close the bookmark window */
void close_bookmark_window(BookmarkWindow *bwin)
{
/* close bookmark file*/
fclose(bookmark_file);
gtk_widget_destroy(bwin->window);
g_free(bwin);
}
/* export bookmarks callback */
void export_bookmarks(GtkButton *button,BookmarkWindow *bwin)
{
}
/* the menu button to add a bookmark */
void add_bookmark_cb(GtkWidget *menu_item,GtkWidget *embed)
{
gchar *url;
gchar *title;
char* file_path = g_strconcat(g_get_home_dir(),"/.Minimo/bookmarks",NULL);
if (!file_path)
return;
if (!(bookmark_file = fopen(file_path,"a+"))) return;
g_free(file_path);
if (!(url= gtk_moz_embed_get_location(minEmbed))) return;
/* doesn't add an empty url or about:blank */
if ((g_ascii_strcasecmp(url," ") != 0) && (g_ascii_strcasecmp(url,"about:blank") != 0))
{
title= gtk_moz_embed_get_title (minEmbed);
fprintf(bookmark_file, "url %s %s\n", url, title);
}
fclose(bookmark_file);
}

Просмотреть файл

@ -1,343 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "minimo_types.h"
#include "preference.h"
#include "gtkmozembed.h"
/* History callbacks */
void view_history(GtkWidget *embed);
static void clear_history(GtkWidget *b, HistoryWindow *hwin);
static void close_history_win(GtkWidget *button, HistoryWindow *hwin);
static void on_history_clist_button_go_cb(GtkWidget *button, HistoryWindow *hwin);
static void remove_from_history(GtkWidget *button, HistoryWindow *hwin);
static void remove_from_list(gchar *text);
static void on_history_destroy(GtkWidget *window);
static void on_search_button_cb(GtkWidget *button, HistoryWindow *hwin);
/* History functions*/
void add_to_history(const gchar *url);
void write_history(void);
void read_history(void);
/* Add an URL into History file */
void add_to_history(const gchar *url) {
GSList *list;
gint equals = 0;
read_history();
if (!url || url == NULL) return ;
if (!g_strncasecmp(url,"about:",6) || !g_strcasecmp(url,"")) return;
while (prot == 1) {
}
prot = 1;
for (list = history; list ; list = list->next) {
if (g_strcasecmp((const gchar*)list->data,url) == 0){
equals = 1;
prot = 0;
}
}
if (equals == 0) {
history = g_slist_prepend(history,g_strdup(url));
write_history();
}
prot = 0;
}
/* Create and show the History Window*/
void view_history(GtkWidget *embed) {
HistoryWindow *hwin;
GSList *list;
GtkWidget *image;
hwin = g_new0(HistoryWindow,1);
read_history();
hwin->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(hwin->window),"destroy", G_CALLBACK(on_history_destroy), NULL);
hwin->title = g_strdup_printf(("Minimo - History (%d) items"), g_slist_length(history));
gtk_window_set_title(GTK_WINDOW(hwin->window),hwin->title);
gtk_widget_set_usize(hwin->window,230,300);
gtk_window_set_resizable(GTK_WINDOW(hwin->window),FALSE);
gtk_window_set_position (GTK_WINDOW(hwin->window),GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_set_modal (GTK_WINDOW (hwin->window), TRUE);
gtk_window_set_keep_above(GTK_WINDOW (hwin->window), TRUE);
g_free(hwin->title);
hwin->vbox = gtk_vbox_new(FALSE,5);
gtk_container_add(GTK_CONTAINER(hwin->window),hwin->vbox);
hwin->scrolled_window = gtk_scrolled_window_new(NULL,NULL);
gtk_box_pack_start(GTK_BOX(hwin->vbox),hwin->scrolled_window,TRUE,TRUE,0);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(hwin->scrolled_window),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC);
hwin->clist = gtk_clist_new(1);
gtk_container_add(GTK_CONTAINER(hwin->scrolled_window),hwin->clist);
hwin->search_label = gtk_label_new("Search: ");
hwin->search_entry = gtk_entry_new();
hwin->search_box = gtk_hbox_new(0,0);
image = gtk_image_new_from_stock (GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR);
hwin->search_button = gtk_button_new();
gtk_container_add(GTK_CONTAINER(hwin->search_button),image);
gtk_tooltips_set_tip (gtk_tooltips_new (), GTK_WIDGET (hwin->search_button), "Find on history", NULL);
image = gtk_image_new_from_stock (GTK_STOCK_YES, GTK_ICON_SIZE_SMALL_TOOLBAR);
hwin->go_button = gtk_button_new ();
gtk_container_add(GTK_CONTAINER(hwin->go_button),image);
gtk_tooltips_set_tip (gtk_tooltips_new (), GTK_WIDGET (hwin->go_button), "Go to", NULL);
hwin->embed = embed;
g_signal_connect(G_OBJECT(hwin->search_button), "clicked", G_CALLBACK(on_search_button_cb), hwin);
g_signal_connect(G_OBJECT(hwin->go_button), "clicked", G_CALLBACK(on_history_clist_button_go_cb), hwin);
gtk_box_pack_start(GTK_BOX(hwin->search_box), hwin->search_label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hwin->search_box), hwin->search_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hwin->search_box), hwin->search_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hwin->search_box), hwin->go_button, FALSE, FALSE, 0);
hwin->remove = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
g_signal_connect(G_OBJECT(hwin->remove), "clicked", G_CALLBACK(remove_from_history), hwin);
hwin->clear = gtk_button_new_from_stock(GTK_STOCK_CLEAR);
g_signal_connect(G_OBJECT(hwin->clear), "clicked", G_CALLBACK(clear_history), hwin);
hwin->close = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
g_signal_connect(G_OBJECT(hwin->close), "clicked", G_CALLBACK(close_history_win), hwin);
hwin->btnbox = gtk_hbox_new(0,0);
gtk_box_pack_start(GTK_BOX(hwin->vbox), hwin->search_box, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hwin->vbox), hwin->btnbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hwin->btnbox), hwin->remove, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hwin->btnbox), hwin->clear, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hwin->btnbox), hwin->close, TRUE, TRUE, 0);
while (prot == 1) {
}
prot = 1;
for (list = history; list ; list = list->next) {
gchar *clist_entry[1];
clist_entry[0] = (gchar *)list->data;
gtk_clist_append(GTK_CLIST(hwin->clist),clist_entry);
}
prot = 0;
gtk_widget_show_all(hwin->window);
}
/* Go to URL selected in the history list */
static void on_history_clist_button_go_cb(GtkWidget *button, HistoryWindow *hwin) {
GList *selection;
gchar *location;
gint row;
selection = GTK_CLIST(hwin->clist)->selection;
if (g_list_length(selection) == 0) return;
row = (gint)g_list_nth_data(selection,0);
gtk_clist_get_text(GTK_CLIST(hwin->clist),row,0,&location);
gtk_moz_embed_stop_load(GTK_MOZ_EMBED(hwin->embed));
gtk_moz_embed_load_url(GTK_MOZ_EMBED(hwin->embed), location);
}
/* Close history window */
static void close_history_win(GtkWidget *button, HistoryWindow *hwin) {
gtk_widget_destroy(hwin->window);
}
/* Remove an URL from history list */
static void remove_from_history(GtkWidget *button, HistoryWindow *hwin) {
GList *selection = GTK_CLIST(hwin->clist)->selection;
gchar *text;
gint row;
if (selection == NULL) return;
gtk_clist_freeze(GTK_CLIST(hwin->clist));
row = (gint) g_list_nth_data(selection,0);
gtk_clist_get_text(GTK_CLIST(hwin->clist), row, 0, &text);
remove_from_list(text);
gtk_clist_remove(GTK_CLIST(hwin->clist), row);
gtk_clist_thaw(GTK_CLIST(hwin->clist));
hwin->title = g_strdup_printf(("Minimo - History (%d) items"), g_slist_length(history));
gtk_window_set_title(GTK_WINDOW(hwin->window),hwin->title);
}
/* Remove an URL from history file */
static void remove_from_list(gchar *text) {
GSList *l;
for (l = history; l ; l = l->next) {
gchar *data = (gchar *)l->data;
if (!strcmp(text,data)) {
history = g_slist_remove(history,data);
return;
}
}
}
/* Remove all URL from history list */
static void clear_history(GtkWidget *b, HistoryWindow *hwin) {
gtk_clist_clear(GTK_CLIST(hwin->clist));
g_slist_free(history);
history = NULL;
gtk_window_set_title(GTK_WINDOW(hwin->window),"Minimo - History (0) items");
}
/* Search an URL in the history list */
static void on_search_button_cb(GtkWidget *button, HistoryWindow *hwin) {
gint rows, i;
G_CONST_RETURN gchar *search_text;
gint search_pos = 0;
rows = GTK_CLIST(hwin->clist)->rows;
if (!rows) return;
search_text = gtk_entry_get_text(GTK_ENTRY(hwin->search_entry));
if (!search_text || !strcmp(search_text,"")) return;
if (search_pos >= rows) search_pos = 0;
if (search_pos) search_pos++;
for (i = search_pos; i < rows ; i++) {
gchar *tmp, *tmp2 = NULL;
gtk_clist_get_text(GTK_CLIST(hwin->clist), i, 0, &tmp);
g_return_if_fail(tmp != NULL);
tmp2 = strstr(tmp,search_text);
if (tmp2 != NULL) {
gtk_clist_moveto(GTK_CLIST(hwin->clist), i, 0, 0.0, 0.0);
gtk_clist_select_row(GTK_CLIST(hwin->clist), i, 0);
GTK_CLIST(hwin->clist)->focus_row = i;
search_pos = i;
}
}
}
/* Close history window */
static void on_history_destroy(GtkWidget *window) {
write_history();
}
/* Read the history file */
void read_history(void) {
gchar *line;
gchar *url;
gchar *user_home = NULL;
FILE *g_history_file = NULL;
gchar *g_history_file_name = NULL;
history = NULL;
user_home = g_strconcat(g_get_home_dir(),NULL);
g_history_file_name = g_strconcat(user_home,"/.Minimo/history",NULL);
if ((g_history_file = fopen(g_history_file_name,"r"))!= NULL)
{
fclose(g_history_file);
g_history_file = fopen(g_history_file_name,"r+");
}
else
g_history_file = fopen(g_history_file_name,"w+");
if (g_history_file == NULL) {
printf("No History file to read!\n");
}
line = (gchar *)g_malloc(1024);
while(fgets(line,1024,g_history_file) != NULL) {
line[strlen(line)-1] = '\0';
url = g_strdup(line);
history = g_slist_append(history,url);
}
fclose(g_history_file);
g_free(line);
}
/* Write the history file */
void write_history(void) {
GSList *list;
gchar *user_home= NULL;
FILE *g_history_file = NULL;
gchar *g_history_file_name = NULL;
user_home = g_strconcat(g_get_home_dir(),NULL);
g_history_file_name = g_strconcat(user_home,"/.Minimo/history",NULL);
g_history_file = fopen(g_history_file_name,"w");
if (g_history_file == NULL) {
printf("Couldn't open history file for writing!\n");
return;
}
for (list = history; list ; list = list->next) {
fprintf(g_history_file,"%s\n",(gchar *)(list->data));
}
fflush(g_history_file);
fclose(g_history_file);
g_free(g_history_file_name);
}

Просмотреть файл

@ -1,349 +0,0 @@
/* XPM */
static char *back_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 16 29 1",
" c black",
". c #2D2D2D",
"X c #3B5035",
"o c #3C5235",
"O c #415639",
"+ c #4A6342",
"@ c #5B7950",
"# c #678C63",
"$ c #698267",
"% c #7EAB78",
"& c #A9C4A7",
"* c #AAC5A8",
"= c #AAC7A8",
"- c #ADC6AB",
"; c #AEC7AC",
": c #ADC8AB",
"> c #B0C7AE",
", c #B0C9B0",
"< c #B1C9B0",
"1 c #B2C9B0",
"2 c #B3CAB1",
"3 c #B4CBB2",
"4 c #B5CEB5",
"5 c #B9CEB7",
"6 c #BBD0B9",
"7 c #BAD1BA",
"8 c #CDDECB",
"9 c #CFDFCC",
"0 c None",
/* pixels */
"0000000000000000",
"0000000 00000000",
"000000 00000000",
"00000 9 00000000",
"0000 82 00",
"000 83447462% 00",
"00 8=22--=;=$ 00",
"0.9:>--=---:# 00",
"00 X@@@@@@@@+ 00",
"000 X@@XXXXXO 00",
"0000 o@ 00",
"00000 X 00000000",
"000000 00000000",
"0000000 00000000",
"0000000000000000",
"0000000000000000"
};
/* XPM */
static char *forward_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 16 35 1",
" c black",
". c #0F1308",
"X c #445B2C",
"o c #43543D",
"O c #4D6146",
"+ c #506B46",
"@ c #5B7950",
"# c #65815C",
"$ c #6C8562",
"% c #6B9060",
"& c #709867",
"* c #7F9F76",
"= c #77A16E",
"- c #8DB389",
"; c #A6BFA0",
": c #A4C3A2",
"> c #A5C4A3",
", c #A8C6A5",
"< c #A9C7A6",
"1 c #AAC6A7",
"2 c #A8C7A8",
"3 c #AAC7A8",
"4 c #ABC7A8",
"5 c #ABC7AA",
"6 c #AEC5A8",
"7 c #ACC8A9",
"8 c #ADC8AD",
"9 c #AEC8AD",
"0 c #AFC8AD",
"q c #B2CBB0",
"w c #BDD3B8",
"e c #BFD4BB",
"r c #C1D6BD",
"t c #C2D7BE",
"y c None",
/* pixels */
"yyyyyyyyyyyyyyyy",
"yyyyyyyy yyyyyyy",
"yyyyyyyy yyyyyy",
"yyyyyyyy = yyyyy",
"yy 4& yyyy",
"yy rwetttq3&.yyy",
"yy 695,,,93>* yy",
"yy ;5,,14340>% y",
"yy $@@@@@@@@X yy",
"yy #+++++@@X yyy",
"yy @X yyyy",
"yyyyyyyy X yyyyy",
"yyyyyyyy yyyyyy",
"yyyyyyyy yyyyyyy",
"yyyyyyyyyyyyyyyy",
"yyyyyyyyyyyyyyyy"
};
/* XPM */
static char *reload_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 16 16 1",
" c black",
". c #35431B",
"X c #50652A",
"o c #6B7957",
"O c #728E3A",
"+ c #7C9B40",
"@ c #9BB46F",
"# c #9CB476",
"$ c #9FA498",
"% c #A8AFA0",
"& c #B1C491",
"* c #BAD09D",
"= c #BDD2A1",
"- c #CCDCB8",
"; c #DEE6D6",
": c None",
/* pixels */
"::::: ::::::::::",
"::::: :::::::::",
":: % ::::::::",
": ;-=* :::::::",
": $@++O :::::::",
": &X . ::::::::",
": # : ::: :::",
": o : ::::: ::",
": ::::: : ; ::",
":: ::: : + ::",
"::::::: ; X+ ::",
":::::: ;+++X ::",
":::::: #+XX ::",
"::::::: # :::",
":::::::: ::::::",
"::::::::: ::::::"
};
/* XPM */
static char *home_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 16 65 1",
" c black",
". c #0B0E09",
"X c #111111",
"o c gray8",
"O c #191919",
"+ c #3D1B14",
"@ c gray18",
"# c #273122",
"$ c #333D2F",
"% c #323232",
"& c #343434",
"* c #393939",
"= c #3F3F3F",
"- c #354031",
"; c #364530",
": c #431D15",
"> c #50231A",
", c #53251B",
"< c #57261D",
"1 c #612B20",
"2 c #763E2F",
"3 c #424A40",
"4 c gray29",
"5 c #465541",
"6 c #495545",
"7 c #5B5B5B",
"8 c #566252",
"9 c #586455",
"0 c #5B6657",
"q c #606060",
"w c #656565",
"e c gray40",
"r c #A54937",
"t c #A95849",
"y c gray52",
"u c #8B8B8B",
"i c #979797",
"p c #9B9B9B",
"a c #AAAAAA",
"s c #B4B4B4",
"d c gray71",
"f c #B6B6B6",
"g c #BBBBBB",
"h c #BCBCBC",
"j c gray77",
"k c gray79",
"l c #CACACA",
"z c gray80",
"x c #CECECE",
"c c gray81",
"v c #D2D2D2",
"b c LightGray",
"n c gray86",
"m c gainsboro",
"M c #DFDFDF",
"N c gray88",
"B c #E2E2E2",
"V c #E4E4E4",
"C c gray91",
"Z c #E9E9E9",
"A c #EAEAEA",
"S c gray93",
"D c #EFEFEF",
"F c gray100",
"G c None",
/* pixels */
"GGGGGGGGGGGGGGGG",
"GGG G GGGGGGG",
"GGG t w7 GGGGGG",
"GGG 2 7iAe GGGGG",
"GGG X*ulCjp GGGG",
"GGG 4pAjAlCy GGG",
"GG 4slAlClCxp GG",
"G O AlAxC@3& o G",
"GGG M><+D*F% GGG",
"GGG N,r,S@*@ GGG",
"GGG M,r,Vhmh GGG",
"GGG B,r<ndvs GGG",
"GGG n<<:xhbs GGG",
"G 33005;#.86-$6G",
"G3 66666 6666GG",
"GGGGGGGGGGGGGGGG"
};
/* XPM */
static char * stop_1_xpm[] = {
/* width height colors chars-per-color */
"16 16 5 1",
/* colors */
" s None m none c None",
". c #808080",
"X c red",
"o s iconColor2 m white c white",
"O s iconColor1 m black c black",
/* image */
" ........ ",
" .XXXXXXXX. ",
" .XXXXXXXXXX. ",
" .XXXXXXXXXXXX. ",
".XXXXXXXXXXXXXX.",
".XXoooooXoXXooXO",
".XoXXXoXoXoXoXoO",
".XXoXXoXoXoXooXO",
".XXXoXoXoXoXoXXO",
".XooXXoXXoXXoXXO",
".XXXXXXXXXXXXXXO",
".XXXXXXXXXXXXXXO",
" .XXXXXXXXXXXXO.",
" .XXXXXXXXXXO. ",
" .XXXXXXXXO. ",
" OOOOOOOO. "};
/* XPM */
static char * stop_2_xpm[] = {
/* width height colors chars-per-color */
"16 16 5 1",
/* colors */
" s None m none c None",
". c #808080",
"X c red",
"o s iconColor2 m white c white",
"O s iconColor1 m black c black",
/* image */
" ........ ",
" .XXXXXXXX. ",
" .XXXoXXoXXX. ",
" .XXXXoXoXoXXX. ",
"OXXXXXXoXXoXXXX.",
"OXXXXXXXXXoXXXX.",
"OXXXXXoooooXXXX.",
"OXXXXXXXXXoXXXX.",
"OXXXXXXoooXXXXX.",
"OXXXXXoXXXoXXXX.",
"OXXXXXXoooXXXXX.",
"OXXXXXXXXXXXXXX.",
".OXXXXoooooXXX. ",
" .OXXXXXoXoXX. ",
" .OXXXXXoXX. ",
" .OOOOOOO. "};
/* XPM */
static char * stop_3_xpm[] = {
/* width height colors chars-per-color */
"16 16 5 1",
/* colors */
" s None m none c None",
". c #808080",
"X s iconColor1 m black c black",
"o c red",
"O s iconColor2 m white c white",
/* image */
" .XXXXXXXX ",
" .Xoooooooo. ",
" .Xoooooooooo. ",
".Xoooooooooooo. ",
"Xoooooooooooooo.",
"Xoooooooooooooo.",
"XooOooOooOooOOo.",
"XooOoOoOoOoOooo.",
"XoOOoOoOoOooOoo.",
"XOoOoOoOoOoooOo.",
"XoOOooOoOOOOOoo.",
".oooooooooooooo.",
" .oooooooooooo. ",
" .oooooooooo. ",
" .oooooooo. ",
" ........ "};
/* XPM */
static char * stop_4_xpm[] = {
/* width height colors chars-per-color */
"16 16 5 1",
/* colors */
" s None m none c None",
". c #808080",
"X s iconColor1 m black c black",
"o c red",
"O s iconColor2 m white c white",
/* image */
" .XXXXXXX. ",
" .ooOoooooX. ",
" .ooOoOoooooX. ",
" .oooOOOOOooooX.",
".ooooooooooooooX",
".oooooOOOooooooX",
".ooooOoooOoooooX",
".oooooOOOooooooX",
".ooooOoooooooooX",
".ooooOOOOOoooooX",
".ooooOoooooooooX",
".ooooOooOooooooX",
" .oooOoOoOoooo. ",
" .oooOooOooo. ",
" .oooooooo. ",
" ........ "};

Просмотреть файл

@ -1,22 +0,0 @@
caps
chrome
popuplite
docshell
editor
embedcomponents
gfx_gtk
gklayout
htmlpars
i18n
imglib2
jar50
necko
nsappshell
pipboot
pipnss
pref
uconv
webbrwsr
widget_gtk2
xpconnect
gkplugin

Просмотреть файл

@ -1,908 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "minimo_bookmark.h"
/* Bookmark global variables */
FILE *gBookmarkFilePointer;
gchar *gBookmarkFilePath;
GtkMozEmbed *gBookmarkMozEmbed;
/* initialize the embed variable */
void bookmark_moz_embed_initialize(GtkWidget *embed)
{
gBookmarkMozEmbed= GTK_MOZ_EMBED(embed);
}
/* Create bookmarks manager window */
void bookmark_create_dialog ()
{
BookmarkWindow *bwin;
GtkTreeViewColumn *column1, *column2;
GtkCellRenderer *renderer1,*renderer2;
bookmark_open_file ();
bwin = g_new0(BookmarkWindow,1);
bwin->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_object_set_data(G_OBJECT(bwin->window),"window",bwin->window);
gtk_window_set_title(GTK_WINDOW(bwin->window),"Bookmarks");
gtk_widget_set_usize(bwin->window,230,350);
gtk_window_set_resizable(GTK_WINDOW(bwin->window),FALSE);
gtk_window_set_position (GTK_WINDOW(bwin->window),GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_set_modal (GTK_WINDOW (bwin->window), TRUE);
gtk_window_set_keep_above(GTK_WINDOW (bwin->window), TRUE);
bwin->vbox1 = gtk_vbox_new(FALSE,0);
gtk_widget_show(bwin->vbox1);
gtk_container_add(GTK_CONTAINER(bwin->window),bwin->vbox1);
bwin->hbox4 = gtk_hbox_new(FALSE,0);
gtk_widget_show(bwin->hbox4);
gtk_box_pack_start(GTK_BOX(bwin->vbox1),bwin->hbox4,FALSE,FALSE,0);
bwin->menubar = gtk_menu_bar_new();
bwin->menu_item_tools = gtk_menu_item_new_with_label("Tools");
gtk_menu_bar_append(GTK_MENU_BAR(bwin->menubar), bwin->menu_item_tools);
gtk_box_pack_start(GTK_BOX(bwin->hbox4),bwin->menubar,FALSE,FALSE,0);
gtk_widget_show (bwin->menu_item_tools);
gtk_widget_show (bwin->menubar);
bwin->menu_tools = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(bwin->menu_item_tools),bwin->menu_tools);
gtk_widget_show (bwin->menu_tools);
bwin->menu_import = gtk_menu_item_new_with_label("Import bookmarks");
gtk_menu_bar_append(GTK_MENU(bwin->menu_tools), bwin->menu_import);
gtk_signal_connect (GTK_OBJECT (bwin->menu_import), "activate", GTK_SIGNAL_FUNC(bookmark_import_cb), bwin);
gtk_widget_show (bwin->menu_import);
bwin->menu_export = gtk_menu_item_new_with_label("Export bookmarks");
gtk_menu_bar_append(GTK_MENU(bwin->menu_tools), bwin->menu_export);
gtk_signal_connect (GTK_OBJECT (bwin->menu_export), "activate", GTK_SIGNAL_FUNC(bookmark_export_cb), bwin);
gtk_widget_show (bwin->menu_export);
bwin->scrolled_window = gtk_scrolled_window_new(NULL,NULL);
gtk_widget_show(bwin->scrolled_window);
gtk_box_pack_start(GTK_BOX(bwin->vbox1),bwin->scrolled_window,TRUE,TRUE,0);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(bwin->scrolled_window),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
/* mount the bookmark treeview */
bwin->treev_data = g_new0(BookmarkTreeVData,1);
bwin->treev_data->treeStore = GTK_TREE_MODEL(gtk_tree_store_new(2,G_TYPE_STRING,G_TYPE_STRING));
bwin->treev = gtk_tree_view_new_with_model(GTK_TREE_MODEL(bwin->treev_data->treeStore));
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (bwin->treev), TRUE);
gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (bwin->treev), TRUE);
gtk_tree_view_set_reorderable(GTK_TREE_VIEW (bwin->treev), TRUE);
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW (bwin->treev), TRUE);
gtk_widget_show(bwin->treev);
gtk_container_add(GTK_CONTAINER(bwin->scrolled_window),bwin->treev);
renderer1 = gtk_cell_renderer_text_new();
gtk_cell_renderer_set_fixed_size (renderer1,100,-1);
column1 = gtk_tree_view_column_new_with_attributes("Name", renderer1, "text", 0, NULL);
gtk_tree_view_column_set_resizable (column1, TRUE);
gtk_tree_view_append_column(GTK_TREE_VIEW(bwin->treev),
column1);
gtk_tree_view_set_expander_column(GTK_TREE_VIEW(bwin->treev),column1);
gtk_tree_view_set_search_column (GTK_TREE_VIEW(bwin->treev),0);
renderer2 = gtk_cell_renderer_text_new();
column2 = gtk_tree_view_column_new_with_attributes("URL", renderer2, "text", 1, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(bwin->treev),
column2);
bwin->treev_data->parentIter = NULL;
bookmark_load_from_file(bwin->treev_data);
/* expand the main tree */
gtk_tree_view_expand_row(GTK_TREE_VIEW (bwin->treev),gtk_tree_path_new_from_string("0"),FALSE);
/* set selection mode */
bwin->selection= gtk_tree_view_get_selection(GTK_TREE_VIEW (bwin->treev));
gtk_tree_selection_set_mode (bwin->selection, GTK_SELECTION_SINGLE);
/* set find function */
gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW(bwin->treev),bookmark_search_function,bwin,NULL);
/* set selection signal */
g_signal_connect(bwin->treev,"cursor-changed",G_CALLBACK(bookmark_on_treev_select_row_cb),bwin);
/* hbox1: name label, name entry, url label, url entry and add button */
bwin->hbox1 = gtk_hbox_new(FALSE,0);
gtk_widget_show(bwin->hbox1);
gtk_box_pack_start(GTK_BOX(bwin->vbox1),bwin->hbox1,FALSE,FALSE,0);
/* name label */
bwin->text_label = gtk_label_new("Name ");
gtk_widget_show(bwin->text_label);
gtk_box_pack_start(GTK_BOX(bwin->hbox1),bwin->text_label,FALSE,FALSE,0);
/* name entry */
bwin->text_entry = gtk_entry_new();
gtk_widget_show(bwin->text_entry);
gtk_box_pack_start(GTK_BOX(bwin->hbox1),bwin->text_entry,TRUE,TRUE,0);
/* url label */
bwin->url_label = gtk_label_new(" URL ");
gtk_widget_show(bwin->url_label);
gtk_box_pack_start(GTK_BOX(bwin->hbox1),bwin->url_label,FALSE,FALSE,2);
/* url entry */
bwin->url_entry = gtk_entry_new();
gtk_widget_show(bwin->url_entry);
gtk_box_pack_start(GTK_BOX(bwin->hbox1),bwin->url_entry,TRUE,TRUE,0);
gtk_entry_set_text(GTK_ENTRY(bwin->url_entry),"");
/* hbox 2: add folder button and folder name entry */
bwin->hbox2 = gtk_hbox_new(FALSE,0);
gtk_widget_show(bwin->hbox2);
gtk_box_pack_start(GTK_BOX(bwin->vbox1),bwin->hbox2,FALSE,FALSE,0);
/* folder name label */
bwin->text_label = gtk_label_new("Folder ");
gtk_widget_show(bwin->text_label);
gtk_box_pack_start(GTK_BOX(bwin->hbox2),bwin->text_label,FALSE,FALSE,0);
/* folder name entry */
bwin->folder_entry = gtk_entry_new();
gtk_widget_show(bwin->folder_entry);
gtk_box_pack_start(GTK_BOX(bwin->hbox2),bwin->folder_entry,TRUE,TRUE,0);
/* add button */
bwin->add_button = gtk_button_new_with_label("Add");
gtk_widget_show(bwin->add_button);
gtk_box_pack_start(GTK_BOX(bwin->hbox2),bwin->add_button,FALSE,FALSE,0);
g_signal_connect(G_OBJECT(bwin->add_button),"clicked",G_CALLBACK(bookmark_add_button_cb),bwin);
/* edit button */
bwin->edit_button = gtk_button_new_with_label("Edit");
gtk_widget_show(bwin->edit_button);
gtk_box_pack_start(GTK_BOX(bwin->hbox2),bwin->edit_button,FALSE,FALSE,0);
g_signal_connect(G_OBJECT(bwin->edit_button),"clicked",G_CALLBACK(bookmark_edit_button_cb),bwin);
/* hbox 3: go, ok, remove buttons */
bwin->hbox3 = gtk_hbox_new(FALSE,0);
gtk_widget_show(bwin->hbox3);
gtk_box_pack_start(GTK_BOX(bwin->vbox1),bwin->hbox3,FALSE,FALSE,0);
/* go button */
bwin->go_button = gtk_button_new_with_label("Go");
gtk_widget_show(bwin->go_button);
gtk_box_pack_start(GTK_BOX(bwin->hbox3),bwin->go_button,FALSE,FALSE,0);
g_signal_connect(G_OBJECT(bwin->go_button),"clicked",G_CALLBACK(bookmark_go_button_cb),bwin);
/* ok button */
bwin->ok_button = gtk_button_new_with_label("Ok");
gtk_widget_show(bwin->ok_button);
gtk_box_pack_start(GTK_BOX(bwin->hbox3),bwin->ok_button,FALSE,FALSE,0);
g_signal_connect(G_OBJECT(bwin->ok_button),"clicked",G_CALLBACK(bookmark_ok_button_cb),bwin);
/* remove button */
bwin->remove_button = gtk_button_new_with_label("Remove");
gtk_widget_show(bwin->remove_button);
gtk_box_pack_start(GTK_BOX(bwin->hbox3),bwin->remove_button,FALSE,FALSE,0);
g_signal_connect(G_OBJECT(bwin->remove_button),"clicked",G_CALLBACK(bookmark_remove_button_cb),bwin);
/* cancel button*/
bwin->cancel_button = gtk_button_new_with_label("Cancel");
gtk_widget_show(bwin->cancel_button);
gtk_box_pack_start(GTK_BOX(bwin->hbox3),bwin->cancel_button,FALSE,FALSE,0);
g_signal_connect(G_OBJECT(bwin->cancel_button),"clicked",G_CALLBACK(bookmark_cancel_button_cb),bwin);
gtk_widget_show(bwin->window);
}
/* verify if there is a bookmark file */
void bookmark_open_file ()
{
gBookmarkFilePath = g_strconcat(g_get_home_dir(),"/.Minimo/bookmarks",NULL);
if (!(g_file_test(gBookmarkFilePath,G_FILE_TEST_EXISTS)))
{
gBookmarkFilePointer = fopen(gBookmarkFilePath,"w+");
fprintf(gBookmarkFilePointer, "folder Bookmarks\n");
fclose(gBookmarkFilePointer);
bookmark_open_file ();
}
else
{
gBookmarkFilePointer = fopen(gBookmarkFilePath,"r");
}
}
/* load the treeview from the file */
void bookmark_load_from_file(BookmarkTreeVData *treev_data)
{
gchar *line = (gchar *)g_malloc(1024);
BookmarkData *data= g_new0(BookmarkData,1);
GtkTreeIter *parentIter= g_new0(GtkTreeIter,1);
while(fgets(line,1023,gBookmarkFilePointer)!= NULL)
{
line = g_strstrip(line);
if (g_strncasecmp(line,"folder",6) == 0)
{
data->label = g_strdup(line+7);
data->url = "";
bookmark_insert_folder_on_treeview(data,treev_data);
continue;
}
if (g_strncasecmp(line,"url",3) == 0)
{
gchar **temp;
temp = g_strsplit(line+4," ",2);
data->url = g_strdup(temp[0]);
if (temp[1] != NULL)
data->label = g_strdup(temp[1]);
else
data->label = g_strdup(temp[0]);
g_strfreev(temp);
bookmark_insert_item_on_treeview(data,treev_data);
continue;
}
if (g_strncasecmp(line,"/folder",7) == 0)
{
if (gtk_tree_model_iter_parent(treev_data->treeStore, parentIter, treev_data->parentIter))
{
treev_data->parentIter= gtk_tree_iter_copy(parentIter);
}
}
}
g_free(line);
g_free(data);
g_free(parentIter);
}
/* the treeview internal search function */
gboolean bookmark_search_function(GtkTreeModel *tree_view, gint column, const gchar *key, GtkTreeIter *iter,void *bwin)
{
BookmarkData *bmark = g_new0(BookmarkData,1);
gtk_tree_model_get(GTK_TREE_MODEL(tree_view), iter, 0, &bmark->label, 1, &bmark->url, -1);
if (g_str_has_prefix(g_ascii_strdown ((char *)(bmark->label),-1),g_ascii_strdown ((char *)key,-1)))
{
gtk_tree_selection_select_iter (((BookmarkWindow *)bwin)->selection, iter);
bookmark_on_treev_select_row_cb (NULL, (BookmarkWindow *)bwin);
}
return TRUE;
}
/* insert a new folder on treeview */
void bookmark_insert_folder_on_treeview(BookmarkData *data, BookmarkTreeVData *treev_data)
{
GtkTreeIter *newIter= g_new0(GtkTreeIter,1);
gtk_tree_store_append(GTK_TREE_STORE(treev_data->treeStore),newIter,treev_data->parentIter);
gtk_tree_store_set(GTK_TREE_STORE(treev_data->treeStore), newIter, 0, data->label, 1, data->url, -1);
treev_data->parentIter= newIter;
}
/* insert a new url on treeview */
void bookmark_insert_item_on_treeview(BookmarkData *data, BookmarkTreeVData *treev_data)
{
GtkTreeIter *newIter= g_new0(GtkTreeIter,1);
gtk_tree_store_append(GTK_TREE_STORE(treev_data->treeStore),newIter,treev_data->parentIter);
gtk_tree_store_set(GTK_TREE_STORE(treev_data->treeStore), newIter, 0, data->label, 1, data->url, -1);
}
/* get selected data */
void bookmark_on_treev_select_row_cb (GtkTreeView *view, BookmarkWindow *bwin)
{
BookmarkData *bmark;
bookmark_clear_all_entries(bwin);
bmark = g_new0(BookmarkData,1);
gtk_tree_selection_get_selected(bwin->selection, &bwin->treev_data->treeStore, &bwin->iter);
gtk_tree_model_get(bwin->treev_data->treeStore, &bwin->iter, 0, &bmark->label, 1, &bmark->url, -1);
if (g_ascii_strcasecmp(bmark->url,"") == 0)
{
gtk_entry_set_text(GTK_ENTRY(bwin->folder_entry), g_strstrip(bmark->label));
gtk_entry_set_text(GTK_ENTRY(bwin->url_entry), "");
}
else
{
gtk_entry_set_text(GTK_ENTRY(bwin->text_entry), g_strstrip(bmark->label));
gtk_entry_set_text(GTK_ENTRY(bwin->url_entry), g_strstrip(bmark->url));
}
bwin->treev_data->parentIter= &bwin->iter;
g_free(bmark);
}
/* add a bookmark */
void bookmark_add_button_cb(GtkWidget *button,BookmarkWindow *bwin)
{
BookmarkData *data;
GtkTreeIter *iter;
iter= g_new0(GtkTreeIter,1);
data = g_new0(BookmarkData,1);
data->url = g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->url_entry)));
/* it's a url */
if (g_ascii_strcasecmp(data->url,"")!=0)
{
data->label = g_strstrip(g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->text_entry))));
gtk_tree_store_append(GTK_TREE_STORE(bwin->treev_data->treeStore),iter,bwin->treev_data->parentIter);
gtk_tree_store_set(GTK_TREE_STORE(bwin->treev_data->treeStore), iter, 0, data->label, 1, data->url, -1);
}
else /* it's a folder */
{
data->label = g_strstrip(g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->folder_entry))));
if (g_ascii_strcasecmp(data->label,"")==0)
data->label = g_strstrip(g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->text_entry))));
gtk_tree_store_append(GTK_TREE_STORE(bwin->treev_data->treeStore),iter,bwin->treev_data->parentIter);
gtk_tree_store_set(GTK_TREE_STORE(bwin->treev_data->treeStore), iter, 0, data->label, 1, "", -1);
}
g_free(iter);
bookmark_clear_all_entries(bwin);
}
/* edit a url or a folder */
void bookmark_edit_button_cb (GtkWidget *button,BookmarkWindow *bwin)
{
BookmarkData *data;
data = g_new0(BookmarkData,1);
data->label = g_strstrip(g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->text_entry))));
data->url = g_strstrip(g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->url_entry))));
/* it's a folder */
if (g_ascii_strcasecmp(data->url,"")==0)
{
data->label = g_strstrip(g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->folder_entry))));
if (g_ascii_strcasecmp(data->label,"")==0)
data->label= g_strstrip(g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->text_entry))));
gtk_tree_store_set(GTK_TREE_STORE(bwin->treev_data->treeStore), &bwin->iter, 0, data->label, 1, "", -1);
}
else /* it's a url */
{
data->label = g_strstrip(g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->text_entry))));
gtk_tree_store_set(GTK_TREE_STORE(bwin->treev_data->treeStore), &bwin->iter, 0, data->label, 1, data->url, -1);
}
bookmark_clear_all_entries(bwin);
}
/* a button to go to a selected url */
void bookmark_go_button_cb (GtkButton *button,BookmarkWindow *bwin)
{
gchar *url;
/* do not open folders */
if ((url= g_strdup(gtk_entry_get_text(GTK_ENTRY(bwin->url_entry)))))
{
gtk_moz_embed_stop_load(GTK_MOZ_EMBED(gBookmarkMozEmbed));
gtk_moz_embed_load_url(GTK_MOZ_EMBED(gBookmarkMozEmbed), url);
}
g_free(url);
bookmark_clear_all_entries(bwin);
}
/* accept new edit configurations and update bookmark menu */
void bookmark_ok_button_cb (GtkWidget *button,BookmarkWindow *bwin)
{
bookmark_write_on_file (bwin);
bookmark_close_dialog(bwin);
}
/* cancel user's operations */
void bookmark_cancel_button_cb (GtkWidget *button,BookmarkWindow *bwin)
{
bookmark_close_dialog(bwin);
}
/* remove a selected bookmark */
void bookmark_remove_button_cb (GtkWidget *button,BookmarkWindow *bwin)
{
BookmarkData *data;
gtk_tree_selection_get_selected(bwin->selection, &bwin->treev_data->treeStore, &bwin->iter);
data = g_new0(BookmarkData,1);
gtk_tree_model_get(bwin->treev_data->treeStore, &bwin->iter, 0, &data->label, 1, &data->url, -1);
gtk_tree_store_remove(GTK_TREE_STORE(bwin->treev_data->treeStore), &bwin->iter);
bookmark_clear_all_entries(bwin);
}
/* write bookmarks on file */
void bookmark_write_on_file (BookmarkWindow *bwin)
{
fclose(gBookmarkFilePointer);
gBookmarkFilePointer = fopen(gBookmarkFilePath,"w");
GtkTreeIter *iter= g_new0(GtkTreeIter,1);
if (!gtk_tree_model_get_iter_first(bwin->treev_data->treeStore,iter)) return;
bookmark_write_node_data_on_file(bwin->treev_data->treeStore, iter);
g_free(iter);
}
/* print node data on file */
void bookmark_write_node_data_on_file (GtkTreeModel *treeStore, GtkTreeIter *iter)
{
BookmarkData *data= g_new0(BookmarkData,1);
GtkTreeIter *newIter= g_new0(GtkTreeIter,1);
gtk_tree_model_get(treeStore, iter, 0, &data->label, 1, &data->url, -1);
/* it's a folder */
if (g_ascii_strcasecmp(data->url,"") == 0)
{
fprintf(gBookmarkFilePointer,"folder %s\n",data->label);
if (!gtk_tree_model_iter_children(treeStore,newIter,iter)) return;
bookmark_write_node_data_on_file(treeStore, newIter);
if (gtk_tree_model_iter_next(treeStore,newIter))
bookmark_write_node_data_on_file(treeStore, newIter);
if(g_ascii_strcasecmp(data->label,"Bookmarks") != 0)
fprintf(gBookmarkFilePointer,"/folder\n");
}
else /* it's a url */
{
fprintf(gBookmarkFilePointer,"url %s %s\n",data->url, data->label);
if (gtk_tree_model_iter_next(treeStore,iter))
{
newIter= gtk_tree_iter_copy(iter);
bookmark_write_node_data_on_file(treeStore, newIter);
}
}
g_free(data);
g_free(newIter);
}
/* clear all the bookmarks entries */
void bookmark_clear_all_entries(BookmarkWindow *bwin)
{
gtk_entry_set_text(GTK_ENTRY(bwin->url_entry),"");
gtk_editable_delete_text(GTK_EDITABLE(bwin->text_entry),0 ,-1);
gtk_editable_delete_text(GTK_EDITABLE(bwin->folder_entry),0 ,-1);
}
/* close the bookmark window */
void bookmark_close_dialog(BookmarkWindow *bwin)
{
/* close bookmark file*/
fclose(gBookmarkFilePointer);
gtk_widget_destroy(bwin->window);
g_free(bwin);
}
/* function used for importing bookmarks */
void bookmark_import_cb(GtkButton *button,BookmarkWindow *bwin)
{
FILE *inFile;
BookmarkData *data= g_new0(BookmarkData,1);
gchar *parsedname;
gchar *line = (gchar *)g_malloc(1024);
gchar *filename= g_strconcat(g_get_home_dir(),"/bookmarks.html",NULL);
GString *name = g_string_new (NULL);
GString *url = g_string_new (NULL);
fclose(gBookmarkFilePointer);
if (!(inFile = fopen(filename,"r"))) return;
if (!(gBookmarkFilePointer = fopen(gBookmarkFilePath,"a"))) return;
if(fgets(line, 256, inFile) != NULL)
if(!strstr(line, "NETSCAPE-Bookmark-file")) return;
while (!feof (inFile))
{
switch (bookmark_get_ns_item (inFile, name, url)) {
case NS_FOLDER: //While selected line is Folder
data->label = g_strdup (g_strstrip(name->str));
fprintf(gBookmarkFilePointer,"folder %s\n",data->label);
g_free (data->label);
break;
case NS_SITE://While selected line in Bookmark
parsedname = bookmark_ns_parse_item (name);
data->label = g_strdup (g_strstrip(parsedname));
if (url->str)
data->url = g_strdup(g_strstrip(url->str));
else
data->url = NULL;
fprintf(gBookmarkFilePointer,"url %s %s\n",data->url,data->label);
g_free (data->label);
g_free (data->url);
g_free (parsedname);
break;
case NS_FOLDER_END://While selected line is end of Folder.
fprintf(gBookmarkFilePointer,"/folder\n");
break;
default:
break;
}
}
bookmark_close_dialog(bwin);
g_string_free (name, TRUE);
g_string_free (url, TRUE);
g_free(data);
g_free(filename);
}
NSItemType bookmark_get_ns_item (FILE *inFile, GString *name, GString *url)
{
gchar *line = NULL;
gchar *found;
gchar *temp = NULL;
gchar *bm_temp = NULL;
GString *nick = g_string_new (NULL);
line = bookmark_read_line_from_html_file (inFile);
if ((found = (char *) bookmark_string_strcasestr (line, "<A HREF=")))
{ // declare site?
g_string_assign (url, found+9); // url=URL+ ADD_DATE ...
g_string_truncate (url, strstr(url->str, "\"") - url->str);
found = (char *) strstr (found+9+url->len, "\">");
if (!found)
{
g_free (line);
return NS_UNKNOWN;
}
g_string_assign (name, found+2);
temp = (char *) bookmark_string_strcasestr(name->str,"</A>");
g_string_truncate (name, temp - (name->str));
if ((found = (char *) bookmark_string_strcasestr (line,"SHORTCUTURL=")))
{
g_string_assign (nick, found+13);
g_string_truncate (nick, strstr(nick->str, "\"") - nick->str);
}
else
g_string_assign (nick, "");
g_free (line);
return NS_SITE;
}
else if ((found = (char *) bookmark_string_strcasestr (line, "<DT><H3")))
{ //declare folder?
found = (char *) strstr(found+7, ">");
if (!found) return NS_UNKNOWN;
g_string_assign (name, found+1);
bm_temp = (char *) bookmark_string_strcasestr (name->str, "</H3>");
g_string_truncate (name, bm_temp - (name->str));
g_free (line);
return NS_FOLDER;
}
else if ((found = (char *) bookmark_string_strcasestr (line, "</DL>")))
{ // end folder?
g_free (line);
return NS_FOLDER_END;
}
else if ((found = (char *) bookmark_string_strcasestr (line, "<HR>")))
{ // separator
g_free (line);
return NS_SEPARATOR;
}
else if ((found = (char *) bookmark_string_strcasestr (line, "<DD>")))
{ // comments
g_string_assign (name, found+4);
g_free (line);
return NS_NOTES;
}
else if (strchr(line, '<')==NULL && strchr(line, '>')==NULL)
{ // continued comments (probably)
g_string_assign (name, line);
g_free (line);
return NS_NOTES;
}
g_free (line);
g_string_free (nick, TRUE);
return NS_UNKNOWN;
}
/**
* bookmark_read_line_from_html_file: reads a line from an opened file and
* returns it in a new allocated string
*/
gchar *bookmark_read_line_from_html_file (FILE *inFile)
{
gchar *line = g_strdup ("");
gchar *t;
gchar *buf = g_new0 (gchar, 256);
/* Read from the file unles endoffile has reached or newline has encountered */
while (!(strchr (buf, '\n') || feof (inFile)))
{
fgets(buf, 256, inFile);
t = line;
line = g_strconcat (line, buf, NULL);
g_free (t);
}
g_free (buf);
return line;
}
/**
* bookmark_string_strcasestr: test if a string b is a substring of string a,
* independent of case.
*/
const gchar *bookmark_string_strcasestr (const gchar *a, const gchar *b)
{
gchar *down_a;
gchar *down_b;
gchar *ptr;
// copy and lower case the strings
down_a = g_strdup (a);
down_b = g_strdup (b);
//down_a = g_utf8_strdown (down_a, strlen (down_a))
g_strdown (down_a);
g_strdown (down_b);
ptr = strstr (down_a, down_b);
g_free (down_a);
g_free (down_b);
return ptr == NULL ? NULL : (a + (ptr - down_a));
}
/**
* This function replaces some weird elements
* like &amp; &le;, etc..
* More info : http://www.w3.org/TR/html4/charset.html#h-5.3.2
*/
char *bookmark_ns_parse_item (GString *string)
{
char *iterator, *temp;
int cnt = 0;
GString *result = g_string_new (NULL);
iterator = string->str;
for (cnt = 0, iterator = string->str;cnt <= (int)(strlen (string->str));cnt++, iterator++)
{
if (*iterator == '&')
{
int jump = 0;
int i;
if (g_strncasecmp (iterator, "&amp;", 5) == 0)
{
g_string_append_c (result, '&');
jump = 5;
}
else if (g_strncasecmp (iterator, "&lt;", 4) == 0)
{
g_string_append_c (result, '<');
jump = 4;
}
else if (g_strncasecmp (iterator, "&gt;", 4) == 0)
{
g_string_append_c (result, '>');
jump = 4;
}
else if (g_strncasecmp (iterator, "&quot;", 6) == 0)
{
g_string_append_c (result, '\"');
jump = 6;
}
else
{
// It must be some numeric thing now
iterator++;
if (iterator && *iterator == '#')
{
int val;
char *num, *tmp;
iterator++;
val = atoi (iterator);
tmp = g_strdup_printf ("%d", val);
jump = strlen (tmp);
g_free (tmp);
num = g_strdup_printf ("%c", (char) val);
g_string_append (result, num);
g_free (num);
}
}
for (i = jump - 1; i > 0; i--)
{
iterator++;
if (iterator == NULL) break;
}
}
else
g_string_append_c (result, *iterator);
}
temp = result->str;
g_string_free (result, FALSE);
return temp;
}
/* function used for exporting bookmarks */
void bookmark_export_cb (GtkButton *button,BookmarkWindow *bwin)
{
gchar *filename= g_strconcat(g_get_home_dir(),"/bookmarks.html",NULL);
BookmarkData *data= g_new0(BookmarkData,1);
gchar *line = (gchar *)g_malloc(1024);
gboolean isFolder= TRUE;
FILE *outFile;
if (!(outFile = fopen (filename, "w"))) return;
fputs ("<!DOCTYPE NETSCAPE-Bookmark-file-1>\n", outFile);
fputs ("<!-- This file was automatically generated by Minimo\n", outFile);
fputs ("It will be read and overwritten.\n", outFile);
fputs ("Do Not Edit! -->\n", outFile);
fputs ("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;"
" charset=UTF-8\">\n", outFile);
fputs ("<TITLE>Bookmarks</TITLE>\n", outFile);
fputs ("<H1>Minimo Bookmarks</H1>\n", outFile);
fputs ("\n", outFile);
fputs ("<DL><p>\n", outFile);
rewind(gBookmarkFilePointer);
while(fgets(line,1023,gBookmarkFilePointer)!= NULL)
{
line = g_strstrip(line);
if (g_strncasecmp(line,"folder",6) == 0)
{
data->label = g_strdup(line+7);
data->url = "";
isFolder = TRUE;
}
if (g_strncasecmp(line,"url",3) == 0)
{
gchar **temp;
temp = g_strsplit(line+4," ",2);
data->url = g_strdup(temp[0]);
if (temp[1] != NULL)
data->label = g_strdup(temp[1]);
else
data->label = g_strdup(temp[0]);
g_strfreev(temp);
isFolder = FALSE;
}
if (g_strncasecmp(line,"/folder",7) == 0)
{
fputs ("</DL><p>\n", outFile);
}
bookmark_export_items (outFile, data, isFolder);
}
fputs ("</DL><p>\n", outFile);
fputs ("</DL><p>\n", outFile);
fclose (outFile);
g_free(data);
g_free(line);
g_free(filename);
}
void bookmark_export_items (FILE *file, BookmarkData *data, gboolean isFolder)
{
gchar *str;
/* it is a url */
if (isFolder == FALSE) {
fputs ("\t<DT><A HREF=\"", file);
fputs (data->url, file);
fputs ("\"", file);
fputs (">", file);
str = g_strdup(data->label);
fputs (str, file);
fputs ("</A>\n", file);
} /* it is a folder */
else
{
fputs ("<DT><H3 ADD_DATE=\"0\">", file);
str = g_strdup(data->label);
fputs (str, file);
fputs ("</H3>\n", file);
fputs ("<DL><p>\n", file);
}
}
void bookmark_add_url_directly_cb (GtkWidget *menu_item,GtkWidget *embed)
{
gchar *url;
gchar *title;
bookmark_open_file ();
fclose(gBookmarkFilePointer);
if (!(gBookmarkFilePointer = fopen(gBookmarkFilePath,"a+"))) return;
if (!(url= gtk_moz_embed_get_location(gBookmarkMozEmbed))) return;
/* doesn't add an empty url or about:blank */
if ((g_ascii_strcasecmp(url,"") != 0) && (g_ascii_strcasecmp(url,"about:blank") != 0))
{
title= gtk_moz_embed_get_title (gBookmarkMozEmbed);
fprintf(gBookmarkFilePointer, "url %s %s\n", url, title);
g_free(title);
}
fclose(gBookmarkFilePointer);
g_free(url);
g_free(gBookmarkFilePath);
}

Просмотреть файл

@ -1,102 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef bookmark_h
#define bookmark_h
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include "minimo_types.h"
#include "gtkmozembed.h"
typedef enum
{
NS_SITE,
NS_NOTES,
NS_FOLDER,
NS_FOLDER_END,
NS_SEPARATOR,
NS_UNKNOWN
} NSItemType;
void bookmark_moz_embed_initialize (GtkWidget *);
void bookmark_create_dialog ();
void bookmark_open_file ();
void bookmark_load_from_file (BookmarkTreeVData *);
gboolean bookmark_search_function(GtkTreeModel *, gint, const gchar *, GtkTreeIter *,void *);
void bookmark_insert_folder_on_treeview (BookmarkData *, BookmarkTreeVData *);
void bookmark_insert_item_on_treeview (BookmarkData *, BookmarkTreeVData *);
void bookmark_on_treev_select_row_cb (GtkTreeView *, BookmarkWindow *);
void bookmark_add_button_cb (GtkWidget *,BookmarkWindow *);
void bookmark_edit_button_cb (GtkWidget * ,BookmarkWindow *);
void bookmark_go_button_cb (GtkButton * ,BookmarkWindow *);
void bookmark_ok_button_cb (GtkWidget * ,BookmarkWindow *);
void bookmark_cancel_button_cb (GtkWidget * ,BookmarkWindow *);
void bookmark_remove_button_cb (GtkWidget * ,BookmarkWindow *);
void bookmark_write_on_file (BookmarkWindow *);
void bookmark_write_node_data_on_file (GtkTreeModel *, GtkTreeIter *);
void bookmark_clear_all_entries (BookmarkWindow *);
void bookmark_close_dialog (BookmarkWindow *);
void bookmark_import_cb (GtkButton *,BookmarkWindow *);
NSItemType bookmark_get_ns_item (FILE *, GString *, GString *);
gchar * bookmark_read_line_from_html_file (FILE *);
const gchar *bookmark_string_strcasestr (const gchar *, const gchar *);
char * bookmark_ns_parse_item (GString *);
void bookmark_export_cb (GtkButton *,BookmarkWindow *);
void bookmark_export_items (FILE *, BookmarkData *, gboolean );
void bookmark_add_url_directly_cb (GtkWidget *,GtkWidget *);
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,112 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef minimo_callbacks_h
#define minimo_callbacks_h
#include "minimo_context.h"
#include "minimo_types.h"
#include "minimo_preference.h"
#include "minimo_bookmark.h"
#include "Minimo.h"
/* context menu callbacks */
void browse_in_window_from_popup(GtkWidget *, MinimoBrowser *);
void download_link_from_popup(GtkWidget *, MinimoBrowser *);
void minimo_load_url(gchar *, MinimoBrowser *);
void make_tab_from_popup(GtkWidget *, MinimoBrowser *);
void open_new_tab_cb (GtkMenuItem *, MinimoBrowser *);
void close_current_tab_cb (GtkMenuItem *, MinimoBrowser *);
/* menu bar callbacks */
void open_bookmark_window_cb (GtkMenuItem *,MinimoBrowser *);
void back_clicked_cb(GtkButton *, MinimoBrowser *);
void reload_clicked_cb(GtkButton *, MinimoBrowser *);
void forward_clicked_cb(GtkButton *, MinimoBrowser *);
void stop_clicked_cb(GtkButton *, MinimoBrowser *);
/* callbacks from the UI */
gboolean delete_cb(GtkWidget *, GdkEventAny *, MinimoBrowser *);
/* callbacks from the widget */
void pref_clicked_cb(GtkButton *, MinimoBrowser *);
void quick_message(gchar* );
/*callbacks from the menuToolButton */
void show_hide_tabs_cb (GtkMenuItem *, MinimoBrowser *);
void open_history_window (GtkButton *, MinimoBrowser *);
void create_find_dialog (GtkWidget *, MinimoBrowser *);
void create_open_document_from_file (GtkMenuItem *, MinimoBrowser *);
void increase_font_size_cb (GtkMenuItem *, MinimoBrowser *);
void decrease_font_size_cb (GtkMenuItem *, MinimoBrowser *);
void full_screen_cb (GtkMenuItem *, MinimoBrowser *);
void unfull_screen_cb (GtkMenuItem *, MinimoBrowser *);
void info_clicked_cb(GtkButton *, MinimoBrowser *);
void open_url_dialog_input_cb (GtkButton *, MinimoBrowser *);
void net_state_change_cb(GtkMozEmbed *, gint , guint , GtkLabel* label);
void progress_change_cb(GtkMozEmbed *, gint , gint , MinimoBrowser* );
void title_changed_cb(GtkMozEmbed *, MinimoBrowser *);
void load_started_cb(GtkMozEmbed *, MinimoBrowser *);
void load_finished_cb(GtkMozEmbed *, MinimoBrowser *);
void location_changed_cb(GtkMozEmbed *embed, GtkLabel *);
void create_save_document_dialog (GtkMenuItem *, MinimoBrowser *, gchar *);
void on_save_ok_cb(GtkWidget *, OpenDialogParams *);
void save_image_from_popup(GtkWidget *, MinimoBrowser *);
void visibility_cb(GtkMozEmbed *, gboolean , MinimoBrowser *);
void set_browser_visibility(MinimoBrowser *, gboolean );
gint open_uri_cb(GtkMozEmbed *, const char *, MinimoBrowser *);
void size_to_cb(GtkMozEmbed *, gint , gint , MinimoBrowser *);
void link_message_cb (GtkWidget *, MinimoBrowser *);
/* callbacks from buttons (mouse or stylus) clicks */
void on_button_clicked_cb(GtkWidget *, MinimoBrowser *);
gint on_button_pressed_cb(GtkWidget *, MinimoBrowser *);
gint on_button_released_cb(GtkWidget *, gpointer *, MinimoBrowser *);
#endif

Просмотреть файл

@ -1,312 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "minimo_context.h"
#include "minimo_callbacks.h"
#include "minimo_bookmark.h"
RightButtonClick *gContextRightButtonClick; /* Emulating right button clicks */
void context_initialize_timer()
{
/* right button click emulation initialization */
gContextRightButtonClick = g_new0(RightButtonClick,1);
gContextRightButtonClick->sig_handler= 0;
gContextRightButtonClick->pressing_timer= g_timer_new();
g_timer_reset(gContextRightButtonClick->pressing_timer);
}
GtkWidget * context_click_on_link (MinimoBrowser *browser, gchar *href, gchar *linktext)
{
GtkWidget *menu, *m1, *m2, *m3;
if (browser->link_menu) gtk_widget_destroy(browser->link_menu);
menu = gtk_menu_new();
g_object_set_data(G_OBJECT(menu), "freehref", href);
g_object_set_data(G_OBJECT(menu), "freelinktext", linktext);
/* Open in this Window */
m1 = gtk_image_menu_item_new_with_mnemonic("_Open link ...");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(m1),
gtk_image_new_from_stock(GTK_STOCK_OPEN,GTK_ICON_SIZE_MENU));
g_signal_connect(G_OBJECT(m1), "activate", G_CALLBACK(browse_in_window_from_popup), browser);
g_object_set_data(G_OBJECT(m1), "link", href);
gtk_menu_append(GTK_MENU(menu), m1);
/* Open in a new Tab */
m2 = gtk_image_menu_item_new_with_mnemonic("Open in a new _tab");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(m2),
gtk_image_new_from_stock(GTK_STOCK_NEW,GTK_ICON_SIZE_MENU));
gtk_menu_append(GTK_MENU(menu), m2);
g_object_set_data(G_OBJECT(m2), "link", href);
g_signal_connect(G_OBJECT(m2), "activate", G_CALLBACK(make_tab_from_popup), browser);
/* Download link */
m3 = gtk_image_menu_item_new_with_mnemonic("_Save link as ...");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(m3),
gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU));
g_signal_connect(G_OBJECT(m3), "activate", G_CALLBACK(download_link_from_popup), browser);
g_object_set_data(G_OBJECT(m3), "link", href);
gtk_menu_append(GTK_MENU(menu), m3);
gtk_widget_show_all(menu);
browser->link_menu = menu;
return (menu);
}
GtkWidget * context_click_on_image (MinimoBrowser *browser, gchar *img)
{
GtkWidget *menu, *m1, *m2, *m3, *m4, *sep;
gchar *lbl, *name, *aux_string;
G_CONST_RETURN gchar *img_basename;
if (browser->image_menu)
gtk_widget_destroy(browser->image_menu);
aux_string = (gchar *)g_malloc(1024);
strcpy (aux_string, "");
img_basename = g_basename(img);
name = g_strdup(img_basename);
menu = gtk_menu_new();
g_object_set_data(G_OBJECT(menu), "freeimg", img);
g_object_set_data(G_OBJECT(menu), "freename", name);
/* View Image */
m1 = gtk_image_menu_item_new_with_mnemonic ("_View image");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(m1),
gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU));
g_signal_connect(G_OBJECT(m1), "activate", G_CALLBACK(browse_in_window_from_popup), browser);
g_object_set_data(G_OBJECT(m1), "link", img);
gtk_menu_append(GTK_MENU(menu), m1);
/* Separator */
sep = gtk_menu_item_new();
gtk_menu_append(GTK_MENU(menu), sep);
/* Save as */
m2 = gtk_image_menu_item_new_with_mnemonic ("_Save image as ...");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(m2),
gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU));
g_signal_connect(G_OBJECT(m2), "activate", G_CALLBACK(download_link_from_popup), browser);
g_object_set_data(G_OBJECT(m2), "link", img);
g_object_set_data(G_OBJECT(m2), "name", aux_string);
gtk_menu_append(GTK_MENU(menu), m2);
/* Save */
lbl = g_strdup_printf("%s %s","Sa_ve image as ",img_basename);
m3 = gtk_image_menu_item_new_with_mnemonic (lbl);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(m3),
gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU));
g_signal_connect(G_OBJECT(m3), "activate", G_CALLBACK(save_image_from_popup), browser);
g_object_set_data(G_OBJECT(m3), "link", img);
g_object_set_data(G_OBJECT(m3), "name", name);
gtk_menu_append(GTK_MENU(menu), m3);
/* Separator */
sep = gtk_menu_item_new();
gtk_menu_append(GTK_MENU(menu), sep);
/* Save page as */
m4 = gtk_image_menu_item_new_with_mnemonic("Save page _as ... ");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(m4),
gtk_image_new_from_stock(GTK_STOCK_COPY, GTK_ICON_SIZE_MENU));
g_signal_connect(G_OBJECT(m4), "activate", G_CALLBACK(download_link_from_popup), browser);
g_object_set_data(G_OBJECT(m4), "link", gtk_moz_embed_get_location(GTK_MOZ_EMBED (browser->mozEmbed)));
gtk_menu_append(GTK_MENU(menu), m4);
gtk_widget_show_all(menu);
gtk_widget_show_all(menu);
g_free(aux_string);
g_free(lbl);
browser->image_menu = menu;
return (menu);
}
GtkWidget * context_click_doc (MinimoBrowser *browser, gchar *href)
{
GtkWidget *menu, *m1,*m2,*m3, *m4, *m5, *m6, *sep;
if (browser->doc_menu) gtk_widget_destroy(browser->doc_menu);
menu = gtk_menu_new();
g_object_set_data(G_OBJECT(menu), "freehref", href);
m1 = gtk_image_menu_item_new_from_stock(GTK_STOCK_GO_BACK,NULL);
g_signal_connect(G_OBJECT(m1), "activate", G_CALLBACK(back_clicked_cb), browser);
gtk_widget_set_sensitive(m1, gtk_moz_embed_can_go_back(GTK_MOZ_EMBED(browser->mozEmbed)));
gtk_menu_append(GTK_MENU(menu), m1);
m2 = gtk_image_menu_item_new_from_stock(GTK_STOCK_GO_FORWARD,NULL);
gtk_menu_append(GTK_MENU(menu), m2);
g_signal_connect(G_OBJECT(m2), "activate", G_CALLBACK(forward_clicked_cb), browser);
gtk_widget_set_sensitive(m2, gtk_moz_embed_can_go_forward(GTK_MOZ_EMBED(browser->mozEmbed)));
m3 = gtk_image_menu_item_new_from_stock(GTK_STOCK_REFRESH,NULL);
g_signal_connect(G_OBJECT(m3), "activate", G_CALLBACK(reload_clicked_cb), browser);
gtk_menu_append(GTK_MENU(menu), m3);
m4 = gtk_image_menu_item_new_from_stock(GTK_STOCK_STOP,NULL);
g_signal_connect(G_OBJECT(m4), "activate", G_CALLBACK(stop_clicked_cb), browser);
gtk_menu_append(GTK_MENU(menu), m4);
/* Separator */
sep = gtk_menu_item_new();
gtk_menu_append(GTK_MENU(menu), sep);
m5 = gtk_image_menu_item_new_with_mnemonic ("_Save page as ... ");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(m5),
gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU));
g_signal_connect(G_OBJECT(m5), "activate", G_CALLBACK(download_link_from_popup), browser);
g_object_set_data(G_OBJECT(m5), "link", gtk_moz_embed_get_location(GTK_MOZ_EMBED (browser->mozEmbed)));
gtk_menu_append(GTK_MENU(menu), m5);
m6 = gtk_image_menu_item_new_with_mnemonic ("_Bookmark this page");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(m6),
gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
g_signal_connect(G_OBJECT(m6), "activate", G_CALLBACK(bookmark_add_url_directly_cb), browser);
gtk_menu_append(GTK_MENU(menu), m6);
gtk_widget_show_all(menu);
browser->doc_menu = menu;
return ( menu );
}
GtkWidget * context_click_link_image (MinimoBrowser *browser, gchar *img, gchar *href)
{
GtkWidget *menu, *m1, *m2, *m3, *m4, *m5, *sep;
gchar *lbl, *name, *aux_string;
G_CONST_RETURN gchar *img_basename;
if (browser->image_link_menu)
gtk_widget_destroy(browser->image_link_menu);
aux_string= (gchar *)g_malloc(1024);
strcpy (aux_string, "link image menu");
img_basename = g_basename(img);
menu = gtk_menu_new();
name = g_strdup(img_basename);
g_object_set_data(G_OBJECT(menu), "freehref", href);
g_object_set_data(G_OBJECT(menu), "freeimg", img);
g_object_set_data(G_OBJECT(menu), "freename", name);
g_signal_connect(G_OBJECT(menu), "destroy", G_CALLBACK(context_destroy_popup), aux_string);
/* Open Link in the current Window */
m1 = gtk_image_menu_item_new_with_mnemonic ("_Open link ...");
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(m1),gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU));
g_signal_connect(G_OBJECT(m1), "activate", G_CALLBACK(browse_in_window_from_popup), browser);
g_object_set_data(G_OBJECT(m1), "link", href);
gtk_menu_append(GTK_MENU(menu), m1);
/* Open Link in a new tab */
m2 = gtk_image_menu_item_new_with_mnemonic ("Open link in a new _Tab");
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(m2),
gtk_image_new_from_stock(GTK_STOCK_NEW, GTK_ICON_SIZE_MENU));
gtk_menu_append(GTK_MENU(menu), m2);
g_object_set_data(G_OBJECT(m2), "link", href);
g_signal_connect(G_OBJECT(m2), "activate", G_CALLBACK(make_tab_from_popup), browser);
/* Separator */
sep = gtk_menu_item_new();
gtk_menu_append(GTK_MENU(menu), sep);
/* View Image */
m3 = gtk_image_menu_item_new_with_mnemonic ("_View image");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(m3),
gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU));
g_signal_connect(G_OBJECT(m3), "activate", G_CALLBACK(browse_in_window_from_popup), browser);
g_object_set_data(G_OBJECT(m3), "link", img);
gtk_menu_append(GTK_MENU(menu), m3);
/* Separator */
sep = gtk_menu_item_new();
gtk_menu_append(GTK_MENU(menu), sep);
m4 = gtk_image_menu_item_new_with_mnemonic ("_Save link as ...");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(m4),gtk_image_new_from_stock(GTK_STOCK_SAVE,
GTK_ICON_SIZE_MENU));
g_signal_connect(G_OBJECT(m4), "activate", G_CALLBACK(download_link_from_popup), browser);
g_object_set_data(G_OBJECT(m4), "link", href);
gtk_menu_append(GTK_MENU(menu), m4);
lbl = g_strdup_printf("%s %s","Save image _as ",img_basename);
m5 = gtk_image_menu_item_new_with_mnemonic (lbl);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(m5),gtk_image_new_from_stock(GTK_STOCK_SAVE,
GTK_ICON_SIZE_MENU));
g_signal_connect(G_OBJECT(m5), "activate", G_CALLBACK(save_image_from_popup), browser);
g_object_set_data(G_OBJECT(m5), "link", img);
g_object_set_data(G_OBJECT(m5), "name", name);
gtk_menu_append(GTK_MENU(menu), m5);
gtk_widget_show_all(menu);
browser->image_link_menu = menu;
g_free(aux_string);
return ( menu );
}
void context_destroy_popup (GtkWidget *menu, gchar *name)
{
gchar *free_href, *free_img, *free_linktext, *free_name;
free_href = (gchar *) g_object_get_data(G_OBJECT(menu), "freehref");
if (free_href) g_free(free_href);
free_img = (gchar *) g_object_get_data(G_OBJECT(menu), "freeimg");
if (free_img) g_free(free_img);
free_linktext = (gchar *) g_object_get_data(G_OBJECT(menu), "freelinktext");
if (free_linktext) g_free(free_linktext);
free_name = (gchar *) g_object_get_data(G_OBJECT(menu), "freename");
if (free_name) g_free(free_name);
return;
}

Просмотреть файл

@ -1,64 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef minimo_context_h
#define minimo_context_h
#include "minimo_types.h"
void context_initialize_timer ();
GtkWidget * context_click_on_link (MinimoBrowser *, gchar *, gchar *);
GtkWidget * context_click_on_image (MinimoBrowser *, gchar *);
GtkWidget * context_click_doc (MinimoBrowser *, gchar *);
GtkWidget * context_click_link_image (MinimoBrowser *, gchar *, gchar *);
void context_destroy_popup (GtkWidget *, gchar *);
#endif

Просмотреть файл

@ -1,336 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "minimo_history.h"
gint gHistoryProt = 0;
GSList *gHistoryList = NULL;
/* Add an URL into History file */
void add_to_history(const gchar *url) {
GSList *list;
gint equals = 0;
history_read_from_file();
if (!url || url == NULL) return ;
if (!g_strncasecmp(url,"about:",6) || !g_strcasecmp(url,"")) return;
while (gHistoryProt == 1) {
}
gHistoryProt = 1;
for (list = gHistoryList; list ; list = list->next) {
if (g_strcasecmp((const gchar*)list->data,url) == 0){
equals = 1;
gHistoryProt = 0;
}
}
if (equals == 0) {
gHistoryList = g_slist_prepend(gHistoryList,g_strdup(url));
history_write_in_file();
}
gHistoryProt = 0;
}
/* Create and show the History Window*/
void history_create_dialog (GtkWidget *embed) {
HistoryWindow *hwin;
GSList *list;
GtkWidget *image;
hwin = g_new0(HistoryWindow,1);
history_read_from_file();
//hwin->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
hwin->window = gtk_dialog_new();
gtk_window_set_position(GTK_WINDOW(hwin->window), GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_set_title(GTK_WINDOW(hwin->window),hwin->title);
gtk_widget_set_usize(hwin->window,230,300);
gtk_window_set_resizable(GTK_WINDOW(hwin->window),FALSE);
gtk_window_set_position (GTK_WINDOW(hwin->window),GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_set_modal (GTK_WINDOW (hwin->window), TRUE);
gtk_window_set_keep_above(GTK_WINDOW (hwin->window), TRUE);
g_signal_connect(G_OBJECT(hwin->window),"destroy", G_CALLBACK(history_destroy_cb), NULL);
hwin->title = g_strdup_printf(("Minimo - History (%d) items"), g_slist_length(gHistoryList));
g_free(hwin->title);
hwin->vbox = gtk_vbox_new(FALSE,5);
// gtk_container_add(GTK_CONTAINER(hwin->window),hwin->vbox);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(hwin->window)->vbox),hwin->vbox, TRUE, TRUE, 0);
hwin->scrolled_window = gtk_scrolled_window_new(NULL,NULL);
gtk_box_pack_start(GTK_BOX(hwin->vbox),hwin->scrolled_window,TRUE,TRUE,0);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(hwin->scrolled_window),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC);
hwin->clist = gtk_clist_new(1);
gtk_container_add(GTK_CONTAINER(hwin->scrolled_window),hwin->clist);
hwin->search_label = gtk_label_new("Search: ");
hwin->search_entry = gtk_entry_new();
hwin->search_box = gtk_hbox_new(0,0);
image = gtk_image_new_from_stock (GTK_STOCK_FIND, GTK_ICON_SIZE_SMALL_TOOLBAR);
hwin->search_button = gtk_button_new();
gtk_container_add(GTK_CONTAINER(hwin->search_button),image);
gtk_tooltips_set_tip (gtk_tooltips_new (), GTK_WIDGET (hwin->search_button), "Find on history", NULL);
image = gtk_image_new_from_stock (GTK_STOCK_YES, GTK_ICON_SIZE_SMALL_TOOLBAR);
hwin->go_button = gtk_button_new ();
gtk_container_add(GTK_CONTAINER(hwin->go_button),image);
gtk_tooltips_set_tip (gtk_tooltips_new (), GTK_WIDGET (hwin->go_button), "Go to", NULL);
hwin->embed = embed;
g_signal_connect(G_OBJECT(hwin->search_button), "clicked", G_CALLBACK(history_search_cb), hwin);
g_signal_connect(G_OBJECT(hwin->go_button), "clicked", G_CALLBACK(history_go_cb), hwin);
gtk_box_pack_start(GTK_BOX(hwin->search_box), hwin->search_label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hwin->search_box), hwin->search_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hwin->search_box), hwin->search_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hwin->search_box), hwin->go_button, FALSE, FALSE, 0);
hwin->remove = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
g_signal_connect(G_OBJECT(hwin->remove), "clicked", G_CALLBACK(history_remove_item_cb), hwin);
hwin->clear = gtk_button_new_from_stock(GTK_STOCK_CLEAR);
g_signal_connect(G_OBJECT(hwin->clear), "clicked", G_CALLBACK(history_cleanup_cb), hwin);
hwin->close = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
g_signal_connect(G_OBJECT(hwin->close), "clicked", G_CALLBACK(history_close_dialog_cb), hwin);
hwin->btnbox = gtk_hbox_new(0,0);
gtk_box_pack_start(GTK_BOX(hwin->vbox), hwin->search_box, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hwin->vbox), hwin->btnbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hwin->btnbox), hwin->remove, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hwin->btnbox), hwin->clear, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hwin->btnbox), hwin->close, TRUE, TRUE, 0);
while (gHistoryProt == 1) {
}
gHistoryProt = 1;
for (list = gHistoryList; list ; list = list->next) {
gchar *clist_entry[1];
clist_entry[0] = (gchar *)list->data;
gtk_clist_append(GTK_CLIST(hwin->clist),clist_entry);
}
gHistoryProt = 0;
gtk_widget_show_all(hwin->window);
}
/* Go to URL selected in the history list */
void history_go_cb(GtkWidget *button, HistoryWindow *hwin) {
GList *selection;
gchar *location;
gint row;
selection = GTK_CLIST(hwin->clist)->selection;
if (g_list_length(selection) == 0) return;
row = (gint)g_list_nth_data(selection,0);
gtk_clist_get_text(GTK_CLIST(hwin->clist),row,0,&location);
gtk_moz_embed_stop_load(GTK_MOZ_EMBED(hwin->embed));
gtk_moz_embed_load_url(GTK_MOZ_EMBED(hwin->embed), location);
}
/* Close history window */
void history_close_dialog_cb (GtkWidget *button, HistoryWindow *hwin)
{
gtk_widget_destroy(hwin->window);
}
/* Remove an URL from history list */
void history_remove_item_cb (GtkWidget *button, HistoryWindow *hwin)
{
GList *selection = GTK_CLIST(hwin->clist)->selection;
gchar *text;
gint row;
if (selection == NULL) return;
gtk_clist_freeze(GTK_CLIST(hwin->clist));
row = (gint) g_list_nth_data(selection,0);
gtk_clist_get_text(GTK_CLIST(hwin->clist), row, 0, &text);
remove_from_list(text);
gtk_clist_remove(GTK_CLIST(hwin->clist), row);
gtk_clist_thaw(GTK_CLIST(hwin->clist));
hwin->title = g_strdup_printf(("Minimo - History (%d) items"), g_slist_length(gHistoryList));
gtk_window_set_title(GTK_WINDOW(hwin->window),hwin->title);
}
/* Remove an URL from history file */
void remove_from_list(gchar *text)
{
GSList *l;
for (l = gHistoryList; l ; l = l->next) {
gchar *data = (gchar *)l->data;
if (!strcmp(text,data)) {
gHistoryList = g_slist_remove(gHistoryList,data);
return;
}
}
}
/* Remove all URL from history list */
void history_cleanup_cb (GtkWidget *b, HistoryWindow *hwin)
{
gtk_clist_clear(GTK_CLIST(hwin->clist));
g_slist_free(gHistoryList);
gHistoryList = NULL;
gtk_window_set_title(GTK_WINDOW(hwin->window),"Minimo - History (0) items");
}
/* Search an URL in the history list */
void history_search_cb(GtkWidget *button, HistoryWindow *hwin)
{
gint rows, i;
G_CONST_RETURN gchar *search_text;
gint search_pos = 0;
rows = GTK_CLIST(hwin->clist)->rows;
if (!rows) return;
search_text = gtk_entry_get_text(GTK_ENTRY(hwin->search_entry));
if (!search_text || !strcmp(search_text,"")) return;
if (search_pos >= rows) search_pos = 0;
if (search_pos) search_pos++;
for (i = search_pos; i < rows ; i++) {
gchar *tmp, *tmp2 = NULL;
gtk_clist_get_text(GTK_CLIST(hwin->clist), i, 0, &tmp);
g_return_if_fail(tmp != NULL);
tmp2 = strstr(tmp,search_text);
if (tmp2 != NULL) {
gtk_clist_moveto(GTK_CLIST(hwin->clist), i, 0, 0.0, 0.0);
gtk_clist_select_row(GTK_CLIST(hwin->clist), i, 0);
GTK_CLIST(hwin->clist)->focus_row = i;
search_pos = i;
}
}
}
/* Close history window */
void history_destroy_cb(GtkWidget *window)
{
history_write_in_file();
}
/* Read the history file */
void history_read_from_file (void) {
gchar *line;
gchar *url;
gchar *user_home = NULL;
FILE *g_history_file = NULL;
gchar *g_history_file_name = NULL;
gHistoryList = NULL;
user_home = g_strconcat(g_get_home_dir(),NULL);
g_history_file_name = g_strconcat(user_home,"/.Minimo/history",NULL);
if ((g_history_file = fopen(g_history_file_name,"r"))!= NULL)
{
fclose(g_history_file);
g_history_file = fopen(g_history_file_name,"r+");
}
else
g_history_file = fopen(g_history_file_name,"w+");
if (g_history_file == NULL) {
printf("No History file to read!\n");
}
line = (gchar *)g_malloc(1024);
while(fgets(line,1024,g_history_file) != NULL) {
line[strlen(line)-1] = '\0';
url = g_strdup(line);
gHistoryList = g_slist_append(gHistoryList,url);
}
fclose(g_history_file);
g_free(line);
}
/* Write the history file */
void history_write_in_file(void) {
GSList *list;
gchar *user_home= NULL;
FILE *g_history_file = NULL;
gchar *g_history_file_name = NULL;
user_home = g_strconcat(g_get_home_dir(),NULL);
g_history_file_name = g_strconcat(user_home,"/.Minimo/history",NULL);
g_history_file = fopen(g_history_file_name,"w");
if (g_history_file == NULL) {
printf("Couldn't open history file for writing!\n");
return;
}
for (list = gHistoryList; list ; list = list->next) {
fprintf(g_history_file,"%s\n",(gchar *)(list->data));
}
fflush(g_history_file);
fclose(g_history_file);
g_free(g_history_file_name);
}

Просмотреть файл

@ -1,70 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef history_h
#define history_h
#include "minimo_types.h"
/* History functions*/
void history_write_in_file (void);
void history_read_from_file (void);
void add_to_history (const gchar *);
/* History callbacks */
void history_create_dialog (GtkWidget *);
void history_go_cb (GtkWidget *, HistoryWindow *);
void history_close_dialog_cb (GtkWidget *, HistoryWindow *);
void history_remove_item_cb (GtkWidget *, HistoryWindow *);
void remove_from_list (gchar *);
void history_cleanup_cb (GtkWidget *, HistoryWindow *);
void history_search_cb (GtkWidget *, HistoryWindow *);
void history_destroy_cb (GtkWidget *);
#endif

Просмотреть файл

@ -1,610 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "minimo_preference.h"
#include "minimo_support.h"
extern gchar *gMinimoUserHomePath;
ConfigData gPreferenceConfigStruct;
PrefWindow *gPreferenceWinStruct;
PrefWindow * preferences_build_dialog (GtkWidget *topLevelWindow) {
gPreferenceWinStruct = g_new0(PrefWindow,1);
gPreferenceWinStruct->dialog = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (gPreferenceWinStruct->dialog), ("Prefs Window"));
gtk_window_set_position (GTK_WINDOW (gPreferenceWinStruct->dialog), GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_set_modal (GTK_WINDOW (gPreferenceWinStruct->dialog), TRUE);
gtk_window_set_resizable (GTK_WINDOW (gPreferenceWinStruct->dialog), FALSE);
gtk_window_set_decorated (GTK_WINDOW (gPreferenceWinStruct->dialog), TRUE);
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (gPreferenceWinStruct->dialog), TRUE);
gtk_window_set_skip_pager_hint (GTK_WINDOW (gPreferenceWinStruct->dialog), TRUE);
gtk_window_set_type_hint (GTK_WINDOW (gPreferenceWinStruct->dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_window_set_gravity (GTK_WINDOW (gPreferenceWinStruct->dialog), GDK_GRAVITY_NORTH_EAST);
gtk_window_set_transient_for(GTK_WINDOW(gPreferenceWinStruct->dialog), GTK_WINDOW(topLevelWindow));
gtk_widget_set_size_request (gPreferenceWinStruct->dialog, 240, 220);
/* Creating "Connection Frame" */
gPreferenceWinStruct->fr_connection = gtk_frame_new (NULL);
gtk_widget_show (gPreferenceWinStruct->fr_connection);
gtk_container_add (GTK_CONTAINER(GTK_DIALOG (gPreferenceWinStruct->dialog)->vbox), gPreferenceWinStruct->fr_connection);
/* Connection Frame's VBOX */
gPreferenceWinStruct->vbox_connection = gtk_vbox_new (FALSE, 0);
gtk_widget_show (gPreferenceWinStruct->vbox_connection);
gtk_container_add (GTK_CONTAINER (gPreferenceWinStruct->fr_connection), gPreferenceWinStruct->vbox_connection);
gPreferenceWinStruct->hbox_direct_connection = gtk_hbox_new (FALSE, 0);
gtk_widget_show (gPreferenceWinStruct->hbox_direct_connection);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->vbox_connection), gPreferenceWinStruct->hbox_direct_connection, TRUE, TRUE, 0);
/* Radio Buttons - Direct/Manual Connetion */
gPreferenceWinStruct->rb_direct_connection = gtk_radio_button_new_with_mnemonic (NULL, "Direct connection to the Internet");
gtk_widget_show (gPreferenceWinStruct->rb_direct_connection);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->hbox_direct_connection), gPreferenceWinStruct->rb_direct_connection, FALSE, FALSE, 0);
gPreferenceWinStruct->rb_direct_connection_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (gPreferenceWinStruct->rb_direct_connection));
gPreferenceWinStruct->hbox_manual_connection = gtk_hbox_new (FALSE, 0);
gtk_widget_show (gPreferenceWinStruct->hbox_manual_connection);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->vbox_connection), gPreferenceWinStruct->hbox_manual_connection, TRUE, TRUE, 0);
gPreferenceWinStruct->vbox_manual = gtk_vbox_new (FALSE, 0);
gtk_widget_show (gPreferenceWinStruct->vbox_manual);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->hbox_manual_connection), gPreferenceWinStruct->vbox_manual, TRUE, TRUE, 0);
gPreferenceWinStruct->rb_manual_connection = gtk_radio_button_new_with_mnemonic (NULL, "Manual proxy configuration");
gtk_widget_show (gPreferenceWinStruct->rb_manual_connection);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->vbox_manual), gPreferenceWinStruct->rb_manual_connection, FALSE, FALSE, 0);
gPreferenceWinStruct->rb_manual_connection_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (gPreferenceWinStruct->rb_manual_connection));
gtk_radio_button_set_group (GTK_RADIO_BUTTON (gPreferenceWinStruct->rb_manual_connection), gPreferenceWinStruct->rb_direct_connection_group);
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gPreferenceWinStruct->rb_direct_connection));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gPreferenceWinStruct->rb_direct_connection), gPreferenceConfigStruct.direct_connection);
/* HTTP Widget HBOX */
gPreferenceWinStruct->hbox_http = gtk_hbox_new (FALSE, 0);
gtk_widget_show (gPreferenceWinStruct->hbox_http);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->vbox_manual), gPreferenceWinStruct->hbox_http, TRUE, TRUE, 0);
gPreferenceWinStruct->lb_http = gtk_label_new ("HTTP Proxy: ");
gtk_widget_show (gPreferenceWinStruct->lb_http);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->hbox_http), gPreferenceWinStruct->lb_http, FALSE, FALSE, 0);
gPreferenceWinStruct->en_http_proxy = gtk_entry_new ();
gtk_widget_show (gPreferenceWinStruct->en_http_proxy);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->hbox_http), gPreferenceWinStruct->en_http_proxy, TRUE, TRUE, 0);
gtk_widget_modify_font(gPreferenceWinStruct->en_http_proxy, getOrCreateDefaultMinimoFont());
gtk_widget_set_size_request (gPreferenceWinStruct->en_http_proxy, 60, -1);
gPreferenceWinStruct->lb_port_http = gtk_label_new (" Port: ");
gtk_widget_show (gPreferenceWinStruct->lb_port_http);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->hbox_http), gPreferenceWinStruct->lb_port_http, FALSE, FALSE, 0);
gPreferenceWinStruct->en_http_port = gtk_entry_new ();
gtk_widget_show (gPreferenceWinStruct->en_http_port);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->hbox_http), gPreferenceWinStruct->en_http_port, TRUE, TRUE, 0);
gtk_widget_set_size_request (gPreferenceWinStruct->en_http_port, 30, -1);
/* SSL Widget HBOX */
gPreferenceWinStruct->hbox_ssl = gtk_hbox_new (FALSE, 0);
gtk_widget_show (gPreferenceWinStruct->hbox_ssl);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->vbox_manual), gPreferenceWinStruct->hbox_ssl, TRUE, TRUE, 0);
gPreferenceWinStruct->lb_ssl = gtk_label_new ("SSL Proxy: ");
gtk_widget_show (gPreferenceWinStruct->lb_ssl);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->hbox_ssl), gPreferenceWinStruct->lb_ssl, FALSE, FALSE, 0);
gPreferenceWinStruct->en_ssl = gtk_entry_new ();
gtk_widget_show (gPreferenceWinStruct->en_ssl);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->hbox_ssl), gPreferenceWinStruct->en_ssl, TRUE, TRUE, 0);
gtk_widget_set_size_request (gPreferenceWinStruct->en_ssl, 60, -1);
gPreferenceWinStruct->lb_ssl_port = gtk_label_new (" Port: ");
gtk_widget_show (gPreferenceWinStruct->lb_ssl_port);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->hbox_ssl), gPreferenceWinStruct->lb_ssl_port, FALSE, FALSE, 0);
gPreferenceWinStruct->en_ssl_port = gtk_entry_new ();
gtk_widget_show (gPreferenceWinStruct->en_ssl_port);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->hbox_ssl), gPreferenceWinStruct->en_ssl_port, TRUE, TRUE, 0);
gtk_widget_modify_font(gPreferenceWinStruct->en_ssl, getOrCreateDefaultMinimoFont());
gtk_widget_set_size_request (gPreferenceWinStruct->en_ssl_port, 30, -1);
/* FTP Widgets HBOX */
gPreferenceWinStruct->hbox_ftp = gtk_hbox_new (FALSE, 0);
gtk_widget_show (gPreferenceWinStruct->hbox_ftp);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->vbox_manual), gPreferenceWinStruct->hbox_ftp, TRUE, TRUE, 0);
gPreferenceWinStruct->lb_ftp = gtk_label_new ("FTP Proxy: ");
gtk_widget_show (gPreferenceWinStruct->lb_ftp);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->hbox_ftp), gPreferenceWinStruct->lb_ftp, FALSE, FALSE, 0);
gPreferenceWinStruct->en_ftp_proxy = gtk_entry_new ();
gtk_widget_show (gPreferenceWinStruct->en_ftp_proxy);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->hbox_ftp), gPreferenceWinStruct->en_ftp_proxy, TRUE, TRUE, 0);
gtk_widget_set_size_request (gPreferenceWinStruct->en_ftp_proxy, 60, -1);
gPreferenceWinStruct->lb_ftp_port = gtk_label_new (" Port: ");
gtk_widget_show (gPreferenceWinStruct->lb_ftp_port);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->hbox_ftp), gPreferenceWinStruct->lb_ftp_port, FALSE, FALSE, 0);
gPreferenceWinStruct->en_ftp_port = gtk_entry_new ();
gtk_widget_show (gPreferenceWinStruct->en_ftp_port);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->hbox_ftp), gPreferenceWinStruct->en_ftp_port, TRUE, TRUE, 0);
gtk_widget_modify_font(gPreferenceWinStruct->en_ftp_proxy, getOrCreateDefaultMinimoFont());
gtk_widget_set_size_request (gPreferenceWinStruct->en_ftp_port, 30, -1);
gPreferenceWinStruct->hbox_noproxy = gtk_hbox_new (FALSE, 0);
gtk_widget_show (gPreferenceWinStruct->hbox_noproxy);
gtk_box_pack_start (GTK_BOX (gPreferenceWinStruct->vbox_connection), gPreferenceWinStruct->hbox_noproxy, TRUE, TRUE, 0);
if (gPreferenceConfigStruct.direct_connection == 0) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gPreferenceWinStruct->rb_direct_connection), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gPreferenceWinStruct->rb_manual_connection), TRUE);
} else if (gPreferenceConfigStruct.direct_connection == 1) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gPreferenceWinStruct->rb_direct_connection), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gPreferenceWinStruct->rb_manual_connection), FALSE);
}
gtk_entry_set_text (GTK_ENTRY (gPreferenceWinStruct->en_http_proxy), gPreferenceConfigStruct.http_proxy);
gtk_entry_set_text (GTK_ENTRY (gPreferenceWinStruct->en_http_port), gPreferenceConfigStruct.http_proxy_port);
gtk_entry_set_text (GTK_ENTRY (gPreferenceWinStruct->en_ssl), gPreferenceConfigStruct.ssl_proxy);
gtk_entry_set_text (GTK_ENTRY (gPreferenceWinStruct->en_ssl_port), gPreferenceConfigStruct.ssl_proxy_port);
gtk_entry_set_text (GTK_ENTRY (gPreferenceWinStruct->en_ftp_proxy), gPreferenceConfigStruct.ftp_proxy);
gtk_entry_set_text (GTK_ENTRY (gPreferenceWinStruct->en_ftp_port), gPreferenceConfigStruct.ftp_proxy_port);
/* Creating "Popup Frame" */
gPreferenceWinStruct->fr_popup = gtk_frame_new (NULL);
gtk_widget_show (gPreferenceWinStruct->fr_popup);
gtk_container_add (GTK_CONTAINER(GTK_DIALOG (gPreferenceWinStruct->dialog)->vbox), gPreferenceWinStruct->fr_popup);
/* Proxy Frame's label */
gPreferenceWinStruct->lb_connection = gtk_label_new ("Configure Proxies:");
gtk_widget_show (gPreferenceWinStruct->lb_connection);
gtk_frame_set_label_widget (GTK_FRAME (gPreferenceWinStruct->fr_connection), gPreferenceWinStruct->lb_connection);
gPreferenceWinStruct->vbox_popup = gtk_vbox_new (FALSE, 0);
gtk_widget_show (gPreferenceWinStruct->vbox_popup);
gtk_container_add (GTK_CONTAINER (gPreferenceWinStruct->fr_popup), gPreferenceWinStruct->vbox_popup);
gPreferenceWinStruct->block_popup = gtk_check_button_new_with_label ("Block Popup Windows");
if (gPreferenceConfigStruct.disable_popups == 1) {
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(gPreferenceWinStruct->block_popup), TRUE);
} else
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(gPreferenceWinStruct->block_popup), FALSE);
gtk_container_add(GTK_CONTAINER(gPreferenceWinStruct->vbox_popup), gPreferenceWinStruct->block_popup);
gPreferenceWinStruct->lb_popup = gtk_label_new ("Block Popups");
gtk_widget_show (gPreferenceWinStruct->lb_popup);
gtk_frame_set_label_widget (GTK_FRAME (gPreferenceWinStruct->fr_popup), gPreferenceWinStruct->lb_popup);
/* Ok and Cancel Button */
gPreferenceWinStruct->cancelbutton = gtk_button_new_with_label("Cancel");
gtk_widget_modify_font(GTK_BIN(gPreferenceWinStruct->cancelbutton)->child, getOrCreateDefaultMinimoFont());
gtk_widget_show (gPreferenceWinStruct->cancelbutton);
gtk_dialog_add_action_widget (GTK_DIALOG (gPreferenceWinStruct->dialog), gPreferenceWinStruct->cancelbutton, GTK_RESPONSE_CANCEL);
gtk_widget_set_size_request (gPreferenceWinStruct->cancelbutton, 10, -1);
gPreferenceWinStruct->okbutton = gtk_button_new_with_label("Ok");
gtk_widget_modify_font(GTK_BIN(gPreferenceWinStruct->okbutton)->child, getOrCreateDefaultMinimoFont());
gtk_widget_show (gPreferenceWinStruct->okbutton);
gtk_dialog_add_action_widget (GTK_DIALOG (gPreferenceWinStruct->dialog), gPreferenceWinStruct->okbutton, GTK_RESPONSE_OK);
gtk_widget_set_size_request (gPreferenceWinStruct->okbutton, 10, -1);
/* Setting font styles */
gtk_widget_modify_font(gPreferenceWinStruct->rb_manual_connection, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(gPreferenceWinStruct->rb_direct_connection, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(gPreferenceWinStruct->lb_http, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(gPreferenceWinStruct->lb_port_http, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(gPreferenceWinStruct->en_http_port, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(gPreferenceWinStruct->lb_ssl, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(gPreferenceWinStruct->en_ssl, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(gPreferenceWinStruct->en_ssl_port, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(gPreferenceWinStruct->lb_ssl_port, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(gPreferenceWinStruct->lb_ftp, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(gPreferenceWinStruct->en_ftp_proxy, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(gPreferenceWinStruct->lb_ftp_port, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(gPreferenceWinStruct->en_ftp_port, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(gPreferenceWinStruct->lb_connection, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(gPreferenceWinStruct->lb_popup, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(gPreferenceWinStruct->block_popup, getOrCreateDefaultMinimoFont());
gtk_widget_show_all(gPreferenceWinStruct->dialog);
/* connection singnals to buttons */
gtk_signal_connect_object(GTK_OBJECT(gPreferenceWinStruct->cancelbutton), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), gPreferenceWinStruct->dialog);
gtk_signal_connect_object(GTK_OBJECT(gPreferenceWinStruct->okbutton), "clicked", GTK_SIGNAL_FUNC(preferences_ok_cb), gPreferenceWinStruct);
return gPreferenceWinStruct;
}
void preferences_save_cb (GtkButton *button, PrefWindow *pref) {
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gPreferenceWinStruct->rb_direct_connection)) == TRUE)
gPreferenceConfigStruct.direct_connection = 1;
else gPreferenceConfigStruct.direct_connection = 0;
gPreferenceConfigStruct.http_proxy = g_strdup (gtk_entry_get_text (GTK_ENTRY (gPreferenceWinStruct->en_http_proxy)));
gPreferenceConfigStruct.http_proxy_port = g_strdup (gtk_entry_get_text (GTK_ENTRY (gPreferenceWinStruct->en_http_port)));
gPreferenceConfigStruct.ftp_proxy = g_strdup (gtk_entry_get_text (GTK_ENTRY (gPreferenceWinStruct->en_ftp_proxy)));
gPreferenceConfigStruct.ftp_proxy_port = g_strdup (gtk_entry_get_text (GTK_ENTRY (gPreferenceWinStruct->en_ftp_port)));
gPreferenceConfigStruct.ssl_proxy = g_strdup (gtk_entry_get_text (GTK_ENTRY (gPreferenceWinStruct->en_ssl)));
gPreferenceConfigStruct.ssl_proxy_port = g_strdup (gtk_entry_get_text (GTK_ENTRY (gPreferenceWinStruct->en_ssl_port)));
gPreferenceConfigStruct.disable_popups = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gPreferenceWinStruct->block_popup));
preferences_write_config ();
}
void preferences_ok_cb (GtkButton *button, PrefWindow *pref) {
preferences_save_cb (button, pref);
preferences_close_cb (button, pref);
}
void preferences_close_cb (GtkButton *button, PrefWindow *pref) {
gtk_widget_destroy (gPreferenceWinStruct->dialog);
g_free (pref);
}
/* Read the current 'minimo's preferences and configs' into his file: $home/.Minimo/config */
void preferences_read_config (void)
{
FILE *config_file;
gchar *file, *oldfile;
gchar *line, tmpstr[1024];
gint i, temp;
gMinimoUserHomePath = g_strconcat(g_get_home_dir(),NULL);
oldfile = g_strconcat(gMinimoUserHomePath,"/.minimorc", NULL);
file = g_strconcat(gMinimoUserHomePath,"/.Minimo/config", NULL);
if (access(oldfile, F_OK) == 0 && access(file, F_OK) == -1 && errno == ENOENT) {
if (rename(oldfile, file) == 0) {
g_print("Note: .minimorc was moved to %s\n", file);
g_free(oldfile);
} else {
g_warning("Error moving .minimorc to %s: %s\n", file, strerror(errno));
/* we can still read the old file */
g_free(file); file = oldfile;
}
} else {
g_free(oldfile);
}
/* defaults */
gPreferenceConfigStruct.home = g_strdup("http://www.minimo.org");
gPreferenceConfigStruct.xsize = 700;
gPreferenceConfigStruct.ysize = 500;
gPreferenceConfigStruct.layout = 0;
gPreferenceConfigStruct.mailer = g_strdup("pronto %t %s %c");
gPreferenceConfigStruct.max_go = 15;
gPreferenceConfigStruct.maxpopupitems = 15;
gPreferenceConfigStruct.java = TRUE;
gPreferenceConfigStruct.javascript = TRUE;
gPreferenceConfigStruct.http_proxy = g_strdup("");
gPreferenceConfigStruct.ftp_proxy = g_strdup("");
gPreferenceConfigStruct.ftp_proxy_port = g_strdup("");
gPreferenceConfigStruct.http_proxy_port = g_strdup("");
gPreferenceConfigStruct.ssl_proxy = g_strdup("");
gPreferenceConfigStruct.ssl_proxy_port = g_strdup("");
gPreferenceConfigStruct.no_proxy_for = g_strdup("localhost");
gPreferenceConfigStruct.direct_connection = 1;
gPreferenceConfigStruct.popup_in_new_window = 0;
gPreferenceConfigStruct.disable_popups = 0;
gPreferenceConfigStruct.current_font_size = DEFAULT_FONT_SIZE;
for (i=0; i < LANG_FONT_NUM; i++) {
gPreferenceConfigStruct.min_font_size [i]= DEFAULT_MIN_FONT_SIZE;
}
config_file = fopen(file,"r");
if (config_file == NULL) {
preferences_write_config ();
}
config_file = fopen(file,"r");
line = (gchar *)g_malloc(1024);
while(fgets(line,1024,config_file) != NULL) {
line[strlen(line)-1] = '\0';
if (g_strncasecmp(line,"home=",5) == 0) {
gPreferenceConfigStruct.home = g_strdup(line+5);
if (g_strcasecmp(gPreferenceConfigStruct.home,"") == 0) {
g_free(gPreferenceConfigStruct.home);
gPreferenceConfigStruct.home = g_strdup("about:blank");
}
} else if (g_strncasecmp(line,"xsize=",6) == 0) {
gPreferenceConfigStruct.xsize = atoi(line+6);
} else if (g_strncasecmp(line,"ysize=",6) == 0) {
gPreferenceConfigStruct.ysize = atoi(line+6);
} else if (g_strncasecmp(line,"layout=",7) == 0) {
gPreferenceConfigStruct.layout = atoi(line+7);
} else if (g_strncasecmp(line,"mailer=",7) == 0) {
g_free(gPreferenceConfigStruct.mailer); gPreferenceConfigStruct.mailer = g_strdup(line+7);
} else if (g_strncasecmp(line,"maxpopup=",9) == 0) {
gPreferenceConfigStruct.maxpopupitems = atoi(line+9);
} else if (g_strncasecmp(line,"http_proxy=",11) == 0) {
g_free(gPreferenceConfigStruct.http_proxy);
gPreferenceConfigStruct.http_proxy = g_strdup(line+11);
} else if (g_strncasecmp(line,"http_proxy_port=",16) == 0) {
g_free(gPreferenceConfigStruct.http_proxy_port);
gPreferenceConfigStruct.http_proxy_port = g_strdup(line+16);
} else if (g_strncasecmp(line,"ftp_proxy=",10) == 0) {
g_free(gPreferenceConfigStruct.ftp_proxy);
gPreferenceConfigStruct.ftp_proxy = g_strdup(line+10);
} else if (g_strncasecmp(line,"ftp_proxy_port=",15) == 0) {
g_free(gPreferenceConfigStruct.ftp_proxy_port);
gPreferenceConfigStruct.ftp_proxy_port = g_strdup(line+15);
} else if (g_strncasecmp(line,"no_proxy_for=",13) == 0) {
g_free(gPreferenceConfigStruct.no_proxy_for);
gPreferenceConfigStruct.no_proxy_for = g_strdup(line+13);
} else if (g_strncasecmp(line,"ssl_proxy=",10) == 0) {
g_free(gPreferenceConfigStruct.ssl_proxy);
gPreferenceConfigStruct.ssl_proxy = g_strdup(line+10);
} else if (g_strncasecmp(line,"ssl_proxy_port=",15) == 0) {
g_free(gPreferenceConfigStruct.ssl_proxy_port);
gPreferenceConfigStruct.ssl_proxy_port = g_strdup(line+15);
} else if (g_strncasecmp(line,"direct_connection=",18) == 0) {
gPreferenceConfigStruct.direct_connection = atoi(line+18);
} else if (g_strncasecmp(line,"max_go=",7) == 0) {
gPreferenceConfigStruct.max_go = atoi(line+7);
} else if (g_strncasecmp(line,"popup_in_new_window=",20) == 0) {
gPreferenceConfigStruct.popup_in_new_window = atoi (line + 20);
} else if (g_strncasecmp(line,"disable_popups=",15) == 0) {
gPreferenceConfigStruct.disable_popups = atoi(line+15);
} else if (g_strncasecmp(line,"fontsize_",9) == 0) {
for (i = 0; i < LANG_FONT_NUM; i++) {
g_snprintf (tmpstr, 1024, "%s=", lang_font_item[i]);
if (g_strncasecmp(line+9,tmpstr,strlen(tmpstr)))
continue;
gPreferenceConfigStruct.font_size[i] = atoi(line+9+strlen(tmpstr));
};
} else if (g_strncasecmp(line,"min_fontsize_",13) == 0) {
for (i=0; i < LANG_FONT_NUM; i++) {
g_snprintf(tmpstr,1024,"%s=",lang_font_item[i]);
if (g_strncasecmp(line+13,tmpstr,strlen(tmpstr)))
continue;
gPreferenceConfigStruct.min_font_size[i] = atoi(line+13+strlen(tmpstr));
}
} else if (g_strncasecmp(line,"java=",5) == 0) {
temp = atoi(line+5);
if (temp) {
gPreferenceConfigStruct.java = TRUE;
} else {
gPreferenceConfigStruct.java = FALSE;
}
} else if (g_strncasecmp(line,"javascript=",11) == 0) {
temp = atoi(line+11);
if (temp) {
gPreferenceConfigStruct.javascript = TRUE;
} else {
gPreferenceConfigStruct.javascript = FALSE;
}
}
}
fflush (config_file);
fclose(config_file);
g_free(line);
g_free(file);
}
/* Write the current 'minimo's configs' into his file: $home/.Minimo/config */
void preferences_write_config ()
{
FILE *config_file;
gchar *file;
file = g_strconcat(gMinimoUserHomePath,"/.Minimo/config",NULL);
config_file = fopen(file,"w");
if (config_file == NULL) {
g_error ("Cannot write history file!");
return ;
}
fprintf(config_file,"home=%s\n",gPreferenceConfigStruct.home);
fprintf(config_file,"xsize=%d\n",gPreferenceConfigStruct.xsize);
fprintf(config_file,"ysize=%d\n",gPreferenceConfigStruct.ysize);
fprintf(config_file,"layout=%d\n",gPreferenceConfigStruct.layout);
fprintf(config_file,"mailer=%s\n",gPreferenceConfigStruct.mailer);
fprintf(config_file,"maxpopup=%d\n",gPreferenceConfigStruct.maxpopupitems);
fprintf(config_file,"http_proxy=%s\n",gPreferenceConfigStruct.http_proxy);
fprintf(config_file,"http_proxy_port=%s\n",gPreferenceConfigStruct.http_proxy_port);
fprintf(config_file,"ftp_proxy=%s\n",gPreferenceConfigStruct.ftp_proxy);
fprintf(config_file,"ftp_proxy_port=%s\n",gPreferenceConfigStruct.ftp_proxy_port);
fprintf(config_file,"ssl_proxy=%s\n",gPreferenceConfigStruct.ssl_proxy);
fprintf(config_file,"ssl_proxy_port=%s\n",gPreferenceConfigStruct.ssl_proxy_port);
fprintf(config_file,"no_proxy_for=%s\n",gPreferenceConfigStruct.no_proxy_for);
fprintf(config_file,"direct_connection=%d\n",gPreferenceConfigStruct.direct_connection);
fprintf(config_file,"max_go=%d\n",gPreferenceConfigStruct.max_go);
fprintf(config_file,"popup_in_new_window=%d\n",gPreferenceConfigStruct.popup_in_new_window);
fprintf(config_file,"disable_popups=%d\n",gPreferenceConfigStruct.disable_popups);
if (gPreferenceConfigStruct.javascript == TRUE) {
fprintf(config_file,"javascript=1\n");
} else {
fprintf(config_file,"javascript=0\n");
}
if (gPreferenceConfigStruct.java == TRUE) {
fprintf(config_file,"java=1\n");
} else {
fprintf(config_file,"java=0\n");
}
fclose(config_file);
g_free(file);
preferences_set_mozilla_config ();
}
void preferences_set_mozilla_config (void)
{
gint disk_cache= 0, mem_cache= 0;
gchar *cachedir;
mozilla_preference_set_boolean ("security.warn_entering_secure", FALSE);
mozilla_preference_set_boolean ("security.warn_leaving_secure", FALSE);
mozilla_preference_set_boolean ("security.warn_submit_insecure", FALSE);
mozilla_preference_set_boolean ("security.warn_viewing_mixed", FALSE);
if (gPreferenceConfigStruct.disable_popups)
mozilla_preference_set_boolean ("dom.disable_open_during_load", TRUE);
else
mozilla_preference_set_boolean ("dom.disable_open_during_load", FALSE);
mozilla_preference_set_boolean("nglayout.widget.gfxscrollbars", TRUE);
/*for (i = 0; i < LANG_FONT_NUM; i++) {
g_snprintf(tmpstr, 1024, "font.min-size.variable.", "");
mozilla_preference_set_int(tmpstr, gPreferenceConfigStruct.current_font_size);
g_snprintf(tmpstr, 1024, "font.min-size.variable.x-western", "");
mozilla_preference_set_int(tmpstr, 2);
g_snprintf(tmpstr, 1024, "font.min-size.fixed.x-western", "");
mozilla_preference_set_int(tmpstr, 2);
g_snprintf (tmpstr, 1024, "font.size.variable.%s", lang_font_item[i]);
mozilla_preference_set_int(tmpstr,gPreferenceConfigStruct.current_font_size);
g_snprintf(tmpstr, 1024, "font.min-size.variable.%s", lang_font_item[i]);
mozilla_preference_set_int(tmpstr, gPreferenceConfigStruct.current_font_size);
//mozilla_preference_set_int(tmpstr, DEFAULT_MIN_FONT_SIZE);
}*/
mozilla_preference_set_boolean ("security.enable_java", gPreferenceConfigStruct.java);
mozilla_preference_set_boolean ("javascript.enabled", gPreferenceConfigStruct.javascript);
mozilla_preference_set_boolean ("browser.view_source.syntax_highlight", TRUE);
cachedir = g_strconcat(gMinimoUserHomePath,"/.Minimo/cache",NULL);
mkdir(cachedir,0755);
mozilla_preference_set("browser.cache.directory",cachedir);
g_free(cachedir);
if ((disk_cache > 0) || (mem_cache > 0)) {
mozilla_preference_set_boolean("browser.cache.disk.enable",TRUE);
mozilla_preference_set_boolean("browser.cache.enable", TRUE);
}
else
{
mozilla_preference_set_boolean("browser.cache.disk.enable",FALSE);
mozilla_preference_set_boolean("browser.cache.enable", FALSE);
}
if (disk_cache > 0) {
mozilla_preference_set_boolean("browser.cache.disk.enable",TRUE);
mozilla_preference_set_int("browser.cache.disk_cache_size",disk_cache);
mozilla_preference_set_int("browser.cache.disk.capacity",disk_cache);
}
else
{
mozilla_preference_set_boolean("browser.cache.disk.enable",FALSE);
mozilla_preference_set_int("browser.cache.disk_cache_size", 0);
mozilla_preference_set_int("browser.cache.disk.capacity",0);
}
if (mem_cache > 0) {
mozilla_preference_set_int("browser.cache.memory_cache_size",mem_cache);
mozilla_preference_set_int("browser.cache.memory.capacity",mem_cache);
} else {
mozilla_preference_set_int("browser.cache.memory_cache_size", 0);
mozilla_preference_set_int("browser.cache.memory.capacity",0);
}
/* set proxy stuff */
preferences_set_mozilla_proxy_config ();
mozilla_save_prefs ();
}
void preferences_set_mozilla_proxy_config(void)
{
gint network_type = 0;
if (gPreferenceConfigStruct.direct_connection) {
mozilla_preference_set("network.proxy.http","");
mozilla_preference_set("network.proxy.ssl","");
mozilla_preference_set("network.proxy.ftp","");
mozilla_preference_set("network.proxy.no_proxies_on", " ");
mozilla_preference_set_int("network.proxy.type",network_type);
} else {
if (strlen(gPreferenceConfigStruct.http_proxy) != 0 && strcmp(gPreferenceConfigStruct.http_proxy,"") != 0 && strlen(gPreferenceConfigStruct.http_proxy_port) > 0 && strcmp(gPreferenceConfigStruct.http_proxy_port,"") != 0) {
mozilla_preference_set_int ("network.proxy.type", 1);
network_type=1;
mozilla_preference_set ("network.proxy.http", gPreferenceConfigStruct.http_proxy);
mozilla_preference_set_int ("network.proxy.http_port", atoi(gPreferenceConfigStruct.http_proxy_port));
}
if (strlen(gPreferenceConfigStruct.ftp_proxy) != 0 && strcmp(gPreferenceConfigStruct.ftp_proxy,"") != 0 && strlen(gPreferenceConfigStruct.ftp_proxy_port) > 0 && strcmp(gPreferenceConfigStruct.http_proxy_port,"") != 0) {
if (!network_type)
mozilla_preference_set_int("network.proxy.type", 1);
mozilla_preference_set ("network.proxy.ftp", gPreferenceConfigStruct.ftp_proxy);
mozilla_preference_set_int ("network.proxy.ftp_port", atoi(gPreferenceConfigStruct.ftp_proxy_port));
}
if (strlen(gPreferenceConfigStruct.ssl_proxy) != 0 && strcmp(gPreferenceConfigStruct.ssl_proxy,"") != 0 && strlen(gPreferenceConfigStruct.ssl_proxy_port) > 0 && strcmp (gPreferenceConfigStruct.ssl_proxy_port,"") != 0) {
if (!network_type)
mozilla_preference_set_int("network.proxy.type", 1);
mozilla_preference_set ("network.proxy.ssl", gPreferenceConfigStruct.ssl_proxy);
mozilla_preference_set_int ("network.proxy.ssl_port", atoi(gPreferenceConfigStruct.ssl_proxy_port));
}
if (strlen(gPreferenceConfigStruct.no_proxy_for) != 0)
mozilla_preference_set("network.proxy.no_proxies_on", gPreferenceConfigStruct.no_proxy_for);
else
mozilla_preference_set("network.proxy.no_proxies_on", " ");
}
}

Просмотреть файл

@ -1,69 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef preference_h
#define preference_h
#include "mozilla_api.h"
#include "minimo_types.h"
/* Callbacks */
void preferences_close_cb (GtkButton *, PrefWindow *);
void preferences_ok_cb (GtkButton *, PrefWindow *);
/* Support methods */
void preferences_read_config (void);
void preferences_write_config (void);
void preferences_set_mozilla_config (void);
void preferences_set_mozilla_proxy_config(void);
/* UI Methods */
PrefWindow * preferences_build_dialog (GtkWidget *);
#endif

Просмотреть файл

@ -1,260 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "minimo_support.h"
#include "Minimo.h"
#include "minimo_callbacks.h"
extern GList *gMinimoBrowserList; /* the list of browser windows
currently open */
extern gchar *gMinimoProfilePath;
/* Variable to enable pango settings */
static PangoFontDescription* gDefaultMinimoFont = NULL;
/* Data Struct for make possible the real autocomplete */
GList *gAutoCompleteList = g_list_alloc(); /* Auto Complete List */
GtkEntryCompletion *gMinimoEntryCompletion;
GtkListStore *gMinimoAutoCompleteListStore;
GtkTreeIter gMinimoAutoCompleteIter;
/* body */
void support_handle_remote(int sig) {
FILE *fp;
char url[256];
sprintf(url, "/tmp/Mosaic.%d", getpid());
if ((fp = fopen(url, "r"))) {
if (fgets(url, sizeof(url) - 1, fp)) {
MinimoBrowser *bw = NULL;
if (strncmp(url, "goto", 4) == 0 &&
fgets(url, sizeof(url) - 1, fp)) {
GList *tmp_list = gMinimoBrowserList;
bw =(MinimoBrowser *)tmp_list->data;
if(!bw) return;
} else if (strncmp(url, "newwin", 6) == 0 &&
fgets(url, sizeof(url) - 1, fp)) {
bw = new_gtk_browser(GTK_MOZ_EMBED_FLAG_DEFAULTCHROME);
gtk_widget_set_usize(bw->mozEmbed, 240, 320);
set_browser_visibility(bw, TRUE);
}
if (bw)
gtk_moz_embed_load_url(GTK_MOZ_EMBED(bw->mozEmbed), url);
fclose(fp);
}
}
return;
}
void support_init_remote() {
gchar *file;
FILE *fp;
signal(SIGUSR1, SIG_IGN);
/* Write the pidfile : would be useful for automation process*/
file = g_strconcat(g_get_home_dir(), "/", ".mosaicpid", NULL);
if((fp = fopen(file, "w"))) {
fprintf (fp, "%d\n", getpid());
fclose (fp);
signal(SIGUSR1, support_handle_remote);
}
g_free(file);
}
void support_cleanup_remote() {
gchar *file;
signal(SIGUSR1, SIG_IGN);
file = g_strconcat(g_get_home_dir(), "/", ".mosaicpid", NULL);
unlink(file);
g_free(file);
}
void support_autocomplete_populate(gpointer data, gpointer combobox) {
if (!data || !combobox)
return;
gtk_combo_set_popdown_strings (GTK_COMBO (combobox), gAutoCompleteList);
}
void support_populate_autocomplete(GtkCombo *comboBox) {
g_list_foreach(gAutoCompleteList, support_autocomplete_populate, comboBox);
}
gint support_autocomplete_list_cmp(gconstpointer a, gconstpointer b) {
if (!a)
return -1;
if (!b)
return 1;
return strcmp((char*)a, (char*)b);
}
void support_init_autocomplete() {
if (!gAutoCompleteList)
return;
char* full_path = g_strdup_printf("%s/%s", gMinimoProfilePath, "autocomplete.txt");
FILE *fp;
char url[255];
gMinimoAutoCompleteListStore = gtk_list_store_new (1, G_TYPE_STRING);
if((fp = fopen(full_path, "r+"))) {
while(fgets(url, sizeof(url) - 1, fp)) {
int length = strlen(url);
if (url[length-1] == '\n')
url[length-1] = '\0';
gAutoCompleteList = g_list_append(gAutoCompleteList, g_strdup(url));
/* Append url's to autocompletion feature */
gtk_list_store_append (gMinimoAutoCompleteListStore, &gMinimoAutoCompleteIter);
gtk_list_store_set (gMinimoAutoCompleteListStore, &gMinimoAutoCompleteIter, 0, url, -1);
}
fclose(fp);
}
gAutoCompleteList = g_list_sort(gAutoCompleteList, support_autocomplete_list_cmp);
}
void support_autocomplete_writer(gpointer data, gpointer fp) {
FILE* file = (FILE*) fp;
char* url = (char*) data;
if (!url || !fp)
return;
fwrite(url, strlen(url), 1, file);
fputc('\n', file);
}
void support_autocomplete_destroy(gpointer data, gpointer dummy) {
g_free(data);
}
void support_cleanup_autocomplete() {
char* full_path = g_strdup_printf("%s/%s", gMinimoProfilePath, "autocomplete.txt");
FILE *fp;
if((fp = fopen(full_path, "w"))) {
g_list_foreach(gAutoCompleteList, support_autocomplete_writer, fp);
fclose(fp);
}
g_free(full_path);
g_list_foreach(gAutoCompleteList, support_autocomplete_destroy, NULL);
}
void support_add_autocomplete(const char* value, OpenDialogParams* params) {
GList* found = g_list_find_custom(gAutoCompleteList, value, support_autocomplete_list_cmp);
if (!found) {
gAutoCompleteList = g_list_insert_sorted(gAutoCompleteList, g_strdup(value), support_autocomplete_list_cmp);
/* Append url's to autocompletion*/
gtk_list_store_append (gMinimoAutoCompleteListStore, &gMinimoAutoCompleteIter);
gtk_list_store_set (gMinimoAutoCompleteListStore, &gMinimoAutoCompleteIter, 0, value, -1);
}
gtk_combo_set_popdown_strings (GTK_COMBO (params->dialog_combo), gAutoCompleteList);
}
/* Method that build the entry completion */
void support_build_entry_completion (MinimoBrowser* browser)
{
/* Minimo entry completion */
gMinimoEntryCompletion = gtk_entry_completion_new ();
gtk_entry_completion_set_model (gMinimoEntryCompletion, GTK_TREE_MODEL (gMinimoAutoCompleteListStore));
gtk_entry_completion_set_text_column (gMinimoEntryCompletion, 0);
}
/* Method to sep up the escape key handler */
void support_setup_escape_key_handler(GtkWidget *window)
{
g_signal_connect(G_OBJECT(window), "key_press_event", G_CALLBACK(support_escape_key_handler), NULL);
}
/* Method to handler the escape key */
gint support_escape_key_handler(GtkWidget *window, GdkEventKey *ev)
{
g_return_val_if_fail(window != NULL, FALSE);
if (ev->keyval == GDK_Escape) {
gtk_widget_destroy(window);
return (1);
}
return (0);
}
PangoFontDescription* getOrCreateDefaultMinimoFont()
{
if (gDefaultMinimoFont)
return gDefaultMinimoFont;
gDefaultMinimoFont = pango_font_description_from_string("sans 8");
return gDefaultMinimoFont;
}
void support_destroy_dialog_params_cb(GtkWidget *widget, OpenDialogParams* params)
{
free(params);
}

Просмотреть файл

@ -1,77 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef minimo_support_h
#define minimo_support_h
#include "minimo_types.h"
void support_handle_remote (int );
void support_init_remote ();
void support_cleanup_remote ();
void support_destroy_dialog_params_cb (GtkWidget *, OpenDialogParams* );
void support_build_entry_completion (MinimoBrowser* );
void support_autocomplete_populate (gpointer , gpointer );
void support_populate_autocomplete (GtkCombo *);
gint support_autocomplete_list_cmp (gconstpointer , gconstpointer );
void support_init_autocomplete ();
void support_autocomplete_writer (gpointer , gpointer );
void support_autocomplete_destroy (gpointer , gpointer );
void support_cleanup_autocomplete ();
void support_add_autocomplete (const char* , OpenDialogParams* );
void support_setup_escape_key_handler(GtkWidget *);
gint support_escape_key_handler(GtkWidget *, GdkEventKey *);
PangoFontDescription* getOrCreateDefaultMinimoFont();
#endif

Просмотреть файл

@ -1,312 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef minimo_types_h
#define minimo_types_h
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <dirent.h>
#include "gtkmozembed.h"
/* MINIMO TOOLBAR STRUCT */
typedef struct _MinimoToolBar {
GtkWidget *toolbar;
GtkWidget *OpenButton;
GtkWidget *BackButton;
GtkWidget *ReloadButton;
GtkWidget *ForwardButton;
GtkWidget *StopButton;
GtkWidget *PrefsButton;
GtkWidget *InfoButton;
GtkWidget *QuitButton;
} MinimoToolbar;
/* MINIMO STRUCT */
typedef struct _MinimoBrowser {
GtkWidget *topLevelWindow;
GtkWidget *topLevelVBox;
GtkWidget *mozEmbed;
MinimoToolbar toolbar;
gboolean show_tabs;
GtkWidget *notebook;
GtkWidget *label_notebook;
GtkWidget *active_page;
GtkWidget *progressPopup;
GtkWidget *progressBar;
gint totalBytes;
GtkWidget *link_menu;
GtkWidget *image_menu;
GtkWidget *doc_menu;
GtkWidget *image_link_menu;
GtkWidget *reload_menu;
gboolean didFind;
} MinimoBrowser;
typedef struct _PrefWindow /* configuration data struct */
{
GtkWidget *dialog;
GtkWidget *okbutton;
GtkWidget *cancelbutton;
GtkWidget *applybutton;
GtkWidget *block_popup;
GtkWidget *vbox_popup;
GtkWidget *fr_connection;
GtkWidget *vbox_connection;
GtkWidget *hbox_connection;
GtkWidget *hbox_direct_connection;
GtkWidget *fr_popup;
GtkWidget *lb_popup;
GtkWidget *vbox_manual;
GtkWidget *rb_manual_connection;
GtkWidget *hbox_http;
GtkWidget *lb_http;
GtkWidget *en_http_proxy;
GtkWidget *box_popup;
GtkWidget *lb_port_http;
GtkWidget *en_http_port;
GtkWidget *hbox_ssl;
GtkWidget *lb_ssl;
GtkWidget *en_ssl;
GtkWidget *lb_ssl_port;
GtkWidget *en_ssl_port;
GtkWidget *hbox_ftp;
GtkWidget *lb_ftp;
GtkWidget *en_ftp_proxy;
GtkWidget *lb_ftp_port;
GtkWidget *en_ftp_port;
GtkWidget *hbox_noproxy;
GtkWidget *lb_connection;
GSList *rb_direct_connection_group;
GSList *rb_manual_connection_group;
GtkWidget *hbox_manual_connection;
GtkWidget *rb_direct_connection;
} PrefWindow;
/* SPECIFIC STRUCT FOR SPECIFY SOME PARAMETERS OF '_open_dialog_params' METHOD */
typedef struct _open_dialog_params
{
GtkWidget* dialog_combo;
GtkWidget* main_combo;
} OpenDialogParams;
/* SPECIFIC STRUCT FOR THE RIGHT CLICK BUTTON EMULATION */
typedef struct _right_button_click
{
GTimer *pressing_timer;
gulong sig_handler;
} RightButtonClick;
/****************/
/* PREFERENCE.H */
/****************/
#define LANG_FONT_NUM 15
#define DEFAULT_FONT_SIZE 10
#define DEFAULT_MIN_FONT_SIZE 5
#define DEFAULT_SERIF_FONT "-adobe-times-medium-r-normal-*-14-*-*-*-p-*-iso8859-1"
#define DEFAULT_SANSSERIF_FONT "-adobe-times-medium-r-normal-*-14-*-*-*-p-*-iso8859-1"
#define DEFAULT_CURSIVE_FONT "-adobe-times-medium-r-normal-*-14-*-*-*-p-*-iso8859-1"
#define DEFAULT_FANTASY_FONT "-adobe-times-medium-r-normal-*-14-*-*-*-p-*-iso8859-1"
#define DEFAULT_MONOSPACE_FONT "-adobe-times-medium-r-normal-*-14-*-*-*-p-*-iso8859-1"
static const char *lang_font_item [LANG_FONT_NUM] =
{
"x-western",
"x-central-euro",
"ja",
"zh-TW",
"zh-CN",
"ko",
"x-cyrillic",
"x-baltic",
"el",
"tr",
"x-unicode",
"x-user-def",
"th",
"he",
"ar"
};
/**
* configuration data struct
*/
typedef struct _ConfigData /* configuration data struct */
{
/* minimo prefs */
gchar *home;
gchar *mailer;
gint xsize;
gint ysize;
gint layout;
gint maxpopupitems;
gint max_go;
/* mozilla prefs */
gchar *http_proxy;
gchar *http_proxy_port;
gchar *ftp_proxy;
gchar *ftp_proxy_port;
gchar *ssl_proxy;
gchar *ssl_proxy_port;
gint font_size[LANG_FONT_NUM];
gint min_font_size[LANG_FONT_NUM];
gint current_font_size;
gboolean java;
gboolean javascript;
gboolean underline_links;
gchar *no_proxy_for;
gint direct_connection;
gint popup_in_new_window;
gint disable_popups;
gint tab_text_length;
} ConfigData;
/****************/
/* HISTORY.H */
/****************/
/* History Window Structure */
typedef struct _HistoryWindow{
GtkWidget *window;
GtkWidget *scrolled_window;
GtkWidget *clist;
GtkWidget *vbox;
GtkWidget *remove;
GtkWidget *close;
GtkWidget *btnbox;
GtkWidget *clear;
GtkWidget *search_label;
GtkWidget *search_entry;
GtkWidget *search_box;
GtkWidget *search_button;
GtkWidget *go_button;
GtkWidget *embed;
gchar *title;
}HistoryWindow;
/****************/
/* BOOKMARK.H */
/****************/
/* represent a bookmark item */
typedef struct _BookmarkData {
gchar *label;
gchar *url;
} BookmarkData;
/* Represents Bookmarks Tree View*/
typedef struct _BookmarkTreeVData {
GtkTreeModel *treeStore;
GtkTreeIter *parentIter;
} BookmarkTreeVData;
/* Bookmarks Window Structure */
typedef struct _BookmarkWindow {
FILE *bookmark_file;
GtkWidget *window;
GtkWidget *menubar;
GtkWidget *menu_item_tools;
GtkWidget *menu_tools;
GtkWidget *menu_import;
GtkWidget *menu_export;
GtkWidget *scrolled_window;
GtkWidget *vbox1;
GtkWidget *hbox4;
GtkWidget *hbox1;
GtkWidget *hbox2;
GtkWidget *hbox3;
GtkWidget *text_label;
GtkWidget *text_entry;
GtkWidget *url_label;
GtkWidget *url_entry;
GtkWidget *add_button;
GtkWidget *edit_button;
GtkWidget *folder_entry;
GtkWidget *remove_button;
GtkWidget *ok_button;
GtkWidget *go_button;
GtkWidget *cancel_button;
GtkWidget *treev;
GtkTreeIter iter;
GtkTreeSelection *selection;
BookmarkTreeVData *treev_data;
} BookmarkWindow;
#endif

Просмотреть файл

@ -1,447 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla_api.h"
/*
* mozilla_locale_to_unicode: Decodes a string encoded for the current
* locale into unicode. Used for getting text entered in a GTK+ entry
* into a form which mozilla can use.
*
*/
PRUnichar *
mozilla_locale_to_unicode (const gchar *locStr)
{
if (locStr == NULL)
{
return (NULL);
}
nsAutoString autoStr;
autoStr.AssignWithConversion (locStr);
PRUnichar *uniStr = ToNewUnicode(autoStr);
return ( uniStr );
}
/*
* mozilla_find: Look for a text in the current shown webpage
*
*/
gboolean
mozilla_find(GtkMozEmbed *b, const char *exp, PRBool IgnoreCase,
PRBool SearchBackWards, PRBool DoWrapFind,
PRBool SearchEntireWord, PRBool SearchInFrames,
PRBool DidFind)
{
PRUnichar *search_string;
g_return_val_if_fail(b != NULL, FALSE);
nsIWebBrowser *wb = nsnull;
gtk_moz_embed_get_nsIWebBrowser( b, &wb);
nsCOMPtr<nsIWebBrowserFind> finder(do_GetInterface(wb));
search_string = mozilla_locale_to_unicode(exp);
finder->SetSearchString(search_string);
finder->SetFindBackwards(SearchBackWards);
finder->SetWrapFind(DoWrapFind);
finder->SetEntireWord(SearchEntireWord);
finder->SetSearchFrames(SearchInFrames);
finder->SetMatchCase(IgnoreCase);
finder->FindNext(&DidFind);
g_free(search_string);
return ( DidFind );
}
/*
* mozilla_preference_set: Method used to set up some specific text-based parameters of the gecko render engine
*
*/
gboolean
mozilla_preference_set (const char *preference_name, const char *new_value)
{
g_return_val_if_fail (preference_name != NULL, FALSE);
g_return_val_if_fail (new_value != NULL, FALSE);
nsCOMPtr<nsIPref> pref = do_CreateInstance(PREF_ID);
if (pref)
{
nsresult rv = pref->SetCharPref (preference_name, new_value);
return ( NS_SUCCEEDED (rv) ? TRUE : FALSE );
}
return (FALSE);
}
/*
* mozilla_preference_set: Method used to set up some specific boolean-based parameters of the gecko render engine
*
*/
gboolean
mozilla_preference_set_boolean (const char *preference_name, gboolean new_boolean_value)
{
g_return_val_if_fail (preference_name != NULL, FALSE);
nsCOMPtr<nsIPref> pref = do_CreateInstance(PREF_ID);
if (pref)
{
nsresult rv = pref->SetBoolPref (preference_name, new_boolean_value ? PR_TRUE : PR_FALSE);
return ( NS_SUCCEEDED (rv) ? TRUE : FALSE );
}
return (FALSE);
}
/*
* mozilla_preference_set: Method used to set up some specific integer-based parameters of the gecko render engine
*
*/
gboolean
mozilla_preference_set_int (const char *preference_name, gint new_int_value)
{
g_return_val_if_fail (preference_name != NULL, FALSE);
nsCOMPtr<nsIPref> pref = do_CreateInstance(PREF_ID);
if (pref)
{
nsresult rv = pref->SetIntPref (preference_name, new_int_value);
return ( NS_SUCCEEDED (rv) ? TRUE : FALSE );
}
return (FALSE);
}
/*
* mozilla_save: Method used to save an webpage and its files into the disk
*
*/
gboolean
mozilla_save(GtkMozEmbed *b, gchar *file_name, gint all)
{
nsCOMPtr<nsIWebBrowser> wb;
gint i = 0;
gchar *relative_path = NULL;
g_return_val_if_fail(b != NULL, FALSE);
gtk_moz_embed_get_nsIWebBrowser(b,getter_AddRefs(wb));
if (!wb) return (FALSE);
nsCOMPtr<nsIWebNavigation> nav(do_QueryInterface(wb));
nsCOMPtr<nsIDOMDocument> domDoc;
nav->GetDocument(getter_AddRefs(domDoc));
if (!domDoc) return (FALSE);
nsCOMPtr<nsIWebBrowserPersist> persist(do_QueryInterface(wb));
if (persist) {
nsCOMPtr<nsILocalFile> file;
nsCOMPtr<nsILocalFile> relative = nsnull;
if (all) {
relative_path = g_strdup(file_name);
relative_path = g_strconcat(relative_path,"_files/", NULL);
for (i=strlen(relative_path)-1 ; i >= 0; --i)
if (relative_path[i] == '/')
{
relative_path[i] = '\0';
break;
}
mkdir(relative_path,0755);
nsAutoString s; s.AssignWithConversion(relative_path);
NS_NewLocalFile(s, PR_TRUE, getter_AddRefs(relative));
}
nsAutoString s; s.AssignWithConversion(file_name);
NS_NewLocalFile(s,PR_TRUE,getter_AddRefs(file));
if (file) persist->SaveDocument(domDoc,file,relative, nsnull, 0, 0);
if (all) g_free(relative_path);
return (TRUE);
}
return (FALSE);
}
void
mozilla_save_image(GtkMozEmbed *b,gchar *location, gchar *FullPath)
{
nsresult rv = NS_OK;
if (strlen(location) == 0 || !location) return;
nsCOMPtr<nsIURI> linkURI;
rv = NS_NewURI(getter_AddRefs(linkURI), location);
if (NS_FAILED(rv)) return;
nsIWebBrowser *wb = nsnull;
gtk_moz_embed_get_nsIWebBrowser(b,&wb);
nsCOMPtr<nsIWebBrowserPersist> persist(do_QueryInterface(wb));
if (persist) {
nsCOMPtr<nsILocalFile> file;
nsAutoString s; s.AssignWithConversion(FullPath);
NS_NewLocalFile(s, PR_TRUE, getter_AddRefs(file));
if (!file) return;
persist->SaveURI(linkURI, nsnull, nsnull, nsnull, nsnull, file);
}
return;
}
/*
* mozilla_get_link_message: Method used to get "link messages" from the Gecko Render Engine.
* eg. When the user put the mouse over a link, the render engine throws messages that can be cautch for after
* used by Minimo Browser.
*
*/
gchar *
mozilla_get_link_message (GtkWidget *embed)
{
gchar *link;
link = gtk_moz_embed_get_link_message (GTK_MOZ_EMBED (embed));
return link;
}
gboolean
mozilla_save_prefs (void)
{
nsCOMPtr<nsIPrefService> prefService = do_GetService (PREF_ID);
g_return_val_if_fail (prefService != nsnull, FALSE);
nsresult rv = prefService->SavePrefFile (nsnull);
return NS_SUCCEEDED (rv) ? TRUE : FALSE;
}
glong
mozilla_get_context_menu_type(GtkMozEmbed *b, gpointer event, gchar **img, gchar **link, gchar **linktext)
{
nsresult result;
*img = *link = NULL;
nsIDOMMouseEvent *aMouseEvent = (nsIDOMMouseEvent*)event;
nsCOMPtr<nsIDOMEventTarget> OriginalTarget;
nsCOMPtr<nsIDOMNSEvent> aEvent = do_QueryInterface(aMouseEvent);
if (!aEvent) return(CONTEXT_NONE);
result = aEvent->GetOriginalTarget(getter_AddRefs(OriginalTarget));
if (NS_FAILED(result) || !OriginalTarget) return (CONTEXT_NONE);
nsCOMPtr<nsIDOMNode> OriginalNode = do_QueryInterface(OriginalTarget);
if (!OriginalNode) return (CONTEXT_NONE);
nsString nodename;
OriginalNode->GetNodeName(nodename);
if (nodename.EqualsLiteral ("xul:thumb") ||
nodename.EqualsLiteral ("xul:slider"))
return (CONTEXT_NONE);
nsCOMPtr<nsIDOMEventTarget> EventTarget;
result = aMouseEvent->GetTarget(getter_AddRefs(EventTarget));
if (NS_FAILED(result) || !EventTarget) return ( CONTEXT_NONE );
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(EventTarget);
if (!node) return (CONTEXT_NONE);
nsCOMPtr<nsIDOMDocument> domDoc;
result = node->GetOwnerDocument(getter_AddRefs(domDoc));
if (!NS_SUCCEEDED (result) || !domDoc) return (CONTEXT_NONE);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
if(!doc) return (CONTEXT_NONE);
nsCOMPtr<nsIDOMNSDocument> nsDoc = do_QueryInterface(domDoc);
if (!nsDoc) return (CONTEXT_NONE);
nsIURI *baseURI;
baseURI = doc->GetBaseURI ();
if (!baseURI) return (CONTEXT_NONE);
nsString mime;
nsDoc->GetContentType(mime);
if (mime.EqualsLiteral("text/xul")) return (CONTEXT_NONE);
PRUint32 flags = CONTEXT_NONE;
nsCOMPtr<nsIDOMHTMLElement> element;
do {
PRUint16 type;
node->GetNodeType(&type);
element = do_QueryInterface(node);
if (element)
{
nsAutoString tag;
element->GetTagName(tag);
if (tag.EqualsIgnoreCase("input"))
{
flags |= CONTEXT_INPUT;
}
else if (tag.EqualsIgnoreCase("img")) //if (tag.EqualsWithConversion("img", PR_TRUE))
{
flags |= CONTEXT_IMAGE;
char *src = mozilla_get_attribute (node, "src");
if (!src) return ( CONTEXT_NONE );
nsAutoString srca;
srca.AssignWithConversion(src);
nsCString srcc,imgc;
srcc.AssignWithConversion(srca);
result = baseURI->Resolve(srcc, imgc);
g_free(src);
*img = ToNewCString(imgc);
if (!img) return (CONTEXT_NONE);
}
else
{
flags |= CONTEXT_OTHER;
}
nsCOMPtr<nsIDOMNamedNodeMap> attributes;
node->GetAttributes(getter_AddRefs(attributes));
if (attributes)
{
nsCOMPtr<nsIDOMNode> hrefNode;
nsAutoString href;
href.AssignWithConversion("href");
attributes->GetNamedItem(href, getter_AddRefs(hrefNode));
if (hrefNode)
{
flags |= CONTEXT_LINK;
nsAutoString linkhtml;
nsCOMPtr<nsIDOMNSHTMLElement> nsElement;
nsElement = do_QueryInterface (element);
if (nsElement)
{
result = nsElement->GetInnerHTML(linkhtml);
if (NS_SUCCEEDED(result) && ToNewCString(linkhtml))
*linktext = g_strdup(ToNewCString(linkhtml));
}
char *href = mozilla_get_attribute (node, "href");
if (!href) return (CONTEXT_NONE );
nsAutoString hrefa;
hrefa.AssignWithConversion(href);
nsCString hrefc,linkc;
hrefc.AssignWithConversion(hrefa);
result = baseURI->Resolve(hrefc,linkc);
g_free(href);
*link = ToNewCString(linkc);
if (!link) return (CONTEXT_NONE);
break;
}
}
}
nsCOMPtr<nsIDOMNode> parentNode;
node->GetParentNode(getter_AddRefs(parentNode));
if (!parentNode)
{
node = nsnull;
flags |= CONTEXT_DOCUMENT;
break;
}
node = parentNode;
} while (node);
return(flags);
}
gchar *
mozilla_get_attribute (nsIDOMNode *node, gchar *attribute)
{
nsresult result;
nsCOMPtr<nsIDOMNamedNodeMap> attributes;
result = node->GetAttributes(getter_AddRefs (attributes));
if (!NS_SUCCEEDED (result) || !attributes) return ( NULL );
nsAutoString attr;
attr.AssignWithConversion (attribute);
nsCOMPtr<nsIDOMNode> attrNode;
result = attributes->GetNamedItem (attr, getter_AddRefs (attrNode));
if (!NS_SUCCEEDED (result) || !attrNode) return (NULL);
nsAutoString nodeValue;
result = attrNode->GetNodeValue (nodeValue);
if (!NS_SUCCEEDED (result)) return (NULL);
char *cstr = ToNewCString(nodeValue);
char *lifeSucks = g_strdup (cstr);
nsMemory::Free (cstr);
return (lifeSucks);
}

Просмотреть файл

@ -1,124 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_api_h
#define mozilla_api_h
#include "minimo_types.h"
/* mozilla specific headers */
#include "prenv.h"
#include "nsMemory.h"
#include "gtkmozembed_internal.h"
/* Includes used by Find features */
#include "nsIWebBrowser.h"
#include "nsIWebBrowserFind.h"
#include "nsNetUtil.h"
/* Includes used by 'mozilla_preference_set', 'mozilla_preference_set_int' and 'mozilla_preference_set_boolean' */
#include "nsIPref.h"
/* Includes used by 'save_mozilla' */
#include "nsIPresShell.h"
#include "nsIDocShell.h"
#include "nsIDOMDocument.h"
#include "nsIWebBrowserPersist.h"
#include "nsIWebNavigation.h"
#include "nsIDocShellTreeItem.h"
#include "nsILocalFile.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIDocument.h"
/* Includes used by 'menu context' */
#include "nsIDOMMouseEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMNSDocument.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMNamedNodeMap.h"
#include "nsIDOMNSHTMLElement.h"
#define PREF_ID NS_PREF_CONTRACTID
#ifdef NS_TRACE_MALLOC
#include "nsTraceMalloc.h"
#endif
#ifdef MOZ_JPROF
#include "jprof.h"
#endif
/* Mozilla API Methods - make possible the direct comunitation between Minimo Browser and the "Gecko Render Engine" */
PRUnichar *mozilla_locale_to_unicode (const gchar *locStr);
gboolean mozilla_find(GtkMozEmbed *b, const char *exp, PRBool IgnoreCase,
PRBool SearchBackWards, PRBool DoWrapFind,
PRBool SearchEntireWord, PRBool SearchInFrames,
PRBool DidFind);
gboolean mozilla_preference_set (const char *preference_name, const char *new_value);
gboolean mozilla_preference_set_boolean (const char *preference_name, gboolean new_boolean_value);
gboolean mozilla_preference_set_int (const char *preference_name, gint new_int_value);
gboolean mozilla_save(GtkMozEmbed *b, gchar *file_name, gint all);
void mozilla_save_image(GtkMozEmbed *b,gchar *location, gchar *FullPath);
gchar *mozilla_get_link_message (GtkWidget *embed);
glong mozilla_get_context_menu_type(GtkMozEmbed *b, gpointer event, gchar **img, gchar **link, gchar **linktext);
gchar *mozilla_get_attribute (nsIDOMNode *node, gchar *attribute);
gboolean mozilla_save_prefs (void);
#define CONTEXT_NONE 0
#define CONTEXT_DEFAULT 1
#define CONTEXT_LINK 2
#define CONTEXT_IMAGE 4
#define CONTEXT_DOCUMENT 8
#define CONTEXT_INPUT 64
#define CONTEXT_OTHER 128
#define CONTEXT_XUL 256
#endif

Просмотреть файл

@ -1,653 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Doug Turner <dougt@meer.net> Branched from TestGtkEmbed.cpp
*
* The 10LE Team (in alphabetical order)
* -------------------------------------
*
* Ilias Biris <ext-ilias.biris@indt.org.br> - Coordinator
* Afonso Costa <afonso.costa@indt.org.br>
* Antonio Gomes <antonio.gomes@indt.org.br>
* Diego Gonzalez <diego.gonzalez@indt.org.br>
* Raoni Novellino <raoni.novellino@indt.org.br>
* Andre Pedralho <andre.pedralho@indt.org.br>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla_api.h"
typedef struct _PrefWindow /* configuration data struct */
{
GtkWidget *dialog;
GtkWidget *okbutton;
GtkWidget *cancelbutton;
GtkWidget *applybutton;
GtkWidget *block_popup;
GtkWidget *vbox_popup;
GtkWidget *fr_connection;
GtkWidget *vbox_connection;
GtkWidget *hbox_connection;
GtkWidget *hbox_direct_connection;
GtkWidget *fr_popup;
GtkWidget *lb_popup;
GtkWidget *vbox_manual;
GtkWidget *rb_manual_connection;
GtkWidget *hbox_http;
GtkWidget *lb_http;
GtkWidget *en_http_proxy;
GtkWidget *box_popup;
GtkWidget *lb_port_http;
GtkWidget *en_http_port;
GtkWidget *hbox_ssl;
GtkWidget *lb_ssl;
GtkWidget *en_ssl;
GtkWidget *lb_ssl_port;
GtkWidget *en_ssl_port;
GtkWidget *hbox_ftp;
GtkWidget *lb_ftp;
GtkWidget *en_ftp_proxy;
GtkWidget *lb_ftp_port;
GtkWidget *en_ftp_port;
GtkWidget *hbox_noproxy;
GtkWidget *lb_connection;
GSList *rb_direct_connection_group;
GSList *rb_manual_connection_group;
GtkWidget *hbox_manual_connection;
GtkWidget *rb_direct_connection;
} PrefWindow;
ConfigData config;
PrefWindow *prefWindow;
/* Callbacks */
void close_preferences_cb (GtkButton *button, PrefWindow *pref);
void ok_preferences_cb (GtkButton *button, PrefWindow *pref);
/* Support methods */
void read_minimo_config(void);
void write_minimo_config(void);
void set_mozilla_prefs(void);
void minimo_set_proxy_prefs(void);
/* UI Methods */
PrefWindow * build_pref_window (GtkWidget *topLevelWindow);
PrefWindow * build_pref_window (GtkWidget *topLevelWindow) {
prefWindow = g_new0(PrefWindow,1);
prefWindow->dialog = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (prefWindow->dialog), ("Prefs Window"));
gtk_window_set_position (GTK_WINDOW (prefWindow->dialog), GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_set_modal (GTK_WINDOW (prefWindow->dialog), TRUE);
gtk_window_set_resizable (GTK_WINDOW (prefWindow->dialog), FALSE);
gtk_window_set_decorated (GTK_WINDOW (prefWindow->dialog), TRUE);
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (prefWindow->dialog), TRUE);
gtk_window_set_skip_pager_hint (GTK_WINDOW (prefWindow->dialog), TRUE);
gtk_window_set_type_hint (GTK_WINDOW (prefWindow->dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_window_set_gravity (GTK_WINDOW (prefWindow->dialog), GDK_GRAVITY_NORTH_EAST);
gtk_window_set_transient_for(GTK_WINDOW(prefWindow->dialog), GTK_WINDOW(topLevelWindow));
gtk_widget_set_size_request (prefWindow->dialog, 240, 220);
/* Creating "Connection Frame" */
prefWindow->fr_connection = gtk_frame_new (NULL);
gtk_widget_show (prefWindow->fr_connection);
gtk_container_add (GTK_CONTAINER(GTK_DIALOG (prefWindow->dialog)->vbox), prefWindow->fr_connection);
/* Connection Frame's VBOX */
prefWindow->vbox_connection = gtk_vbox_new (FALSE, 0);
gtk_widget_show (prefWindow->vbox_connection);
gtk_container_add (GTK_CONTAINER (prefWindow->fr_connection), prefWindow->vbox_connection);
prefWindow->hbox_direct_connection = gtk_hbox_new (FALSE, 0);
gtk_widget_show (prefWindow->hbox_direct_connection);
gtk_box_pack_start (GTK_BOX (prefWindow->vbox_connection), prefWindow->hbox_direct_connection, TRUE, TRUE, 0);
/* Radio Buttons - Direct/Manual Connetion */
prefWindow->rb_direct_connection = gtk_radio_button_new_with_mnemonic (NULL, "Direct connection to the Internet");
gtk_widget_show (prefWindow->rb_direct_connection);
gtk_box_pack_start (GTK_BOX (prefWindow->hbox_direct_connection), prefWindow->rb_direct_connection, FALSE, FALSE, 0);
prefWindow->rb_direct_connection_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (prefWindow->rb_direct_connection));
prefWindow->hbox_manual_connection = gtk_hbox_new (FALSE, 0);
gtk_widget_show (prefWindow->hbox_manual_connection);
gtk_box_pack_start (GTK_BOX (prefWindow->vbox_connection), prefWindow->hbox_manual_connection, TRUE, TRUE, 0);
prefWindow->vbox_manual = gtk_vbox_new (FALSE, 0);
gtk_widget_show (prefWindow->vbox_manual);
gtk_box_pack_start (GTK_BOX (prefWindow->hbox_manual_connection), prefWindow->vbox_manual, TRUE, TRUE, 0);
prefWindow->rb_manual_connection = gtk_radio_button_new_with_mnemonic (NULL, "Manual proxy configuration");
gtk_widget_show (prefWindow->rb_manual_connection);
gtk_box_pack_start (GTK_BOX (prefWindow->vbox_manual), prefWindow->rb_manual_connection, FALSE, FALSE, 0);
prefWindow->rb_manual_connection_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (prefWindow->rb_manual_connection));
gtk_radio_button_set_group (GTK_RADIO_BUTTON (prefWindow->rb_manual_connection), prefWindow->rb_direct_connection_group);
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prefWindow->rb_direct_connection));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefWindow->rb_direct_connection), config.direct_connection);
/* HTTP Widget HBOX */
prefWindow->hbox_http = gtk_hbox_new (FALSE, 0);
gtk_widget_show (prefWindow->hbox_http);
gtk_box_pack_start (GTK_BOX (prefWindow->vbox_manual), prefWindow->hbox_http, TRUE, TRUE, 0);
prefWindow->lb_http = gtk_label_new ("HTTP Proxy: ");
gtk_widget_show (prefWindow->lb_http);
gtk_box_pack_start (GTK_BOX (prefWindow->hbox_http), prefWindow->lb_http, FALSE, FALSE, 0);
prefWindow->en_http_proxy = gtk_entry_new ();
gtk_widget_show (prefWindow->en_http_proxy);
gtk_box_pack_start (GTK_BOX (prefWindow->hbox_http), prefWindow->en_http_proxy, TRUE, TRUE, 0);
gtk_widget_modify_font(prefWindow->en_http_proxy, getOrCreateDefaultMinimoFont());
gtk_widget_set_size_request (prefWindow->en_http_proxy, 60, -1);
prefWindow->lb_port_http = gtk_label_new (" Port: ");
gtk_widget_show (prefWindow->lb_port_http);
gtk_box_pack_start (GTK_BOX (prefWindow->hbox_http), prefWindow->lb_port_http, FALSE, FALSE, 0);
prefWindow->en_http_port = gtk_entry_new ();
gtk_widget_show (prefWindow->en_http_port);
gtk_box_pack_start (GTK_BOX (prefWindow->hbox_http), prefWindow->en_http_port, TRUE, TRUE, 0);
gtk_widget_set_size_request (prefWindow->en_http_port, 30, -1);
/* SSL Widget HBOX */
prefWindow->hbox_ssl = gtk_hbox_new (FALSE, 0);
gtk_widget_show (prefWindow->hbox_ssl);
gtk_box_pack_start (GTK_BOX (prefWindow->vbox_manual), prefWindow->hbox_ssl, TRUE, TRUE, 0);
prefWindow->lb_ssl = gtk_label_new ("SSL Proxy: ");
gtk_widget_show (prefWindow->lb_ssl);
gtk_box_pack_start (GTK_BOX (prefWindow->hbox_ssl), prefWindow->lb_ssl, FALSE, FALSE, 0);
prefWindow->en_ssl = gtk_entry_new ();
gtk_widget_show (prefWindow->en_ssl);
gtk_box_pack_start (GTK_BOX (prefWindow->hbox_ssl), prefWindow->en_ssl, TRUE, TRUE, 0);
gtk_widget_set_size_request (prefWindow->en_ssl, 60, -1);
prefWindow->lb_ssl_port = gtk_label_new (" Port: ");
gtk_widget_show (prefWindow->lb_ssl_port);
gtk_box_pack_start (GTK_BOX (prefWindow->hbox_ssl), prefWindow->lb_ssl_port, FALSE, FALSE, 0);
prefWindow->en_ssl_port = gtk_entry_new ();
gtk_widget_show (prefWindow->en_ssl_port);
gtk_box_pack_start (GTK_BOX (prefWindow->hbox_ssl), prefWindow->en_ssl_port, TRUE, TRUE, 0);
gtk_widget_modify_font(prefWindow->en_ssl, getOrCreateDefaultMinimoFont());
gtk_widget_set_size_request (prefWindow->en_ssl_port, 30, -1);
/* FTP Widgets HBOX */
prefWindow->hbox_ftp = gtk_hbox_new (FALSE, 0);
gtk_widget_show (prefWindow->hbox_ftp);
gtk_box_pack_start (GTK_BOX (prefWindow->vbox_manual), prefWindow->hbox_ftp, TRUE, TRUE, 0);
prefWindow->lb_ftp = gtk_label_new ("FTP Proxy: ");
gtk_widget_show (prefWindow->lb_ftp);
gtk_box_pack_start (GTK_BOX (prefWindow->hbox_ftp), prefWindow->lb_ftp, FALSE, FALSE, 0);
prefWindow->en_ftp_proxy = gtk_entry_new ();
gtk_widget_show (prefWindow->en_ftp_proxy);
gtk_box_pack_start (GTK_BOX (prefWindow->hbox_ftp), prefWindow->en_ftp_proxy, TRUE, TRUE, 0);
gtk_widget_set_size_request (prefWindow->en_ftp_proxy, 60, -1);
prefWindow->lb_ftp_port = gtk_label_new (" Port: ");
gtk_widget_show (prefWindow->lb_ftp_port);
gtk_box_pack_start (GTK_BOX (prefWindow->hbox_ftp), prefWindow->lb_ftp_port, FALSE, FALSE, 0);
prefWindow->en_ftp_port = gtk_entry_new ();
gtk_widget_show (prefWindow->en_ftp_port);
gtk_box_pack_start (GTK_BOX (prefWindow->hbox_ftp), prefWindow->en_ftp_port, TRUE, TRUE, 0);
gtk_widget_modify_font(prefWindow->en_ftp_proxy, getOrCreateDefaultMinimoFont());
gtk_widget_set_size_request (prefWindow->en_ftp_port, 30, -1);
prefWindow->hbox_noproxy = gtk_hbox_new (FALSE, 0);
gtk_widget_show (prefWindow->hbox_noproxy);
gtk_box_pack_start (GTK_BOX (prefWindow->vbox_connection), prefWindow->hbox_noproxy, TRUE, TRUE, 0);
if (config.direct_connection == 0) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefWindow->rb_direct_connection), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefWindow->rb_manual_connection), TRUE);
} else if (config.direct_connection == 1) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefWindow->rb_direct_connection), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefWindow->rb_manual_connection), FALSE);
}
gtk_entry_set_text (GTK_ENTRY (prefWindow->en_http_proxy), config.http_proxy);
gtk_entry_set_text (GTK_ENTRY (prefWindow->en_http_port), config.http_proxy_port);
gtk_entry_set_text (GTK_ENTRY (prefWindow->en_ssl), config.ssl_proxy);
gtk_entry_set_text (GTK_ENTRY (prefWindow->en_ssl_port), config.ssl_proxy_port);
gtk_entry_set_text (GTK_ENTRY (prefWindow->en_ftp_proxy), config.ftp_proxy);
gtk_entry_set_text (GTK_ENTRY (prefWindow->en_ftp_port), config.ftp_proxy_port);
/* Creating "Popup Frame" */
prefWindow->fr_popup = gtk_frame_new (NULL);
gtk_widget_show (prefWindow->fr_popup);
gtk_container_add (GTK_CONTAINER(GTK_DIALOG (prefWindow->dialog)->vbox), prefWindow->fr_popup);
/* Proxy Frame's label */
prefWindow->lb_connection = gtk_label_new ("Configure Proxies:");
gtk_widget_show (prefWindow->lb_connection);
gtk_frame_set_label_widget (GTK_FRAME (prefWindow->fr_connection), prefWindow->lb_connection);
prefWindow->vbox_popup = gtk_vbox_new (FALSE, 0);
gtk_widget_show (prefWindow->vbox_popup);
gtk_container_add (GTK_CONTAINER (prefWindow->fr_popup), prefWindow->vbox_popup);
prefWindow->block_popup = gtk_check_button_new_with_label ("Block Popup Windows");
if (config.disable_popups == 1) {
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(prefWindow->block_popup), TRUE);
} else gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(prefWindow->block_popup), FALSE);
gtk_container_add(GTK_CONTAINER(prefWindow->vbox_popup), prefWindow->block_popup);
prefWindow->lb_popup = gtk_label_new ("Block Popups");
gtk_widget_show (prefWindow->lb_popup);
gtk_frame_set_label_widget (GTK_FRAME (prefWindow->fr_popup), prefWindow->lb_popup);
/* Ok and Cancel Button */
prefWindow->cancelbutton = gtk_button_new_with_label("Cancel");
gtk_widget_modify_font(GTK_BIN(prefWindow->cancelbutton)->child, getOrCreateDefaultMinimoFont());
gtk_widget_show (prefWindow->cancelbutton);
gtk_dialog_add_action_widget (GTK_DIALOG (prefWindow->dialog), prefWindow->cancelbutton, GTK_RESPONSE_CANCEL);
gtk_widget_set_size_request (prefWindow->cancelbutton, 10, -1);
prefWindow->okbutton = gtk_button_new_with_label("Ok");
gtk_widget_modify_font(GTK_BIN(prefWindow->okbutton)->child, getOrCreateDefaultMinimoFont());
gtk_widget_show (prefWindow->okbutton);
gtk_dialog_add_action_widget (GTK_DIALOG (prefWindow->dialog), prefWindow->okbutton, GTK_RESPONSE_OK);
gtk_widget_set_size_request (prefWindow->okbutton, 10, -1);
/* Setting font styles */
gtk_widget_modify_font(prefWindow->rb_manual_connection, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(prefWindow->rb_direct_connection, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(prefWindow->lb_http, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(prefWindow->lb_port_http, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(prefWindow->en_http_port, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(prefWindow->lb_ssl, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(prefWindow->en_ssl, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(prefWindow->en_ssl_port, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(prefWindow->lb_ssl_port, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(prefWindow->lb_ftp, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(prefWindow->en_ftp_proxy, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(prefWindow->lb_ftp_port, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(prefWindow->en_ftp_port, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(prefWindow->lb_connection, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(prefWindow->lb_popup, getOrCreateDefaultMinimoFont());
gtk_widget_modify_font(prefWindow->block_popup, getOrCreateDefaultMinimoFont());
gtk_widget_show_all(prefWindow->dialog);
/* connection singnals to buttons */
gtk_signal_connect_object(GTK_OBJECT(prefWindow->cancelbutton), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), prefWindow->dialog);
gtk_signal_connect_object(GTK_OBJECT(prefWindow->okbutton), "clicked", GTK_SIGNAL_FUNC(ok_preferences_cb), prefWindow);
return prefWindow;
}
void save_preferences_cb (GtkButton *button, PrefWindow *pref) {
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prefWindow->rb_direct_connection)) == TRUE)
config.direct_connection = 1;
else config.direct_connection = 0;
config.http_proxy = g_strdup (gtk_entry_get_text (GTK_ENTRY (prefWindow->en_http_proxy)));
config.http_proxy_port = g_strdup (gtk_entry_get_text (GTK_ENTRY (prefWindow->en_http_port)));
config.ftp_proxy = g_strdup (gtk_entry_get_text (GTK_ENTRY (prefWindow->en_ftp_proxy)));
config.ftp_proxy_port = g_strdup (gtk_entry_get_text (GTK_ENTRY (prefWindow->en_ftp_port)));
config.ssl_proxy = g_strdup (gtk_entry_get_text (GTK_ENTRY (prefWindow->en_ssl)));
config.ssl_proxy_port = g_strdup (gtk_entry_get_text (GTK_ENTRY (prefWindow->en_ssl_port)));
config.disable_popups = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prefWindow->block_popup));
write_minimo_config();
}
void ok_preferences_cb (GtkButton *button, PrefWindow *pref) {
save_preferences_cb (button, pref);
close_preferences_cb (button, pref);
}
void close_preferences_cb (GtkButton *button, PrefWindow *pref) {
gtk_widget_destroy (prefWindow->dialog);
g_free (pref);
}
/* Read the current 'minimo config' into his file: $home/.Minimo/config */
void read_minimo_config(void)
{
FILE *config_file;
gchar *file, *oldfile;
gchar *line, tmpstr[1024];
gint i, temp;
user_home = g_strconcat(g_get_home_dir(),NULL);
oldfile = g_strconcat(user_home,"/.minimorc", NULL);
file = g_strconcat(user_home,"/.Minimo/config", NULL);
if (access(oldfile, F_OK) == 0 && access(file, F_OK) == -1 && errno == ENOENT) {
if (rename(oldfile, file) == 0) {
g_print("Note: .minimorc was moved to %s\n", file);
g_free(oldfile);
} else {
g_warning("Error moving .minimorc to %s: %s\n", file, strerror(errno));
/* we can still read the old file */
g_free(file); file = oldfile;
}
} else {
g_free(oldfile);
}
/* defaults */
config.home = g_strdup("http://www.minimo.org");
config.xsize = 700;
config.ysize = 500;
config.layout = 0;
config.mailer = g_strdup("pronto %t %s %c");
config.max_go = 15;
config.maxpopupitems = 15;
config.java = TRUE;
config.javascript = TRUE;
config.http_proxy = g_strdup("");
config.ftp_proxy = g_strdup("");
config.ftp_proxy_port = g_strdup("");
config.http_proxy_port = g_strdup("");
config.ssl_proxy = g_strdup("");
config.ssl_proxy_port = g_strdup("");
config.no_proxy_for = g_strdup("localhost");
config.direct_connection = 1;
config.popup_in_new_window = 0;
config.disable_popups = 0;
config.current_font_size = DEFAULT_FONT_SIZE;
config_file = fopen(file,"r");
if (config_file == NULL) {
write_minimo_config();
}
config_file = fopen(file,"r");
line = (gchar *)g_malloc(1024);
while(fgets(line,1024,config_file) != NULL) {
line[strlen(line)-1] = '\0';
if (g_strncasecmp(line,"home=",5) == 0) {
config.home = g_strdup(line+5);
if (g_strcasecmp(config.home,"") == 0) {
g_free(config.home);
config.home = g_strdup("about:blank");
}
} else if (g_strncasecmp(line,"xsize=",6) == 0) {
config.xsize = atoi(line+6);
} else if (g_strncasecmp(line,"ysize=",6) == 0) {
config.ysize = atoi(line+6);
} else if (g_strncasecmp(line,"layout=",7) == 0) {
config.layout = atoi(line+7);
} else if (g_strncasecmp(line,"mailer=",7) == 0) {
g_free(config.mailer);
config.mailer = g_strdup(line+7);
} else if (g_strncasecmp(line,"maxpopup=",9) == 0) {
config.maxpopupitems = atoi(line+9);
} else if (g_strncasecmp(line,"http_proxy=",11) == 0) {
g_free(config.http_proxy);
config.http_proxy = g_strdup(line+11);
} else if (g_strncasecmp(line,"http_proxy_port=",16) == 0) {
g_free(config.http_proxy_port);
config.http_proxy_port = g_strdup(line+16);
} else if (g_strncasecmp(line,"ftp_proxy=",10) == 0) {
g_free(config.ftp_proxy);
config.ftp_proxy = g_strdup(line+10);
} else if (g_strncasecmp(line,"ftp_proxy_port=",15) == 0) {
g_free(config.ftp_proxy_port);
config.ftp_proxy_port = g_strdup(line+15);
} else if (g_strncasecmp(line,"no_proxy_for=",13) == 0) {
g_free(config.no_proxy_for);
config.no_proxy_for = g_strdup(line+13);
} else if (g_strncasecmp(line,"ssl_proxy=",10) == 0) {
g_free(config.ssl_proxy);
config.ssl_proxy = g_strdup(line+10);
} else if (g_strncasecmp(line,"ssl_proxy_port=",15) == 0) {
g_free(config.ssl_proxy_port);
config.ssl_proxy_port = g_strdup(line+15);
} else if (g_strncasecmp(line,"no_proxy_for=",13) == 0) {
g_free(config.no_proxy_for);
config.no_proxy_for = g_strdup(line+13);
} else if (g_strncasecmp(line,"direct_connection=",18) == 0) {
config.direct_connection = atoi(line+18);
} else if (g_strncasecmp(line,"max_go=",7) == 0) {
config.max_go = atoi(line+7);
} else if (g_strncasecmp(line,"popup_in_new_window=",20) == 0) {
config.popup_in_new_window = atoi (line + 20);
} else if (g_strncasecmp(line,"disable_popups=",15) == 0) {
config.disable_popups = atoi(line+15);
} else if (g_strncasecmp(line,"fontsize_",9) == 0) {
for (i = 0; i < LANG_FONT_NUM; i++) {
g_snprintf (tmpstr, 1024, "%s=", lang_font_item[i]);
if (g_strncasecmp(line+9,tmpstr,strlen(tmpstr)))
continue;
config.font_size[i] = atoi(line+9+strlen(tmpstr));
};
} else if (g_strncasecmp(line,"min_fontsize_",13) == 0) {
for (i=0; i < LANG_FONT_NUM; i++) {
g_snprintf(tmpstr,1024,"%s=",lang_font_item[i]);
if (g_strncasecmp(line+13,tmpstr,strlen(tmpstr)))
continue;
config.min_font_size[i] = atoi(line+13+strlen(tmpstr));
}
} else if (g_strncasecmp(line,"java=",5) == 0) {
temp = atoi(line+5);
if (temp) {
config.java = TRUE;
} else {
config.java = FALSE;
}
} else if (g_strncasecmp(line,"javascript=",11) == 0) {
temp = atoi(line+11);
if (temp) {
config.javascript = TRUE;
} else {
config.javascript = FALSE;
}
}
}
fflush (config_file);
fclose(config_file);
g_free(line);
g_free(file);
}
/* Write the current 'minimo config' into his file: $home/.Minimo/config */
void write_minimo_config()
{
FILE *config_file;
gchar *file;
file = g_strconcat(user_home,"/.Minimo/config",NULL);
config_file = fopen(file,"w");
if (config_file == NULL) {
g_error ("Cannot write config file!");
return ;
}
fprintf(config_file,"home=%s\n",config.home);
fprintf(config_file,"xsize=%d\n",config.xsize);
fprintf(config_file,"ysize=%d\n",config.ysize);
fprintf(config_file,"layout=%d\n",config.layout);
fprintf(config_file,"mailer=%s\n",config.mailer);
fprintf(config_file,"maxpopup=%d\n",config.maxpopupitems);
fprintf(config_file,"http_proxy=%s\n",config.http_proxy);
fprintf(config_file,"http_proxy_port=%s\n",config.http_proxy_port);
fprintf(config_file,"ftp_proxy=%s\n",config.ftp_proxy);
fprintf(config_file,"ftp_proxy_port=%s\n",config.ftp_proxy_port);
fprintf(config_file,"ssl_proxy=%s\n",config.ssl_proxy);
fprintf(config_file,"ssl_proxy_port=%s\n",config.ssl_proxy_port);
fprintf(config_file,"no_proxy_for=%s\n",config.no_proxy_for);
fprintf(config_file,"direct_connection=%d\n",config.direct_connection);
fprintf(config_file,"max_go=%d\n",config.max_go);
fprintf(config_file,"popup_in_new_window=%d\n",config.popup_in_new_window);
fprintf(config_file,"disable_popups=%d\n",config.disable_popups);
if (config.javascript == TRUE) {
fprintf(config_file,"javascript=1\n");
} else {
fprintf(config_file,"javascript=0\n");
}
if (config.java == TRUE) {
fprintf(config_file,"java=1\n");
} else {
fprintf(config_file,"java=0\n");
}
fclose(config_file);
g_free(file);
set_mozilla_prefs ();
}
void set_mozilla_prefs(void)
{
gint i, disk_cache= 0, mem_cache= 0;
gchar *cachedir, tmpstr[1024];
mozilla_preference_set_boolean ("security.warn_entering_secure", FALSE);
mozilla_preference_set_boolean ("security.warn_leaving_secure", FALSE);
mozilla_preference_set_boolean ("security.warn_submit_insecure", FALSE);
mozilla_preference_set_boolean ("security.warn_viewing_mixed", FALSE);
if (config.disable_popups)
mozilla_preference_set_boolean ("dom.disable_open_during_load", TRUE);
else
mozilla_preference_set_boolean ("dom.disable_open_during_load", FALSE);
mozilla_preference_set_boolean("nglayout.widget.gfxscrollbars", TRUE);
for (i = 0; i < LANG_FONT_NUM; i++) {
g_snprintf (tmpstr, 1024, "font.size.variable.%s", lang_font_item[i]);
mozilla_preference_set_int(tmpstr,DEFAULT_FONT_SIZE);
g_snprintf(tmpstr, 1024, "font.min-size.variable.%s", lang_font_item[i]);
mozilla_preference_set_int(tmpstr, DEFAULT_MIN_FONT_SIZE);
}
mozilla_preference_set_boolean ("security.enable_java", config.java);
mozilla_preference_set_boolean ("javascript.enabled", config.javascript);
mozilla_preference_set_boolean ("browser.view_source.syntax_highlight", TRUE);
cachedir = g_strconcat(user_home,"/.Minimo/cache",NULL);
mkdir(cachedir,0755);
mozilla_preference_set("browser.cache.directory",cachedir);
g_free(cachedir);
if ((disk_cache > 0) || (mem_cache > 0)) {
mozilla_preference_set_boolean("browser.cache.disk.enable",TRUE);
mozilla_preference_set_boolean("browser.cache.enable", TRUE);
}
else
{
mozilla_preference_set_boolean("browser.cache.disk.enable",FALSE);
mozilla_preference_set_boolean("browser.cache.enable", FALSE);
}
if (disk_cache > 0) {
mozilla_preference_set_boolean("browser.cache.disk.enable",TRUE);
mozilla_preference_set_int("browser.cache.disk_cache_size",disk_cache);
mozilla_preference_set_int("browser.cache.disk.capacity",disk_cache);
}
else
{
mozilla_preference_set_boolean("browser.cache.disk.enable",FALSE);
mozilla_preference_set_int("browser.cache.disk_cache_size", 0);
mozilla_preference_set_int("browser.cache.disk.capacity",0);
}
if (mem_cache > 0) {
mozilla_preference_set_int("browser.cache.memory_cache_size",mem_cache);
mozilla_preference_set_int("browser.cache.memory.capacity",mem_cache);
} else {
mozilla_preference_set_int("browser.cache.memory_cache_size", 0);
mozilla_preference_set_int("browser.cache.memory.capacity",0);
}
/* set proxy stuff */
minimo_set_proxy_prefs();
mozilla_save_prefs ();
}
void minimo_set_proxy_prefs(void)
{
gint network_type = 0;
if (config.direct_connection) {
mozilla_preference_set("network.proxy.http","");
mozilla_preference_set("network.proxy.ssl","");
mozilla_preference_set("network.proxy.ftp","");
mozilla_preference_set("network.proxy.no_proxies_on", " ");
mozilla_preference_set_int("network.proxy.type",network_type);
} else {
if (strlen(config.http_proxy) != 0 && strcmp(config.http_proxy,"") != 0 && strlen(config.http_proxy_port) > 0 && strcmp(config.http_proxy_port,"") != 0) {
mozilla_preference_set_int ("network.proxy.type", 1);
network_type=1;
mozilla_preference_set ("network.proxy.http", config.http_proxy);
mozilla_preference_set_int ("network.proxy.http_port", atoi(config.http_proxy_port));
}
if (strlen(config.ftp_proxy) != 0 && strcmp(config.ftp_proxy,"") != 0 && strlen(config.ftp_proxy_port) > 0 && strcmp(config.http_proxy_port,"") != 0) {
if (!network_type)
mozilla_preference_set_int("network.proxy.type", 1);
mozilla_preference_set ("network.proxy.ftp", config.ftp_proxy);
mozilla_preference_set_int ("network.proxy.ftp_port", atoi(config.ftp_proxy_port));
}
if (strlen(config.ssl_proxy) != 0 && strcmp(config.ssl_proxy,"") != 0 && strlen(config.ssl_proxy_port) > 0 && strcmp (config.ssl_proxy_port,"") != 0) {
if (!network_type)
mozilla_preference_set_int("network.proxy.type", 1);
mozilla_preference_set ("network.proxy.ssl", config.ssl_proxy);
mozilla_preference_set_int ("network.proxy.ssl_port", atoi(config.ssl_proxy_port));
}
if (strlen(config.no_proxy_for) != 0)
mozilla_preference_set("network.proxy.no_proxies_on", config.no_proxy_for);
else
mozilla_preference_set("network.proxy.no_proxies_on", " ");
}
}

Просмотреть файл

@ -1 +0,0 @@
Makefile

Просмотреть файл

@ -1,11 +0,0 @@
Package: minimo
Section: x11
Priority: optional
Version: 0.2-b
Source: http://mozilla.org/projects/minimo/
Architecture: arm
Priority: optional
Maintainer: Doug Turner <dougt@meer.net>
Depends: libgtk2.0-0, libxt
Description: Minimo (Mini Mozilla) is a lightweight branch of the mozilla web browser targeting embedded devices
.

Просмотреть файл

@ -1,8 +0,0 @@
#!/bin/sh
#
# This is a very simple wrapper script for minimo
cd /usr/lib/mozilla-minimo
export LD_LIBRARY_PATH=/usr/lib/mozilla-minimo
exec ./Minimo file:///usr/lib/mozilla-minimo/startpage/start.html

Просмотреть файл

@ -1,9 +0,0 @@
[Desktop Entry]
Name=Minimo
Comment=Minimo web browser
Exec=minimo http://www.mozilla.org/projects/minimo/home.html
Terminal=0
Type=Application
Icon=minimo.png
Categories=Application;PIM
StartupNotify=True

Двоичные данные
embedding/minimo/ipkg/minimo.png

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 844 B

Просмотреть файл

@ -1,39 +0,0 @@
#!/bin/sh
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
echo "Packaging Minimo from"
echo $MOZ_OBJDIR
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
while true; do
echo -n "Delete dist/Embed (y/n) "
read yn
case $yn in
y* | Y* ) rm -rf $MOZ_OBJDIR/dist/Embed ; break ;;
[nN]* ) echo "skipping clean" ; break ;;
q* ) exit ;;
* ) echo "unknown response. Asking again" ;;
esac
done
pushd ..
./package.sh
popd
rm -rf build
mkdir -p build/usr/lib/mozilla-minimo
mkdir -p build/usr/share/applications
mkdir -p build/usr/share/pixmaps
mkdir -p build/usr/bin
cp -a $MOZ_OBJDIR/dist/Embed/* build/usr/lib/mozilla-minimo/
cp -a startpage build/usr/lib/mozilla-minimo
cp minimo build/usr/bin/
cp minimo.desktop build/usr/share/applications/
cp minimo.png build/usr/share/pixmaps/
mkdir -p build/CONTROL
cp control.in build/CONTROL/control
ipkg-build -o root -g root build

Просмотреть файл

@ -1,49 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
<title>Mozilla Minimo Homepage</title>
</head>
<body>
<table cellpadding="0" cellspacing="0" border="0"
style="text-align: left; width: 100%;">
<tbody>
<tr align="center">
<td style="vertical-align: top;">
<h1 style="background-color: rgb(102, 102, 204);"><img
src="http://mozilla.org/projects/minimo/MinimoM.gif" title=""
alt="M" style="width: 32px; height: 32px;">inimo</h1>
</td>
</tr>
<tr align="center">
<td
style="vertical-align: top; background-color: rgb(102, 102, 204);"><big><span
style="font-weight: bold; color: rgb(255, 255, 255);">The Minimo
Browser Home Page</span></big></td>
</tr>
<tr align="center">
<td
style="vertical-align: top; background-color: rgb(204, 204, 255);">Small
Device Links and Test Sites<br>
<a href="http://edition.cnn.com/QUICKNEWS/print.html"><br>
CNN Quick News</a><br>
<a href="http://google.com/palm">Search on Google</a><br>
<a href="http://news.google.com/news/en/us/mainlite.html">Google
News</a><br>
<a
href="http://www.hiptop.com/mblinks/?action=view_category&amp;category_id=1">Popular
Hiptop sites<br>
</a><a href="http://mozilla.org/">Mozilla.org</a><a
href="http://www.hiptop.com/mblinks/?action=view_category&amp;category_id=1"><br>
</a><a href="http://www.mozilla.org/projects/minimo/">More
infomation about Minimo</a><br>
<br>
<br>
</td>
</tr>
</tbody>
</table>
<br>
</body>
</html>

Просмотреть файл

@ -1,70 +0,0 @@
mk_add_options MOZ_CO_PROJECT=suite
ac_add_options --enable-application=suite
# build minimo
MINIMO=1
mk_add_options MINIMO=1
# use GTK+-2 widget set with XFT font rendering
ac_add_options --enable-default-toolkit=gtk2
ac_add_options --enable-xft
ac_add_options --disable-freetype2
# disable XUL support to reduce codesize
ac_add_options --disable-xul
# enable minimal profile support
ac_add_options --disable-profilesharing
ac_add_options --disable-profilelocking
ac_add_options --enable-single-profile
# disable features and skip various build steps
ac_add_options --disable-extensions
ac_add_options --disable-accessibility
ac_add_options --disable-composer
ac_add_options --enable-plaintext-editor-only
ac_add_options --disable-mailnews
ac_add_options --disable-ldap
ac_add_options --disable-postscript
ac_add_options --disable-mathml
ac_add_options --disable-jsd
ac_add_options --disable-jsloader
ac_add_options --disable-installer
ac_add_options --disable-xpinstall
ac_add_options --disable-xpfe-components
ac_add_options --disable-xprint
ac_add_options --disable-necko-disk-cache
ac_add_options --disable-plugins
# configure necko to allocate smaller network buffers
ac_add_options --enable-necko-small-buffers
# disable debug logging and tests
ac_add_options --disable-dtd-debug
ac_add_options --disable-logging
ac_add_options --disable-tests
# build crypto module (PSM + NSS)
ac_add_options --enable-crypto
# build minimal set of protocol handlers
ac_add_options --enable-necko-protocols=http,file,res,jar
# build minimal set of image decoders
ac_add_options --enable-image-decoders=png,gif,jpeg
# code generation options (optimize for size)
# ac_add_options --enable-optimize=-Os
# ac_add_options --enable-strip
# ac_add_options --disable-debug
ac_add_options --enable-reorder
ac_add_options --enable-elf-dynstr-gc
# enable static build
ac_add_options --disable-shared
ac_add_options --enable-static
# remove link dependency on libstdc++.so
LIBS=-lsupc++
CXX=gcc

Просмотреть файл

@ -1,12 +0,0 @@
# include base minimo build options
. $topsrcdir/embedding/minimo/mozconfig
# cross compile for arm-linux
PATH=/opt/toolchain/bin:/opt/toolchain/arm-linux/local/bin:$PATH
CROSS_COMPILE=1
LIBIDL_CONFIG=/opt/toolchain/arm-linux/local/bin/libIDL-config-2
HOST_LIBIDL_CONFIG=/usr/bin/libIDL-config
ac_add_options --target=arm-linux
ac_add_options --x-includes=/opt/toolchain/arm-linux/local/X11R6/include
ac_add_options --x-libraries=/opt/toolchain/arm-linux/local/X11R6/lib
CXX=arm-linux-gcc

Просмотреть файл

@ -1,57 +0,0 @@
#!/bin/sh
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Minimo.
#
# The Initial Developer of the Original Code is
# Doug Turner <dougt@meer.net>.
# Portions created by the Initial Developer are Copyright (C) 2003
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
pushd .
cd $MOZ_OBJDIR/embedding/config/
make
make merge_xpt
cd ../../dist/Embed/chrome
rm installed-chrome.txt pipnss.jar
unzip embed.jar
rm embed.jar
find . -type f -exec cp '{}' . \;
rm -rf skin content locale
popd
cp all.js $MOZ_OBJDIR/dist/Embed/greprefs/all.js
cp README $MOZ_OBJDIR/dist/Embed/
cat smallScreen.css >> $MOZ_OBJDIR/dist/Embed/res/ua.css

Просмотреть файл

@ -1,71 +0,0 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Minimo.
#
# The Initial Developer of the Original Code is
# Doug Turner <dougt@meer.net>.
# Portions created by the Initial Developer are Copyright (C) 2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE_NAME = popuplite
MODULE = popuplite
LIBRARY_NAME = popuplite
IS_COMPONENT = 1
EXPORT_LIBRARY = 1
MOZILLA_INTERNAL_API = 1
REQUIRES = \
layout \
content \
necko \
xpcom \
string \
uconv \
appshell \
pref \
$(NULL)
CPPSRCS = \
nsSimplePopupBlocker.cpp \
$(NULL)
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,101 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Doug Turner <dougt@meer.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIPopupWindowManager.h"
#include "nsServiceManagerUtils.h"
#include "nsIModule.h"
#include "nsIGenericFactory.h"
class nsIURI;
class nsSimplePopupBlocker : public nsIPopupWindowManager
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPOPUPWINDOWMANAGER
nsSimplePopupBlocker();
virtual ~nsSimplePopupBlocker();
private:
PRUint32 mPolicy;
};
nsSimplePopupBlocker::nsSimplePopupBlocker()
: mPolicy(DENY_POPUP)
{
}
nsSimplePopupBlocker::~nsSimplePopupBlocker(void)
{
}
NS_IMPL_ISUPPORTS1(nsSimplePopupBlocker, nsIPopupWindowManager)
NS_IMETHODIMP
nsSimplePopupBlocker::TestPermission(nsIURI *aURI, PRUint32 *aPermission)
{
NS_ENSURE_ARG_POINTER(aURI);
NS_ENSURE_ARG_POINTER(aPermission);
// For now, I don't care if we should display the popup. Eventually,
// we need to do some bookkeeping.
*aPermission = DENY_POPUP;
return NS_OK;
}
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSimplePopupBlocker)
#define NS_POPUPWINDOWMANAGER_CID \
{0x822bcd11, 0x6432, 0x48be, {0x9e, 0x9d, 0x36, 0xf7, 0x80, 0x4b, 0x77, 0x47}}
static const nsModuleComponentInfo components[] = {
{ "Simple Popup Blocker",
NS_POPUPWINDOWMANAGER_CID,
NS_POPUPWINDOWMANAGER_CONTRACTID,
nsSimplePopupBlockerConstructor
},
};
NS_IMPL_NSGETMODULE(popuplite, components)

Просмотреть файл

@ -1,4 +0,0 @@
cd /usr/bin/minimo
export LD_LIBRARY_PATH=/usr/bin/minimo
./TestGtkEmbed http://www.mozilla.org/projects/minimo/home.html

Просмотреть файл

@ -1,84 +0,0 @@
* {
/* on a small screen, we need to use a readable font */
font-size: small ! important;
}
/* for all elements but the root element and the body, let's */
/* cancel all annoying document's settings */
* {
/* first cancel all size settings */
width: auto ! important;
height: auto ! important;
/* and make the width adjust to screen layout for the device */
max-width: 100% ! important;
/* max-heights should not apply to small screens */
max-height: none ! important;
/* remove all positioning */
position: static ! important;
/* remove all positioning offsets */
top: auto ! important;
left: auto ! important;
/* and cancel floats */
float: none ! important;
/* margins and paddings have to be changed */
padding: 0px ! important;
margin: 0px ! important;
/* avoid overflow on pre and table cells */
white-space: normal ! important;
}
table,tbody,thead,tfoot,tr,td,th,col,colgroup {
/* we need to "flatten" all tables */
display: block ! important;
}
img[width="1"], img[height="1"],img[width="468"], img[height="600"] {
/* let's get rid of 1 pixel wide/high images */
/* and of std formats of ads ; current ads formats are */
/* too big for small screens */
display: none ! important;
}
li {
/* better placement of the bullet on a small screen */
list-style-position: inside ! important;
}
:-moz-any-link {
/* we need to make anchors more visible */
text-decoration: underline !important;
}
ul,ol {
display: block ! important;
}
li {
display: list-item ! important;
}
a {
background-image: none ! important;
}
img[src*="spacer"] {
display: none ! important;
}
/* google maps hack */
@-moz-document domain(maps.google.com)
{
div#rhs { display: none ! important;}
div#map { height: 80%;
width: 100%;
overflow: hidden;
position: inherit;
}
}

Просмотреть файл

Просмотреть файл

@ -1 +0,0 @@
Moved to mozilla/minimo.