summaryrefslogtreecommitdiffstats
path: root/x11-toolkits
diff options
context:
space:
mode:
authorahze <ahze@df743ca5-7f9a-e211-a948-0013205c9059>2012-01-25 08:03:51 +0800
committerahze <ahze@df743ca5-7f9a-e211-a948-0013205c9059>2012-01-25 08:03:51 +0800
commit4ef20daf8022e7cf42a67d299b86bf72bdad6834 (patch)
tree9e065b21f5fbd2ccadf6c03534cc80d217cd4cbf /x11-toolkits
parent4fce0cc566ac2f87c1b905bdd0df77996ab5818a (diff)
downloadmarcuscom-ports-4ef20daf8022e7cf42a67d299b86bf72bdad6834.tar.gz
marcuscom-ports-4ef20daf8022e7cf42a67d299b86bf72bdad6834.tar.zst
marcuscom-ports-4ef20daf8022e7cf42a67d299b86bf72bdad6834.zip
Update to 2.24.9
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@16669 df743ca5-7f9a-e211-a948-0013205c9059
Diffstat (limited to 'x11-toolkits')
-rw-r--r--x11-toolkits/gtk20/Makefile4
-rw-r--r--x11-toolkits/gtk20/distinfo4
-rw-r--r--x11-toolkits/gtk20/files/patch-DND-vnc-fix84
-rw-r--r--x11-toolkits/gtk20/files/patch-gtk_Makefile.in26
4 files changed, 9 insertions, 109 deletions
diff --git a/x11-toolkits/gtk20/Makefile b/x11-toolkits/gtk20/Makefile
index 9b0a73ff7..c7fdf3765 100644
--- a/x11-toolkits/gtk20/Makefile
+++ b/x11-toolkits/gtk20/Makefile
@@ -3,12 +3,12 @@
# Whom: Vanilla I. Shu <vanilla@MinJe.com.TW>
#
# $FreeBSD$
-# $MCom: ports/x11-toolkits/gtk20/Makefile,v 1.228 2011/12/22 13:43:43 kwm Exp $
+# $MCom: ports/x11-toolkits/gtk20/Makefile,v 1.229 2012/01/19 00:33:53 ahze Exp $
#
# Remember to update graphics/gtk-update-icon-cache too.
PORTNAME= gtk
-PORTVERSION= 2.24.8
+PORTVERSION= 2.24.9
PORTREVISION?= 1
CATEGORIES= x11-toolkits
MASTER_SITES= GNOME
diff --git a/x11-toolkits/gtk20/distinfo b/x11-toolkits/gtk20/distinfo
index 7472e22df..bf74815fc 100644
--- a/x11-toolkits/gtk20/distinfo
+++ b/x11-toolkits/gtk20/distinfo
@@ -1,2 +1,2 @@
-SHA256 (gnome2/gtk+-2.24.8.tar.xz) = 8a3b29f667933cf52eea2db7b066723edbc80443ca9c75b7cd7cbe8c8b90b93c
-SIZE (gnome2/gtk+-2.24.8.tar.xz) = 12811268
+SHA256 (gnome2/gtk+-2.24.9.tar.xz) = 84204bf24cac739fd979943127e7b29cb46b1017684aa24dce630faa01bcb61d
+SIZE (gnome2/gtk+-2.24.9.tar.xz) = 13200580
diff --git a/x11-toolkits/gtk20/files/patch-DND-vnc-fix b/x11-toolkits/gtk20/files/patch-DND-vnc-fix
deleted file mode 100644
index 35ee2fae9..000000000
--- a/x11-toolkits/gtk20/files/patch-DND-vnc-fix
+++ /dev/null
@@ -1,84 +0,0 @@
---- gdk/x11/gdkdnd-x11.c
-+++ gdk/x11/gdkdnd-x11.c
-@@ -683,11 +683,16 @@ is_pointer_within_shape (GdkDisplay *display,
- GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
- GdkRegion *input_shape;
-
-- child->shape = _xwindow_get_shape (display_x11->xdisplay,
-- child->xid, ShapeBounding);
-+ child->shape = NULL;
-+ if (gdk_display_supports_shapes (display))
-+ child->shape = _xwindow_get_shape (display_x11->xdisplay,
-+ child->xid, ShapeBounding);
- #ifdef ShapeInput
-- input_shape = _xwindow_get_shape (display_x11->xdisplay,
-- child->xid, ShapeInput);
-+ input_shape = NULL;
-+ if (gdk_display_supports_input_shapes (display))
-+ input_shape = _xwindow_get_shape (display_x11->xdisplay,
-+ child->xid, ShapeInput);
-+
- if (child->shape && input_shape)
- {
- gdk_region_intersect (child->shape, input_shape);
-diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
-index c2c32f0..f32246e 100644
---- gdk/x11/gdkwindow-x11.c
-+++ gdk/x11/gdkwindow-x11.c
-@@ -4659,17 +4659,24 @@ _xwindow_get_shape (Display *xdisplay,
- shape = NULL;
- rn = 0;
-
-- xrl = XShapeGetRectangles (xdisplay,
-- window,
-- shape_type, &rn, &ord);
-+ /* Note that XShapeGetRectangles returns NULL in two situations:
-+ * - the server doesn't support the SHAPE extension
-+ * - the shape is empty
-+ *
-+ * Since we can't discriminate these here, we always return
-+ * an empty shape. It is the callers responsibility to check
-+ * whether the server supports the SHAPE extensions beforehand.
-+ */
-+ xrl = XShapeGetRectangles (xdisplay, window, shape_type, &rn, &ord);
-
-- if (xrl == NULL || rn == 0)
-+ if (rn == 0)
- return gdk_region_new (); /* Empty */
-
- if (ord != YXBanded)
- {
- /* This really shouldn't happen with any xserver, as they
-- generally convert regions to YXBanded internally */
-+ * generally convert regions to YXBanded internally
-+ */
- g_warning ("non YXBanded shape masks not supported");
- XFree (xrl);
- return NULL;
-@@ -4684,10 +4691,10 @@ _xwindow_get_shape (Display *xdisplay,
- rl[i].height = xrl[i].height;
- }
- XFree (xrl);
--
-+
- shape = _gdk_region_new_from_yxbanded_rects (rl, rn);
- g_free (rl);
--
-+
- return shape;
- }
-
-@@ -4736,10 +4743,10 @@ _gdk_windowing_window_get_input_shape (GdkWindow *window)
- {
- #if defined(ShapeInput)
- if (!GDK_WINDOW_DESTROYED (window) &&
-- gdk_display_supports_shapes (GDK_WINDOW_DISPLAY (window)))
-+ gdk_display_supports_input_shapes (GDK_WINDOW_DISPLAY (window)))
- return _xwindow_get_shape (GDK_WINDOW_XDISPLAY (window),
-- GDK_WINDOW_XID (window),
-- ShapeInput);
-+ GDK_WINDOW_XID (window),
-+ ShapeInput);
- #endif
-
- return NULL;
diff --git a/x11-toolkits/gtk20/files/patch-gtk_Makefile.in b/x11-toolkits/gtk20/files/patch-gtk_Makefile.in
index 9846a2751..7668f953b 100644
--- a/x11-toolkits/gtk20/files/patch-gtk_Makefile.in
+++ b/x11-toolkits/gtk20/files/patch-gtk_Makefile.in
@@ -1,9 +1,5 @@
-Stock icons. This was removed in 2.21.x, however it is used by atleast firefox.
-
-https://bugzilla.gnome.org/show_bug.cgi?id=629878
-
---- gtk/Makefile.in.orig 2011-03-04 12:02:32.000000000 +0100
-+++ gtk/Makefile.in 2011-03-04 12:03:28.000000000 +0100
+--- gtk/Makefile.in.orig 2012-01-24 23:53:56.800847574 -0500
++++ gtk/Makefile.in 2012-01-24 23:53:56.889849878 -0500
@@ -71,8 +71,7 @@
@HAVE_INTROSPECTION_TRUE@@USE_X11_TRUE@am__append_15 = --add-include-path=$(top_builddir)/gdk/x11
@HAVE_INTROSPECTION_TRUE@am__append_16 = Gtk-2.0.gir
@@ -14,19 +10,7 @@ https://bugzilla.gnome.org/show_bug.cgi?id=629878
@OS_WIN32_TRUE@am__append_18 = \
@OS_WIN32_TRUE@ $(GTK_UPDATE_ICON_CACHE_MANIFEST)
-@@ -1358,9 +1357,9 @@
- # gtk-update-icon-cache.exe doesn't require any special privileges.
- @OS_WIN32_TRUE@GTK_UPDATE_ICON_CACHE_MANIFEST = gtk-update-icon-cache.exe.manifest
- gtk_query_immodules_2_0_DEPENDENCIES = $(DEPS)
--gtk_query_immodules_2_0_LDADD = $(LDADDS)
-+gtk_query_immodules_2_0_LDADD = $(LDADDS) $(GLIB_LIBS)
- gtk_query_immodules_2_0_SOURCES = queryimmodules.c
--gtk_update_icon_cache_LDADD = $(GDK_PIXBUF_LIBS)
-+gtk_update_icon_cache_LDADD = $(GDK_PIXBUF_LIBS) $(GLIB_LIBS)
- gtk_update_icon_cache_SOURCES = updateiconcache.c
- STOCK_ICONS = \
- stock-icons/16/document-open-recent.png \
-@@ -1601,7 +1600,171 @@
+@@ -1898,7 +1897,171 @@
stock-icons/24/folder-remote.png \
stock-icons/24/user-home.png \
stock-icons/24/user-desktop.png \
@@ -199,9 +183,9 @@ https://bugzilla.gnome.org/show_bug.cgi?id=629878
@CROSS_COMPILING_FALSE@gtk_update_icon_cache_program = \
@CROSS_COMPILING_FALSE@ ./gtk-update-icon-cache
-@@ -2873,6 +3036,88 @@
+@@ -5628,6 +5791,88 @@
&& $(LN_S) folder.png user-desktop.png \
- && $(RM) user-home.png.png \
+ && $(RM) user-home.png \
&& $(LN_S) folder.png user-home.png \
+ && $(LN_S) application-exit.png gtk-quit.png \
+ && $(LN_S) dialog-info.png gtk-info.png \
id='n496' href='#n496'>496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836
/*
 *  Copyright (C) 2000-2004 Marco Pesenti Gritti
 *  Copyright (C) 2003, 2004 Christian Persch
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 *  $Id$
 */

#include "config.h"

#include "ephy-shell.h"
#include "ephy-type-builtins.h"
#include "ephy-embed-shell.h"
#include "eel-gconf-extensions.h"
#include "ephy-prefs.h"
#include "ephy-file-helpers.h"
#include "ephy-favicon-cache.h"
#include "ephy-window.h"
#include "ephy-bookmarks-import.h"
#include "ephy-bookmarks-editor.h"
#include "ephy-history-window.h"
#include "pdm-dialog.h"
#include "prefs-dialog.h"
#include "ephy-debug.h"
#include "ephy-extensions-manager.h"
#include "toolbar.h"
#include "ephy-session.h"
#include "downloader-view.h"
#include "egg-toolbars-model.h"
#include "ephy-toolbars-model.h"
#include "ephy-automation.h"
#include "print-dialog.h"

#ifdef ENABLE_DBUS
#include "ephy-dbus.h"
#endif

#include <string.h>
#include <bonobo/bonobo-main.h>
#include <glib/gi18n.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkmessagedialog.h>
#include <gtk/gtknotebook.h>
#include <dirent.h>
#include <unistd.h>
#include <libgnomeui/gnome-client.h>

#define AUTOMATION_IID "OAFIID:GNOME_Epiphany_Automation"

#define EPHY_SHELL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_SHELL, EphyShellPrivate))

struct _EphyShellPrivate
{
    BonoboGenericFactory *automation_factory;
    EphySession *session;
    EphyBookmarks *bookmarks;
    EggToolbarsModel *toolbars_model;
    EggToolbarsModel *fs_toolbars_model;
    EphyExtensionsManager *extensions_manager;
    GObject *dbus_service;
    GtkWidget *bme;
    GtkWidget *history_window;
    GObject *pdm_dialog;
    GObject *prefs_dialog;
    GObject *print_setup_dialog;
    GList *del_on_exit;
};

EphyShell *ephy_shell = NULL;

static void ephy_shell_class_init   (EphyShellClass *klass);
static void ephy_shell_init     (EphyShell *shell);
static void ephy_shell_finalize     (GObject *object);

static GObjectClass *parent_class = NULL;

GQuark
ephy_shell_error_quark (void)
{
    static GQuark q = 0;

    if (q == 0)
    {
        q = g_quark_from_static_string ("ephy-shell-error-quark");
    }

    return q;
}

GType
ephy_shell_get_type (void)
{
    static GType type = 0;

    if (G_UNLIKELY (type == 0))
    {
        static const GTypeInfo our_info =
        {
            sizeof (EphyShellClass),
            NULL, /* base_init */
            NULL, /* base_finalize */
            (GClassInitFunc) ephy_shell_class_init,
            NULL,
            NULL, /* class_data */
            sizeof (EphyShell),
            0, /* n_preallocs */
            (GInstanceInitFunc) ephy_shell_init
        };

        type = g_type_register_static (EPHY_TYPE_EMBED_SHELL,
                           "EphyShell",
                           &our_info, 0);
    }

    return type;
}

static void
ephy_shell_class_init (EphyShellClass *klass)
{
    GObjectClass *object_class = G_OBJECT_CLASS (klass);

    parent_class = g_type_class_peek_parent (klass);

    object_class->finalize = ephy_shell_finalize;

    g_type_class_add_private (object_class, sizeof(EphyShellPrivate));
}

static BonoboObject *
ephy_automation_factory_cb (BonoboGenericFactory *this_factory,
                const char *iid,
                EphyShell *shell)
{
    if (strcmp (iid, AUTOMATION_IID) == 0)
    {
        return BONOBO_OBJECT (g_object_new (EPHY_TYPE_AUTOMATION, NULL));
    }

    g_assert_not_reached ();

    return NULL;
}

static BonoboGenericFactory *
ephy_automation_factory_new (EphyShell *shell)
{
    BonoboGenericFactory *factory;
    GClosure *factory_closure;

    factory = g_object_new (bonobo_generic_factory_get_type (), NULL);

    factory_closure = g_cclosure_new
        (G_CALLBACK (ephy_automation_factory_cb), shell, NULL);

    bonobo_generic_factory_construct_noreg
        (factory, AUTOMATION_FACTORY_IID, factory_closure);

    return factory;
}

static void
ephy_shell_init (EphyShell *shell)
{
    EphyShell **ptr = &ephy_shell;

    shell->priv = EPHY_SHELL_GET_PRIVATE (shell);

    /* globally accessible singleton */
    g_assert (ephy_shell == NULL);
    ephy_shell = shell;
    g_object_add_weak_pointer (G_OBJECT(ephy_shell),
                   (gpointer *)ptr);

    /* Instantiate the automation factory */
    shell->priv->automation_factory = ephy_automation_factory_new (shell);
}

static char *
path_from_command_line_arg (const char *arg)
{
    char path[PATH_MAX];

    if (realpath (arg, path) != NULL)
    {
        return g_strdup (path);
    }
    else
    {
        return g_strdup (arg);
    }
}

static void
open_urls (GNOME_EphyAutomation automation,
       const char **args, CORBA_Environment *ev,
       gboolean new_tab, gboolean existing_window,
       gboolean fullscreen)
{
    int i;

    if (args == NULL)
    {
        /* Homepage or resume */
        GNOME_EphyAutomation_loadurl
            (automation, "", fullscreen,
             existing_window, new_tab, ev);
    }
    else
    {
        for (i = 0; args[i] != NULL; i++)
        {
            char *path;

            path = path_from_command_line_arg (args[i]);

            GNOME_EphyAutomation_loadurl
                (automation, path, fullscreen,
                 existing_window, new_tab, ev);

            g_free (path);
        }
    }
}

static gboolean
save_yourself_cb (GnomeClient *client,
          gint phase,
          GnomeSaveStyle save_style,
          gboolean shutdown,
          GnomeInteractStyle interact_style,
          gboolean fast,
          EphyShell *shell)
{
    char *argv[] = { NULL, "--load-session", NULL };
    char *discard_argv[] = { "rm", "-f", NULL };
    EphySession *session;
    char *tmp, *save_to;

    LOG ("save_yourself_cb")

    tmp = g_build_filename (ephy_dot_dir (),
                "session_gnome-XXXXXX",
                NULL);
    save_to = ephy_file_tmp_filename (tmp, "xml");
    g_free (tmp);

    session = EPHY_SESSION (ephy_shell_get_session (shell));

    argv[0] = g_get_prgname ();
    argv[2] = save_to;
    gnome_client_set_restart_command
        (client, 3, argv);

    discard_argv[2] = save_to;
    gnome_client_set_discard_command (client, 3,
                      discard_argv);

    ephy_session_save (session, save_to);

    g_free (save_to);

    return TRUE;
}

static void
die_cb (GnomeClient* client,
    EphyShell *shell)
{
    EphySession *session;

    LOG ("die_cb")

    session = EPHY_SESSION (ephy_shell_get_session (shell));
    ephy_session_close (session);
}

static void
gnome_session_init (EphyShell *shell)
{
    GnomeClient *client;

    client = gnome_master_client ();

    g_signal_connect (G_OBJECT (client),
              "save_yourself",
              G_CALLBACK (save_yourself_cb),
              shell);
    g_signal_connect (G_OBJECT (client),
              "die",
              G_CALLBACK (die_cb),
              shell);
}

gboolean
ephy_shell_startup (EphyShell *shell,
            EphyShellStartupFlags flags,
            const char **args,
            const char *string_arg,
            GError **error)
{
    CORBA_Environment ev;
    GNOME_EphyAutomation automation;
    Bonobo_RegistrationResult result;

    ephy_ensure_dir_exists (ephy_dot_dir ());

    CORBA_exception_init (&ev);

    result = bonobo_activation_register_active_server
        (AUTOMATION_FACTORY_IID, BONOBO_OBJREF (shell->priv->automation_factory), NULL);

    switch (result)
    {
        case Bonobo_ACTIVATION_REG_SUCCESS:
            break;
        case Bonobo_ACTIVATION_REG_ALREADY_ACTIVE:
            break;
        case Bonobo_ACTIVATION_REG_NOT_LISTED:
            g_set_error (error, EPHY_SHELL_ERROR,
                     EPHY_SHELL_ERROR_MISSING_SERVER,
                     _("Bonobo couldn't locate the GNOME_Epiphany_Automation.server "
                       "file. You can use bonobo-activation-sysconf to configure "
                       "the search path for bonobo server files."));
            break;
        case Bonobo_ACTIVATION_REG_ERROR:
            g_set_error (error, EPHY_SHELL_ERROR,
                     EPHY_SHELL_ERROR_FACTORY_REG_FAILED,
                     _("Epiphany can't be used now, due to an unexpected error "
                       "from Bonobo when attempting to register the automation "
                       "server"));
            break;
        default:
            g_assert_not_reached ();
    }

    if (result == Bonobo_ACTIVATION_REG_SUCCESS ||
         result == Bonobo_ACTIVATION_REG_ALREADY_ACTIVE)
    {
        automation = bonobo_activation_activate_from_id (AUTOMATION_IID,
                                 0, NULL, &ev);
        if (CORBA_Object_is_nil (automation, &ev))
        {
            g_set_error (error, EPHY_SHELL_ERROR,
                     EPHY_SHELL_ERROR_OBJECT_REG_FAILED,
                     _("Epiphany can't be used now, due to an unexpected error "
                       "from Bonobo when attempting to locate the automation "
                       "object."));
            automation = NULL;
        }
        else if (flags & EPHY_SHELL_STARTUP_BOOKMARKS_EDITOR)
        {
            GNOME_EphyAutomation_openBookmarksEditor
                (automation, &ev);
        }
        else if (flags & EPHY_SHELL_STARTUP_SESSION)
        {
            GNOME_EphyAutomation_loadSession
                (automation, string_arg, &ev);
        }
        else if (flags & EPHY_SHELL_STARTUP_IMPORT_BOOKMARKS)
        {
            GNOME_EphyAutomation_importBookmarks
                (automation, string_arg, &ev);
        }
        else if (flags & EPHY_SHELL_STARTUP_ADD_BOOKMARK)
        {
            GNOME_EphyAutomation_addBookmark
                (automation, string_arg, &ev);
        }
        else
        {
            open_urls (automation, args, &ev,
                   flags & EPHY_SHELL_STARTUP_TABS,
                   flags & EPHY_SHELL_STARTUP_EXISTING_WINDOW,
                   flags & EPHY_SHELL_STARTUP_FULLSCREEN);
        }

        if (automation)
        {
            bonobo_object_release_unref (automation, &ev);
        }

        gnome_session_init (shell);
    }

    CORBA_exception_free (&ev);
    gdk_notify_startup_complete ();

    return !(result == Bonobo_ACTIVATION_REG_ALREADY_ACTIVE);
}

static void
ephy_shell_finalize (GObject *object)
{
    EphyShell *shell = EPHY_SHELL (object);

    g_assert (ephy_shell == NULL);

    /* this will unload the extensions */
    LOG ("Unref extension manager")
    if (shell->priv->extensions_manager)
    {
        g_object_unref (shell->priv->extensions_manager);
    }

#ifdef ENABLE_DBUS
    LOG ("Shutting down DBUS service")
    if (shell->priv->dbus_service)
    {
        g_object_unref (shell->priv->dbus_service);
    }
#endif

    LOG ("Unref session manager")
    if (shell->priv->session)
    {
        g_object_unref (shell->priv->session);
    }

    LOG ("Unref toolbars model")
    if (shell->priv->toolbars_model)
    {
        g_object_unref (shell->priv->toolbars_model);
    }

    LOG ("Unref fullscreen toolbars model")
    if (shell->priv->fs_toolbars_model)
    {
        g_object_unref (shell->priv->fs_toolbars_model);
    }

    LOG ("Unref Bookmarks Editor");
    if (shell->priv->bme)
    {
        gtk_widget_destroy (GTK_WIDGET (shell->priv->bme));
    }

    LOG ("Unref History Window");
    if (shell->priv->history_window)
    {
        gtk_widget_destroy (GTK_WIDGET (shell->priv->history_window));
    }

    LOG ("Unref PDM Dialog")
    if (shell->priv->pdm_dialog)
    {
        g_object_unref (shell->priv->pdm_dialog);
    }

    LOG ("Unref prefs dialog")
    if (shell->priv->prefs_dialog)
    {
        g_object_unref (shell->priv->prefs_dialog);
    }

    LOG ("Unref print setup dialog")
    if (shell->priv->print_setup_dialog)
    {
        g_object_unref (shell->priv->print_setup_dialog);
    }

    LOG ("Unref bookmarks")
    if (shell->priv->bookmarks)
    {
        g_object_unref (shell->priv->bookmarks);
    }

    G_OBJECT_CLASS (parent_class)->finalize (object);

    if (shell->priv->automation_factory)
    {
        bonobo_activation_unregister_active_server
            (AUTOMATION_FACTORY_IID, BONOBO_OBJREF (shell->priv->automation_factory));

        bonobo_object_unref (shell->priv->automation_factory);
    }

    LOG ("Ephy shell finalized")
}

EphyShell *
ephy_shell_new (void)
{
    return EPHY_SHELL (g_object_new (EPHY_TYPE_SHELL, NULL));
}

static void
load_homepage (EphyEmbed *embed)
{
    char *home;

    home = eel_gconf_get_string(CONF_GENERAL_HOMEPAGE);

    if (home == NULL || home[0] == '\0')
    {
        g_free (home);

        home = g_strdup ("about:blank");
    }

    ephy_embed_load_url (embed, home);

    g_free (home);
}

/**
 * ephy_shell_new_tab:
 * @shell: a #EphyShell
 * @parent_window: the target #EphyWindow or %NULL
 * @previous_tab: the referrer tab or %NULL
 * @url: an url to load or %NULL
 *
 * Create a new tab and the parent window when necessary.
 * Use this function to open urls in new window/tabs.
 *
 * ReturnValue: the created #EphyTab
 **/
EphyTab *
ephy_shell_new_tab (EphyShell *shell,
            EphyWindow *parent_window,
            EphyTab *previous_tab,
            const char *url,
            EphyNewTabFlags flags)
{
    EphyWindow *window;
    EphyTab *tab;
    EphyEmbed *embed;
    gboolean in_new_window = TRUE;
    gboolean jump_to;
    EphyEmbed *previous_embed = NULL;
    GtkWidget *nb;
    int position = -1;
    Toolbar *toolbar;

    if (flags & EPHY_NEW_TAB_IN_NEW_WINDOW) in_new_window = TRUE;
    if (flags & EPHY_NEW_TAB_IN_EXISTING_WINDOW) in_new_window = FALSE;

    in_new_window = in_new_window && !eel_gconf_get_boolean (CONF_LOCKDOWN_FULLSCREEN);

    jump_to = (flags & EPHY_NEW_TAB_JUMP) != 0;

    LOG ("Opening new tab parent-window %p parent-tab %p in-new-window:%s jump-to:%s",
         parent_window, previous_tab, in_new_window ? "t" : "f", jump_to ? "t" : "f")

    if (!in_new_window && parent_window != NULL)
    {
        window = parent_window;
    }
    else
    {
        window = ephy_window_new ();
    }

    toolbar = EPHY_TOOLBAR (ephy_window_get_toolbar (window));

    if (previous_tab != NULL)
    {
        previous_embed = ephy_tab_get_embed (previous_tab);
    }

    if ((flags & EPHY_NEW_TAB_APPEND_AFTER) && previous_tab != NULL)
    {
        nb = ephy_window_get_notebook (window);
        position = gtk_notebook_page_num (GTK_NOTEBOOK (nb),
                          GTK_WIDGET (previous_tab)) + 1;
    }

    tab = ephy_tab_new ();
    gtk_widget_show (GTK_WIDGET (tab));
    embed = ephy_tab_get_embed (tab);

    ephy_window_add_tab (window, tab, position, jump_to);
    gtk_widget_show (GTK_WIDGET (window));

    if (flags & EPHY_NEW_TAB_HOME_PAGE ||
        flags & EPHY_NEW_TAB_NEW_PAGE)
    {
        ephy_tab_set_location (tab, "", EPHY_TAB_ADDRESS_EXPIRE_NEXT);
        toolbar_activate_location (toolbar);
        load_homepage (embed);
    }
    else if (flags & EPHY_NEW_TAB_OPEN_PAGE)
    {
        g_assert (url != NULL);
        ephy_embed_load_url (embed, url);
    }

    if (flags & EPHY_NEW_TAB_FULLSCREEN_MODE)
    {
        gtk_window_fullscreen (GTK_WINDOW (window));
    }

    return tab;
}

/**
 * ephy_shell_get_session:
 * @shell: the #EphyShell
 *
 * Returns current session.
 *
 * Return value: the current session.
 **/
GObject *
ephy_shell_get_session (EphyShell *shell)
{
    g_return_val_if_fail (EPHY_IS_SHELL (shell), NULL);

    if (shell->priv->session == NULL)
    {
        EphyExtensionsManager *manager;

        shell->priv->session = g_object_new (EPHY_TYPE_SESSION, NULL);

        manager = EPHY_EXTENSIONS_MANAGER
            (ephy_shell_get_extensions_manager (shell));
        ephy_extensions_manager_register (manager,
                          G_OBJECT (shell->priv->session));
    }

    return G_OBJECT (shell->priv->session);
}

EphyBookmarks *
ephy_shell_get_bookmarks (EphyShell *shell)
{
    if (shell->priv->bookmarks == NULL)
    {
        shell->priv->bookmarks = ephy_bookmarks_new ();
    }

    return shell->priv->bookmarks;
}

GObject *
ephy_shell_get_toolbars_model (EphyShell *shell, gboolean fullscreen)
{
    LOG ("ephy_shell_get_toolbars_model fs=%d", fullscreen)

    if (fullscreen)
    {
        if (shell->priv->fs_toolbars_model == NULL)
        {
            gboolean success;
            const char *xml;

            shell->priv->fs_toolbars_model = egg_toolbars_model_new ();
            xml = ephy_file ("epiphany-fs-toolbar.xml");
            g_return_val_if_fail (xml != NULL, NULL);

            success = egg_toolbars_model_load
                (shell->priv->fs_toolbars_model, xml);
            g_return_val_if_fail (success, NULL);
        }

        return G_OBJECT (shell->priv->fs_toolbars_model);
    }
    else
    {
        if (shell->priv->toolbars_model == NULL)
        {
            EphyBookmarks *bookmarks;
            GObject *bookmarksbar_model;

            shell->priv->toolbars_model = ephy_toolbars_model_new ();

            /* get the bookmarks toolbars model. we have to do this
             * before loading the toolbars model from disk, since
             * this will connect the get_item_* signals
             */
            bookmarks = ephy_shell_get_bookmarks (shell);
            bookmarksbar_model = ephy_bookmarks_get_toolbars_model (bookmarks);

            /* ok, now we can load the model */
            ephy_toolbars_model_load
                (EPHY_TOOLBARS_MODEL (shell->priv->toolbars_model));
        }

        return G_OBJECT (shell->priv->toolbars_model);
    }
}

GObject *
ephy_shell_get_extensions_manager (EphyShell *es)
{
    g_return_val_if_fail (EPHY_IS_SHELL (es), NULL);

    if (es->priv->extensions_manager == NULL)
    {
        /* Instantiate extensions manager */
        es->priv->extensions_manager =
            g_object_new (EPHY_TYPE_EXTENSIONS_MANAGER, NULL);

        ephy_extensions_manager_startup (es->priv->extensions_manager);
    }

    return G_OBJECT (es->priv->extensions_manager);
}

static void
toolwindow_show_cb (GtkWidget *widget, EphyShell *es)
{
    EphySession *session;

    LOG ("Ref shell for %s", G_OBJECT_TYPE_NAME (widget))

    session = EPHY_SESSION (ephy_shell_get_session (es));
    ephy_session_add_window (ephy_shell->priv->session, GTK_WINDOW (widget));
    g_object_ref (ephy_shell);
}

static void
toolwindow_hide_cb (GtkWidget *widget, EphyShell *es)
{
    EphySession *session;

    LOG ("Unref shell for %s", G_OBJECT_TYPE_NAME (widget))

    session = EPHY_SESSION (ephy_shell_get_session (es));
    ephy_session_remove_window (ephy_shell->priv->session, GTK_WINDOW (widget));
    g_object_unref (ephy_shell);
}

GtkWidget *
ephy_shell_get_bookmarks_editor (EphyShell *shell)
{
    EphyBookmarks *bookmarks;

    if (shell->priv->bme == NULL)
    {
        bookmarks = ephy_shell_get_bookmarks (ephy_shell);
        g_assert (bookmarks != NULL);
        shell->priv->bme = ephy_bookmarks_editor_new (bookmarks);

        g_signal_connect (shell->priv->bme, "show", 
                  G_CALLBACK (toolwindow_show_cb), shell);
        g_signal_connect (shell->priv->bme, "hide", 
                  G_CALLBACK (toolwindow_hide_cb), shell);
    }

    return shell->priv->bme;
}

GtkWidget *
ephy_shell_get_history_window (EphyShell *shell)
{
    EphyHistory *history;

    if (shell->priv->history_window == NULL)
    {
        history = EPHY_HISTORY
            (ephy_embed_shell_get_global_history (embed_shell));
        g_assert (history != NULL);
        shell->priv->history_window = ephy_history_window_new (history);

        g_signal_connect (shell->priv->history_window, "show",
                  G_CALLBACK (toolwindow_show_cb), shell);
        g_signal_connect (shell->priv->history_window, "hide",
                  G_CALLBACK (toolwindow_hide_cb), shell);
    }

    return shell->priv->history_window;
}

GObject *
ephy_shell_get_pdm_dialog (EphyShell *shell)
{
    if (shell->priv->pdm_dialog == NULL)
    {
        shell->priv->pdm_dialog = g_object_new (EPHY_TYPE_PDM_DIALOG, NULL);

        g_object_add_weak_pointer (shell->priv->pdm_dialog,
                       (gpointer *) &shell->priv->pdm_dialog);
    }

    return shell->priv->pdm_dialog;
}

GObject *
ephy_shell_get_prefs_dialog (EphyShell *shell)
{
    if (shell->priv->prefs_dialog == NULL)
    {
        shell->priv->prefs_dialog = g_object_new (EPHY_TYPE_PREFS_DIALOG, NULL);

        g_object_add_weak_pointer (shell->priv->prefs_dialog,
                       (gpointer *) &shell->priv->prefs_dialog);
    }

    return shell->priv->prefs_dialog;
}

GObject *
ephy_shell_get_print_setup_dialog (EphyShell *shell)
{
    if (shell->priv->print_setup_dialog == NULL)
    {
        shell->priv->print_setup_dialog = G_OBJECT (ephy_print_setup_dialog_new ());

        g_object_add_weak_pointer (shell->priv->print_setup_dialog,
                       (gpointer *) &shell->priv->print_setup_dialog);
    }

    return shell->priv->print_setup_dialog;
}

#ifdef ENABLE_DBUS
GObject *
ephy_shell_get_dbus_service (EphyShell *shell)
{
    g_return_val_if_fail (EPHY_IS_SHELL (shell), NULL);

    if (shell->priv->dbus_service == NULL)
    {
        shell->priv->dbus_service = g_object_new (EPHY_TYPE_DBUS, NULL);
        ephy_dbus_startup (EPHY_DBUS (shell->priv->dbus_service));
    }

    return G_OBJECT (shell->priv->dbus_service);
}
#endif