aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/Evolution-Component.idl137
-rw-r--r--shell/Evolution-ConfigControl.idl26
-rw-r--r--shell/Evolution-Shell.idl87
-rw-r--r--shell/Evolution.idl20
-rw-r--r--shell/Makefile.am102
-rw-r--r--shell/apps_evolution_shell.schemas.in24
-rw-r--r--shell/e-active-connection-dialog.glade193
-rw-r--r--shell/e-component-registry.c327
-rw-r--r--shell/e-component-registry.h104
-rw-r--r--shell/e-component-view.c151
-rw-r--r--shell/e-component-view.h79
-rw-r--r--shell/e-corba-config-page.c155
-rw-r--r--shell/e-corba-config-page.h68
-rw-r--r--shell/e-shell-common.h (renamed from shell/importer/intelligent.h)19
-rw-r--r--shell/e-shell-constants.h50
-rw-r--r--shell/e-shell-content.c1384
-rw-r--r--shell/e-shell-content.h143
-rw-r--r--shell/e-shell-importer.c24
-rw-r--r--shell/e-shell-importer.h15
-rw-r--r--shell/e-shell-migrate.c335
-rw-r--r--shell/e-shell-migrate.h (renamed from shell/evolution-component.h)45
-rw-r--r--shell/e-shell-module.c629
-rw-r--r--shell/e-shell-module.h157
-rw-r--r--shell/e-shell-nm.c52
-rw-r--r--shell/e-shell-settings-dialog.c357
-rw-r--r--shell/e-shell-settings-dialog.h65
-rw-r--r--shell/e-shell-settings.c559
-rw-r--r--shell/e-shell-settings.h114
-rw-r--r--shell/e-shell-sidebar.c681
-rw-r--r--shell/e-shell-sidebar.h97
-rw-r--r--shell/e-shell-switcher.c700
-rw-r--r--shell/e-shell-switcher.h92
-rw-r--r--shell/e-shell-taskbar.c421
-rw-r--r--shell/e-shell-taskbar.h87
-rw-r--r--shell/e-shell-view.c1030
-rw-r--r--shell/e-shell-view.h195
-rw-r--r--shell/e-shell-window-actions.c2230
-rw-r--r--shell/e-shell-window-actions.h123
-rw-r--r--shell/e-shell-window-commands.c1396
-rw-r--r--shell/e-shell-window-commands.h31
-rw-r--r--shell/e-shell-window-private.c575
-rw-r--r--shell/e-shell-window-private.h128
-rw-r--r--shell/e-shell-window.c1749
-rw-r--r--shell/e-shell-window.h139
-rw-r--r--shell/e-shell.c2185
-rw-r--r--shell/e-shell.h205
-rw-r--r--shell/e-sidebar.c795
-rw-r--r--shell/e-sidebar.h88
-rw-r--r--shell/e-user-creatable-items-handler.c914
-rw-r--r--shell/e-user-creatable-items-handler.h70
-rw-r--r--shell/es-event.c18
-rw-r--r--shell/es-event.h15
-rw-r--r--shell/es-menu.c186
-rw-r--r--shell/es-menu.h97
-rw-r--r--shell/evolution-component.c48
-rw-r--r--shell/evolution-config-control.c175
-rw-r--r--shell/evolution-config-control.h64
-rw-r--r--shell/evolution-listener.c71
-rw-r--r--shell/evolution-listener.h54
-rw-r--r--shell/evolution-shell-component-utils.c112
-rw-r--r--shell/evolution-shell-component-utils.h52
-rw-r--r--shell/importer/GNOME_Evolution_Importer.idl97
-rw-r--r--shell/importer/Makefile.am68
-rw-r--r--shell/importer/evolution-importer-client.c267
-rw-r--r--shell/importer/evolution-importer-client.h74
-rw-r--r--shell/importer/evolution-importer-listener.c224
-rw-r--r--shell/importer/evolution-importer-listener.h71
-rw-r--r--shell/importer/evolution-importer.c249
-rw-r--r--shell/importer/evolution-importer.h100
-rw-r--r--shell/importer/evolution-intelligent-importer.c197
-rw-r--r--shell/importer/evolution-intelligent-importer.h74
-rw-r--r--shell/importer/import.glade124
-rw-r--r--shell/importer/intelligent.c469
-rw-r--r--shell/main.c444
-rw-r--r--shell/shell.error.xml27
-rw-r--r--shell/test/GNOME_Evolution_Test.server.in.in39
-rw-r--r--shell/test/Makefile.am25
-rw-r--r--shell/test/e-test-shell-module.c192
-rw-r--r--shell/test/e-test-shell-view.c155
-rw-r--r--shell/test/e-test-shell-view.h67
-rw-r--r--shell/test/evolution-test-component.c178
-rw-r--r--shell/test/evolution-test-component.h56
82 files changed, 12338 insertions, 11103 deletions
diff --git a/shell/Evolution-Component.idl b/shell/Evolution-Component.idl
deleted file mode 100644
index ccf806ff91..0000000000
--- a/shell/Evolution-Component.idl
+++ /dev/null
@@ -1,137 +0,0 @@
-/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Interface for the Evolution components.
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 2003 Ximian, Inc.
- */
-
-#ifndef _GNOME_EVOLUTION_COMPONENT_IDL
-#define _GNOME_EVOLUTION_COMPONENT_IDL
-
-#include <Bonobo.idl>
-
-#ifndef __evolution_shell_COMPILATION
-#ifdef __ORBIT_IDL__
-%{
-#pragma include_defs shell/evolution-component.h
-%}
-#pragma inhibit push
-#endif
-#endif
-
-module GNOME {
-module Evolution {
- enum CreatableItem {
- CREATABLE_OBJECT,
- CREATABLE_FOLDER
- };
- enum ShellState {
- USER_OFFLINE,
- FORCED_OFFLINE,
- USER_ONLINE
- };
-
- /* A type of item that the component can create when asked by the user,
- e.g. a mail message or an appointment. */
- struct CreatableItemType {
- string id;
- string description;
- string menuDescription;
- string tooltip;
- char menuShortcut;
- string iconName;
- CreatableItem type;
- };
- typedef sequence <CreatableItemType> CreatableItemTypeList;
-
- interface ComponentView : Bonobo::Unknown {
- void getControls (out Bonobo::Control sidebar_control,
- out Bonobo::Control view_control,
- out Bonobo::Control statusbar_control);
- };
-
- interface Listener : Bonobo::Unknown {
- /* Indicate the change of state is complete */
- void complete();
- };
-
- interface Component : Bonobo::Unknown {
- exception Failed {};
- exception UnknownType {};
- /* We don't know about the old version we're upgrading from */
- exception UnsupportedVersion {};
- /* We encountered a non-recoverable, fatal error, explain why */
- exception UpgradeFailed {
- string what;
- string why;
- };
-
- /*** Upgrade path. ***/
-
- void upgradeFromVersion (in short major, in short minor, in short revision)
- raises (UnsupportedVersion, UpgradeFailed);
-
- /*** Basic functionality. ***/
- ComponentView createView(in ShellView parent,
- in boolean select_item)
- raises (Failed);
-
-
- /* Check if the component can quit.
- Do not perform any quit-related tasks however.
- May be called multiple times, depending on user interaction. */
- boolean requestQuit ();
-
- /* Ask the component to quit. Returns TRUE when the
- component has completed any closing-down tasks, and
- is ready to exit(). This will be called repeatedly
- at intervals until it returns TRUE. */
- boolean quit ();
-
- /* Notify the component of whether the shell is currently
- running in interactive mode or not. (I.e. basically,
- whether there are any Evolution windows on the screen.)
- @new_view_xid is an X Window ID ("None" if @now_interactive
- is FALSE) */
- void interactive (in boolean now_interactive,
- in unsigned long new_view_xid);
-
-
- /*** The following stuff is needed to build the "New" toolbar
- item as well as the "File -> New" submenu. ***/
-
- /* List of creatable items. */
- readonly attribute CreatableItemTypeList userCreatableItems;
-
- /* Pop up a new editing dialog for the item with the specified
- @item_type_name. */
- void requestCreateItem (in string item_type_name)
- raises (UnknownType, Failed);
-
-
- /*** URI handling (e.g. for the command-line, "evolution
- mailto:foo@bar.org") ***/
- void handleURI (in string uri);
-
-
- /*** Send/receive. ***/
-
- void sendAndReceive ();
-
- /* Set the online status of the component asynchronously */
-
- void setLineStatus(in ShellState shell_state, in Listener listener);
- };
-
-};
-};
-
-#ifndef __evolution_shell_COMPILATION
-#ifdef __ORBIT_IDL__
-#pragma inhibit pop
-#endif
-#endif
-#endif /* _GNOME_EVOLUTION_COMPONENT_IDL */
diff --git a/shell/Evolution-ConfigControl.idl b/shell/Evolution-ConfigControl.idl
deleted file mode 100644
index 901932d209..0000000000
--- a/shell/Evolution-ConfigControl.idl
+++ /dev/null
@@ -1,26 +0,0 @@
-/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Additional interfaces for the Controls used in configuration dialogs.
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 2002 Ximian, Inc.
- */
-
-#ifndef _GNOME_EVOLUTION_CONFIGCONTROL_IDL
-#define _GNOME_EVOLUTION_CONFIGCONTROL_IDL
-
-module GNOME {
-module Evolution {
- interface ConfigControl : Bonobo::Unknown {
- /* The actual Control. */
- readonly attribute Bonobo::Control control;
-
- /* Get the event source for this control. */
- readonly attribute Bonobo::EventSource eventSource;
- };
-}; /* module Evolution */
-}; /* module GNOME */
-
-#endif
diff --git a/shell/Evolution-Shell.idl b/shell/Evolution-Shell.idl
deleted file mode 100644
index d39ec8edeb..0000000000
--- a/shell/Evolution-Shell.idl
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Interface for the Evolution shell.
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 2000, 2001 Ximian, Inc.
- */
-
-#ifndef _GNOME_EVOLUTION_SHELL_IDL
-#define _GNOME_EVOLUTION_SHELL_IDL
-
-#include <Bonobo.idl>
-
-#ifndef __evolution_shell_COMPILATION
-#ifdef __ORBIT_IDL__
-%{
-#pragma include_defs shell/evolution-component.h
-%}
-#pragma inhibit push
-#endif
-#endif
-
-module GNOME {
-module Evolution {
-
-
- interface ShellView : Bonobo::Unknown {
- /* Should really use a ComponentView i guess */
- void setTitle(in string component, in string title);
- void setComponent(in string component);
- void setButtonIcon(in string component, in string iconName);
- };
-
- interface Shell : Bonobo::Unknown {
- exception Busy {};
- exception ComponentNotFound {};
- exception InternalError {};
- exception InvalidURI {};
- exception NotFound {};
- exception NotReady {};
- exception UnsupportedSchema {};
-
- /**
- * createNewWindow:
- * @component_id: id or alias of the component to display in the new window.
- *
- */
- ShellView createNewWindow (in string component_id)
- raises (NotReady, ComponentNotFound, UnsupportedSchema, InternalError);
-
- /**
- * handleURI:
- * @uri: URI to handle
- *
- * This handles the specified URI. It is different from
- * `::createNewView' as it doesn't necessarily imply creating a
- * new ShellView. (For example, a `mailto:' URI will invoke
- * the message composer.)
- */
- void handleURI (in string uri)
- raises (NotReady, ComponentNotFound, NotFound, UnsupportedSchema, InvalidURI, InternalError);
-
- /**
- * setLineStatus:
- *
- * Set the shell into on-line or off-line mode.
- */
- void setLineStatus (in boolean online)
- raises (NotReady);
-
- /*
- * Lookup a component by id.
- */
- /*Component findComponent(in string id)
- raises (NotReady, ComponentNotFound);*/
- };
-};
-};
-
-#ifndef __evolution_shell_COMPILATION
-#ifdef __ORBIT_IDL__
-#pragma inhibit pop
-#endif
-#endif
-#endif /* _GNOME_EVOLUTION_SHELL_IDL */
diff --git a/shell/Evolution.idl b/shell/Evolution.idl
deleted file mode 100644
index 059d017444..0000000000
--- a/shell/Evolution.idl
+++ /dev/null
@@ -1,20 +0,0 @@
-/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * CORBA interface for the Evolution shell.
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 2000, 2001 Ximian, Inc.
- */
-
-#ifndef _GNOME_EVOLUTION_IDL
-#define _GNOME_EVOLUTION_IDL
-
-#include <Bonobo.idl>
-
-#include <Evolution-ConfigControl.idl>
-#include <Evolution-Shell.idl>
-#include <Evolution-Component.idl>
-
-#endif
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 6d47f6e933..8fd5896fe3 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -3,7 +3,9 @@ SUBDIRS = . test
endif
INCLUDES = \
+ -I$(top_srcdir)/e-util \
-I$(top_srcdir)/widgets \
+ -I$(top_srcdir)/widgets/menus \
-I$(top_srcdir)/widgets/misc \
-I$(top_srcdir) \
-I$(top_srcdir)/shell \
@@ -11,8 +13,11 @@ INCLUDES = \
-DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \
-DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \
-DEVOLUTION_DATADIR=\""$(datadir)"\" \
+ -DEVOLUTION_GALVIEWSDIR=\""$(viewsdir)"\" \
-DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \
-DEVOLUTION_HELPDIR=\""$(evolutionhelpdir)"\" \
+ -DEVOLUTION_MODULEDIR=\""$(moduledir)"\" \
+ -DEVOLUTION_RULEDIR=\""$(privdatadir)"\" \
-DEVOLUTION_UIDIR=\""$(evolutionuidir)"\" \
-DEVOLUTION_TOOLSDIR=\""$(privlibexecdir)"\" \
-DPREFIX=\""$(prefix)"\" \
@@ -25,32 +30,6 @@ INCLUDES = \
noinst_PROGRAMS = evolution
-# Shell CORBA stuff
-
-IDLS = \
- Evolution-ConfigControl.idl \
- Evolution-Component.idl \
- Evolution-Shell.idl \
- Evolution.idl
-
-IDL_GENERATED_H = \
- Evolution.h
-
-IDL_GENERATED_C = \
- Evolution-common.c \
- Evolution-skels.c \
- Evolution-stubs.c
-
-idl_defines = \
- -D__evolution_shell_COMPILATION
-
-IDL_GENERATED = $(IDL_GENERATED_H) $(IDL_GENERATED_C)
-
-$(IDL_GENERATED_H): $(IDLS)
- $(ORBIT_IDL) -I $(srcdir) $(idl_defines) $(IDL_INCLUDES) $(srcdir)/Evolution.idl
-
-$(IDL_GENERATED_C): $(IDL_GENERATED_H)
-
if NM_SUPPORT
NM_SUPPORT_FILES = e-shell-nm.c
endif
@@ -72,10 +51,6 @@ $(DATASERVER_IDL_GENERATED_H): $(DATASERVER_IDL)
$(DATASERVER_IDL_GENERATED_C): $(DATASERVER_IDL_GENERATED_H)
-# IDL install
-
-idl_DATA = $(IDLS)
-
# Shell library
privsolib_LTLIBRARIES = \
@@ -84,24 +59,29 @@ privsolib_LTLIBRARIES = \
eshellincludedir = $(privincludedir)/shell
eshellinclude_HEADERS = \
- Evolution.h \
- e-component-view.h \
- e-user-creatable-items-handler.h \
- evolution-config-control.h \
- evolution-component.h \
- evolution-listener.h \
- evolution-shell-component-utils.h \
- es-event.h \
- es-menu.h
+ e-shell-common.h \
+ e-shell-content.h \
+ e-shell-module.h \
+ e-shell-settings.h \
+ e-shell-sidebar.h \
+ e-shell-switcher.h \
+ e-shell-taskbar.h \
+ e-shell-view.h \
+ e-shell-window.h \
+ e-shell-window-actions.h \
+ es-event.h
libeshell_la_SOURCES = \
$(IDL_GENERATED) \
- e-component-view.c \
- evolution-component.c \
- evolution-listener.c \
- e-user-creatable-items-handler.c \
- evolution-config-control.c \
- evolution-shell-component-utils.c \
+ e-shell-content.c \
+ e-shell-module.c \
+ e-shell-settings.c \
+ e-shell-sidebar.c \
+ e-shell-switcher.c \
+ e-shell-taskbar.c \
+ e-shell-view.c \
+ e-shell-window.c \
+ e-shell-window-actions.c \
$(eshellinclude_HEADERS)
libeshell_la_LDFLAGS = $(NO_UNDEFINED)
@@ -109,6 +89,7 @@ libeshell_la_LDFLAGS = $(NO_UNDEFINED)
libeshell_la_LIBADD = \
$(top_builddir)/e-util/libeutil.la \
$(top_builddir)/widgets/misc/libemiscwidgets.la \
+ $(top_builddir)/widgets/menus/libmenus.la \
$(SHELL_LIBS)
# Evolution executable
@@ -120,34 +101,23 @@ endif
evolution_SOURCES = \
$(DATASERVER_IDL_GENERATED) \
$(NM_SUPPORT_FILES) \
- e-component-registry.c \
- e-component-registry.h \
e-config-upgrade.c \
e-config-upgrade.h \
- e-corba-config-page.c \
- e-corba-config-page.h \
e-shell.c \
e-shell.h \
- e-shell-constants.h \
e-shell-importer.c \
e-shell-importer.h \
- e-shell-settings-dialog.c \
- e-shell-settings-dialog.h \
- e-shell-window-commands.c \
- e-shell-window-commands.h \
- e-shell-window.c \
- e-shell-window.h \
- e-shell-view.c \
- e-shell-view.h \
- e-sidebar.c \
- e-sidebar.h \
+ e-shell-migrate.c \
+ e-shell-migrate.h \
+ e-shell-window-private.c \
+ e-shell-window-private.h \
es-event.c \
- es-menu.c \
main.c
evolution_LDADD = \
libeshell.la \
$(top_builddir)/widgets/e-timezone-dialog/libetimezonedialog.la \
+ $(top_builddir)/widgets/menus/libmenus.la \
$(top_builddir)/widgets/misc/libemiscwidgets.la \
$(top_builddir)/e-util/libeutil.la \
$(TZDIALOG_LIBS) \
@@ -160,17 +130,11 @@ endif
# Misc stuff
-server_in_files = GNOME_Evolution_Shell.server.in.in
-server_DATA = $(server_in_files:.server.in.in=.server)
-@EVO_SERVER_RULE@
-@INTLTOOL_SERVER_RULE@
-
error_DATA = shell.error
errordir = $(privdatadir)/errors
@EVO_PLUGIN_RULE@
glade_DATA = \
- e-active-connection-dialog.glade \
import.glade
# GConf schemas
@@ -228,8 +192,6 @@ endif
# Extra dist stuff
EXTRA_DIST = \
- $(IDLS) \
- $(server_in_files) \
shell.error.xml \
$(glade_DATA) \
$(schema_in_files) \
@@ -255,7 +217,7 @@ evolution.pure: evolution
endif
-BUILT_SOURCES = $(IDL_GENERATED) $(server_DATA) $(DATASERVER_IDL_GENERATED) $(error_DATA)
+BUILT_SOURCES = $(server_DATA) $(DATASERVER_IDL_GENERATED) $(error_DATA)
CLEANFILES = $(BUILT_SOURCES)
DISTCLEANFILES = $(schema_DATA)
diff --git a/shell/apps_evolution_shell.schemas.in b/shell/apps_evolution_shell.schemas.in
index c5c6276c25..c908de65e5 100644
--- a/shell/apps_evolution_shell.schemas.in
+++ b/shell/apps_evolution_shell.schemas.in
@@ -99,8 +99,8 @@
<!-- View defaults -->
<schema>
- <key>/schemas/apps/evolution/shell/view_defaults/width</key>
- <applyto>/apps/evolution/shell/view_defaults/width</applyto>
+ <key>/schemas/apps/evolution/shell/view_defaults/window_width</key>
+ <applyto>/apps/evolution/shell/view_defaults/window_width</applyto>
<owner>evolution</owner>
<type>int</type>
<default>640</default>
@@ -111,8 +111,8 @@
</schema>
<schema>
- <key>/schemas/apps/evolution/shell/view_defaults/height</key>
- <applyto>/apps/evolution/shell/view_defaults/height</applyto>
+ <key>/schemas/apps/evolution/shell/view_defaults/window_height</key>
+ <applyto>/apps/evolution/shell/view_defaults/window_height</applyto>
<owner>evolution</owner>
<type>int</type>
<default>480</default>
@@ -123,20 +123,8 @@
</schema>
<schema>
- <key>/schemas/apps/evolution/shell/view_defaults/maximized</key>
- <applyto>/apps/evolution/shell/view_defaults/maximized</applyto>
- <owner>evolution</owner>
- <type>bool</type>
- <default>TRUE</default>
- <locale name="C">
- <short>Default window state</short>
- <long>Whether or not the window should be maximized.</long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/evolution/shell/view_defaults/maximized</key>
- <applyto>/apps/evolution/shell/view_defaults/maximized</applyto>
+ <key>/schemas/apps/evolution/shell/view_defaults/window_maximized</key>
+ <applyto>/apps/evolution/shell/view_defaults/window_maximized</applyto>
<owner>evolution</owner>
<type>bool</type>
<default>TRUE</default>
diff --git a/shell/e-active-connection-dialog.glade b/shell/e-active-connection-dialog.glade
deleted file mode 100644
index 534a7948f7..0000000000
--- a/shell/e-active-connection-dialog.glade
+++ /dev/null
@@ -1,193 +0,0 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
-
-<glade-interface>
-
-<widget class="GtkDialog" id="active_connection_dialog">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Active Connections</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
- <property name="modal">False</property>
- <property name="default_width">256</property>
- <property name="default_height">192</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="has_separator">False</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox2">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area2">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
-
- <child>
- <widget class="GtkButton" id="cancelbutton1">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="response_id">-6</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="okbutton1">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-ok</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="response_id">-5</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="vbox2">
- <property name="border_width">12</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">12</property>
-
- <child>
- <widget class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">&lt;b&gt;Active Connections&lt;/b&gt;</property>
- <property name="use_underline">False</property>
- <property name="use_markup">True</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkHBox" id="hbox1">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">12</property>
-
- <child>
- <widget class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="label" translatable="yes"></property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="vbox3">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">12</property>
-
- <child>
- <widget class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="visible">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
- <child>
- <widget class="GtkTreeView" id="active_connection_treeview">
- <property name="visible">True</property>
- <property name="headers_visible">True</property>
- <property name="rules_hint">False</property>
- <property name="reorderable">False</property>
- <property name="enable_search">True</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkLabel" id="instruction_label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Click OK to close these connections and go offline</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_CENTER</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
-</glade-interface>
diff --git a/shell/e-component-registry.c b/shell/e-component-registry.c
deleted file mode 100644
index cff9369aee..0000000000
--- a/shell/e-component-registry.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-component-registry.h"
-
-#include <glib/gi18n.h>
-
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-exception.h>
-
-#include <string.h>
-#include <stdlib.h>
-
-struct _EComponentRegistryPrivate {
- GSList *infos;
-
- guint init:1;
-};
-
-G_DEFINE_TYPE (EComponentRegistry, e_component_registry, G_TYPE_OBJECT)
-
-/* EComponentInfo handling. */
-
-static EComponentInfo *
-component_info_new (const char *id,
- GNOME_Evolution_Component iface,
- const char *alias,
- const char *button_label,
- const char *button_tooltips,
- const char *menu_label,
- const char *menu_accelerator,
- const char *icon_name,
- int sort_order)
-{
- EComponentInfo *info = g_new0 (EComponentInfo, 1);
-
- info->id = g_strdup (id);
- info->iface = bonobo_object_dup_ref(iface, NULL);
- info->alias = g_strdup (alias);
- info->button_label = g_strdup (button_label);
- info->button_tooltips = g_strdup (button_tooltips);
- info->menu_label = g_strdup (menu_label);
- info->menu_accelerator = g_strdup (menu_accelerator);
- info->icon_name = g_strdup (icon_name);
- info->sort_order = sort_order;
-
- return info;
-}
-
-static void
-component_info_free (EComponentInfo *info)
-{
- g_free (info->id);
- g_free (info->alias);
- g_free (info->button_label);
- g_free (info->button_tooltips);
- g_free (info->menu_label);
- g_free (info->menu_accelerator);
-
- if (info->iface != NULL)
- bonobo_object_release_unref (info->iface, NULL);
-
- g_slist_foreach (info->uri_schemas, (GFunc) g_free, NULL);
- g_slist_free (info->uri_schemas);
-
- g_free (info);
-}
-
-static int
-component_info_compare_func (EComponentInfo *a,
- EComponentInfo *b)
-{
- if (a->sort_order != b->sort_order)
- return a->sort_order - b->sort_order;
-
- return strcmp (a->button_label, b->button_label);
-}
-
-
-/* Utility methods. */
-
-static void
-set_schemas (EComponentInfo *component_info,
- Bonobo_ServerInfo *server_info)
-{
- Bonobo_ActivationProperty *property = bonobo_server_info_prop_find (server_info, "evolution:uri_schemas");
- Bonobo_StringList *list;
- int i;
-
- if (property == NULL)
- return;
-
- if (property->v._d != Bonobo_ACTIVATION_P_STRINGV) {
- CORBA_free (property);
- return;
- }
-
- list = & property->v._u.value_stringv;
-
- for (i = 0; i < list->_length; i ++)
- component_info->uri_schemas = g_slist_prepend (component_info->uri_schemas, g_strdup (list->_buffer [i]));
-
- CORBA_free (property);
-}
-
-static void
-query_components (EComponentRegistry *registry)
-{
- Bonobo_ServerInfoList *info_list;
- const gchar * const *language_names;
- CORBA_Environment ev;
- GSList *languages = NULL;
- char *query;
- int i;
-
- if (registry->priv->init)
- return;
-
- registry->priv->init = TRUE;
-
- CORBA_exception_init (&ev);
- query = g_strdup_printf ("repo_ids.has ('IDL:GNOME/Evolution/Component:%s')", BASE_VERSION);
- info_list = bonobo_activation_query (query, NULL, &ev);
- g_free (query);
-
- if (BONOBO_EX (&ev)) {
- char *ex_text = bonobo_exception_get_text (&ev);
- g_warning ("Cannot query for components: %s\n", ex_text);
- g_free (ex_text);
- CORBA_exception_free (&ev);
- return;
- }
-
- language_names = g_get_language_names ();
- while (*language_names != NULL)
- languages = g_slist_append (languages, (gpointer)(*language_names++));
-
- for (i = 0; i < info_list->_length; i++) {
- const char *id;
- const char *label;
- const char *menu_label;
- const char *menu_accelerator;
- const char *alias;
- const char *icon_name;
- const char *sort_order_string;
- const char *tooltips;
- EComponentInfo *info;
- int sort_order;
- GNOME_Evolution_Component iface;
-
- id = info_list->_buffer[i].iid;
- iface = bonobo_activation_activate_from_id ((char *)id, 0, NULL, &ev);
- if (BONOBO_EX (&ev) || iface == CORBA_OBJECT_NIL) {
- char *ex_text = bonobo_exception_get_text (&ev);
-
- g_warning("Cannot activate '%s': %s\n", id, ex_text);
- g_free(ex_text);
- CORBA_exception_free(&ev);
- CORBA_exception_init(&ev);
- continue;
- }
-
- label = bonobo_server_info_prop_lookup (& info_list->_buffer[i], "evolution:button_label", languages);
-
- tooltips = bonobo_server_info_prop_lookup (& info_list->_buffer[i], "evolution:button_tooltips", languages);
-
- menu_label = bonobo_server_info_prop_lookup (& info_list->_buffer[i], "evolution:menu_label", languages);
-
- menu_accelerator = bonobo_server_info_prop_lookup (& info_list->_buffer[i], "evolution:menu_accelerator", languages);
-
- alias = bonobo_server_info_prop_lookup (& info_list->_buffer[i], "evolution:component_alias", NULL);
-
- icon_name = bonobo_server_info_prop_lookup (& info_list->_buffer[i], "evolution:button_icon", NULL);
-
- sort_order_string = bonobo_server_info_prop_lookup (& info_list->_buffer[i],
- "evolution:button_sort_order", NULL);
- if (sort_order_string == NULL)
- sort_order = 0;
- else
- sort_order = atoi (sort_order_string);
-
- info = component_info_new (id, iface, alias, label, tooltips, menu_label,
- menu_accelerator, icon_name, sort_order);
- set_schemas (info, & info_list->_buffer [i]);
-
- registry->priv->infos = g_slist_prepend (registry->priv->infos, info);
-
- bonobo_object_release_unref(iface, NULL);
- }
- g_slist_free(languages);
-
- CORBA_free (info_list);
- CORBA_exception_free (&ev);
-
- registry->priv->infos = g_slist_sort (registry->priv->infos,
- (GCompareFunc) component_info_compare_func);
-}
-
-
-/* GObject methods. */
-
-static void
-impl_finalize (GObject *object)
-{
- EComponentRegistry *component_registry;
- EComponentRegistryPrivate *priv;
-
- component_registry = E_COMPONENT_REGISTRY (object);
- priv = component_registry->priv;
-
- g_slist_foreach (priv->infos, (GFunc) component_info_free, NULL);
- g_free (priv);
-
- (* G_OBJECT_CLASS (e_component_registry_parent_class)->finalize) (object);
-}
-
-
-static void
-e_component_registry_class_init (EComponentRegistryClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = impl_finalize;
-}
-
-
-static void
-e_component_registry_init (EComponentRegistry *registry)
-{
- registry->priv = g_new0 (EComponentRegistryPrivate, 1);
-}
-
-
-EComponentRegistry *
-e_component_registry_new (void)
-{
- return g_object_new (e_component_registry_get_type (), NULL);
-}
-
-
-GSList *
-e_component_registry_peek_list (EComponentRegistry *registry)
-{
- g_return_val_if_fail (E_IS_COMPONENT_REGISTRY (registry), NULL);
-
- query_components(registry);
-
- return registry->priv->infos;
-}
-
-
-EComponentInfo *
-e_component_registry_peek_info (EComponentRegistry *registry,
- enum _EComponentRegistryField field,
- const char *key)
-{
- GSList *p, *q;
-
- g_return_val_if_fail (E_IS_COMPONENT_REGISTRY (registry), NULL);
-
- query_components(registry);
-
- for (p = registry->priv->infos; p != NULL; p = p->next) {
- EComponentInfo *info = p->data;
-
- switch (field) {
- case ECR_FIELD_ID:
- if (info->id && (strcmp (info->id, key) == 0))
- return info;
- break;
- case ECR_FIELD_ALIAS:
- if (info->alias && (strcmp (info->alias, key) == 0))
- return info;
- break;
- case ECR_FIELD_SCHEMA:
- for (q = info->uri_schemas; q != NULL; q = q->next)
- if (strcmp((char *)q->data, key) == 0)
- return info;
- break;
- }
- }
-
- return NULL;
-}
-
-GNOME_Evolution_Component
-e_component_registry_activate (EComponentRegistry *registry,
- const char *id,
- CORBA_Environment *ev)
-{
- EComponentInfo *info;
-
- g_return_val_if_fail (E_IS_COMPONENT_REGISTRY (registry), CORBA_OBJECT_NIL);
-
- info = e_component_registry_peek_info (registry, ECR_FIELD_ID, id);
- if (info == NULL) {
- g_warning ("%s - Unknown id \"%s\"", G_STRFUNC, id);
- return CORBA_OBJECT_NIL;
- }
-
- /* it isn't in the registry unless it is already activated */
- return bonobo_object_dup_ref (info->iface, NULL);
-}
diff --git a/shell/e-component-registry.h b/shell/e-component-registry.h
deleted file mode 100644
index fa0de9c5c1..0000000000
--- a/shell/e-component-registry.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef __E_COMPONENT_REGISTRY_H__
-#define __E_COMPONENT_REGISTRY_H__
-
-
-#include "Evolution.h"
-
-#include <glib-object.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-
-#define E_TYPE_COMPONENT_REGISTRY (e_component_registry_get_type ())
-#define E_COMPONENT_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_COMPONENT_REGISTRY, EComponentRegistry))
-#define E_COMPONENT_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_COMPONENT_REGISTRY, EComponentRegistryClass))
-#define E_IS_COMPONENT_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_COMPONENT_REGISTRY))
-#define E_IS_COMPONENT_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_COMPONENT_REGISTRY))
-
-
-typedef struct _EComponentRegistry EComponentRegistry;
-typedef struct _EComponentRegistryPrivate EComponentRegistryPrivate;
-typedef struct _EComponentRegistryClass EComponentRegistryClass;
-
-struct _EComponentRegistry {
- GObject parent;
-
- EComponentRegistryPrivate *priv;
-};
-
-struct _EComponentRegistryClass {
- GObjectClass parent_class;
-};
-
-enum _EComponentRegistryField {
- ECR_FIELD_ID,
- ECR_FIELD_ALIAS,
- ECR_FIELD_SCHEMA,
-};
-
-struct _EComponentInfo {
- char *id;
-
- char *alias;
-
- /* NULL if not activated. */
- GNOME_Evolution_Component iface;
-
- char *button_label;
- char *button_tooltips;
- char *menu_label;
- char *menu_accelerator;
- char *icon_name;
-
- int sort_order;
-
- /* List of URI schemas that this component supports. */
- GSList *uri_schemas; /* <char *> */
-};
-typedef struct _EComponentInfo EComponentInfo;
-
-
-GType e_component_registry_get_type (void);
-EComponentRegistry *e_component_registry_new (void);
-
-GSList *e_component_registry_peek_list (EComponentRegistry *registry);
-EComponentInfo *e_component_registry_peek_info (EComponentRegistry *registry,
- enum _EComponentRegistryField type,
- const char *key);
-
-GNOME_Evolution_Component e_component_registry_activate (EComponentRegistry *registry,
- const char *id,
- CORBA_Environment *ev);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __E_COMPONENT_REGISTRY_H__ */
diff --git a/shell/e-component-view.c b/shell/e-component-view.c
deleted file mode 100644
index cbe59529c4..0000000000
--- a/shell/e-component-view.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Helper class for evolution components to setup a view
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Michael Zucchi <notzed@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-
-#include "e-component-view.h"
-
-#include "bonobo/bonobo-control.h"
-
-static BonoboObjectClass *parent_class = NULL;
-
-static void
-impl_ComponentView_getControls(PortableServer_Servant servant,
- Bonobo_Control *side_control,
- Bonobo_Control *view_control,
- Bonobo_Control *statusbar_control,
- CORBA_Environment *ev)
-{
- EComponentView *ecv = (EComponentView *)bonobo_object_from_servant(servant);
-
- *side_control = CORBA_Object_duplicate (BONOBO_OBJREF (ecv->side_control), ev);
- *view_control = CORBA_Object_duplicate (BONOBO_OBJREF (ecv->view_control), ev);
- *statusbar_control = CORBA_Object_duplicate (BONOBO_OBJREF (ecv->statusbar_control), ev);
-}
-
-/* GObject methods. */
-
-static void
-impl_dispose (GObject *object)
-{
- EComponentView *ecv = (EComponentView *)object;
-
- ecv->side_control = NULL;
- ecv->view_control = NULL;
- ecv->statusbar_control = NULL;
-
- ((GObjectClass *)parent_class)->dispose(object);
-}
-
-static void
-impl_finalise (GObject *object)
-{
- EComponentView *ecv = (EComponentView *)object;
-
- g_free(ecv->id);
-
- ((GObjectClass *)parent_class)->finalize(object);
-}
-
-static void
-e_component_view_class_init (EComponentViewClass *klass)
-{
- GObjectClass *object_class;
- POA_GNOME_Evolution_ComponentView__epv *epv;
-
- parent_class = g_type_class_ref(bonobo_object_get_type());
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalise;
-
- epv = & klass->epv;
- epv->getControls = impl_ComponentView_getControls;
-}
-
-static void
-e_component_view_init (EComponentView *shell)
-{
-}
-
-EComponentView *e_component_view_new(GNOME_Evolution_ShellView parent, const char *id, struct _GtkWidget *side, struct _GtkWidget *view, struct _GtkWidget *statusbar)
-{
- EComponentView *new = g_object_new (e_component_view_get_type (), NULL);
- CORBA_Environment ev = { NULL };
-
- new->id = g_strdup(id);
- new->shell_view = CORBA_Object_duplicate(parent, &ev);
- CORBA_exception_free(&ev);
-
- /* FIXME: hook onto destroys */
- new->side_control = bonobo_control_new(side);
- new->view_control = bonobo_control_new(view);
- new->statusbar_control = bonobo_control_new(statusbar);
-
- return new;
-}
-
-EComponentView *e_component_view_new_controls(GNOME_Evolution_ShellView parent, const char *id, BonoboControl *side, BonoboControl *view, BonoboControl *statusbar)
-{
- EComponentView *new = g_object_new (e_component_view_get_type (), NULL);
- CORBA_Environment ev = { NULL };
-
- new->id = g_strdup(id);
- new->shell_view = CORBA_Object_duplicate(parent, &ev);
- CORBA_exception_free(&ev);
-
- /* FIXME: hook onto destroys */
- new->side_control = side;
- new->view_control = view;
- new->statusbar_control = statusbar;
-
- return new;
-}
-
-void
-e_component_view_set_title(EComponentView *ecv, const char *title)
-{
- CORBA_Environment ev = { NULL };
-
- /* save roundtrips, check title is the same */
- GNOME_Evolution_ShellView_setTitle(ecv->shell_view, ecv->id, title, &ev);
- CORBA_exception_free(&ev);
-}
-
-void
-e_component_view_set_button_icon (EComponentView *ecv, const char *iconName)
-{
- CORBA_Environment ev = { NULL };
-
- /* save roundtrips, check title is the same */
- GNOME_Evolution_ShellView_setButtonIcon(ecv->shell_view, ecv->id, iconName, &ev);
- CORBA_exception_free(&ev);
-}
-
-BONOBO_TYPE_FUNC_FULL (EComponentView, GNOME_Evolution_ComponentView, bonobo_object_get_type(), e_component_view)
-
diff --git a/shell/e-component-view.h b/shell/e-component-view.h
deleted file mode 100644
index 96a48d1e02..0000000000
--- a/shell/e-component-view.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Michael Zucchi <notzed@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_COMPONENT_VIEW_H_
-#define _E_COMPONENT_VIEW_H_
-
-#include <bonobo/bonobo-object.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-struct _GtkWidget;
-
-typedef struct _EComponentView EComponentView;
-typedef struct _EComponentViewPrivate EComponentViewPrivate;
-typedef struct _EComponentViewClass EComponentViewClass;
-
-#include "Evolution.h"
-
-#define E_TYPE_COMPONENT_VIEW (e_component_view_get_type ())
-#define E_COMPONENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_COMPONENT_VIEW, EComponentView))
-#define E_COMPONENT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_COMPONENT_VIEW, EComponentViewClass))
-#define E_IS_COMPONENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_COMPONENT_VIEW))
-#define E_IS_COMPONENT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_COMPONENT_VIEW))
-
-struct _EComponentView {
- BonoboObject parent;
-
- EComponentViewPrivate *priv;
-
- char *id;
- GNOME_Evolution_ShellView shell_view;
-
- struct _BonoboControl *side_control;
- struct _BonoboControl *view_control;
- struct _BonoboControl *statusbar_control;
-};
-
-struct _EComponentViewClass {
- BonoboObjectClass parent_class;
-
- POA_GNOME_Evolution_ComponentView__epv epv;
-};
-
-GType e_component_view_get_type(void);
-EComponentView *e_component_view_new(GNOME_Evolution_ShellView shell_view, const char *id, struct _GtkWidget *side, struct _GtkWidget *view, struct _GtkWidget *status);
-EComponentView *e_component_view_new_controls(GNOME_Evolution_ShellView parent, const char *id, struct _BonoboControl *side, struct _BonoboControl *view, struct _BonoboControl *statusbar);
-
-void e_component_view_set_title(EComponentView *ecv, const char *title);
-void e_component_view_set_button_icon (EComponentView *ecv, const char *iconName);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_COMPONENT_VIEW_H_ */
-
diff --git a/shell/e-corba-config-page.c b/shell/e-corba-config-page.c
deleted file mode 100644
index 603a8fd21f..0000000000
--- a/shell/e-corba-config-page.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-corba-config-page.h"
-
-#include "Evolution.h"
-
-#include <string.h>
-
-#include <bonobo/bonobo-widget.h>
-#include <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-listener.h>
-
-
-struct _ECorbaConfigPagePrivate {
- GNOME_Evolution_ConfigControl config_control_interface;
-};
-
-G_DEFINE_TYPE (ECorbaConfigPage, e_corba_config_page, E_TYPE_CONFIG_PAGE)
-
-/* GObject methods. */
-
-static void
-impl_dispose (GObject *object)
-{
- ECorbaConfigPage *corba_config_page;
- ECorbaConfigPagePrivate *priv;
- CORBA_Environment ev;
-
- corba_config_page = E_CORBA_CONFIG_PAGE (object);
- priv = corba_config_page->priv;
-
- CORBA_exception_init (&ev);
-
- if (priv->config_control_interface != CORBA_OBJECT_NIL) {
- bonobo_object_release_unref (priv->config_control_interface, &ev);
- priv->config_control_interface = CORBA_OBJECT_NIL;
- }
-
- CORBA_exception_free (&ev);
-
- (* G_OBJECT_CLASS (e_corba_config_page_parent_class)->dispose) (object);
-}
-
-static void
-impl_finalize (GObject *object)
-{
- ECorbaConfigPage *corba_config_page;
- ECorbaConfigPagePrivate *priv;
-
- corba_config_page = E_CORBA_CONFIG_PAGE (object);
- priv = corba_config_page->priv;
-
- g_free (priv);
-
- (* G_OBJECT_CLASS (e_corba_config_page_parent_class)->finalize) (object);
-}
-
-/* GTK+ ctors. */
-
-static void
-e_corba_config_page_class_init (ECorbaConfigPageClass *class)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (class);
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-}
-
-static void
-e_corba_config_page_init (ECorbaConfigPage *corba_config_page)
-{
- ECorbaConfigPagePrivate *priv;
-
- priv = g_new (ECorbaConfigPagePrivate, 1);
- priv->config_control_interface = CORBA_OBJECT_NIL;
-
- corba_config_page->priv = priv;
-}
-
-
-gboolean
-e_corba_config_page_construct (ECorbaConfigPage *corba_config_page,
- GNOME_Evolution_ConfigControl corba_object)
-{
- Bonobo_Control control;
- GtkWidget *control_widget;
- CORBA_Environment ev;
-
- g_return_val_if_fail (E_IS_CORBA_CONFIG_PAGE (corba_config_page), FALSE);
- g_return_val_if_fail (corba_object != CORBA_OBJECT_NIL, FALSE);
-
- CORBA_exception_init (&ev);
-
- control = GNOME_Evolution_ConfigControl__get_control (corba_object, &ev);
- if (BONOBO_EX (&ev)) {
- g_warning ("Can't get control from ::ConfigControl -- %s", BONOBO_EX_REPOID (&ev));
- CORBA_exception_init (&ev);
- return FALSE;
- }
-
- control_widget = bonobo_widget_new_control_from_objref (control, CORBA_OBJECT_NIL);
- gtk_widget_show (control_widget);
- gtk_container_add (GTK_CONTAINER (corba_config_page), control_widget);
-
- /* Notice we *don't* unref the corba_object here as
- bonobo_widget_new_control_from_objref() effectively takes ownership
- for the object that we get from ::__get_control. */
-
- CORBA_exception_free (&ev);
-
- return TRUE;
-}
-
-GtkWidget *
-e_corba_config_page_new_from_objref (GNOME_Evolution_ConfigControl corba_object)
-{
- ECorbaConfigPage *corba_config_page;
-
- g_return_val_if_fail (corba_object != CORBA_OBJECT_NIL, NULL);
- g_return_val_if_fail (corba_object != CORBA_OBJECT_NIL, NULL);
-
- corba_config_page = g_object_new (e_corba_config_page_get_type (), NULL);
- if (! e_corba_config_page_construct (corba_config_page, corba_object)) {
- gtk_widget_destroy (GTK_WIDGET (corba_config_page));
- return NULL;
- }
-
- return GTK_WIDGET (corba_config_page);
-}
diff --git a/shell/e-corba-config-page.h b/shell/e-corba-config-page.h
deleted file mode 100644
index 9a6747cf22..0000000000
--- a/shell/e-corba-config-page.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_CORBA_CONFIG_PAGE_H_
-#define _E_CORBA_CONFIG_PAGE_H_
-
-#include "e-config-page.h"
-
-#include "Evolution.h"
-
-#include <bonobo/bonobo-object.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#define E_TYPE_CORBA_CONFIG_PAGE (e_corba_config_page_get_type ())
-#define E_CORBA_CONFIG_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CORBA_CONFIG_PAGE, ECorbaConfigPage))
-#define E_CORBA_CONFIG_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CORBA_CONFIG_PAGE, ECorbaConfigPageClass))
-#define E_IS_CORBA_CONFIG_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CORBA_CONFIG_PAGE))
-#define E_IS_CORBA_CONFIG_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_CORBA_CONFIG_PAGE))
-
-
-typedef struct _ECorbaConfigPage ECorbaConfigPage;
-typedef struct _ECorbaConfigPagePrivate ECorbaConfigPagePrivate;
-typedef struct _ECorbaConfigPageClass ECorbaConfigPageClass;
-
-struct _ECorbaConfigPage {
- EConfigPage parent;
-
- ECorbaConfigPagePrivate *priv;
-};
-
-struct _ECorbaConfigPageClass {
- EConfigPageClass parent_class;
-};
-
-
-GType e_corba_config_page_get_type (void);
-GtkWidget *e_corba_config_page_new_from_objref (GNOME_Evolution_ConfigControl objref);
-gboolean e_corba_config_page_construct (ECorbaConfigPage *corba_config_page,
- GNOME_Evolution_ConfigControl objref);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_CORBA_CONFIG_PAGE_H_ */
diff --git a/shell/importer/intelligent.h b/shell/e-shell-common.h
index bbdf00cc18..50c84152c9 100644
--- a/shell/importer/intelligent.h
+++ b/shell/e-shell-common.h
@@ -1,4 +1,6 @@
/*
+ * e-shell-common.h
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -13,16 +15,19 @@
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*
- * Authors:
- * Kjartan Maraas <kmaraas@gnome.org>
- *
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
-#ifndef __INTELLIGENT_H__
-#define __INTELLIGENT_H__
-
-void intelligent_importer_init (void);
+#ifndef E_SHELL_COMMON_H
+#define E_SHELL_COMMON_H
+#ifdef HAVE_CONFIG_H
+#include <config.h>
#endif
+
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
+#endif /* E_SHELL_COMMON_H */
diff --git a/shell/e-shell-constants.h b/shell/e-shell-constants.h
deleted file mode 100644
index 25aec79d6f..0000000000
--- a/shell/e-shell-constants.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef E_SHELL_CONSTANTS_H
-#define E_SHELL_CONSTANTS_H
-
-#define E_SHELL_URI_PREFIX "evolution:"
-#define E_SHELL_URI_PREFIX_LEN 10
-
-#define E_SHELL_DEFAULTURI_PREFIX "default:"
-#define E_SHELL_DEFAULTURI_PREFIX_LEN 8
-
-#define E_SHELL_MINI_ICON_SUFFIX "-mini"
-#define E_SHELL_MINI_ICON_SUFFIX_LEN 5
-
-#define E_SHELL_ICON_SIZE 48
-#define E_SHELL_MINI_ICON_SIZE 16
-
-#define E_PATH_SEPARATOR '/'
-#define E_PATH_SEPARATOR_S "/"
-
-#define E_LOCAL_STORAGE_NAME "local"
-#define E_SUMMARY_STORAGE_NAME "summary"
-
-#define E_SUMMARY_URI "evolution:/summary"
-#define E_LOCAL_INBOX_URI "evolution:/local/Inbox"
-#define E_LOCAL_CONTACTS_URI "evolution:/local/Contacts"
-#define E_LOCAL_CALENDAR_URI "evolution:/local/Calendar"
-#define E_LOCAL_TASKS_URI "evolution:/local/Tasks"
-
-#endif
diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c
new file mode 100644
index 0000000000..e83bb341ef
--- /dev/null
+++ b/shell/e-shell-content.c
@@ -0,0 +1,1384 @@
+/*
+ * e-shell-content.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-shell-content.h"
+
+#include <glib/gi18n.h>
+
+#include <filter/rule-editor.h>
+#include <widgets/misc/e-action-combo-box.h>
+#include <widgets/misc/e-icon-entry.h>
+
+#include <e-shell-module.h>
+#include <e-shell-view.h>
+#include <e-shell-window-actions.h>
+
+#define E_SHELL_CONTENT_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SHELL_CONTENT, EShellContentPrivate))
+
+struct _EShellContentPrivate {
+
+ gpointer shell_view; /* weak pointer */
+
+ RuleContext *search_context;
+ FilterRule *search_rule;
+ gchar *system_filename;
+ gchar *user_filename;
+
+ /* Container for the following widgets */
+ GtkWidget *search_bar;
+
+ /* Search bar widgets */
+ GtkWidget *filter_label;
+ GtkWidget *filter_combo_box;
+ GtkWidget *search_label;
+ GtkWidget *search_entry;
+ GtkWidget *scope_label;
+ GtkWidget *scope_combo_box;
+
+ GtkStateType search_state;
+};
+
+enum {
+ PROP_0,
+ PROP_FILTER_ACTION,
+ PROP_FILTER_VALUE,
+ PROP_FILTER_VISIBLE,
+ PROP_SEARCH_CONTEXT,
+ PROP_SEARCH_RULE,
+ PROP_SEARCH_TEXT,
+ PROP_SEARCH_VISIBLE,
+ PROP_SCOPE_ACTION,
+ PROP_SCOPE_VALUE,
+ PROP_SCOPE_VISIBLE,
+ PROP_SHELL_VIEW
+};
+
+static gpointer parent_class;
+
+static void
+shell_content_dialog_rule_changed (GtkWidget *dialog,
+ FilterRule *rule)
+{
+ gboolean sensitive;
+
+ sensitive = (rule != NULL) && (rule->parts != NULL);
+
+ gtk_dialog_set_response_sensitive (
+ GTK_DIALOG (dialog), GTK_RESPONSE_OK, sensitive);
+ gtk_dialog_set_response_sensitive (
+ GTK_DIALOG (dialog), GTK_RESPONSE_APPLY, sensitive);
+}
+
+static void
+action_search_execute_cb (GtkAction *action,
+ EShellContent *shell_content)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ EIconEntry *icon_entry;
+ GtkStateType visual_state;
+ const gchar *search_text;
+
+ /* EShellView subclasses are responsible for actually
+ * executing the search. This is all cosmetic stuff. */
+
+ shell_view = e_shell_content_get_shell_view (shell_content);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ if (!e_shell_view_is_active (shell_view))
+ return;
+
+ icon_entry = E_ICON_ENTRY (shell_content->priv->search_entry);
+ search_text = e_shell_content_get_search_text (shell_content);
+
+ if (search_text != NULL && *search_text != '\0')
+ visual_state = GTK_STATE_SELECTED;
+ else
+ visual_state = GTK_STATE_NORMAL;
+
+ e_icon_entry_set_visual_state (icon_entry, visual_state);
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
+ gtk_action_set_sensitive (action, TRUE);
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_SAVE (shell_window);
+ gtk_action_set_sensitive (action, TRUE);
+
+ /* Direct the focus away from the search entry, so that a
+ * focus-in event is required before the text can be changed.
+ * This will reset the entry to the appropriate visual state. */
+ gtk_widget_grab_focus (gtk_bin_get_child (GTK_BIN (shell_content)));
+}
+
+static void
+shell_content_entry_activated_cb (EShellContent *shell_content,
+ GtkWidget *entry)
+{
+ EShellWindow *shell_window;
+ EShellView *shell_view;
+ GtkAction *action;
+
+ shell_view = e_shell_content_get_shell_view (shell_content);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ /* Verify the shell view is active before proceeding. */
+ if (!e_shell_view_is_active (shell_view))
+ return;
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_EXECUTE (shell_window);
+ gtk_action_activate (action);
+}
+
+static gboolean
+shell_content_entry_focus_in_cb (EShellContent *shell_content,
+ GdkEventFocus *focus_event,
+ GtkWidget *entry)
+{
+ EIconEntry *icon_entry;
+ GtkStateType visual_state;
+
+ icon_entry = E_ICON_ENTRY (shell_content->priv->search_entry);
+ visual_state = e_icon_entry_get_visual_state (icon_entry);
+
+ if (visual_state == GTK_STATE_INSENSITIVE)
+ gtk_entry_set_text (GTK_ENTRY (entry), "");
+
+ e_icon_entry_set_visual_state (icon_entry, GTK_STATE_NORMAL);
+
+ return FALSE;
+}
+
+static gboolean
+shell_content_entry_focus_out_cb (EShellContent *shell_content,
+ GdkEventFocus *focus_event,
+ GtkWidget *entry)
+{
+ /* FIXME */
+ return FALSE;
+}
+
+static gboolean
+shell_content_entry_key_press_cb (EShellContent *shell_content,
+ GdkEventKey *key_event,
+ GtkWidget *entry)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ GtkAction *action;
+ guint mask;
+
+ mask = gtk_accelerator_get_default_mod_mask ();
+ if ((key_event->state & mask) != GDK_MOD1_MASK)
+ return FALSE;
+
+ if (key_event->keyval != GDK_Down)
+ return FALSE;
+
+ shell_view = e_shell_content_get_shell_view (shell_content);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_OPTIONS (shell_window);
+ gtk_action_activate (action);
+
+ return TRUE;
+}
+
+static void
+shell_content_init_search_context (EShellContent *shell_content)
+{
+ EShellContentClass *shell_content_class;
+ EShellView *shell_view;
+ EShellViewClass *shell_view_class;
+ EShellModule *shell_module;
+ RuleContext *context;
+ FilterRule *rule;
+ FilterPart *part;
+ gchar *system_filename;
+ gchar *user_filename;
+
+ shell_view = e_shell_content_get_shell_view (shell_content);
+ shell_module = e_shell_view_get_shell_module (shell_view);
+ shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
+ g_return_if_fail (shell_view_class->search_rules != NULL);
+
+ shell_content_class = E_SHELL_CONTENT_GET_CLASS (shell_content);
+ g_return_if_fail (shell_content_class->new_search_context != NULL);
+
+ /* The basename for built-in searches is specified in the
+ * shell view class. All built-in search rules live in the
+ * same directory. */
+ system_filename = g_build_filename (
+ EVOLUTION_RULEDIR, shell_view_class->search_rules, NULL);
+
+ /* The filename for custom saved searches is always of
+ * the form "$(shell_module_data_dir)/searches.xml". */
+ user_filename = g_build_filename (
+ e_shell_module_get_data_dir (shell_module),
+ "searches.xml", NULL);
+
+ context = shell_content_class->new_search_context ();
+ rule_context_add_part_set (
+ context, "partset", FILTER_TYPE_PART,
+ rule_context_add_part, rule_context_next_part);
+ rule_context_add_rule_set (
+ context, "ruleset", FILTER_TYPE_RULE,
+ rule_context_add_rule, rule_context_next_rule);
+ rule_context_load (context, system_filename, user_filename);
+
+ /* XXX Not sure why this is necessary. */
+ g_object_set_data_full (
+ G_OBJECT (context), "system",
+ g_strdup (system_filename), g_free);
+ g_object_set_data_full (
+ G_OBJECT (context), "user",
+ g_strdup (user_filename), g_free);
+
+ rule = filter_rule_new ();
+ part = rule_context_next_part (context, NULL);
+ if (part == NULL)
+ g_warning (
+ "Could not load %s search: no parts",
+ e_shell_view_get_name (shell_view));
+ else
+ filter_rule_add_part (rule, filter_part_clone (part));
+
+ shell_content->priv->search_context = context;
+ shell_content->priv->system_filename = system_filename;
+ shell_content->priv->user_filename = user_filename;
+}
+
+static void
+shell_content_set_shell_view (EShellContent *shell_content,
+ EShellView *shell_view)
+{
+ g_return_if_fail (shell_content->priv->shell_view == NULL);
+
+ shell_content->priv->shell_view = shell_view;
+
+ g_object_add_weak_pointer (
+ G_OBJECT (shell_view),
+ &shell_content->priv->shell_view);
+}
+
+static void
+shell_content_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_FILTER_ACTION:
+ e_shell_content_set_filter_action (
+ E_SHELL_CONTENT (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_FILTER_VALUE:
+ e_shell_content_set_filter_value (
+ E_SHELL_CONTENT (object),
+ g_value_get_int (value));
+ return;
+
+ case PROP_FILTER_VISIBLE:
+ e_shell_content_set_filter_visible (
+ E_SHELL_CONTENT (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_SEARCH_RULE:
+ e_shell_content_set_search_rule (
+ E_SHELL_CONTENT (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_SEARCH_TEXT:
+ e_shell_content_set_search_text (
+ E_SHELL_CONTENT (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_SEARCH_VISIBLE:
+ e_shell_content_set_search_visible (
+ E_SHELL_CONTENT (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_SCOPE_ACTION:
+ e_shell_content_set_scope_action (
+ E_SHELL_CONTENT (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_SCOPE_VALUE:
+ e_shell_content_set_scope_value (
+ E_SHELL_CONTENT (object),
+ g_value_get_int (value));
+ return;
+
+ case PROP_SCOPE_VISIBLE:
+ e_shell_content_set_scope_visible (
+ E_SHELL_CONTENT (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_SHELL_VIEW:
+ shell_content_set_shell_view (
+ E_SHELL_CONTENT (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+shell_content_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_FILTER_ACTION:
+ g_value_set_object (
+ value, e_shell_content_get_filter_action (
+ E_SHELL_CONTENT (object)));
+ return;
+
+ case PROP_FILTER_VALUE:
+ g_value_set_int (
+ value, e_shell_content_get_filter_value (
+ E_SHELL_CONTENT (object)));
+ return;
+
+ case PROP_FILTER_VISIBLE:
+ g_value_set_boolean (
+ value, e_shell_content_get_filter_visible (
+ E_SHELL_CONTENT (object)));
+ return;
+
+ case PROP_SEARCH_CONTEXT:
+ g_value_set_object (
+ value, e_shell_content_get_search_context (
+ E_SHELL_CONTENT (object)));
+ return;
+
+ case PROP_SEARCH_RULE:
+ g_value_set_object (
+ value, e_shell_content_get_search_rule (
+ E_SHELL_CONTENT (object)));
+ return;
+
+ case PROP_SEARCH_TEXT:
+ g_value_set_string (
+ value, e_shell_content_get_search_text (
+ E_SHELL_CONTENT (object)));
+ return;
+
+ case PROP_SEARCH_VISIBLE:
+ g_value_set_boolean (
+ value, e_shell_content_get_search_visible (
+ E_SHELL_CONTENT (object)));
+ return;
+
+ case PROP_SCOPE_ACTION:
+ g_value_set_object (
+ value, e_shell_content_get_scope_action (
+ E_SHELL_CONTENT (object)));
+ return;
+
+ case PROP_SCOPE_VALUE:
+ g_value_set_int (
+ value, e_shell_content_get_scope_value (
+ E_SHELL_CONTENT (object)));
+ return;
+
+ case PROP_SCOPE_VISIBLE:
+ g_value_set_boolean (
+ value, e_shell_content_get_scope_visible (
+ E_SHELL_CONTENT (object)));
+ return;
+
+ case PROP_SHELL_VIEW:
+ g_value_set_object (
+ value, e_shell_content_get_shell_view (
+ E_SHELL_CONTENT (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+shell_content_dispose (GObject *object)
+{
+ EShellContentPrivate *priv;
+
+ priv = E_SHELL_CONTENT_GET_PRIVATE (object);
+
+ if (priv->shell_view != NULL) {
+ g_object_remove_weak_pointer (
+ G_OBJECT (priv->shell_view), &priv->shell_view);
+ priv->shell_view = NULL;
+ }
+
+ if (priv->filter_label != NULL) {
+ g_object_unref (priv->filter_label);
+ priv->filter_label = NULL;
+ }
+
+ if (priv->filter_combo_box != NULL) {
+ g_object_unref (priv->filter_combo_box);
+ priv->filter_combo_box = NULL;
+ }
+
+ if (priv->search_context != NULL) {
+ g_object_unref (priv->search_context);
+ priv->search_context = NULL;
+ }
+
+ if (priv->search_label != NULL) {
+ g_object_unref (priv->search_label);
+ priv->search_label = NULL;
+ }
+
+ if (priv->search_entry != NULL) {
+ g_object_unref (priv->search_entry);
+ priv->search_entry = NULL;
+ }
+
+ if (priv->scope_label != NULL) {
+ g_object_unref (priv->scope_label);
+ priv->scope_label = NULL;
+ }
+
+ if (priv->scope_combo_box != NULL) {
+ g_object_unref (priv->scope_combo_box);
+ priv->scope_combo_box = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+shell_content_finalize (GObject *object)
+{
+ EShellContentPrivate *priv;
+
+ priv = E_SHELL_CONTENT_GET_PRIVATE (object);
+
+ g_free (priv->system_filename);
+ g_free (priv->user_filename);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+shell_content_constructed (GObject *object)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ EShellContent *shell_content;
+ EIconEntry *icon_entry;
+ GtkSizeGroup *size_group;
+ GtkAction *action;
+ GtkWidget *widget;
+
+ shell_content = E_SHELL_CONTENT (object);
+ shell_view = e_shell_content_get_shell_view (shell_content);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ icon_entry = E_ICON_ENTRY (shell_content->priv->search_entry);
+ size_group = e_shell_view_get_size_group (shell_view);
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
+ e_icon_entry_add_action_end (icon_entry, action);
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_EXECUTE (shell_window);
+ g_signal_connect (
+ action, "activate",
+ G_CALLBACK (action_search_execute_cb), shell_content);
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_OPTIONS (shell_window);
+ e_icon_entry_add_action_start (icon_entry, action);
+
+ widget = shell_content->priv->search_bar;
+ gtk_size_group_add_widget (size_group, widget);
+
+ shell_content_init_search_context (shell_content);
+}
+
+static void
+shell_content_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ EShellContentPrivate *priv;
+ GtkRequisition child_requisition;
+ GtkWidget *child;
+
+ priv = E_SHELL_CONTENT_GET_PRIVATE (widget);
+
+ requisition->width = 0;
+ requisition->height = 0;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ gtk_widget_size_request (child, requisition);
+
+ child = priv->search_bar;
+ gtk_widget_size_request (child, &child_requisition);
+ requisition->width = MAX (requisition->width, child_requisition.width);
+ requisition->height += child_requisition.height;
+}
+
+static void
+shell_content_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ EShellContentPrivate *priv;
+ GtkAllocation child_allocation;
+ GtkRequisition child_requisition;
+ GtkWidget *child;
+
+ priv = E_SHELL_CONTENT_GET_PRIVATE (widget);
+
+ widget->allocation = *allocation;
+
+ child = priv->search_bar;
+ gtk_widget_size_request (child, &child_requisition);
+
+ child_allocation.x = allocation->x;
+ child_allocation.y = allocation->y;
+ child_allocation.width = allocation->width;
+ child_allocation.height = child_requisition.height;
+
+ gtk_widget_size_allocate (child, &child_allocation);
+
+ child_allocation.y += child_requisition.height;
+ child_allocation.height =
+ allocation->height - child_requisition.height;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (child != NULL)
+ gtk_widget_size_allocate (child, &child_allocation);
+}
+
+static void
+shell_content_remove (GtkContainer *container,
+ GtkWidget *widget)
+{
+ EShellContentPrivate *priv;
+
+ priv = E_SHELL_CONTENT_GET_PRIVATE (container);
+
+ /* Look in the internal widgets first. */
+
+ if (widget == priv->search_bar) {
+ gtk_widget_unparent (priv->search_bar);
+ gtk_widget_queue_resize (GTK_WIDGET (container));
+ return;
+ }
+
+ /* Chain up to parent's remove() method. */
+ GTK_CONTAINER_CLASS (parent_class)->remove (container, widget);
+}
+
+static void
+shell_content_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data)
+{
+ EShellContentPrivate *priv;
+
+ priv = E_SHELL_CONTENT_GET_PRIVATE (container);
+
+ if (include_internals)
+ callback (priv->search_bar, callback_data);
+
+ /* Chain up to parent's forall() method. */
+ GTK_CONTAINER_CLASS (parent_class)->forall (
+ container, include_internals, callback, callback_data);
+}
+
+static void
+shell_content_class_init (EShellContentClass *class)
+{
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+ GtkContainerClass *container_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EShellContentPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = shell_content_set_property;
+ object_class->get_property = shell_content_get_property;
+ object_class->dispose = shell_content_dispose;
+ object_class->finalize = shell_content_finalize;
+ object_class->constructed = shell_content_constructed;
+
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->size_request = shell_content_size_request;
+ widget_class->size_allocate = shell_content_size_allocate;
+
+ container_class = GTK_CONTAINER_CLASS (class);
+ container_class->remove = shell_content_remove;
+ container_class->forall = shell_content_forall;
+
+ class->new_search_context = rule_context_new;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FILTER_ACTION,
+ g_param_spec_object (
+ "filter-action",
+ NULL,
+ NULL,
+ GTK_TYPE_RADIO_ACTION,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FILTER_VALUE,
+ g_param_spec_int (
+ "filter-value",
+ NULL,
+ NULL,
+ G_MININT,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FILTER_VISIBLE,
+ g_param_spec_boolean (
+ "filter-visible",
+ NULL,
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SEARCH_CONTEXT,
+ g_param_spec_object (
+ "search-context",
+ NULL,
+ NULL,
+ RULE_TYPE_CONTEXT,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SEARCH_RULE,
+ g_param_spec_object (
+ "search-rule",
+ NULL,
+ NULL,
+ FILTER_TYPE_RULE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SEARCH_TEXT,
+ g_param_spec_string (
+ "search-text",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SEARCH_VISIBLE,
+ g_param_spec_boolean (
+ "search-visible",
+ NULL,
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SCOPE_ACTION,
+ g_param_spec_object (
+ "scope-action",
+ NULL,
+ NULL,
+ GTK_TYPE_RADIO_ACTION,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SCOPE_VALUE,
+ g_param_spec_int (
+ "scope-value",
+ NULL,
+ NULL,
+ G_MININT,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SCOPE_VISIBLE,
+ g_param_spec_boolean (
+ "scope-visible",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL_VIEW,
+ g_param_spec_object (
+ "shell-view",
+ NULL,
+ NULL,
+ E_TYPE_SHELL_VIEW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+shell_content_init (EShellContent *shell_content)
+{
+ GtkBox *box;
+ GtkLabel *label;
+ GtkWidget *mnemonic;
+ GtkWidget *widget;
+ EIconEntry *icon_entry;
+
+ shell_content->priv = E_SHELL_CONTENT_GET_PRIVATE (shell_content);
+
+ GTK_WIDGET_SET_FLAGS (shell_content, GTK_NO_WINDOW);
+
+ /*** Build the Search Bar ***/
+
+ widget = gtk_hbox_new (FALSE, 3);
+ gtk_widget_set_parent (widget, GTK_WIDGET (shell_content));
+ shell_content->priv->search_bar = g_object_ref_sink (widget);
+ gtk_widget_show (widget);
+
+ box = GTK_BOX (widget);
+
+ /* Filter Combo Widgets */
+
+ /* Translators: The "Show:" label precedes a combo box that
+ * allows the user to filter the current view. Examples of
+ * items that appear in the combo box are "Unread Messages",
+ * "Important Messages", or "Active Appointments". */
+ widget = gtk_label_new_with_mnemonic (_("Sho_w:"));
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
+ shell_content->priv->filter_label = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ label = GTK_LABEL (widget);
+
+ widget = e_action_combo_box_new ();
+ gtk_label_set_mnemonic_widget (label, widget);
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
+ shell_content->priv->filter_combo_box = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ /* Scope Combo Widgets */
+
+ widget = e_action_combo_box_new ();
+ gtk_box_pack_end (box, widget, FALSE, FALSE, 0);
+ shell_content->priv->scope_combo_box = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ mnemonic = widget;
+
+ /* Translators: This is part of the quick search interface.
+ * example: Search: [_______________] in [ Current Folder ] */
+ widget = gtk_label_new_with_mnemonic (_("i_n"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), mnemonic);
+ gtk_box_pack_end (box, widget, FALSE, FALSE, 0);
+ shell_content->priv->scope_label = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ /* Search Entry Widgets */
+
+ widget = e_icon_entry_new ();
+ gtk_box_pack_end (box, widget, FALSE, FALSE, 0);
+ shell_content->priv->search_entry = g_object_ref (widget);
+ shell_content->priv->search_state = GTK_STATE_NORMAL;
+ gtk_widget_show (widget);
+
+ icon_entry = E_ICON_ENTRY (widget);
+
+ /* Translators: This is part of the quick search interface.
+ * example: Search: [_______________] in [ Current Folder ] */
+ widget = gtk_label_new_with_mnemonic (_("Sear_ch:"));
+ gtk_box_pack_end (box, widget, FALSE, FALSE, 0);
+ shell_content->priv->search_label = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ label = GTK_LABEL (widget);
+
+ widget = e_icon_entry_get_entry (icon_entry);
+ gtk_label_set_mnemonic_widget (label, widget);
+ g_signal_connect_swapped (
+ widget, "activate",
+ G_CALLBACK (shell_content_entry_activated_cb), shell_content);
+ g_signal_connect_swapped (
+ widget, "focus-in-event",
+ G_CALLBACK (shell_content_entry_focus_in_cb), shell_content);
+ g_signal_connect_swapped (
+ widget, "focus-out-event",
+ G_CALLBACK (shell_content_entry_focus_out_cb), shell_content);
+ g_signal_connect_swapped (
+ widget, "key-press-event",
+ G_CALLBACK (shell_content_entry_key_press_cb), shell_content);
+}
+
+GType
+e_shell_content_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EShellContentClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) shell_content_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EShellContent),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) shell_content_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ GTK_TYPE_BIN, "EShellContent", &type_info, 0);
+ }
+
+ return type;
+}
+
+/**
+ * e_shell_content_new:
+ * @shell_view: an #EShellView
+ *
+ * Creates a new #EShellContent instance belonging to @shell_view.
+ *
+ * Returns: a new #EShellContent instance
+ **/
+GtkWidget *
+e_shell_content_new (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ return g_object_new (
+ E_TYPE_SHELL_CONTENT, "shell-view", shell_view, NULL);
+}
+
+/**
+ * e_shell_content_check_state:
+ * @shell_content: an #EShellContent
+ *
+ * #EShellContent subclasses should implement the
+ * <structfield>check_state</structfield> method in #EShellContentClass
+ * to return a set of flags describing the current content selection.
+ * Subclasses are responsible for defining their own flags. This is
+ * primarily used to assist shell views with updating actions (see
+ * e_shell_view_update_actions()).
+ *
+ * Returns: a set of flags describing the current @shell_content selection
+ **/
+guint32
+e_shell_content_check_state (EShellContent *shell_content)
+{
+ EShellContentClass *shell_content_class;
+
+ g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), 0);
+
+ shell_content_class = E_SHELL_CONTENT_GET_CLASS (shell_content);
+ g_return_val_if_fail (shell_content_class->check_state != NULL, 0);
+
+ return shell_content_class->check_state (shell_content);
+}
+
+/**
+ * e_shell_content_get_shell_view:
+ * @shell_content: an #EShellContent
+ *
+ * Returns the #EShellView that was passed to e_shell_content_new().
+ *
+ * Returns: the #EShellView to which @shell_content belongs
+ **/
+EShellView *
+e_shell_content_get_shell_view (EShellContent *shell_content)
+{
+ g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
+
+ return E_SHELL_VIEW (shell_content->priv->shell_view);
+}
+
+GtkRadioAction *
+e_shell_content_get_filter_action (EShellContent *shell_content)
+{
+ EActionComboBox *combo_box;
+
+ g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
+
+ combo_box = E_ACTION_COMBO_BOX (shell_content->priv->filter_combo_box);
+
+ return e_action_combo_box_get_action (combo_box);
+}
+
+void
+e_shell_content_set_filter_action (EShellContent *shell_content,
+ GtkRadioAction *filter_action)
+{
+ EActionComboBox *combo_box;
+
+ g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
+
+ combo_box = E_ACTION_COMBO_BOX (shell_content->priv->filter_combo_box);
+
+ e_action_combo_box_set_action (combo_box, filter_action);
+ g_object_notify (G_OBJECT (shell_content), "filter-action");
+}
+
+gint
+e_shell_content_get_filter_value (EShellContent *shell_content)
+{
+ EActionComboBox *combo_box;
+
+ g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), 0);
+
+ combo_box = E_ACTION_COMBO_BOX (shell_content->priv->filter_combo_box);
+
+ return e_action_combo_box_get_current_value (combo_box);
+}
+
+void
+e_shell_content_set_filter_value (EShellContent *shell_content,
+ gint filter_value)
+{
+ EActionComboBox *combo_box;
+
+ g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
+
+ combo_box = E_ACTION_COMBO_BOX (shell_content->priv->filter_combo_box);
+
+ e_action_combo_box_set_current_value (combo_box, filter_value);
+ g_object_notify (G_OBJECT (shell_content), "filter-value");
+}
+
+gboolean
+e_shell_content_get_filter_visible (EShellContent *shell_content)
+{
+ g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), FALSE);
+
+ return GTK_WIDGET_VISIBLE (shell_content->priv->filter_combo_box);
+}
+
+void
+e_shell_content_set_filter_visible (EShellContent *shell_content,
+ gboolean filter_visible)
+{
+ g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
+
+ if (filter_visible) {
+ gtk_widget_show (shell_content->priv->filter_label);
+ gtk_widget_show (shell_content->priv->filter_combo_box);
+ } else {
+ gtk_widget_hide (shell_content->priv->filter_label);
+ gtk_widget_hide (shell_content->priv->filter_combo_box);
+ }
+}
+
+void
+e_shell_content_add_filter_separator_before (EShellContent *shell_content,
+ gint action_value)
+{
+ EActionComboBox *combo_box;
+
+ g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
+
+ combo_box = E_ACTION_COMBO_BOX (shell_content->priv->filter_combo_box);
+
+ e_action_combo_box_add_separator_before (combo_box, action_value);
+}
+
+void
+e_shell_content_add_filter_separator_after (EShellContent *shell_content,
+ gint action_value)
+{
+ EActionComboBox *combo_box;
+
+ g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
+
+ combo_box = E_ACTION_COMBO_BOX (shell_content->priv->filter_combo_box);
+
+ e_action_combo_box_add_separator_after (combo_box, action_value);
+}
+
+RuleContext *
+e_shell_content_get_search_context (EShellContent *shell_content)
+{
+ g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
+
+ return shell_content->priv->search_context;
+}
+
+FilterRule *
+e_shell_content_get_search_rule (EShellContent *shell_content)
+{
+ g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
+
+ return shell_content->priv->search_rule;
+}
+
+void
+e_shell_content_set_search_rule (EShellContent *shell_content,
+ FilterRule *search_rule)
+{
+ g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
+
+ if (search_rule != NULL) {
+ g_return_if_fail (IS_FILTER_RULE (search_rule));
+ g_object_ref (search_rule);
+ }
+
+ if (shell_content->priv->search_rule != NULL)
+ g_object_unref (shell_content->priv->search_rule);
+
+ shell_content->priv->search_rule = search_rule;
+ g_object_notify (G_OBJECT (shell_content), "search-rule");
+}
+
+const gchar *
+e_shell_content_get_search_text (EShellContent *shell_content)
+{
+ EIconEntry *icon_entry;
+ GtkWidget *text_entry;
+
+ g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
+
+ if (shell_content->priv->search_state == GTK_STATE_INSENSITIVE)
+ return "";
+
+ icon_entry = E_ICON_ENTRY (shell_content->priv->search_entry);
+ text_entry = e_icon_entry_get_entry (icon_entry);
+
+ return gtk_entry_get_text (GTK_ENTRY (text_entry));
+}
+
+void
+e_shell_content_set_search_text (EShellContent *shell_content,
+ const gchar *search_text)
+{
+ EIconEntry *icon_entry;
+ GtkWidget *text_entry;
+
+ g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
+
+ icon_entry = E_ICON_ENTRY (shell_content->priv->search_entry);
+ text_entry = e_icon_entry_get_entry (icon_entry);
+
+ search_text = (search_text != NULL) ? search_text : "";
+ gtk_entry_set_text (GTK_ENTRY (text_entry), search_text);
+ g_object_notify (G_OBJECT (shell_content), "search-text");
+}
+
+gboolean
+e_shell_content_get_search_visible (EShellContent *shell_content)
+{
+ g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), FALSE);
+
+ return GTK_WIDGET_VISIBLE (shell_content->priv->search_entry);
+}
+
+void
+e_shell_content_set_search_visible (EShellContent *shell_content,
+ gboolean search_visible)
+{
+ g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
+
+ if (search_visible) {
+ gtk_widget_show (shell_content->priv->search_label);
+ gtk_widget_show (shell_content->priv->search_entry);
+ } else {
+ gtk_widget_hide (shell_content->priv->search_label);
+ gtk_widget_hide (shell_content->priv->search_entry);
+ }
+}
+
+GtkRadioAction *
+e_shell_content_get_scope_action (EShellContent *shell_content)
+{
+ EActionComboBox *combo_box;
+
+ g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), NULL);
+
+ combo_box = E_ACTION_COMBO_BOX (shell_content->priv->scope_combo_box);
+
+ return e_action_combo_box_get_action (combo_box);
+}
+
+void
+e_shell_content_set_scope_action (EShellContent *shell_content,
+ GtkRadioAction *scope_action)
+{
+ EActionComboBox *combo_box;
+
+ g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
+
+ combo_box = E_ACTION_COMBO_BOX (shell_content->priv->scope_combo_box);
+
+ e_action_combo_box_set_action (combo_box, scope_action);
+ g_object_notify (G_OBJECT (shell_content), "scope-action");
+}
+
+gint
+e_shell_content_get_scope_value (EShellContent *shell_content)
+{
+ EActionComboBox *combo_box;
+
+ g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), 0);
+
+ combo_box = E_ACTION_COMBO_BOX (shell_content->priv->scope_combo_box);
+
+ return e_action_combo_box_get_current_value (combo_box);
+}
+
+void
+e_shell_content_set_scope_value (EShellContent *shell_content,
+ gint scope_value)
+{
+ EActionComboBox *combo_box;
+
+ g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
+
+ combo_box = E_ACTION_COMBO_BOX (shell_content->priv->scope_combo_box);
+
+ e_action_combo_box_set_current_value (combo_box, scope_value);
+ g_object_notify (G_OBJECT (shell_content), "scope-value");
+}
+
+gboolean
+e_shell_content_get_scope_visible (EShellContent *shell_content)
+{
+ g_return_val_if_fail (E_IS_SHELL_CONTENT (shell_content), FALSE);
+
+ return GTK_WIDGET_VISIBLE (shell_content->priv->scope_combo_box);
+}
+
+void
+e_shell_content_set_scope_visible (EShellContent *shell_content,
+ gboolean scope_visible)
+{
+ g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
+
+ if (scope_visible) {
+ gtk_widget_show (shell_content->priv->scope_label);
+ gtk_widget_show (shell_content->priv->scope_combo_box);
+ } else {
+ gtk_widget_hide (shell_content->priv->scope_label);
+ gtk_widget_hide (shell_content->priv->scope_combo_box);
+ }
+
+ g_object_notify (G_OBJECT (shell_content), "scope-visible");
+}
+
+void
+e_shell_content_run_advanced_search_dialog (EShellContent *shell_content)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ GtkAction *action;
+ GtkWidget *dialog;
+ GtkWidget *widget;
+ FilterRule *rule;
+ RuleContext *context;
+ const gchar *user_filename;
+ gint response;
+
+ g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
+
+ shell_view = e_shell_content_get_shell_view (shell_content);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ user_filename = shell_content->priv->user_filename;
+
+ rule = e_shell_content_get_search_rule (shell_content);
+
+ if (rule == NULL)
+ rule = filter_rule_new ();
+ else
+ rule = filter_rule_clone (rule);
+
+ context = e_shell_content_get_search_context (shell_content);
+ widget = filter_rule_get_widget (rule, context);
+ filter_rule_set_source (rule, FILTER_SOURCE_INCOMING);
+
+ dialog = gtk_dialog_new_with_buttons (
+ _("Advanced Search"), GTK_WINDOW (shell_window),
+ GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_APPLY,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 7);
+ gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 300);
+
+ gtk_box_pack_start (
+ GTK_BOX (GTK_DIALOG (dialog)->vbox), widget, TRUE, TRUE, 0);
+
+ g_signal_connect_swapped (
+ rule, "changed", G_CALLBACK (
+ shell_content_dialog_rule_changed), dialog);
+
+ shell_content_dialog_rule_changed (dialog, rule);
+
+run:
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ if (response != GTK_RESPONSE_OK && response != GTK_RESPONSE_APPLY)
+ goto exit;
+
+ if (!filter_rule_validate (rule))
+ goto run;
+
+ e_shell_content_set_search_rule (shell_content, rule);
+
+ action = E_SHELL_WINDOW_ACTION_SEARCH_EXECUTE (shell_window);
+ gtk_action_activate (action);
+
+ if (response == GTK_RESPONSE_APPLY) {
+ if (!rule_context_find_rule (context, rule->name, rule->source))
+ rule_context_add_rule (context, rule);
+ rule_context_save (context, user_filename);
+ goto run;
+ }
+
+exit:
+ g_object_unref (rule);
+ gtk_widget_destroy (dialog);
+}
+
+void
+e_shell_content_run_edit_searches_dialog (EShellContent *shell_content)
+{
+ RuleContext *context;
+ RuleEditor *editor;
+ const gchar *user_filename;
+
+ g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
+
+ context = e_shell_content_get_search_context (shell_content);
+ user_filename = shell_content->priv->user_filename;
+
+ editor = rule_editor_new (
+ context, FILTER_SOURCE_INCOMING, _("Searches"));
+ gtk_window_set_title (GTK_WINDOW (editor), _("Searches"));
+
+ if (gtk_dialog_run (GTK_DIALOG (editor)) == GTK_RESPONSE_OK)
+ rule_context_save (context, user_filename);
+
+ gtk_widget_destroy (GTK_WIDGET (editor));
+}
+
+void
+e_shell_content_run_save_search_dialog (EShellContent *shell_content)
+{
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ GtkWidget *dialog;
+ GtkWidget *widget;
+ FilterRule *rule;
+ RuleContext *context;
+ const gchar *search_text;
+ const gchar *user_filename;
+ gchar *search_name;
+ gint response;
+
+ g_return_if_fail (E_IS_SHELL_CONTENT (shell_content));
+
+ shell_view = e_shell_content_get_shell_view (shell_content);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ user_filename = shell_content->priv->user_filename;
+
+ rule = e_shell_content_get_search_rule (shell_content);
+ g_return_if_fail (IS_FILTER_RULE (rule));
+ rule = filter_rule_clone (rule);
+
+ search_text = e_shell_content_get_search_text (shell_content);
+ if (search_text == NULL || *search_text == '\0')
+ search_text = "''";
+
+ search_name = g_strdup_printf ("%s %s", rule->name, search_text);
+ filter_rule_set_name (rule, search_name);
+ g_free (search_name);
+
+ context = e_shell_content_get_search_context (shell_content);
+ widget = filter_rule_get_widget (rule, context);
+ filter_rule_set_source (rule, FILTER_SOURCE_INCOMING);
+
+ dialog = gtk_dialog_new_with_buttons (
+ _("Save Search"), GTK_WINDOW (shell_window),
+ GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 7);
+ gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 300);
+
+ gtk_box_pack_start (
+ GTK_BOX (GTK_DIALOG (dialog)->vbox), widget, TRUE, TRUE, 0);
+
+ g_signal_connect_swapped (
+ rule, "changed", G_CALLBACK (
+ shell_content_dialog_rule_changed), dialog);
+
+ shell_content_dialog_rule_changed (dialog, rule);
+
+run:
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ if (response != GTK_RESPONSE_OK)
+ goto exit;
+
+ if (!filter_rule_validate (rule))
+ goto run;
+
+ rule_context_add_rule (context, rule);
+ rule_context_save (context, user_filename);
+
+exit:
+ g_object_unref (rule);
+ gtk_widget_destroy (dialog);
+}
diff --git a/shell/e-shell-content.h b/shell/e-shell-content.h
new file mode 100644
index 0000000000..04639771f3
--- /dev/null
+++ b/shell/e-shell-content.h
@@ -0,0 +1,143 @@
+/*
+ * e-shell-content.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+/**
+ * SECTION: e-shell-content
+ * @short_description: the right side of the main window
+ * @include: shell/e-shell-content.h
+ **/
+
+#ifndef E_SHELL_CONTENT_H
+#define E_SHELL_CONTENT_H
+
+#include <shell/e-shell-common.h>
+#include <filter/filter-rule.h>
+#include <filter/rule-context.h>
+
+/* Standard GObject macros */
+#define E_TYPE_SHELL_CONTENT \
+ (e_shell_content_get_type ())
+#define E_SHELL_CONTENT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_SHELL_CONTENT, EShellContent))
+#define E_SHELL_CONTENT_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_SHELL_CONTENT, EShellContentClass))
+#define E_IS_SHELL_CONTENT(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_SHELL_CONTENT))
+#define E_IS_SHELL_CONTENT_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((obj), E_TYPE_SHELL_CONTENT))
+#define E_SHELL_CONTENT_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_SHELL_CONTENT, EShellContentClass))
+
+G_BEGIN_DECLS
+
+/* Avoid including <e-shell-view.h>, because it includes us! */
+struct _EShellView;
+
+typedef struct _EShellContent EShellContent;
+typedef struct _EShellContentClass EShellContentClass;
+typedef struct _EShellContentPrivate EShellContentPrivate;
+
+/**
+ * EShellContent:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ **/
+struct _EShellContent {
+ GtkBin parent;
+ EShellContentPrivate *priv;
+};
+
+struct _EShellContentClass {
+ GtkBinClass parent_class;
+
+ /* Factory Methods */
+ RuleContext * (*new_search_context) (void);
+
+ guint32 (*check_state) (EShellContent *shell_content);
+};
+
+GType e_shell_content_get_type (void);
+GtkWidget * e_shell_content_new (struct _EShellView *shell_view);
+guint32 e_shell_content_check_state (EShellContent *shell_content);
+struct _EShellView *
+ e_shell_content_get_shell_view (EShellContent *shell_content);
+GtkRadioAction *e_shell_content_get_filter_action
+ (EShellContent *shell_content);
+void e_shell_content_set_filter_action
+ (EShellContent *shell_content,
+ GtkRadioAction *filter_action);
+gint e_shell_content_get_filter_value(EShellContent *shell_content);
+void e_shell_content_set_filter_value(EShellContent *shell_content,
+ gint filter_value);
+gboolean e_shell_content_get_filter_visible
+ (EShellContent *shell_content);
+void e_shell_content_set_filter_visible
+ (EShellContent *shell_content,
+ gboolean filter_visible);
+void e_shell_content_add_filter_separator_before
+ (EShellContent *shell_content,
+ gint action_value);
+void e_shell_content_add_filter_separator_after
+ (EShellContent *shell_content,
+ gint action_value);
+RuleContext * e_shell_content_get_search_context
+ (EShellContent *shell_content);
+FilterRule * e_shell_content_get_search_rule (EShellContent *shell_content);
+void e_shell_content_set_search_rule (EShellContent *shell_content,
+ FilterRule *search_rule);
+const gchar * e_shell_content_get_search_text (EShellContent *shell_content);
+void e_shell_content_set_search_text (EShellContent *shell_content,
+ const gchar *search_text);
+gboolean e_shell_content_get_search_visible
+ (EShellContent *shell_content);
+void e_shell_content_set_search_visible
+ (EShellContent *shell_content,
+ gboolean search_visible);
+GtkRadioAction *e_shell_content_get_scope_action(EShellContent *shell_content);
+void e_shell_content_set_scope_action(EShellContent *shell_content,
+ GtkRadioAction *scope_action);
+gint e_shell_content_get_scope_value (EShellContent *shell_content);
+void e_shell_content_set_scope_value (EShellContent *shell_content,
+ gint scope_value);
+gboolean e_shell_content_get_scope_visible
+ (EShellContent *shell_content);
+void e_shell_content_set_scope_visible
+ (EShellContent *shell_content,
+ gboolean scope_visible);
+const gchar * e_shell_content_get_view_id (EShellContent *shell_content);
+void e_shell_content_set_view_id (EShellContent *shell_content,
+ const gchar *view_id);
+void e_shell_content_run_advanced_search_dialog
+ (EShellContent *shell_content);
+void e_shell_content_run_edit_searches_dialog
+ (EShellContent *shell_content);
+void e_shell_content_run_save_search_dialog
+ (EShellContent *shell_content);
+
+G_END_DECLS
+
+#endif /* E_SHELL_CONTENT_H */
diff --git a/shell/e-shell-importer.c b/shell/e-shell-importer.c
index 68ce5abec0..8a639342b1 100644
--- a/shell/e-shell-importer.c
+++ b/shell/e-shell-importer.c
@@ -48,7 +48,6 @@
#include "e-shell.h"
#include "e-shell-window.h"
-#include "e-shell-constants.h"
#include "e-shell-importer.h"
@@ -251,29 +250,6 @@ filetype_changed_cb (GtkWidget *combobox, ImportData *data)
filename_changed (data->filepage->filename, data);
}
-#if 0
-static int
-compare_info_name (const void *data1, const void *data2)
-{
- const Bonobo_ServerInfo *info1 = (Bonobo_ServerInfo *)data1;
- const Bonobo_ServerInfo *info2 = (Bonobo_ServerInfo *)data2;
- const char *name1 = get_name_from_component_info (info1);
- const char *name2 = get_name_from_component_info (info2);
-
- /* If we can't find a name for a plug-in, its iid will be used
- * for display. Put such plug-ins at the end of the list since
- * their displayed name won't be really user-friendly
- */
- if (name1 == NULL) {
- return -1;
- }
- if (name2 == NULL) {
- return 1;
- }
- return g_utf8_collate (name1, name2);
-}
-#endif
-
static ImportDialogFilePage *
importer_file_page_new (ImportData *data)
{
diff --git a/shell/e-shell-importer.h b/shell/e-shell-importer.h
index f4489c3020..d78c04ab5d 100644
--- a/shell/e-shell-importer.h
+++ b/shell/e-shell-importer.h
@@ -20,9 +20,16 @@
*
*/
-#ifndef _E_SHELL_IMPORTER_H_
-#define _E_SHELL_IMPORTER_H_
+#ifndef E_SHELL_IMPORTER_H
+#define E_SHELL_IMPORTER_H
-void e_shell_importer_start_import (EShellWindow *shell_window);
+#include "e-shell-common.h"
+#include "e-shell-window.h"
-#endif
+G_BEGIN_DECLS
+
+void e_shell_importer_start_import (EShellWindow *shell_window);
+
+G_END_DECLS
+
+#endif /* E_SHELL_IMPORTER_H */
diff --git a/shell/e-shell-migrate.c b/shell/e-shell-migrate.c
new file mode 100644
index 0000000000..aa3e1e0f97
--- /dev/null
+++ b/shell/e-shell-migrate.c
@@ -0,0 +1,335 @@
+/*
+ * e-shell-migrate.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-shell-migrate.h"
+
+#include <string.h>
+#include <unistd.h>
+#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+#include <libedataserver/e-xml-utils.h>
+
+#include "e-util/e-bconf-map.h"
+#include "e-util/e-error.h"
+#include "e-util/e-fsutils.h"
+#include "e-util/e-util.h"
+
+#define GCONF_VERSION_KEY "/apps/evolution/version"
+#define GCONF_LAST_VERSION_KEY "/apps/evolution/last_version"
+
+static const gchar *
+shell_migrate_get_old_data_dir (void)
+{
+ static gchar *old_data_dir = NULL;
+
+ if (G_UNLIKELY (old_data_dir == NULL))
+ old_data_dir = g_build_filename (
+ g_get_home_dir (), "evolution", NULL);
+
+ return old_data_dir;
+}
+
+static gboolean
+shell_migrate_attempt (EShell *shell,
+ gint major,
+ gint minor,
+ gint micro)
+{
+ GList *modules;
+ gboolean success = TRUE;
+
+ modules = e_shell_get_shell_modules (shell);
+
+ while (success && modules != NULL) {
+ EShellModule *shell_module = modules->data;
+ GError *error = NULL;
+
+ success = e_shell_module_migrate (
+ shell_module, major, minor, micro, &error);
+
+ if (error != NULL) {
+ gint response;
+
+ response = e_error_run (
+ NULL, "shell:upgrade-failed",
+ error->message, NULL);
+
+ if (response == GTK_RESPONSE_CANCEL)
+ success = FALSE;
+
+ g_error_free (error);
+ }
+
+ modules = g_list_next (modules);
+ }
+
+ return success;
+}
+
+static void
+shell_migrate_get_version (EShell *shell,
+ gint *major,
+ gint *minor,
+ gint *micro)
+{
+ GConfClient *client;
+ const gchar *key;
+ const gchar *old_data_dir;
+ gchar *string;
+
+ old_data_dir = shell_migrate_get_old_data_dir ();
+
+ key = GCONF_VERSION_KEY;
+ client = e_shell_get_gconf_client (shell);
+ string = gconf_client_get_string (client, key, NULL);
+
+ if (string != NULL) {
+ /* Since 1.4.0 we've kept the version key in GConf. */
+ sscanf (string, "%d.%d.%d", major, minor, micro);
+ g_free (string);
+
+ } else if (!g_file_test (old_data_dir, G_FILE_TEST_IS_DIR)) {
+ /* If the old data directory does not exist,
+ * it must be a new installation. */
+ *major = 0;
+ *minor = 0;
+ *micro = 0;
+
+ } else {
+ xmlDocPtr doc;
+ xmlNodePtr source;
+ gchar *filename;
+
+ filename = g_build_filename (
+ old_data_dir, "config.xmldb", NULL);
+ doc = e_xml_parse_file (filename);
+ g_free (filename);
+
+ if (doc == NULL)
+ return;
+
+ source = e_bconf_get_path (doc, "/Shell");
+ if (source != NULL) {
+ key = "upgrade_from_1_0_to_1_2_performed";
+ string = e_bconf_get_value (source, key);
+ }
+
+ if (string != NULL && *string == '1') {
+ *major = 1;
+ *minor = 2;
+ *micro = 0;
+ } else {
+ *major = 1;
+ *minor = 0;
+ *micro = 0;
+ }
+
+ g_free (string);
+
+ if (doc != NULL)
+ xmlFreeDoc (doc);
+ }
+}
+
+static gint
+shell_migrate_remove_dir (const gchar *root,
+ const gchar *path)
+{
+ GDir *dir;
+ const gchar *basename;
+ gchar *filename;
+ gint result = -1;
+
+ /* Recursively removes a directory and its contents. */
+
+ dir = g_dir_open (path, 0, NULL);
+ if (dir == NULL)
+ return -1;
+
+ while ((basename = g_dir_read_name (dir)) != NULL) {
+ filename = g_build_filename (path, basename, NULL);
+
+ /* Make sure we haven't strayed from the evolution dir. */
+ g_return_val_if_fail (strlen (path) >= strlen (root), -1);
+ g_return_val_if_fail (g_str_has_prefix (path, root), -1);
+
+ if (g_file_test (filename, G_FILE_TEST_IS_DIR)) {
+ if (shell_migrate_remove_dir (root, filename) < 0)
+ goto fail;
+ } else {
+ if (g_unlink (filename) < 0)
+ goto fail;
+ }
+
+ g_free (filename);
+ filename = NULL;
+ }
+
+ result = g_rmdir (path);
+
+fail:
+ g_free (filename);
+ g_dir_close (dir);
+
+ return result;
+}
+
+gboolean
+e_shell_migrate_attempt (EShell *shell)
+{
+ GConfClient *client;
+ const gchar *key;
+ const gchar *old_data_dir;
+ gint major, minor, micro;
+ gint last_major, last_minor, last_micro;
+ gint curr_major, curr_minor, curr_micro;
+ gboolean migrated = FALSE;
+ gchar *string;
+
+ g_return_val_if_fail (E_IS_SHELL (shell), FALSE);
+
+ client = e_shell_get_gconf_client (shell);
+ old_data_dir = shell_migrate_get_old_data_dir ();
+
+ if (sscanf (BASE_VERSION, "%d.%d", &curr_major, &curr_minor) != 2) {
+ g_warning ("Could not parse BASE_VERSION (%s)", BASE_VERSION);
+ return TRUE;
+ }
+
+ curr_micro = atoi (UPGRADE_REVISION);
+
+ shell_migrate_get_version (shell, &major, &minor, &micro);
+
+ if (!(curr_major > major ||
+ (curr_major == major && curr_minor > minor) ||
+ (curr_minor == minor && curr_micro > micro)))
+ goto check_old;
+
+ /* If upgrading from < 1.5, we need to copy most data from
+ * ~/evolution to ~/.evolution. Make sure we have the disk
+ * space for it before proceeding. */
+ if (major == 1 && minor < 5) {
+ glong avail;
+ glong usage;
+
+ usage = e_fsutils_usage (old_data_dir);
+ avail = e_fsutils_avail (g_get_home_dir ());
+ if (usage >= 0 && avail >= 0 && avail < usage) {
+ gchar *need;
+ gchar *have;
+
+ need = g_strdup_printf (_("%ld KB"), usage);
+ have = g_strdup_printf (_("%ld KB"), avail);
+
+ e_error_run (
+ NULL, "shell:upgrade-nospace",
+ need, have, NULL);
+
+ g_free (need);
+ g_free (have);
+
+ _exit (EXIT_SUCCESS);
+ }
+ }
+
+ if (!shell_migrate_attempt (shell, major, minor, micro))
+ _exit (EXIT_SUCCESS);
+
+ /* Record a successful migration. */
+ string = g_strdup_printf ("%d.%d.%d", major, minor, micro);
+ gconf_client_set_string (client, GCONF_VERSION_KEY, string, NULL);
+ g_free (string);
+
+ migrated = TRUE;
+
+check_old:
+
+ key = GCONF_LAST_VERSION_KEY;
+
+ /* Try to retrieve the last migrated version from GConf. */
+ string = gconf_client_get_string (client, key, NULL);
+ if (migrated || string == NULL || sscanf (string, "%d.%d.%d",
+ &last_major, &last_minor, &last_micro) != 3) {
+ last_major = major;
+ last_minor = minor;
+ last_micro = micro;
+ }
+ g_free (string);
+
+ /* If the last migrated version was old, check for stuff to remove. */
+ if (last_major == 1 && last_minor < 5 &&
+ g_file_test (old_data_dir, G_FILE_TEST_IS_DIR)) {
+
+ gint response;
+
+ string = g_strdup_printf (
+ "%d.%d.%d", last_major, last_minor, last_micro);
+ response = e_error_run (
+ NULL, "shel:upgrade-remove-1-4", string, NULL);
+ g_free (string);
+
+ switch (response) {
+ case GTK_RESPONSE_OK: /* delete */
+ response = e_error_run (
+ NULL,
+ "shell:upgrade-remove-1-4-confirm",
+ NULL);
+ if (response == GTK_RESPONSE_OK)
+ shell_migrate_remove_dir (
+ old_data_dir, old_data_dir);
+ else
+ break;
+ /* fall through */
+
+ case GTK_RESPONSE_ACCEPT: /* keep */
+ last_major = curr_major;
+ last_minor = curr_minor;
+ last_micro = curr_micro;
+ break;
+
+ default:
+ break;
+ }
+ } else {
+ last_major = curr_major;
+ last_minor = curr_minor;
+ last_micro = curr_micro;
+ }
+
+ string = g_strdup_printf (
+ "%d.%d.%d", last_major, last_minor, last_micro);
+ gconf_client_set_string (client, key, string, NULL);
+ g_free (string);
+
+ return TRUE;
+}
+
+GQuark
+e_shell_migrate_error_quark (void)
+{
+ static GQuark quark = 0;
+
+ if (G_UNLIKELY (quark == 0))
+ quark = g_quark_from_static_string (
+ "e-shell-migrate-error-quark");
+
+ return quark;
+}
diff --git a/shell/evolution-component.h b/shell/e-shell-migrate.h
index 9202829708..45907ce7ce 100644
--- a/shell/evolution-component.h
+++ b/shell/e-shell-migrate.h
@@ -1,6 +1,5 @@
/*
- *
- * Abstract class wrapper for EvolutionComponent
+ * e-shell-migrate.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -16,32 +15,38 @@
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*
- * Authors:
- * Michael Zucchi <notzed@novell.com>
- *
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
-#ifndef _EVOLUTION_COMPONENT_H_
-#define _EVOLUTION_COMPONENT_H_
+/* This is an EShell extension that handles migrating from older versions. */
-#include <bonobo/bonobo-object.h>
-#include "shell/Evolution.h"
+#ifndef E_SHELL_MIGRATE_H
+#define E_SHELL_MIGRATE_H
-typedef struct _EvolutionComponent EvolutionComponent;
-typedef struct _EvolutionComponentClass EvolutionComponentClass;
+#include <shell/e-shell-common.h>
+#include <shell/e-shell.h>
+
+/**
+ * E_SHELL_MIGRATE_ERROR:
+ *
+ * Error domain for migration operations. Errors in this domain will be
+ * from the #EShellMigrateError enumeration. See #GError for information
+ * on error domains.
+ **/
+#define E_SHELL_MIGRATE_ERROR \
+ (e_shell_migrate_error_quark ())
-struct _EvolutionComponent {
- BonoboObject parent;
-};
+G_BEGIN_DECLS
-struct _EvolutionComponentClass {
- BonoboObjectClass parent_class;
+/* XXX Need more specific error codes? */
+typedef enum {
+ E_SHELL_MIGRATE_ERROR_FAILED
+} EShellMigrateError;
- POA_GNOME_Evolution_Component__epv epv;
-};
+gboolean e_shell_migrate_attempt (EShell *shell);
+GQuark e_shell_migrate_error_quark (void);
-GType evolution_component_get_type(void);
+G_END_DECLS
-#endif /* _EVOLUTION_COMPONENT_H_ */
+#endif /* E_SHELL_MIGRATE_H */
diff --git a/shell/e-shell-module.c b/shell/e-shell-module.c
new file mode 100644
index 0000000000..7e1bba1cec
--- /dev/null
+++ b/shell/e-shell-module.c
@@ -0,0 +1,629 @@
+/*
+ * e-shell-module.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-shell-module.h"
+
+#include <errno.h>
+#include <gmodule.h>
+#include <glib/gi18n.h>
+#include <e-util/e-util.h>
+
+#include <e-shell.h>
+
+/* This is the symbol we look for when loading a module. */
+#define INIT_SYMBOL "e_shell_module_init"
+
+#define E_SHELL_MODULE_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SHELL_MODULE, EShellModulePrivate))
+
+struct _EShellModulePrivate {
+
+ /* Set during module initialization. This must
+ * come first in the struct so EShell can read it. */
+ EShellModuleInfo info;
+
+ GModule *module;
+ gchar *filename;
+
+ gpointer shell; /* weak pointer */
+ gchar *config_dir;
+ gchar *data_dir;
+
+ GType shell_view_type;
+ GHashTable *events;
+
+ /* Initializes the loaded type module. */
+ void (*init) (GTypeModule *type_module);
+
+ guint started : 1;
+};
+
+enum {
+ PROP_0,
+ PROP_FILENAME,
+ PROP_SHELL
+};
+
+enum {
+ ACTIVITY_ADDED,
+ LAST_SIGNAL
+};
+
+static gpointer parent_class;
+static guint signals[LAST_SIGNAL];
+
+static void
+shell_module_set_filename (EShellModule *shell_module,
+ const gchar *filename)
+{
+ g_return_if_fail (shell_module->priv->filename == NULL);
+ shell_module->priv->filename = g_strdup (filename);
+}
+
+static void
+shell_module_set_shell (EShellModule *shell_module,
+ EShell *shell)
+{
+ g_return_if_fail (shell_module->priv->shell == NULL);
+
+ shell_module->priv->shell = shell;
+
+ g_object_add_weak_pointer (
+ G_OBJECT (shell_module),
+ &shell_module->priv->shell);
+}
+
+static void
+shell_module_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_FILENAME:
+ shell_module_set_filename (
+ E_SHELL_MODULE (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_SHELL:
+ shell_module_set_shell (
+ E_SHELL_MODULE (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+shell_module_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_FILENAME:
+ g_value_set_string (
+ value, e_shell_module_get_filename (
+ E_SHELL_MODULE (object)));
+ return;
+
+ case PROP_SHELL:
+ g_value_set_object (
+ value, e_shell_module_get_shell (
+ E_SHELL_MODULE (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+shell_module_finalize (GObject *object)
+{
+ EShellModulePrivate *priv;
+
+ priv = E_SHELL_MODULE_GET_PRIVATE (object);
+
+ g_free (priv->filename);
+ g_free (priv->data_dir);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static gboolean
+shell_module_load (GTypeModule *type_module)
+{
+ EShellModulePrivate *priv;
+ gpointer symbol;
+
+ priv = E_SHELL_MODULE_GET_PRIVATE (type_module);
+
+ g_return_val_if_fail (priv->filename != NULL, FALSE);
+ priv->module = g_module_open (priv->filename, 0);
+
+ if (priv->module == NULL)
+ goto fail;
+
+ if (!g_module_symbol (priv->module, INIT_SYMBOL, &symbol))
+ goto fail;
+
+ priv->init = symbol;
+ priv->init (type_module);
+
+ return TRUE;
+
+fail:
+ g_warning ("%s", g_module_error ());
+
+ if (priv->module != NULL)
+ g_module_close (priv->module);
+
+ return FALSE;
+}
+
+static void
+shell_module_unload (GTypeModule *type_module)
+{
+ EShellModulePrivate *priv;
+
+ priv = E_SHELL_MODULE_GET_PRIVATE (type_module);
+
+ g_module_close (priv->module);
+ priv->module = NULL;
+
+ priv->init = NULL;
+}
+
+static void
+shell_module_class_init (EShellModuleClass *class)
+{
+ GObjectClass *object_class;
+ GTypeModuleClass *type_module_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EShellModulePrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = shell_module_set_property;
+ object_class->get_property = shell_module_get_property;
+ object_class->finalize = shell_module_finalize;
+
+ type_module_class = G_TYPE_MODULE_CLASS (class);
+ type_module_class->load = shell_module_load;
+ type_module_class->unload = shell_module_unload;
+
+ /**
+ * EShellModule:filename
+ *
+ * The filename of the module.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_FILENAME,
+ g_param_spec_string (
+ "filename",
+ _("Filename"),
+ _("The filename of the module"),
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ /**
+ * EShellModule:shell
+ *
+ * The #EShell singleton.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL,
+ g_param_spec_object (
+ "shell",
+ _("Shell"),
+ _("The EShell singleton"),
+ E_TYPE_SHELL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ /**
+ * EShellModule::activity-added
+ * @shell_module: the #EShellModule that emitted the signal
+ * @activity: an #EActivity
+ *
+ * Broadcasts a newly added activity.
+ **/
+ signals[ACTIVITY_ADDED] = g_signal_new (
+ "activity-added",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ E_TYPE_ACTIVITY);
+}
+
+static void
+shell_module_init (EShellModule *shell_module)
+{
+ shell_module->priv = E_SHELL_MODULE_GET_PRIVATE (shell_module);
+}
+
+GType
+e_shell_module_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo type_info = {
+ sizeof (EShellModuleClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) shell_module_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EShellModule),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) shell_module_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ G_TYPE_TYPE_MODULE, "EShellModule", &type_info, 0);
+ }
+
+ return type;
+}
+
+/**
+ * e_shell_module_new:
+ * @shell: an #EShell
+ * @filename: the name of the file containing the shell module
+ *
+ * Loads @filename as a #GTypeModule and tries to invoke a module
+ * function named <function>e_shell_module_init</function>, passing
+ * the newly loaded #GTypeModule as an argument. The shell module is
+ * responsible for defining such a function to perform the appropriate
+ * initialization steps.
+ *
+ * Returns: a new #EShellModule
+ **/
+EShellModule *
+e_shell_module_new (EShell *shell,
+ const gchar *filename)
+{
+ g_return_val_if_fail (filename != NULL, NULL);
+
+ return g_object_new (
+ E_TYPE_SHELL_MODULE, "shell", shell,
+ "filename", filename, NULL);
+}
+
+/**
+ * e_shell_module_compare:
+ * @shell_module_a: an #EShellModule
+ * @shell_module_b: an #EShellModule
+ *
+ * Using the <structfield>sort_order</structfield> field from both modules'
+ * #EShellModuleInfo, compares @shell_module_a with @shell_mobule_b and
+ * returns -1, 0 or +1 if @shell_module_a is found to be less than, equal
+ * to or greater than @shell_module_b, respectively.
+ *
+ * Returns: -1, 0 or +1, for a less than, equal to or greater than result
+ **/
+gint
+e_shell_module_compare (EShellModule *shell_module_a,
+ EShellModule *shell_module_b)
+{
+ gint a = shell_module_a->priv->info.sort_order;
+ gint b = shell_module_b->priv->info.sort_order;
+
+ return (a < b) ? -1 : (a > b);
+}
+
+/**
+ * e_shell_module_get_config_dir:
+ * @shell_module: an #EShellModule
+ *
+ * Returns the absolute path to the configuration directory for
+ * @shell_module. The string is owned by @shell_module and should
+ * not be modified or freed.
+ *
+ * Returns: the module's configuration directory
+ **/
+const gchar *
+e_shell_module_get_config_dir (EShellModule *shell_module)
+{
+ g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), NULL);
+ g_return_val_if_fail (shell_module->priv->config_dir != NULL, NULL);
+
+ return shell_module->priv->config_dir;
+}
+
+/**
+ * e_shell_module_get_data_dir:
+ * @shell_module: an #EShellModule
+ *
+ * Returns the absolute path to the data directory for @shell_module.
+ * The string is owned by @shell_module and should not be modified or
+ * freed.
+ *
+ * Returns: the module's data directory
+ **/
+const gchar *
+e_shell_module_get_data_dir (EShellModule *shell_module)
+{
+ g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), NULL);
+ g_return_val_if_fail (shell_module->priv->data_dir != NULL, NULL);
+
+ return shell_module->priv->data_dir;
+}
+
+/**
+ * e_shell_module_get_filename:
+ * @shell_module: an #EShellModule
+ *
+ * Returns the name of the file from which @shell_module was loaded.
+ * The string is owned by @shell_module and should not be modified or
+ * freed.
+ *
+ * Returns: the module's file name
+ **/
+const gchar *
+e_shell_module_get_filename (EShellModule *shell_module)
+{
+ g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), NULL);
+
+ return shell_module->priv->filename;
+}
+
+/**
+ * e_shell_module_get_shell:
+ * @shell_module: an #EShellModule
+ *
+ * Returns the #EShell that was passed to e_shell_module_new().
+ *
+ * Returns: the #EShell
+ **/
+EShell *
+e_shell_module_get_shell (EShellModule *shell_module)
+{
+ g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), NULL);
+
+ return E_SHELL (shell_module->priv->shell);
+}
+
+/**
+ * e_shell_module_get_shell_view_type:
+ * @shell_module: an #EShellModule
+ *
+ * Returns the #GType of the #EShellView subclass for @shell_module.
+ *
+ * Returns: the #GType of an #EShellView subclass
+ **/
+GType
+e_shell_module_get_shell_view_type (EShellModule *shell_module)
+{
+ g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), 0);
+
+ return shell_module->priv->shell_view_type;
+}
+
+/**
+ * e_shell_module_add_activity:
+ * @shell_module: an #EShellModule
+ * @activity: an #EActivity
+ *
+ * Emits an #EShellModule::activity-added signal.
+ **/
+void
+e_shell_module_add_activity (EShellModule *shell_module,
+ EActivity *activity)
+{
+ g_return_if_fail (E_IS_SHELL_MODULE (shell_module));
+ g_return_if_fail (E_IS_ACTIVITY (activity));
+
+ g_signal_emit (shell_module, signals[ACTIVITY_ADDED], 0, activity);
+}
+
+/**
+ * e_shell_module_start:
+ * @shell_module: an #EShellModule
+ *
+ * Tells the @shell_module to begin loading data or running background
+ * tasks which may consume significant resources. This gets called in
+ * reponse to the user switching to the corresponding #EShellView for
+ * the first time. The function is idempotent for each @shell_module.
+ **/
+void
+e_shell_module_start (EShellModule *shell_module)
+{
+ EShellModuleInfo *module_info;
+
+ g_return_if_fail (E_IS_SHELL_MODULE (shell_module));
+
+ module_info = &shell_module->priv->info;
+
+ if (module_info->start != NULL && !shell_module->priv->started)
+ module_info->start (shell_module);
+
+ shell_module->priv->started = TRUE;
+}
+
+/**
+ * e_shell_module_is_busy:
+ * @shell_module: an #EShellModule
+ *
+ * Returns %TRUE if @shell_module is busy and cannot be shutdown at
+ * present. Each module must define what "busy" means to them and
+ * determine an appropriate response.
+ *
+ * XXX This function is likely to change or disappear. I'm toying with
+ * the idea of just having it check whether there are any unfinished
+ * #EActivity<!-- -->'s left, so we have a consistent and easily
+ * testable definition of what "busy" means.
+ *
+ * Returns: %TRUE if the module is busy
+ **/
+gboolean
+e_shell_module_is_busy (EShellModule *shell_module)
+{
+ EShellModuleInfo *module_info;
+
+ g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), FALSE);
+
+ module_info = &shell_module->priv->info;
+
+ if (module_info->is_busy != NULL)
+ return module_info->is_busy (shell_module);
+
+ return FALSE;
+}
+
+/**
+ * e_shell_module_shutdown:
+ * @shell_module: an #EShellModule
+ *
+ * Alerts @shell_module to begin shutdown procedures. If the module is
+ * busy and cannot immediately shut down, the function returns %FALSE.
+ * A %TRUE response implies @shell_module has successfully shut down.
+ *
+ * XXX This function is likely to change or disappear. I'm toying with
+ * the idea of just having it check whether there are any unfinished
+ * #EActivity<!-- -->'s left, so we have a consistent and easily
+ * testable definition of what "busy" means.
+ *
+ * Returns: %TRUE if the module has shut down, %FALSE if the module is
+ * busy and cannot immediately shut down
+ */
+gboolean
+e_shell_module_shutdown (EShellModule *shell_module)
+{
+ EShellModuleInfo *module_info;
+
+ g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), TRUE);
+
+ module_info = &shell_module->priv->info;
+
+ if (module_info->shutdown != NULL)
+ return module_info->shutdown (shell_module);
+
+ return TRUE;
+}
+
+/**
+ * e_shell_migrate:
+ * @shell_module: an #EShellModule
+ * @major: major part of version to migrate from
+ * @minor: minor part of version to migrate from
+ * @micro: micro part of version to migrate from
+ * @error: return location for a #GError, or %NULL
+ *
+ * Attempts to migrate data and settings from version %major.%minor.%micro.
+ * Returns %TRUE if the migration was successful or if no action was
+ * necessary. Returns %FALSE and sets %error if the migration failed.
+ *
+ * Returns: %TRUE if successful, %FALSE otherwise
+ **/
+gboolean
+e_shell_module_migrate (EShellModule *shell_module,
+ gint major,
+ gint minor,
+ gint micro,
+ GError **error)
+{
+ EShellModuleInfo *module_info;
+
+ g_return_val_if_fail (E_IS_SHELL_MODULE (shell_module), TRUE);
+
+ module_info = &shell_module->priv->info;
+
+ if (module_info->migrate != NULL)
+ return module_info->migrate (
+ shell_module, major, minor, micro, error);
+
+ return TRUE;
+}
+
+/**
+ * e_shell_module_set_info:
+ * @shell_module: an #EShellModule
+ * @info: an #EShellModuleInfo
+ * @shell_view_type: the #GType of a #EShellView subclass
+ *
+ * Registers basic configuration information about @shell_module that
+ * the #EShell can use for processing command-line arguments.
+ *
+ * Configuration information should be registered from
+ * @shell_module<!-- -->'s <function>e_shell_module_init</function>
+ * initialization function. See e_shell_module_new() for more information.
+ **/
+void
+e_shell_module_set_info (EShellModule *shell_module,
+ const EShellModuleInfo *info,
+ GType shell_view_type)
+{
+ GTypeModule *type_module;
+ EShellModuleInfo *module_info;
+ const gchar *pathname;
+
+ g_return_if_fail (E_IS_SHELL_MODULE (shell_module));
+ g_return_if_fail (info != NULL);
+
+ type_module = G_TYPE_MODULE (shell_module);
+ module_info = &shell_module->priv->info;
+
+ /* A module name is required. */
+ g_return_if_fail (info->name != NULL);
+ module_info->name = g_intern_string (info->name);
+ g_type_module_set_name (type_module, module_info->name);
+
+ module_info->aliases = g_intern_string (info->aliases);
+ module_info->schemes = g_intern_string (info->schemes);
+ module_info->sort_order = info->sort_order;
+
+ module_info->start = info->start;
+ module_info->is_busy = info->is_busy;
+ module_info->shutdown = info->shutdown;
+ module_info->migrate = info->migrate;
+
+ /* Determine the user data directory for this module. */
+ g_free (shell_module->priv->data_dir);
+ shell_module->priv->data_dir = g_build_filename (
+ e_get_user_data_dir (), module_info->name, NULL);
+
+ /* Determine the user configuration directory for this module. */
+ g_free (shell_module->priv->config_dir);
+ shell_module->priv->config_dir = g_build_filename (
+ shell_module->priv->data_dir, "config", NULL);
+
+ /* Create the user configuration directory for this module,
+ * which should also create the user data directory. */
+ pathname = shell_module->priv->config_dir;
+ if (g_mkdir_with_parents (pathname, 0777) != 0)
+ g_critical (
+ "Cannot create directory %s: %s",
+ pathname, g_strerror (errno));
+
+ shell_module->priv->shell_view_type = shell_view_type;
+}
diff --git a/shell/e-shell-module.h b/shell/e-shell-module.h
new file mode 100644
index 0000000000..9032823bc2
--- /dev/null
+++ b/shell/e-shell-module.h
@@ -0,0 +1,157 @@
+/*
+ * e-shell-module.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+/**
+ * SECTION: e-shell-module
+ * @short_description: dynamically loaded capabilities
+ * @include: shell/e-shell-module.h
+ **/
+
+#ifndef E_SHELL_MODULE_H
+#define E_SHELL_MODULE_H
+
+#include <shell/e-shell-common.h>
+#include <widgets/misc/e-activity.h>
+
+/* Standard GObject macros */
+#define E_TYPE_SHELL_MODULE \
+ (e_shell_module_get_type ())
+#define E_SHELL_MODULE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_SHELL_MODULE, EShellModule))
+#define E_SHELL_MODULE_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_SHELL_MODULE, EShellModuleClass))
+#define E_IS_SHELL_MODULE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_SHELL_MODULE))
+#define E_IS_SHELL_MODULE_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_SHELL_MODULE))
+#define E_SHELL_MODULE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_SHELL_MODULE, EShellModuleClass))
+
+G_BEGIN_DECLS
+
+/* Avoid including <e-shell.h>, because it includes us! */
+struct _EShell;
+
+typedef struct _EShellModule EShellModule;
+typedef struct _EShellModuleInfo EShellModuleInfo;
+typedef struct _EShellModuleClass EShellModuleClass;
+typedef struct _EShellModulePrivate EShellModulePrivate;
+
+/**
+ * EShellModuleInfo:
+ * @name: The name of the module. Also becomes the name of
+ * the corresponding #EShellView subclass that the
+ * module will register.
+ * @aliases: Colon-separated list of aliases that can be used
+ * when referring to a module by name.
+ * @schemes: Colon-separated list of URI schemes. The #EShell
+ * will forward command-line URIs to the appropriate
+ * module based on this list.
+ * @sort_order: Used to determine the order of modules listed in
+ * the main menu and in the switcher. See
+ * e_shell_module_compare().
+ * @start: Callback for notifying the module to begin loading data
+ * and running background tasks. This is called just before
+ * the first instantiation of the corresponding #EShellView
+ * subclass. It allows the module to delay initialization
+ * steps that consume significant resources until they are
+ * actually needed.
+ * @is_busy: Callback for querying whether the module has
+ * operations in progress that cannot be cancelled
+ * or finished immediately. Returning %TRUE prevents
+ * the application from shutting down.
+ * @shutdown: Callback for notifying the module to begin
+ * shutting down. Returning %FALSE indicates there
+ * are still unfinished operations and the #EShell
+ * should check back shortly.
+ * @migrate: Callback for notifying the module to migrate data and
+ * settings from the given version. Returns %TRUE if the
+ * migration was successful or if no action was necessary.
+ * Returns %FALSE and sets a #GError if the migration failed.
+ *
+ * Provides basic information about an #EShellModule instance. Shell
+ * modules should pass this structure to e_shell_module_set_info() in
+ * their "e_shell_module_init" functions.
+ **/
+struct _EShellModuleInfo {
+ const gchar *name;
+ const gchar *aliases;
+ const gchar *schemes;
+ gint sort_order;
+
+ void (*start) (EShellModule *shell_module);
+ gboolean (*is_busy) (EShellModule *shell_module);
+ gboolean (*shutdown) (EShellModule *shell_module);
+ gboolean (*migrate) (EShellModule *shell_module,
+ gint major,
+ gint minor,
+ gint micro,
+ GError **error);
+};
+
+/**
+ * EShellModule:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ **/
+struct _EShellModule {
+ GTypeModule parent;
+ EShellModulePrivate *priv;
+};
+
+struct _EShellModuleClass {
+ GTypeModuleClass parent_class;
+};
+
+GType e_shell_module_get_type (void);
+EShellModule * e_shell_module_new (struct _EShell *shell,
+ const gchar *filename);
+gint e_shell_module_compare (EShellModule *shell_module_a,
+ EShellModule *shell_module_b);
+const gchar * e_shell_module_get_config_dir (EShellModule *shell_module);
+const gchar * e_shell_module_get_data_dir (EShellModule *shell_module);
+const gchar * e_shell_module_get_filename (EShellModule *shell_module);
+struct _EShell *e_shell_module_get_shell (EShellModule *shell_module);
+GType e_shell_module_get_shell_view_type
+ (EShellModule *shell_module);
+void e_shell_module_add_activity (EShellModule *shell_module,
+ EActivity *activity);
+void e_shell_module_start (EShellModule *shell_module);
+gboolean e_shell_module_is_busy (EShellModule *shell_module);
+gboolean e_shell_module_shutdown (EShellModule *shell_module);
+gboolean e_shell_module_migrate (EShellModule *shell_module,
+ gint major,
+ gint minor,
+ gint micro,
+ GError **error);
+void e_shell_module_set_info (EShellModule *shell_module,
+ const EShellModuleInfo *info,
+ GType shell_view_type);
+
+G_END_DECLS
+
+#endif /* E_SHELL_MODULE_H */
diff --git a/shell/e-shell-nm.c b/shell/e-shell-nm.c
index f7e4d3e63b..7b2f49e236 100644
--- a/shell/e-shell-nm.c
+++ b/shell/e-shell-nm.c
@@ -30,44 +30,36 @@
#include <string.h>
#include <glib.h>
#include <e-shell.h>
-#include <Evolution.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <dbus/dbus-glib.h>
#include <NetworkManager/NetworkManager.h>
-gboolean e_shell_dbus_initialise (EShell *shell);
+static DBusConnection *dbus_connection;
-static DBusConnection *dbus_connection = NULL;
+/* Forward Declaration */
+gboolean e_shell_dbus_initialize (EShell *shell);
static gboolean
-reinit_dbus (gpointer user_data)
+reinit_dbus (EShell *shell)
{
- EShell *shell = user_data;
-
- if (e_shell_dbus_initialise (shell))
- return FALSE;
-
- /* keep trying to re-establish dbus connection */
-
- return TRUE;
+ return !e_shell_dbus_initialize (shell);
}
static DBusHandlerResult
e_shell_network_monitor (DBusConnection *connection G_GNUC_UNUSED,
- DBusMessage *message, void *user_data)
+ DBusMessage *message,
+ gpointer user_data)
{
- const char *object;
- EShell *shell = user_data;
- GNOME_Evolution_ShellState shell_state;
- EShellLineStatus line_status;
DBusError error = DBUS_ERROR_INIT;
+ EShell *shell = user_data;
+ const gchar *path;
guint32 state;
- object = dbus_message_get_path (message);
+ path = dbus_message_get_path (message);
if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected") &&
- object && !strcmp (object, DBUS_PATH_LOCAL)) {
+ path != NULL && strcmp (path, DBUS_PATH_LOCAL) == 0) {
dbus_connection_unref (dbus_connection);
dbus_connection = NULL;
@@ -89,24 +81,28 @@ e_shell_network_monitor (DBusConnection *connection G_GNUC_UNUSED,
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- line_status = e_shell_get_line_status (shell);
-
- if (line_status == E_SHELL_LINE_STATUS_ONLINE && (state == NM_STATE_ASLEEP || state == NM_STATE_DISCONNECTED)) {
- shell_state = GNOME_Evolution_FORCED_OFFLINE;
- e_shell_set_line_status (shell, shell_state);
- } else if (line_status == E_SHELL_LINE_STATUS_FORCED_OFFLINE && state == NM_STATE_CONNECTED) {
- shell_state = GNOME_Evolution_USER_ONLINE;
- e_shell_set_line_status (shell, shell_state);
+ switch (state) {
+ case NM_STATE_CONNECTED:
+ e_shell_set_network_available (shell, TRUE);
+ break;
+ case NM_STATE_ASLEEP:
+ case NM_STATE_DISCONNECTED:
+ e_shell_set_network_available (shell, FALSE);
+ break;
+ default:
+ break;
}
return DBUS_HANDLER_RESULT_HANDLED;
}
gboolean
-e_shell_dbus_initialise (EShell *shell)
+e_shell_dbus_initialize (EShell *shell)
{
DBusError error = DBUS_ERROR_INIT;
+ g_return_val_if_fail (E_IS_SHELL (shell), FALSE);
+
if (dbus_connection != NULL)
return TRUE;
diff --git a/shell/e-shell-settings-dialog.c b/shell/e-shell-settings-dialog.c
deleted file mode 100644
index 11b8ad7719..0000000000
--- a/shell/e-shell-settings-dialog.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib/gi18n.h>
-
-#include "e-shell-settings-dialog.h"
-
-#include "e-corba-config-page.h"
-#include <e-util/e-icon-factory.h>
-
-#include <bonobo/bonobo-widget.h>
-#include <bonobo/bonobo-exception.h>
-
-#include <bonobo-activation/bonobo-activation.h>
-
-#include <stdlib.h>
-#include <string.h>
-
-struct _EShellSettingsDialogPrivate {
- GHashTable *types;
-};
-
-G_DEFINE_TYPE (EShellSettingsDialog, e_shell_settings_dialog, E_TYPE_MULTI_CONFIG_DIALOG)
-
-
-/* FIXME ugly hack to work around that sizing of invisible widgets is broken
- with Bonobo. */
-
-static void
-set_dialog_size (EShellSettingsDialog *dialog)
-{
- PangoLayout *layout;
- PangoContext *context;
- PangoFontMetrics *metrics;
- int width, height;
-
- layout = gtk_widget_create_pango_layout (GTK_WIDGET (dialog), "M");
- context = pango_layout_get_context (layout);
- metrics = pango_context_get_metrics (context,
- gtk_widget_get_style (GTK_WIDGET (dialog))->font_desc,
- pango_context_get_language (context));
-
- pango_layout_get_pixel_size (layout, &width, NULL);
-
- width *= 60;
- height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics)
- + pango_font_metrics_get_descent (metrics)) * 30;
-
- gtk_window_set_default_size((GtkWindow *)dialog, width, height);
- g_object_unref (layout);
- pango_font_metrics_unref (metrics);
-}
-
-
-/* Page handling. */
-
-struct _Page {
- char *title;
- char *description;
- GdkPixbuf *icon;
- Bonobo_ActivationProperty *type;
- int priority;
- EConfigPage *page_widget;
-};
-typedef struct _Page Page;
-
-static Page *
-page_new (const char *title,
- const char *description,
- GdkPixbuf *icon,
- Bonobo_ActivationProperty *type,
- int priority,
- EConfigPage *page_widget)
-{
- Page *page;
-
- if (icon != NULL)
- g_object_ref (icon);
-
- page = g_new (Page, 1);
- page->title = g_strdup (title);
- page->description = g_strdup (description);
- page->icon = icon;
- page->type = type;
- page->priority = priority;
- page->page_widget = page_widget;
-
- return page;
-}
-
-static void
-page_free (Page *page)
-{
- g_free (page->title);
- g_free (page->description);
-
- if (page->icon != NULL)
- g_object_unref (page->icon);
-
- g_free (page);
-}
-
-static int
-compare_page_func (const void *a,
- const void *b)
-{
- const Page *page_a;
- const Page *page_b;
-
- page_a = (const Page *) a;
- page_b = (const Page *) b;
-
- if (page_a->priority == page_b->priority)
- return strcmp (page_a->title, page_b->title);
-
- return page_a->priority - page_b->priority;
-}
-
-static GList *
-sort_page_list (GList *list)
-{
- return g_list_sort (list, compare_page_func);
-}
-
-static void
-load_pages (EShellSettingsDialog *dialog)
-{
- EShellSettingsDialogPrivate *priv;
- Bonobo_ServerInfoList *control_list;
- const gchar * const *language_names;
- CORBA_Environment ev;
- GSList *languages = NULL;
- GList *page_list;
- GList *p;
- int i, j;
-
- priv = dialog->priv;
-
- CORBA_exception_init (&ev);
-
- control_list = bonobo_activation_query ("repo_ids.has('IDL:GNOME/Evolution/ConfigControl:" BASE_VERSION "')", NULL, &ev);
- if (ev._major != CORBA_NO_EXCEPTION || control_list == NULL) {
- g_warning ("Cannot load configuration pages -- %s", BONOBO_EX_REPOID (&ev));
- CORBA_exception_free (&ev);
- return;
- }
-
- CORBA_exception_free (&ev);
-
- language_names = g_get_language_names ();
- while (*language_names != NULL)
- languages = g_slist_append (languages, (gpointer)(*language_names++));
-
- page_list = NULL;
- for (i = 0; i < control_list->_length; i ++) {
- CORBA_Object corba_object;
- Bonobo_ServerInfo *info;
- const char *title;
- const char *description;
- const char *icon_path;
- const char *priority_string;
- Bonobo_ActivationProperty *type;
- int priority;
- GdkPixbuf *icon;
-
- CORBA_exception_init (&ev);
-
- info = & control_list->_buffer[i];
-
- title = bonobo_server_info_prop_lookup (info, "evolution2:config_item:title", languages);
- description = bonobo_server_info_prop_lookup (info, "evolution2:config_item:description", languages);
- icon_path = bonobo_server_info_prop_lookup (info, "evolution2:config_item:icon_name", NULL);
- type = bonobo_server_info_prop_find (info, "evolution2:config_item:type");
- priority_string = bonobo_server_info_prop_lookup (info, "evolution2:config_item:priority", NULL);
-
- if (icon_path == NULL) {
- icon = NULL;
- } else {
- if (g_path_is_absolute (icon_path)) {
- icon = gdk_pixbuf_new_from_file (icon_path, NULL);
- } else {
- icon = e_icon_factory_get_icon (icon_path, E_ICON_SIZE_DIALOG);
- }
- }
-
- if (type != NULL && type->v._d != Bonobo_ACTIVATION_P_STRINGV)
- type = NULL;
- if (priority_string == NULL)
- priority = 0xffff;
- else
- priority = atoi (priority_string);
-
- corba_object = bonobo_activation_activate_from_id ((char *) info->iid, 0, NULL, &ev);
-
- if (! BONOBO_EX (&ev)) {
- Page *page;
-
- page = page_new (title, description, icon, type, priority,
- E_CONFIG_PAGE (e_corba_config_page_new_from_objref (corba_object)));
-
- page_list = g_list_prepend (page_list, page);
- } else {
- char *bonobo_ex_text = bonobo_exception_get_text (&ev);
- g_warning ("Cannot activate %s -- %s", info->iid, bonobo_ex_text);
- g_free (bonobo_ex_text);
- }
-
- if (icon != NULL)
- g_object_unref (icon);
-
- CORBA_exception_free (&ev);
- }
- g_slist_free(languages);
-
- page_list = sort_page_list (page_list);
- for (p = page_list, i = 0; p != NULL; p = p->next, i++) {
- Page *page;
-
- page = (Page *) p->data;
-
- e_multi_config_dialog_add_page (E_MULTI_CONFIG_DIALOG (dialog),
- page->title,
- page->description,
- page->icon,
- page->page_widget);
-
- if (page->type != NULL) {
- Bonobo_StringList list = page->type->v._u.value_stringv;
-
- for (j = 0; j < list._length; j++) {
- if (g_hash_table_lookup (priv->types, list._buffer[j]) == NULL)
- g_hash_table_insert (priv->types, g_strdup (list._buffer[j]),
- GINT_TO_POINTER (i));
- }
- }
-
-
- page_free (page);
- }
-
- g_list_free (page_list);
- CORBA_free (control_list);
-}
-
-
-/* GtkObject methods. */
-
-static void
-impl_finalize (GObject *object)
-{
- EShellSettingsDialog *dialog;
- EShellSettingsDialogPrivate *priv;
-
- dialog = E_SHELL_SETTINGS_DIALOG (object);
- priv = dialog->priv;
-
- g_hash_table_destroy (priv->types);
-
- g_free (priv);
-
- (* G_OBJECT_CLASS (e_shell_settings_dialog_parent_class)->finalize) (object);
-}
-
-
-static void
-e_shell_settings_dialog_class_init (EShellSettingsDialogClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = impl_finalize;
-}
-
-static void
-e_shell_settings_dialog_init (EShellSettingsDialog *dialog)
-{
- EShellSettingsDialogPrivate *priv;
-
- priv = g_new (EShellSettingsDialogPrivate, 1);
- priv->types = g_hash_table_new_full (
- g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) NULL);
-
- dialog->priv = priv;
-
- load_pages (dialog);
- set_dialog_size (dialog);
-
- gtk_window_set_title (GTK_WINDOW (dialog), _("Evolution Preferences"));
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
-}
-
-
-GtkWidget *
-e_shell_settings_dialog_new (void)
-{
- EShellSettingsDialog *new;
-
- new = g_object_new (e_shell_settings_dialog_get_type (), NULL);
-
- return GTK_WIDGET (new);
-}
-
-void
-e_shell_settings_dialog_show_type (EShellSettingsDialog *dialog, const char *type)
-{
- EShellSettingsDialogPrivate *priv;
- gpointer key, value;
- int page;
-
- g_return_if_fail (dialog != NULL);
- g_return_if_fail (E_IS_SHELL_SETTINGS_DIALOG (dialog));
- g_return_if_fail (type != NULL);
-
- priv = dialog->priv;
-
- if (!g_hash_table_lookup_extended (priv->types, type, &key, &value)) {
- char *slash, *supertype;
-
- slash = strchr (type, '/');
- if (slash) {
- supertype = g_strndup (type, slash - type);
- value = g_hash_table_lookup (priv->types, type);
- g_free (supertype);
- } else
- value = NULL;
- }
- page = GPOINTER_TO_INT (value);
-
- e_multi_config_dialog_show_page (E_MULTI_CONFIG_DIALOG (dialog), page);
-}
-
-
diff --git a/shell/e-shell-settings-dialog.h b/shell/e-shell-settings-dialog.h
deleted file mode 100644
index 90c09627e2..0000000000
--- a/shell/e-shell-settings-dialog.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_SHELL_SETTINGS_DIALOG_H_
-#define _E_SHELL_SETTINGS_DIALOG_H_
-
-#include "e-multi-config-dialog.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#define E_TYPE_SHELL_SETTINGS_DIALOG (e_shell_settings_dialog_get_type ())
-#define E_SHELL_SETTINGS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SHELL_SETTINGS_DIALOG, EShellSettingsDialog))
-#define E_SHELL_SETTINGS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SHELL_SETTINGS_DIALOG, EShellSettingsDialogClass))
-#define E_IS_SHELL_SETTINGS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SHELL_SETTINGS_DIALOG))
-#define E_IS_SHELL_SETTINGS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SHELL_SETTINGS_DIALOG))
-
-
-typedef struct _EShellSettingsDialog EShellSettingsDialog;
-typedef struct _EShellSettingsDialogPrivate EShellSettingsDialogPrivate;
-typedef struct _EShellSettingsDialogClass EShellSettingsDialogClass;
-
-struct _EShellSettingsDialog {
- EMultiConfigDialog parent;
-
- EShellSettingsDialogPrivate *priv;
-};
-
-struct _EShellSettingsDialogClass {
- EMultiConfigDialogClass parent_class;
-};
-
-
-GType e_shell_settings_dialog_get_type (void);
-GtkWidget *e_shell_settings_dialog_new (void);
-void e_shell_settings_dialog_show_type (EShellSettingsDialog *dialog,
- const char *type);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_SHELL_SETTINGS_DIALOG_H_ */
diff --git a/shell/e-shell-settings.c b/shell/e-shell-settings.c
new file mode 100644
index 0000000000..23dd866bf8
--- /dev/null
+++ b/shell/e-shell-settings.c
@@ -0,0 +1,559 @@
+/*
+ * e-shell-settings.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-shell-settings.h"
+
+#include "e-util/gconf-bridge.h"
+
+#define E_SHELL_SETTINGS_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SHELL_SETTINGS, EShellSettingsPrivate))
+
+struct _EShellSettingsPrivate {
+ GArray *value_array;
+ guint debug : 1;
+};
+
+static GList *instances;
+static guint property_count;
+static gpointer parent_class;
+
+static void
+shell_settings_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EShellSettingsPrivate *priv;
+ GValue *dest_value;
+
+ priv = E_SHELL_SETTINGS_GET_PRIVATE (object);
+
+ dest_value = &g_array_index (
+ priv->value_array, GValue, property_id - 1);
+
+ g_value_copy (value, dest_value);
+ g_object_notify (object, pspec->name);
+
+ if (priv->debug) {
+ gchar *contents;
+
+ contents = g_strdup_value_contents (value);
+ g_debug (
+ "Setting '%s' set to '%s' (%s)",
+ pspec->name, contents, G_VALUE_TYPE_NAME (value));
+ g_free (contents);
+ }
+}
+
+static void
+shell_settings_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EShellSettingsPrivate *priv;
+ GValue *src_value;
+
+ priv = E_SHELL_SETTINGS_GET_PRIVATE (object);
+
+ src_value = &g_array_index (
+ priv->value_array, GValue, property_id - 1);
+
+ g_value_copy (src_value, value);
+}
+
+static void
+shell_settings_finalize (GObject *object)
+{
+ EShellSettingsPrivate *priv;
+ guint ii;
+
+ priv = E_SHELL_SETTINGS_GET_PRIVATE (object);
+
+ for (ii = 0; ii < priv->value_array->len; ii++)
+ g_value_unset (&g_array_index (priv->value_array, GValue, ii));
+
+ g_array_free (priv->value_array, TRUE);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+shell_settings_class_init (EShellSettingsClass *class)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EShellSettingsPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = shell_settings_set_property;
+ object_class->get_property = shell_settings_get_property;
+ object_class->finalize = shell_settings_finalize;
+}
+
+static void
+shell_settings_init (EShellSettings *shell_settings,
+ GObjectClass *object_class)
+{
+ GArray *value_array;
+ GParamSpec **pspecs;
+ guint ii;
+
+ instances = g_list_prepend (instances, shell_settings);
+
+ value_array = g_array_new (FALSE, TRUE, sizeof (GValue));
+ g_array_set_size (value_array, property_count);
+
+ shell_settings->priv = E_SHELL_SETTINGS_GET_PRIVATE (shell_settings);
+ shell_settings->priv->value_array = value_array;
+
+ g_object_freeze_notify (G_OBJECT (shell_settings));
+
+ pspecs = g_object_class_list_properties (object_class, NULL);
+ for (ii = 0; ii < property_count; ii++) {
+ GParamSpec *pspec = pspecs[ii];
+ GValue *value;
+
+ value = &g_array_index (value_array, GValue, ii);
+ g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ g_param_value_set_default (pspec, value);
+ g_object_notify (G_OBJECT (shell_settings), pspec->name);
+ }
+ g_free (pspecs);
+
+ g_object_thaw_notify (G_OBJECT (shell_settings));
+}
+
+GType
+e_shell_settings_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo type_info = {
+ sizeof (EShellSettingsClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) shell_settings_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EShellSettings),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) shell_settings_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ G_TYPE_OBJECT, "EShellSettings", &type_info, 0);
+ }
+
+ return type;
+}
+
+/**
+ * e_shell_settings_install_property:
+ * @pspec: a #GParamSpec
+ *
+ * Installs a new class property for #EShellSettings. This is usually
+ * done during initialization of a #EShellModule or plugin, followed by
+ * a call to e_shell_settings_bind_to_gconf() to bind the property to a
+ * GConf key.
+ **/
+void
+e_shell_settings_install_property (GParamSpec *pspec)
+{
+ static GObjectClass *class = NULL;
+ GList *iter, *next;
+
+ g_return_if_fail (G_IS_PARAM_SPEC (pspec));
+
+ if (G_UNLIKELY (class == NULL))
+ class = g_type_class_ref (E_TYPE_SHELL_SETTINGS);
+
+ if (g_object_class_find_property (class, pspec->name) != NULL) {
+ g_warning (
+ "Settings property \"%s\" already exists",
+ pspec->name);
+ return;
+ }
+
+ for (iter = instances; iter != NULL; iter = iter->next)
+ g_object_freeze_notify (iter->data);
+
+ g_object_class_install_property (class, ++property_count, pspec);
+
+ for (iter = instances; iter != NULL; iter = iter->next) {
+ EShellSettings *shell_settings = iter->data;
+ GArray *value_array;
+ GValue *value;
+
+ value_array = shell_settings->priv->value_array;
+ g_array_set_size (value_array, property_count);
+
+ value = &g_array_index (
+ value_array, GValue, property_count - 1);
+ g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ g_param_value_set_default (pspec, value);
+ g_object_notify (G_OBJECT (shell_settings), pspec->name);
+ }
+
+ for (iter = instances; iter != NULL; iter = next) {
+ next = iter->next;
+ g_object_thaw_notify (iter->data);
+ }
+}
+
+/**
+ * e_shell_settings_bind_to_gconf:
+ * @shell_settings: an #EShellSettings
+ * @property_name: the name of the property to bind
+ * @gconf_key: the GConf key to bind the property to
+ *
+ * Binds @property_name to @gconf_key, causing them to have the same value
+ * at all times.
+ *
+ * The types of @property_name and @gconf_key should be compatible. Floats
+ * and doubles, and ints, uints, longs, unlongs, int64s, uint64s, chars,
+ * uchars and enums can be matched up. Booleans and strings can only be
+ * matched to their respective types.
+ *
+ * On calling this function, @property_name is initialized to the current
+ * value of @gconf_key.
+ **/
+void
+e_shell_settings_bind_to_gconf (EShellSettings *shell_settings,
+ const gchar *property_name,
+ const gchar *gconf_key)
+{
+ g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
+ g_return_if_fail (property_name != NULL);
+ g_return_if_fail (gconf_key != NULL);
+
+ gconf_bridge_bind_property (
+ gconf_bridge_get (), gconf_key,
+ G_OBJECT (shell_settings), property_name);
+}
+
+/**
+ * e_shell_settings_enable_debug:
+ * @shell_settings: an #EShellSettings
+ *
+ * Print a debug message to standard output when a property value changes.
+ **/
+void
+e_shell_settings_enable_debug (EShellSettings *shell_settings)
+{
+ g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
+
+ shell_settings->priv->debug = TRUE;
+}
+
+/**
+ * e_shell_settings_get_boolean:
+ * @shell_settings: an #EShellSettings
+ * @property_name: an installed property name
+ *
+ * Return the contents of an #EShellSettings property of type
+ * #G_TYPE_BOOLEAN.
+ *
+ * Returns: boolean contents of @property_name
+ **/
+gboolean
+e_shell_settings_get_boolean (EShellSettings *shell_settings,
+ const gchar *property_name)
+{
+ GObject *object;
+ GValue value = { 0, };
+ gboolean v_boolean;
+
+ g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), FALSE);
+ g_return_val_if_fail (property_name != NULL, FALSE);
+
+ object = G_OBJECT (shell_settings);
+ g_value_init (&value, G_TYPE_BOOLEAN);
+ g_object_get_property (object, property_name, &value);
+ v_boolean = g_value_get_boolean (&value);
+ g_value_unset (&value);
+
+ return v_boolean;
+}
+
+/**
+ * e_shell_settings_set_boolean:
+ * @shell_settings: an #EShellSettings
+ * @property_name: an installed property name
+ * @v_boolean: boolean value to be set
+ *
+ * Sets the contents of an #EShellSettings property of type #G_TYPE_BOOLEAN
+ * to @v_boolean. If @property_name is bound to a GConf key, the GConf key
+ * will also be set to @v_boolean.
+ **/
+void
+e_shell_settings_set_boolean (EShellSettings *shell_settings,
+ const gchar *property_name,
+ gboolean v_boolean)
+{
+ GObject *object;
+ GValue value = { 0, };
+
+ g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
+ g_return_if_fail (property_name != NULL);
+
+ object = G_OBJECT (shell_settings);
+ g_value_init (&value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&value, v_boolean);
+ g_object_set_property (object, property_name, &value);
+ g_value_unset (&value);
+}
+
+/**
+ * e_shell_settings_get_int:
+ * @shell_settings: an #EShellSettings
+ * @property_name: an installed property name
+ *
+ * Returns the contents of an #EShellSettings property of type
+ * #G_TYPE_INT.
+ *
+ * Returns: integer contents of @property_name
+ **/
+gint
+e_shell_settings_get_int (EShellSettings *shell_settings,
+ const gchar *property_name)
+{
+ GObject *object;
+ GValue value = { 0, };
+ gint v_int;
+
+ g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), 0);
+ g_return_val_if_fail (property_name != NULL, 0);
+
+ object = G_OBJECT (shell_settings);
+ g_value_init (&value, G_TYPE_INT);
+ g_object_get_property (object, property_name, &value);
+ v_int = g_value_get_int (&value);
+ g_value_unset (&value);
+
+ return v_int;
+}
+
+/**
+ * e_shell_settings_set_int:
+ * @shell_settings: an #EShellSettings
+ * @property_name: an installed property name
+ * @v_int: integer value to be set
+ *
+ * Sets the contents of an #EShellSettings property of type #G_TYPE_INT
+ * to @v_int. If @property_name is bound to a GConf key, the GConf key
+ * will also be set to @v_int.
+ **/
+void
+e_shell_settings_set_int (EShellSettings *shell_settings,
+ const gchar *property_name,
+ gint v_int)
+{
+ GObject *object;
+ GValue value = { 0, };
+
+ g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
+ g_return_if_fail (property_name != NULL);
+
+ object = G_OBJECT (shell_settings);
+ g_value_init (&value, G_TYPE_INT);
+ g_value_set_int (&value, v_int);
+ g_object_set_property (object, property_name, &value);
+ g_value_unset (&value);
+}
+
+/**
+ * e_shell_settings_get_string:
+ * @shell_settings: an #EShellSettings
+ * @property_name: an installed property name
+ *
+ * Returns the contents of an #EShellSettings property of type
+ * #G_TYPE_STRING. The returned string should be freed using g_free().
+ *
+ * Returns: string contents of @property_name
+ **/
+gchar *
+e_shell_settings_get_string (EShellSettings *shell_settings,
+ const gchar *property_name)
+{
+ GObject *object;
+ GValue value = { 0, };
+ gchar *v_string;
+
+ g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), NULL);
+ g_return_val_if_fail (property_name != NULL, NULL);
+
+ object = G_OBJECT (shell_settings);
+ g_value_init (&value, G_TYPE_STRING);
+ g_object_get_property (object, property_name, &value);
+ v_string = g_value_dup_string (&value);
+ g_value_unset (&value);
+
+ return v_string;
+}
+
+/**
+ * e_shell_settings_set_string:
+ * @shell_settings: an #EShellSettings
+ * @property_name: an installed property name
+ * @v_string: string to be set
+ *
+ * Sets the contents of an #EShellSettings property of type #G_TYPE_STRING
+ * to @v_string. If @property_name is bound to a GConf key, the GConf key
+ * will also be set to @v_string.
+ **/
+void
+e_shell_settings_set_string (EShellSettings *shell_settings,
+ const gchar *property_name,
+ const gchar *v_string)
+{
+ GObject *object;
+ GValue value = { 0, };
+
+ g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
+ g_return_if_fail (property_name != NULL);
+
+ object = G_OBJECT (shell_settings);
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, v_string);
+ g_object_set_property (object, property_name, &value);
+ g_value_unset (&value);
+}
+
+/**
+ * e_shell_settings_get_object:
+ * @shell_settings: an #EShellSettings
+ * @property_name: an installed property name
+ *
+ * Returns the contents of an #EShellSettings property of type
+ * #G_TYPE_OBJECT. The caller owns the reference to the returned
+ * object, and should call g_object_unref() when finished with it.
+ *
+ * Returns: a new reference to the object under @property_name
+ **/
+gpointer
+e_shell_settings_get_object (EShellSettings *shell_settings,
+ const gchar *property_name)
+{
+ GObject *object;
+ GValue value = { 0, };
+ gpointer v_object;
+
+ g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), NULL);
+ g_return_val_if_fail (property_name != NULL, NULL);
+
+ object = G_OBJECT (shell_settings);
+ g_value_init (&value, G_TYPE_OBJECT);
+ g_object_get_property (object, property_name, &value);
+ v_object = g_value_dup_object (&value);
+ g_value_unset (&value);
+
+ return v_object;
+}
+
+/**
+ * e_shell_settings_set_object:
+ * @shell_settings: an #EShellSettings
+ * @property_name: an installed property name
+ * @v_object: object to be set
+ *
+ * Sets the contents of an #EShellSettings property of type #G_TYPE_OBJECT
+ * to @v_object.
+ **/
+void
+e_shell_settings_set_object (EShellSettings *shell_settings,
+ const gchar *property_name,
+ gpointer v_object)
+{
+ GObject *object;
+ GValue value = { 0, };
+
+ g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
+ g_return_if_fail (property_name != NULL);
+
+ object = G_OBJECT (shell_settings);
+ g_value_init (&value, G_TYPE_OBJECT);
+ g_value_set_object (&value, v_object);
+ g_object_set_property (object, property_name, &value);
+ g_value_unset (&value);
+}
+
+/**
+ * e_shell_settings_get_pointer:
+ * @shell_settings: an #EShellSettings
+ * @property_name: an installed property name
+ *
+ * Returns the contents of an #EShellSettings property of type
+ * #G_TYPE_POINTER.
+ *
+ * Returns: pointer contents of @property_name
+ **/
+gpointer
+e_shell_settings_get_pointer (EShellSettings *shell_settings,
+ const gchar *property_name)
+{
+ GObject *object;
+ GValue value = { 0, };
+ gpointer v_pointer;
+
+ g_return_val_if_fail (E_IS_SHELL_SETTINGS (shell_settings), NULL);
+ g_return_val_if_fail (property_name != NULL, NULL);
+
+ object = G_OBJECT (shell_settings);
+ g_value_init (&value, G_TYPE_POINTER);
+ g_object_get_property (object, property_name, &value);
+ v_pointer = g_value_get_pointer (&value);
+ g_value_unset (&value);
+
+ return v_pointer;
+}
+
+/**
+ * e_shell_settings_set_pointer:
+ * @shell_settings: an #EShellSettings
+ * @property_name: an installed property name
+ * @v_pointer: pointer to be set
+ *
+ * Sets the contents of an #EShellSettings property of type #G_TYPE_POINTER
+ * to @v_pointer.
+ **/
+void
+e_shell_settings_set_pointer (EShellSettings *shell_settings,
+ const gchar *property_name,
+ gpointer v_pointer)
+{
+ GObject *object;
+ GValue value = { 0, };
+
+ g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
+ g_return_if_fail (property_name != NULL);
+
+ object = G_OBJECT (shell_settings);
+ g_value_init (&value, G_TYPE_POINTER);
+ g_value_set_pointer (&value, v_pointer);
+ g_object_set_property (object, property_name, &value);
+ g_value_unset (&value);
+}
diff --git a/shell/e-shell-settings.h b/shell/e-shell-settings.h
new file mode 100644
index 0000000000..a9f6a20f93
--- /dev/null
+++ b/shell/e-shell-settings.h
@@ -0,0 +1,114 @@
+/*
+ * e-shell-settings.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+/**
+ * SECTION: e-shell-settings
+ * @short_description: settings management
+ * @include: shell/e-shell-settings.h
+ **/
+
+#ifndef E_SHELL_SETTINGS_H
+#define E_SHELL_SETTINGS_H
+
+#include <shell/e-shell-common.h>
+
+/* Standard GObject macros */
+#define E_TYPE_SHELL_SETTINGS \
+ (e_shell_settings_get_type ())
+#define E_SHELL_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_SHELL_SETTINGS, EShellSettings))
+#define E_SHELL_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_SHELL_SETTINGS, EShellSettingsClass))
+#define E_IS_SHELL_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_SHELL_SETTINGS))
+#define E_IS_SHELL_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_SHELL_SETTINGS))
+#define E_SHELL_SETTINGS_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_SHELL_SETTINGS, EShellSettingsClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EShellSettings EShellSettings;
+typedef struct _EShellSettingsClass EShellSettingsClass;
+typedef struct _EShellSettingsPrivate EShellSettingsPrivate;
+
+/**
+ * EShellSettings:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ **/
+struct _EShellSettings {
+ GObject parent;
+ EShellSettingsPrivate *priv;
+};
+
+struct _EShellSettingsClass {
+ GObjectClass parent_class;
+};
+
+GType e_shell_settings_get_type (void);
+void e_shell_settings_install_property
+ (GParamSpec *pspec);
+void e_shell_settings_bind_to_gconf (EShellSettings *shell_settings,
+ const gchar *property_name,
+ const gchar *gconf_key);
+void e_shell_settings_enable_debug (EShellSettings *shell_settings);
+
+/* Getters and setters for common EShellSettings property types.
+ * These are more convenient than g_object_get() / g_object_set().
+ * Add more types as needed. If GObject ever adds similar functions,
+ * kill these. */
+
+gboolean e_shell_settings_get_boolean (EShellSettings *shell_settings,
+ const gchar *property_name);
+void e_shell_settings_set_boolean (EShellSettings *shell_settings,
+ const gchar *property_name,
+ gboolean v_boolean);
+gint e_shell_settings_get_int (EShellSettings *shell_settings,
+ const gchar *property_name);
+void e_shell_settings_set_int (EShellSettings *shell_settings,
+ const gchar *property_name,
+ gint v_int);
+gchar * e_shell_settings_get_string (EShellSettings *shell_settings,
+ const gchar *property_name);
+void e_shell_settings_set_string (EShellSettings *shell_settings,
+ const gchar *property_name,
+ const gchar *v_string);
+gpointer e_shell_settings_get_object (EShellSettings *shell_settings,
+ const gchar *property_name);
+void e_shell_settings_set_object (EShellSettings *shell_settings,
+ const gchar *property_name,
+ gpointer v_object);
+gpointer e_shell_settings_get_pointer (EShellSettings *shell_setting,
+ const gchar *property_name);
+void e_shell_settings_set_pointer (EShellSettings *shell_setting,
+ const gchar *property_name,
+ gpointer v_pointer);
+
+G_END_DECLS
+
+#endif /* E_SHELL_SETTINGS_H */
diff --git a/shell/e-shell-sidebar.c b/shell/e-shell-sidebar.c
new file mode 100644
index 0000000000..671bcad9a0
--- /dev/null
+++ b/shell/e-shell-sidebar.c
@@ -0,0 +1,681 @@
+/*
+ * e-shell-sidebar.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-shell-sidebar.h"
+
+#include <e-shell-view.h>
+
+#define E_SHELL_SIDEBAR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SHELL_SIDEBAR, EShellSidebarPrivate))
+
+struct _EShellSidebarPrivate {
+
+ gpointer shell_view; /* weak pointer */
+
+ GtkWidget *event_box;
+ GtkWidget *image;
+ GtkWidget *primary_label;
+ GtkWidget *secondary_label;
+ gchar *primary_text;
+ gchar *secondary_text;
+};
+
+enum {
+ PROP_0,
+ PROP_ICON_NAME,
+ PROP_PRIMARY_TEXT,
+ PROP_SECONDARY_TEXT,
+ PROP_SHELL_VIEW
+};
+
+static gpointer parent_class;
+
+static void
+shell_sidebar_set_shell_view (EShellSidebar *shell_sidebar,
+ EShellView *shell_view)
+{
+ g_return_if_fail (shell_sidebar->priv->shell_view == NULL);
+
+ shell_sidebar->priv->shell_view = shell_view;
+
+ g_object_add_weak_pointer (
+ G_OBJECT (shell_view),
+ &shell_sidebar->priv->shell_view);
+}
+
+static void
+shell_sidebar_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_ICON_NAME:
+ e_shell_sidebar_set_icon_name (
+ E_SHELL_SIDEBAR (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_PRIMARY_TEXT:
+ e_shell_sidebar_set_primary_text (
+ E_SHELL_SIDEBAR (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_SECONDARY_TEXT:
+ e_shell_sidebar_set_secondary_text (
+ E_SHELL_SIDEBAR (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_SHELL_VIEW:
+ shell_sidebar_set_shell_view (
+ E_SHELL_SIDEBAR (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+shell_sidebar_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_ICON_NAME:
+ g_value_set_string (
+ value, e_shell_sidebar_get_icon_name (
+ E_SHELL_SIDEBAR (object)));
+ return;
+
+ case PROP_PRIMARY_TEXT:
+ g_value_set_string (
+ value, e_shell_sidebar_get_primary_text (
+ E_SHELL_SIDEBAR (object)));
+ return;
+
+ case PROP_SECONDARY_TEXT:
+ g_value_set_string (
+ value, e_shell_sidebar_get_secondary_text (
+ E_SHELL_SIDEBAR (object)));
+ return;
+
+ case PROP_SHELL_VIEW:
+ g_value_set_object (
+ value, e_shell_sidebar_get_shell_view (
+ E_SHELL_SIDEBAR (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+shell_sidebar_dispose (GObject *object)
+{
+ EShellSidebarPrivate *priv;
+
+ priv = E_SHELL_SIDEBAR_GET_PRIVATE (object);
+
+ if (priv->shell_view != NULL) {
+ g_object_remove_weak_pointer (
+ G_OBJECT (priv->shell_view), &priv->shell_view);
+ priv->shell_view = NULL;
+ }
+
+ if (priv->image != NULL) {
+ g_object_unref (priv->image);
+ priv->image = NULL;
+ }
+
+ if (priv->event_box != NULL) {
+ g_object_unref (priv->event_box);
+ priv->event_box = NULL;
+ }
+
+ if (priv->primary_label != NULL) {
+ g_object_unref (priv->primary_label);
+ priv->primary_label = NULL;
+ }
+
+ if (priv->secondary_label != NULL) {
+ g_object_unref (priv->secondary_label);
+ priv->secondary_label = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+shell_sidebar_finalize (GObject *object)
+{
+ EShellSidebarPrivate *priv;
+
+ priv = E_SHELL_SIDEBAR_GET_PRIVATE (object);
+
+ g_free (priv->primary_text);
+ g_free (priv->secondary_text);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+shell_sidebar_constructed (GObject *object)
+{
+ EShellView *shell_view;
+ EShellSidebar *shell_sidebar;
+ GtkSizeGroup *size_group;
+ GtkAction *action;
+ GtkWidget *container;
+ GtkWidget *widget;
+ gchar *label;
+ gchar *icon_name;
+
+ shell_sidebar = E_SHELL_SIDEBAR (object);
+ shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
+ size_group = e_shell_view_get_size_group (shell_view);
+ action = e_shell_view_get_action (shell_view);
+
+ widget = shell_sidebar->priv->event_box;
+ gtk_size_group_add_widget (size_group, widget);
+
+ container = widget;
+
+ widget = gtk_hbox_new (FALSE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (widget), 6);
+ gtk_container_add (GTK_CONTAINER (container), widget);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = gtk_image_new ();
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ shell_sidebar->priv->image = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ widget = gtk_label_new (NULL);
+ gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ shell_sidebar->priv->primary_label = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ widget = gtk_label_new (NULL);
+ gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ shell_sidebar->priv->secondary_label = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ g_object_get (action, "icon-name", &icon_name, NULL);
+ e_shell_sidebar_set_icon_name (shell_sidebar, icon_name);
+ g_free (icon_name);
+
+ g_object_get (action, "label", &label, NULL);
+ e_shell_sidebar_set_primary_text (shell_sidebar, label);
+ g_free (label);
+}
+
+static void
+shell_sidebar_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ EShellSidebarPrivate *priv;
+ GtkRequisition child_requisition;
+ GtkWidget *child;
+
+ priv = E_SHELL_SIDEBAR_GET_PRIVATE (widget);
+
+ requisition->width = 0;
+ requisition->height = 0;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ gtk_widget_size_request (child, requisition);
+
+ child = priv->event_box;
+ gtk_widget_size_request (child, &child_requisition);
+ requisition->width = MAX (requisition->width, child_requisition.width);
+ requisition->height += child_requisition.height;
+}
+
+static void
+shell_sidebar_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ EShellSidebarPrivate *priv;
+ GtkAllocation child_allocation;
+ GtkRequisition child_requisition;
+ GtkWidget *child;
+
+ priv = E_SHELL_SIDEBAR_GET_PRIVATE (widget);
+
+ widget->allocation = *allocation;
+
+ child = priv->event_box;
+ gtk_widget_size_request (child, &child_requisition);
+
+ child_allocation.x = allocation->x;
+ child_allocation.y = allocation->y;
+ child_allocation.width = allocation->width;
+ child_allocation.height = child_requisition.height;
+
+ gtk_widget_size_allocate (child, &child_allocation);
+
+ child_allocation.y += child_requisition.height;
+ child_allocation.height =
+ allocation->height - child_requisition.height;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (child != NULL)
+ gtk_widget_size_allocate (child, &child_allocation);
+}
+
+static void
+shell_sidebar_remove (GtkContainer *container,
+ GtkWidget *widget)
+{
+ EShellSidebarPrivate *priv;
+
+ priv = E_SHELL_SIDEBAR_GET_PRIVATE (container);
+
+ /* Look in the internal widgets first. */
+
+ if (widget == priv->event_box) {
+ gtk_widget_unparent (priv->event_box);
+ gtk_widget_queue_resize (GTK_WIDGET (container));
+ return;
+ }
+
+ /* Chain up to parent's remove() method. */
+ GTK_CONTAINER_CLASS (parent_class)->remove (container, widget);
+}
+
+static void
+shell_sidebar_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data)
+{
+ EShellSidebarPrivate *priv;
+
+ priv = E_SHELL_SIDEBAR_GET_PRIVATE (container);
+
+ if (include_internals)
+ callback (priv->event_box, callback_data);
+
+ /* Chain up to parent's forall() method. */
+ GTK_CONTAINER_CLASS (parent_class)->forall (
+ container, include_internals, callback, callback_data);
+}
+
+static void
+shell_sidebar_class_init (EShellSidebarClass *class)
+{
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+ GtkContainerClass *container_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EShellSidebarPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = shell_sidebar_set_property;
+ object_class->get_property = shell_sidebar_get_property;
+ object_class->dispose = shell_sidebar_dispose;
+ object_class->finalize = shell_sidebar_finalize;
+ object_class->constructed = shell_sidebar_constructed;
+
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->size_request = shell_sidebar_size_request;
+ widget_class->size_allocate = shell_sidebar_size_allocate;
+
+ container_class = GTK_CONTAINER_CLASS (class);
+ container_class->remove = shell_sidebar_remove;
+ container_class->forall = shell_sidebar_forall;
+
+ /**
+ * EShellSidebar:icon-name
+ *
+ * The named icon is displayed at the top of the sidebar.
+ */
+ g_object_class_install_property (
+ object_class,
+ PROP_ICON_NAME,
+ g_param_spec_string (
+ "icon-name",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+
+ /**
+ * EShellSidebar:primary-text
+ *
+ * The primary text is displayed in bold at the top of the sidebar.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_PRIMARY_TEXT,
+ g_param_spec_string (
+ "primary-text",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+
+ /**
+ * EShellSidebar:secondary-text
+ *
+ * The secondary text is displayed in a smaller font at the top of
+ * the sidebar.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_SECONDARY_TEXT,
+ g_param_spec_string (
+ "secondary-text",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+
+ /**
+ * EShellSidebar:shell-view
+ *
+ * The #EShellView to which the sidebar widget belongs.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL_VIEW,
+ g_param_spec_object (
+ "shell-view",
+ NULL,
+ NULL,
+ E_TYPE_SHELL_VIEW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+shell_sidebar_init (EShellSidebar *shell_sidebar)
+{
+ GtkStyle *style;
+ GtkWidget *widget;
+ const GdkColor *color;
+
+ shell_sidebar->priv = E_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar);
+
+ GTK_WIDGET_SET_FLAGS (shell_sidebar, GTK_NO_WINDOW);
+
+ widget = gtk_event_box_new ();
+ style = gtk_widget_get_style (widget);
+ color = &style->bg[GTK_STATE_ACTIVE];
+ gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, color);
+ gtk_widget_set_parent (widget, GTK_WIDGET (shell_sidebar));
+ shell_sidebar->priv->event_box = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ /* Finish initialization once we have a shell view. */
+}
+
+GType
+e_shell_sidebar_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EShellSidebarClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) shell_sidebar_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EShellSidebar),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) shell_sidebar_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ GTK_TYPE_BIN, "EShellSidebar", &type_info, 0);
+ }
+
+ return type;
+}
+
+/**
+ * e_shell_sidebar_new:
+ * @shell_view: an #EShellView
+ *
+ * Creates a new #EShellSidebar instance belonging to @shell_view.
+ *
+ * Returns: a new #EShellSidebar instance
+ **/
+GtkWidget *
+e_shell_sidebar_new (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ return g_object_new (
+ E_TYPE_SHELL_SIDEBAR,
+ "shell-view", shell_view, NULL);
+}
+
+/**
+ * e_shell_sidebar_check_state:
+ * @shell_sidebar: an #EShellSidebar
+ *
+ * #EShellSidebar subclasses should implement the
+ * <structfield>check_state</structfield> method in #EShellSidebarClass
+ * to return a set of flags describing the current sidebar selection.
+ * Subclasses are responsible for defining their own flags. This is
+ * primarily used to assist shell views with updating actions (see
+ * e_shell_view_update_actions()).
+ *
+ * Returns: a set of flags describing the current @shell_sidebar selection
+ **/
+guint32
+e_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
+{
+ EShellSidebarClass *shell_sidebar_class;
+
+ g_return_val_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar), 0);
+
+ shell_sidebar_class = E_SHELL_SIDEBAR_GET_CLASS (shell_sidebar);
+ g_return_val_if_fail (shell_sidebar_class->check_state != NULL, 0);
+
+ return shell_sidebar_class->check_state (shell_sidebar);
+}
+
+/**
+ * e_shell_sidebar_get_shell_view:
+ * @shell_sidebar: an #EShellSidebar
+ *
+ * Returns the #EShellView that was passed to e_shell_sidebar_new().
+ *
+ * Returns: the #EShellView to which @shell_sidebar belongs
+ **/
+EShellView *
+e_shell_sidebar_get_shell_view (EShellSidebar *shell_sidebar)
+{
+ g_return_val_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar), NULL);
+
+ return E_SHELL_VIEW (shell_sidebar->priv->shell_view);
+}
+
+/**
+ * e_shell_sidebar_get_icon_name:
+ * @shell_sidebar: an #EShellSidebar
+ *
+ * Returns the icon name displayed at the top of the sidebar.
+ *
+ * Returns: the icon name for @shell_sidebar
+ **/
+const gchar *
+e_shell_sidebar_get_icon_name (EShellSidebar *shell_sidebar)
+{
+ GtkImage *image;
+ const gchar *icon_name;
+
+ g_return_val_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar), NULL);
+
+ image = GTK_IMAGE (shell_sidebar->priv->image);
+ gtk_image_get_icon_name (image, &icon_name, NULL);
+
+ return icon_name;
+}
+
+/**
+ * e_shell_sidebar_set_icon_name:
+ *
+ * Sets the icon name displayed at the top of the sidebar.
+ **/
+void
+e_shell_sidebar_set_icon_name (EShellSidebar *shell_sidebar,
+ const gchar *icon_name)
+{
+ GtkImage *image;
+
+ g_return_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar));
+
+ image = GTK_IMAGE (shell_sidebar->priv->image);
+ gtk_image_set_from_icon_name (image, icon_name, GTK_ICON_SIZE_MENU);
+
+ g_object_notify (G_OBJECT (shell_sidebar), "icon-name");
+}
+
+/**
+ * e_shell_sidebar_get_primary_text:
+ * @shell_sidebar: an #EShellSidebar
+ *
+ * Returns the primary text for @shell_sidebar.
+ *
+ * The primary text is displayed in bold at the top of the sidebar. It
+ * defaults to the shell view's label (as seen on the switcher button),
+ * but typically shows the name of the selected item in the sidebar.
+ *
+ * Returns: the primary text for @shell_sidebar
+ **/
+const gchar *
+e_shell_sidebar_get_primary_text (EShellSidebar *shell_sidebar)
+{
+ g_return_val_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar), NULL);
+
+ return shell_sidebar->priv->primary_text;
+}
+
+/**
+ * e_shell_sidebar_set_primary_text:
+ * @shell_sidebar: an #EShellSidebar
+ * @primary_text: text to be displayed in a bold font
+ *
+ * Sets the primary text for @shell_sidebar.
+ *
+ * The primary text is displayed in bold at the top of the sidebar. It
+ * defaults to the shell view's label (as seen on the switcher button),
+ * but typically shows the name of the selected item in the sidebar.
+ **/
+void
+e_shell_sidebar_set_primary_text (EShellSidebar *shell_sidebar,
+ const gchar *primary_text)
+{
+ GtkLabel *label;
+ gchar *markup;
+
+ g_return_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar));
+
+ g_free (shell_sidebar->priv->primary_text);
+ shell_sidebar->priv->primary_text = g_strdup (primary_text);
+
+ if (primary_text == NULL)
+ primary_text = "";
+
+ label = GTK_LABEL (shell_sidebar->priv->primary_label);
+ markup = g_markup_printf_escaped ("<b>%s</b>", primary_text);
+ gtk_label_set_markup (label, markup);
+ g_free (markup);
+
+ gtk_widget_queue_resize (GTK_WIDGET (shell_sidebar));
+ g_object_notify (G_OBJECT (shell_sidebar), "primary-text");
+}
+
+/**
+ * e_shell_sidebar_get_secondary_text:
+ * @shell_sidebar: an #EShellSidebar
+ *
+ * Returns the secondary text for @shell_sidebar.
+ *
+ * The secondary text is displayed in a smaller font at the top of the
+ * sidebar. It typically shows information about the contents of the
+ * selected sidebar item, such as total number of items, number of
+ * selected items, etc.
+ *
+ * Returns: the secondary text for @shell_sidebar
+ **/
+const gchar *
+e_shell_sidebar_get_secondary_text (EShellSidebar *shell_sidebar)
+{
+ g_return_val_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar), NULL);
+
+ return shell_sidebar->priv->secondary_text;
+}
+
+/**
+ * e_shell_sidebar_set_secondary_text:
+ * @shell_sidebar: an #EShellSidebar
+ * @secondary_text: text to be displayed in a smaller font
+ *
+ * Sets the secondary text for @shell_sidebar.
+ *
+ * The secondary text is displayed in a smaller font at the top of the
+ * sidebar. It typically shows information about the contents of the
+ * selected sidebar item, such as total number of items, number of
+ * selected items, etc.
+ **/
+void
+e_shell_sidebar_set_secondary_text (EShellSidebar *shell_sidebar,
+ const gchar *secondary_text)
+{
+ GtkLabel *label;
+ gchar *markup;
+
+ g_return_if_fail (E_IS_SHELL_SIDEBAR (shell_sidebar));
+
+ g_free (shell_sidebar->priv->secondary_text);
+ shell_sidebar->priv->secondary_text = g_strdup (secondary_text);
+
+ if (secondary_text == NULL)
+ secondary_text = "";
+
+ label = GTK_LABEL (shell_sidebar->priv->secondary_label);
+ markup = g_markup_printf_escaped ("<small>%s</small>", secondary_text);
+ gtk_label_set_markup (label, markup);
+ g_free (markup);
+
+ gtk_widget_queue_resize (GTK_WIDGET (shell_sidebar));
+ g_object_notify (G_OBJECT (shell_sidebar), "secondary-text");
+}
diff --git a/shell/e-shell-sidebar.h b/shell/e-shell-sidebar.h
new file mode 100644
index 0000000000..27966e5429
--- /dev/null
+++ b/shell/e-shell-sidebar.h
@@ -0,0 +1,97 @@
+/*
+ * e-shell-sidebar.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+/**
+ * SECTION: e-shell-sidebar
+ * @short_description: the left side of the main window
+ * @include: shell/e-shell-sidebar.h
+ **/
+
+#ifndef E_SHELL_SIDEBAR_H
+#define E_SHELL_SIDEBAR_H
+
+#include <shell/e-shell-common.h>
+
+/* Standard GObject macros */
+#define E_TYPE_SHELL_SIDEBAR \
+ (e_shell_sidebar_get_type ())
+#define E_SHELL_SIDEBAR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_SHELL_SIDEBAR, EShellSidebar))
+#define E_SHELL_SIDEBAR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_SHELL_SIDEBAR, EShellSidebarClass))
+#define E_IS_SHELL_SIDEBAR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_SHELL_SIDEBAR))
+#define E_IS_SHELL_SIDEBAR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((obj), E_TYPE_SHELL_SIDEBAR))
+#define E_SHELL_SIDEBAR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_SHELL_SIDEBAR, EShellSidebarClass))
+
+G_BEGIN_DECLS
+
+/* Avoid including <e-shell-view.h>, because it includes us! */
+struct _EShellView;
+
+typedef struct _EShellSidebar EShellSidebar;
+typedef struct _EShellSidebarClass EShellSidebarClass;
+typedef struct _EShellSidebarPrivate EShellSidebarPrivate;
+
+/**
+ * EShellSidebar:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ **/
+struct _EShellSidebar {
+ GtkBin parent;
+ EShellSidebarPrivate *priv;
+};
+
+struct _EShellSidebarClass {
+ GtkBinClass parent_class;
+
+ guint32 (*check_state) (EShellSidebar *shell_sidebar);
+};
+
+GType e_shell_sidebar_get_type (void);
+GtkWidget * e_shell_sidebar_new (struct _EShellView *shell_view);
+guint32 e_shell_sidebar_check_state (EShellSidebar *shell_sidebar);
+struct _EShellView *
+ e_shell_sidebar_get_shell_view (EShellSidebar *shell_sidebar);
+const gchar * e_shell_sidebar_get_icon_name (EShellSidebar *shell_sidebar);
+void e_shell_sidebar_set_icon_name (EShellSidebar *shell_sidebar,
+ const gchar *icon_name);
+const gchar * e_shell_sidebar_get_primary_text(EShellSidebar *shell_sidebar);
+void e_shell_sidebar_set_primary_text(EShellSidebar *shell_sidebar,
+ const gchar *primary_text);
+const gchar * e_shell_sidebar_get_secondary_text
+ (EShellSidebar *shell_sidebar);
+void e_shell_sidebar_set_secondary_text
+ (EShellSidebar *shell_sidebar,
+ const gchar *secondary_text);
+
+G_END_DECLS
+
+#endif /* E_SHELL_SIDEBAR_H */
diff --git a/shell/e-shell-switcher.c b/shell/e-shell-switcher.c
new file mode 100644
index 0000000000..e29fa1cb89
--- /dev/null
+++ b/shell/e-shell-switcher.c
@@ -0,0 +1,700 @@
+/*
+ * e-shell-switcher.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-shell-switcher.h"
+
+#include <glib/gi18n.h>
+
+#define E_SHELL_SWITCHER_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SHELL_SWITCHER, EShellSwitcherPrivate))
+
+#define H_PADDING 6
+#define V_PADDING 6
+
+struct _EShellSwitcherPrivate {
+ GList *proxies;
+ gboolean style_set;
+ GtkToolbarStyle style;
+ GtkSettings *settings;
+ gulong settings_handler_id;
+ gboolean toolbar_visible;
+};
+
+enum {
+ PROP_0,
+ PROP_TOOLBAR_STYLE,
+ PROP_TOOLBAR_VISIBLE
+};
+
+enum {
+ STYLE_CHANGED,
+ LAST_SIGNAL
+};
+
+static gpointer parent_class;
+static guint signals[LAST_SIGNAL];
+
+static gint
+shell_switcher_layout_actions (EShellSwitcher *switcher)
+{
+ GtkAllocation *allocation;
+ int num_btns = g_list_length (switcher->priv->proxies), btns_per_row;
+ GList **rows, *p;
+ gboolean icons_only;
+ gint row_number;
+ gint max_width = 0;
+ gint max_height = 0;
+ gint row_last;
+ gint x, y;
+ gint i;
+
+ allocation = &GTK_WIDGET (switcher)->allocation;
+ y = allocation->y + allocation->height;
+
+ if (num_btns == 0)
+ return allocation->height;
+
+ icons_only = (switcher->priv->style == GTK_TOOLBAR_ICONS);
+
+ /* Figure out the max width and height. */
+ for (p = switcher->priv->proxies; p != NULL; p = p->next) {
+ GtkWidget *widget = p->data;
+ GtkRequisition requisition;
+
+ gtk_widget_size_request (widget, &requisition);
+ max_height = MAX (max_height, requisition.height);
+ max_width = MAX (max_width, requisition.width);
+ }
+
+ /* Figure out how many rows and columns we'll use. */
+ btns_per_row = MAX (1, allocation->width / (max_width + H_PADDING));
+ if (!icons_only) {
+ /* If using text buttons, we want to try to have a
+ * completely filled-in grid, but if we can't, we want
+ * the odd row to have just a single button. */
+ while (num_btns % btns_per_row > 1)
+ btns_per_row--;
+ }
+
+ /* Assign buttons to rows. */
+ rows = g_new0 (GList *, num_btns / btns_per_row + 1);
+
+ if (!icons_only && num_btns % btns_per_row != 0) {
+ rows[0] = g_list_append (rows[0], switcher->priv->proxies->data);
+
+ p = switcher->priv->proxies->next;
+ row_number = p ? 1 : 0;
+ } else {
+ p = switcher->priv->proxies;
+ row_number = 0;
+ }
+
+ for (; p != NULL; p = p->next) {
+ GtkWidget *widget = p->data;
+
+ if (g_list_length (rows[row_number]) == btns_per_row)
+ row_number++;
+
+ rows[row_number] = g_list_append (rows[row_number], widget);
+ }
+
+ row_last = row_number;
+
+ /* Layout the buttons. */
+ for (i = row_last; i >= 0; i--) {
+ int len, extra_width;
+
+ x = H_PADDING + allocation->x;
+ y -= max_height;
+ len = g_list_length (rows[i]);
+ if (!icons_only)
+ extra_width = (allocation->width - (len * max_width ) - (len * H_PADDING)) / len;
+ else
+ extra_width = 0;
+ for (p = rows [i]; p != NULL; p = p->next) {
+ GtkAllocation child_allocation;
+
+ child_allocation.x = x;
+ child_allocation.y = y;
+ child_allocation.width = max_width + extra_width;
+ child_allocation.height = max_height;
+
+ gtk_widget_size_allocate (GTK_WIDGET (p->data), &child_allocation);
+
+ x += child_allocation.width + H_PADDING;
+ }
+
+ y -= V_PADDING;
+ }
+
+ for (i = 0; i <= row_last; i ++)
+ g_list_free (rows [i]);
+ g_free (rows);
+
+ return y - allocation->y;
+}
+
+static void
+shell_switcher_toolbar_style_changed_cb (EShellSwitcher *switcher)
+{
+ if (!switcher->priv->style_set) {
+ switcher->priv->style_set = TRUE;
+ e_shell_switcher_unset_style (switcher);
+ }
+}
+
+static void
+shell_switcher_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_TOOLBAR_STYLE:
+ e_shell_switcher_set_style (
+ E_SHELL_SWITCHER (object),
+ g_value_get_enum (value));
+ return;
+
+ case PROP_TOOLBAR_VISIBLE:
+ e_shell_switcher_set_visible (
+ E_SHELL_SWITCHER (object),
+ g_value_get_boolean (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+shell_switcher_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_TOOLBAR_STYLE:
+ g_value_set_enum (
+ value, e_shell_switcher_get_style (
+ E_SHELL_SWITCHER (object)));
+ return;
+
+ case PROP_TOOLBAR_VISIBLE:
+ g_value_set_boolean (
+ value, e_shell_switcher_get_visible (
+ E_SHELL_SWITCHER (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+shell_switcher_dispose (GObject *object)
+{
+ EShellSwitcherPrivate *priv;
+
+ priv = E_SHELL_SWITCHER_GET_PRIVATE (object);
+
+ while (priv->proxies != NULL) {
+ GtkWidget *widget = priv->proxies->data;
+ gtk_container_remove (GTK_CONTAINER (object), widget);
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+shell_switcher_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ EShellSwitcherPrivate *priv;
+ GtkWidget *child;
+ GList *iter;
+
+ priv = E_SHELL_SWITCHER_GET_PRIVATE (widget);
+
+ requisition->width = 0;
+ requisition->height = 0;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (child != NULL)
+ gtk_widget_size_request (child, requisition);
+
+ if (!priv->toolbar_visible)
+ return;
+
+ for (iter = priv->proxies; iter != NULL; iter = iter->next) {
+ GtkWidget *widget = iter->data;
+ GtkRequisition child_requisition;
+
+ gtk_widget_size_request (widget, &child_requisition);
+
+ child_requisition.width += H_PADDING;
+ child_requisition.height += V_PADDING;
+
+ requisition->width = MAX (
+ requisition->width, child_requisition.width);
+ requisition->height += child_requisition.height;
+ }
+}
+
+static void
+shell_switcher_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ EShellSwitcher *switcher;
+ GtkAllocation child_allocation;
+ GtkWidget *child;
+ gint height;
+
+ switcher = E_SHELL_SWITCHER (widget);
+
+ widget->allocation = *allocation;
+
+ if (switcher->priv->toolbar_visible)
+ height = shell_switcher_layout_actions (switcher);
+ else
+ height = allocation->height;
+
+ child_allocation.x = allocation->x;
+ child_allocation.y = allocation->y;
+ child_allocation.width = allocation->width;
+ child_allocation.height = height;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (child != NULL)
+ gtk_widget_size_allocate (child, &child_allocation);
+}
+
+static void
+shell_switcher_screen_changed (GtkWidget *widget,
+ GdkScreen *previous_screen)
+{
+ EShellSwitcherPrivate *priv;
+ GtkSettings *settings;
+
+ priv = E_SHELL_SWITCHER_GET_PRIVATE (widget);
+
+ if (gtk_widget_has_screen (widget))
+ settings = gtk_widget_get_settings (widget);
+ else
+ settings = NULL;
+
+ if (settings == priv->settings)
+ return;
+
+ if (priv->settings != NULL) {
+ g_signal_handler_disconnect (
+ priv->settings, priv->settings_handler_id);
+ g_object_unref (priv->settings);
+ }
+
+ if (settings != NULL) {
+ priv->settings = g_object_ref (settings);
+ priv->settings_handler_id = g_signal_connect_swapped (
+ settings, "notify::gtk-toolbar-style",
+ G_CALLBACK (shell_switcher_toolbar_style_changed_cb),
+ widget);
+ } else
+ priv->settings = NULL;
+
+ shell_switcher_toolbar_style_changed_cb (E_SHELL_SWITCHER (widget));
+}
+
+static void
+shell_switcher_remove (GtkContainer *container,
+ GtkWidget *widget)
+{
+ EShellSwitcherPrivate *priv;
+ GList *link;
+
+ priv = E_SHELL_SWITCHER_GET_PRIVATE (container);
+
+ /* Look in the internal widgets first. */
+
+ link = g_list_find (priv->proxies, widget);
+ if (link != NULL) {
+ GtkWidget *widget = link->data;
+
+ gtk_widget_unparent (widget);
+ priv->proxies = g_list_delete_link (priv->proxies, link);
+ gtk_widget_queue_resize (GTK_WIDGET (container));
+ return;
+ }
+
+ /* Chain up to parent's remove() method. */
+ GTK_CONTAINER_CLASS (parent_class)->remove (container, widget);
+}
+
+static void
+shell_switcher_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data)
+{
+ EShellSwitcherPrivate *priv;
+
+ priv = E_SHELL_SWITCHER_GET_PRIVATE (container);
+
+ if (include_internals)
+ g_list_foreach (
+ priv->proxies, (GFunc) callback, callback_data);
+
+ /* Chain up to parent's forall() method. */
+ GTK_CONTAINER_CLASS (parent_class)->forall (
+ container, include_internals, callback, callback_data);
+}
+
+static void
+shell_switcher_style_changed (EShellSwitcher *switcher,
+ GtkToolbarStyle style)
+{
+ if (switcher->priv->style == style)
+ return;
+
+ switcher->priv->style = style;
+
+ g_list_foreach (
+ switcher->priv->proxies,
+ (GFunc) gtk_tool_item_toolbar_reconfigured, NULL);
+
+ gtk_widget_queue_resize (GTK_WIDGET (switcher));
+ g_object_notify (G_OBJECT (switcher), "toolbar-style");
+}
+
+static GtkIconSize
+shell_switcher_get_icon_size (GtkToolShell *shell)
+{
+ return GTK_ICON_SIZE_LARGE_TOOLBAR;
+}
+
+static GtkOrientation
+shell_switcher_get_orientation (GtkToolShell *shell)
+{
+ return GTK_ORIENTATION_HORIZONTAL;
+}
+
+static GtkToolbarStyle
+shell_switcher_get_style (GtkToolShell *shell)
+{
+ return e_shell_switcher_get_style (E_SHELL_SWITCHER (shell));
+}
+
+static GtkReliefStyle
+shell_switcher_get_relief_style (GtkToolShell *shell)
+{
+ return GTK_RELIEF_NORMAL;
+}
+
+static void
+shell_switcher_class_init (EShellSwitcherClass *class)
+{
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+ GtkContainerClass *container_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EShellSwitcherPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = shell_switcher_set_property;
+ object_class->get_property = shell_switcher_get_property;
+ object_class->dispose = shell_switcher_dispose;
+
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->size_request = shell_switcher_size_request;
+ widget_class->size_allocate = shell_switcher_size_allocate;
+ widget_class->screen_changed = shell_switcher_screen_changed;
+
+ container_class = GTK_CONTAINER_CLASS (class);
+ container_class->remove = shell_switcher_remove;
+ container_class->forall = shell_switcher_forall;
+
+ class->style_changed = shell_switcher_style_changed;
+
+ /**
+ * EShellSwitcher:toolbar-style
+ *
+ * The switcher's toolbar style.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_TOOLBAR_STYLE,
+ g_param_spec_enum (
+ "toolbar-style",
+ _("Toolbar Style"),
+ _("The switcher's toolbar style"),
+ GTK_TYPE_TOOLBAR_STYLE,
+ E_SHELL_SWITCHER_DEFAULT_TOOLBAR_STYLE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ /**
+ * EShellSwitcher:toolbar-visible
+ *
+ * Whether the switcher is visible.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_TOOLBAR_VISIBLE,
+ g_param_spec_boolean (
+ "toolbar-visible",
+ _("Toolbar Visible"),
+ _("Whether the switcher is visible"),
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ /**
+ * EShellSwitcher::style-changed
+ * @switcher: the #EShellSwitcher which emitted the signal
+ * @style: the new #GtkToolbarStyle of the switcher
+ *
+ * Emitted when the style of the switcher changes.
+ **/
+ signals[STYLE_CHANGED] = g_signal_new (
+ "style-changed",
+ G_OBJECT_CLASS_TYPE (class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EShellSwitcherClass, style_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__ENUM,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_TOOLBAR_STYLE);
+}
+
+static void
+shell_switcher_init (EShellSwitcher *switcher)
+{
+ switcher->priv = E_SHELL_SWITCHER_GET_PRIVATE (switcher);
+
+ GTK_WIDGET_SET_FLAGS (switcher, GTK_NO_WINDOW);
+}
+
+static void
+shell_switcher_tool_shell_iface_init (GtkToolShellIface *iface)
+{
+ iface->get_icon_size = shell_switcher_get_icon_size;
+ iface->get_orientation = shell_switcher_get_orientation;
+ iface->get_style = shell_switcher_get_style;
+ iface->get_relief_style = shell_switcher_get_relief_style;
+}
+
+GType
+e_shell_switcher_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EShellSwitcherClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) shell_switcher_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EShellSwitcher),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) shell_switcher_init,
+ NULL /* value_table */
+ };
+
+ static const GInterfaceInfo tool_shell_info = {
+ (GInterfaceInitFunc) shell_switcher_tool_shell_iface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL /* interface_data */
+ };
+
+ type = g_type_register_static (
+ GTK_TYPE_BIN, "EShellSwitcher", &type_info, 0);
+
+ g_type_add_interface_static (
+ type, GTK_TYPE_TOOL_SHELL, &tool_shell_info);
+ }
+
+ return type;
+}
+
+/**
+ * e_shell_switcher_new:
+ *
+ * Creates a new #EShellSwitcher instance.
+ *
+ * Returns: a new #EShellSwitcher instance
+ **/
+GtkWidget *
+e_shell_switcher_new (void)
+{
+ return g_object_new (E_TYPE_SHELL_SWITCHER, NULL);
+}
+
+/**
+ * e_shell_switcher_add_action:
+ * @switcher: an #EShellSwitcher
+ * @action: a #GtkAction
+ *
+ * Adds a button to @switcher that proxies for @action. Switcher buttons
+ * appear in the order they were added.
+ *
+ * #EShellWindow adds switcher actions in the order given by the
+ * <structfield>sort_order</structfield> field in #EShellModuleInfo.
+ **/
+void
+e_shell_switcher_add_action (EShellSwitcher *switcher,
+ GtkAction *action)
+{
+ GtkWidget *widget;
+
+ g_return_if_fail (E_IS_SHELL_SWITCHER (switcher));
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ g_object_ref (action);
+ widget = gtk_action_create_tool_item (action);
+ gtk_tool_item_set_is_important (GTK_TOOL_ITEM (widget), TRUE);
+ gtk_widget_show (widget);
+
+ switcher->priv->proxies = g_list_append (
+ switcher->priv->proxies, widget);
+
+ gtk_widget_set_parent (widget, GTK_WIDGET (switcher));
+ gtk_widget_queue_resize (GTK_WIDGET (switcher));
+}
+
+/**
+ * e_shell_switcher_get_style:
+ * @switcher: an #EShellSwitcher
+ *
+ * Returns whether @switcher has text, icons or both.
+ *
+ * Returns: the current style of @shell
+ **/
+GtkToolbarStyle
+e_shell_switcher_get_style (EShellSwitcher *switcher)
+{
+ g_return_val_if_fail (
+ E_IS_SHELL_SWITCHER (switcher),
+ E_SHELL_SWITCHER_DEFAULT_TOOLBAR_STYLE);
+
+ return switcher->priv->style;
+}
+
+/**
+ * e_shell_switcher_set_style:
+ * @switcher: an #EShellSwitcher
+ * @style: the new style for @switcher
+ *
+ * Alters the view of @switcher to display either icons only, text only,
+ * or both.
+ **/
+void
+e_shell_switcher_set_style (EShellSwitcher *switcher,
+ GtkToolbarStyle style)
+{
+ g_return_if_fail (E_IS_SHELL_SWITCHER (switcher));
+
+ switcher->priv->style_set = TRUE;
+ g_signal_emit (switcher, signals[STYLE_CHANGED], 0, style);
+}
+
+/**
+ * e_shell_switcher_unset_style:
+ * @switcher: an #EShellSwitcher
+ *
+ * Unsets a switcher style set with e_shell_switcher_set_style(), so
+ * that user preferences will be used to determine the switcher style.
+ **/
+void
+e_shell_switcher_unset_style (EShellSwitcher *switcher)
+{
+ GtkSettings *settings;
+ GtkToolbarStyle style;
+
+ g_return_if_fail (E_IS_SHELL_SWITCHER (switcher));
+
+ if (!switcher->priv->style_set)
+ return;
+
+ settings = switcher->priv->settings;
+ if (settings != NULL)
+ g_object_get (settings, "gtk-toolbar-style", &style, NULL);
+ else
+ style = E_SHELL_SWITCHER_DEFAULT_TOOLBAR_STYLE;
+
+ if (style == GTK_TOOLBAR_BOTH)
+ style = GTK_TOOLBAR_BOTH_HORIZ;
+
+ if (style != switcher->priv->style)
+ g_signal_emit (switcher, signals[STYLE_CHANGED], 0, style);
+
+ switcher->priv->style_set = FALSE;
+}
+
+/**
+ * e_shell_switcher_get_visible:
+ * @switcher: an #EShellSwitcher
+ *
+ * Returns %TRUE if the switcher buttons are visible.
+ *
+ * Note that switcher button visibility is different than
+ * @switcher<!-- -->'s GTK_VISIBLE flag, since #EShellSwitcher
+ * is actually a container widget for #EShellSidebar.
+ *
+ * Returns: %TRUE if the switcher buttons are visible
+ **/
+gboolean
+e_shell_switcher_get_visible (EShellSwitcher *switcher)
+{
+ g_return_val_if_fail (E_IS_SHELL_SWITCHER (switcher), FALSE);
+
+ return switcher->priv->toolbar_visible;
+}
+
+/**
+ * e_shell_switcher_set_visible:
+ * @switcher: an #EShellSwitcher
+ * @visible: whether the switcher buttons should be visible
+ *
+ * Sets the switcher button visiblity to @visible.
+ *
+ * Note that switcher button visibility is different than
+ * @switcher<!-- -->'s GTK_VISIBLE flag, since #EShellSwitcher
+ * is actually a container widget for #EShellSidebar.
+ **/
+void
+e_shell_switcher_set_visible (EShellSwitcher *switcher,
+ gboolean visible)
+{
+ GList *iter;
+
+ g_return_if_fail (E_IS_SHELL_SWITCHER (switcher));
+
+ switcher->priv->toolbar_visible = visible;
+
+ for (iter = switcher->priv->proxies; iter != NULL; iter = iter->next)
+ g_object_set (iter->data, "visible", visible, NULL);
+
+ gtk_widget_queue_resize (GTK_WIDGET (switcher));
+
+ g_object_notify (G_OBJECT (switcher), "toolbar-visible");
+}
diff --git a/shell/e-shell-switcher.h b/shell/e-shell-switcher.h
new file mode 100644
index 0000000000..f04cec13e6
--- /dev/null
+++ b/shell/e-shell-switcher.h
@@ -0,0 +1,92 @@
+/*
+ * e-shell-switcher.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+/**
+ * SECTION: e-shell-switcher
+ * @short_description: buttons for switching views
+ * @include: shell/e-shell-switcher.h
+ **/
+
+#ifndef E_SHELL_SWITCHER_H
+#define E_SHELL_SWITCHER_H
+
+#include <e-shell-common.h>
+
+/* Standard GObject macros */
+#define E_TYPE_SHELL_SWITCHER \
+ (e_shell_switcher_get_type ())
+#define E_SHELL_SWITCHER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_SHELL_SWITCHER, EShellSwitcher))
+#define E_SHELL_SWITCHER_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_SHELL_SWITCHER, EShellSwitcherClass))
+#define E_IS_SHELL_SWITCHER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_SHELL_SWITCHER))
+#define E_IS_SHELL_SWITCHER_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((obj), E_TYPE_SHELL_SWITCHER))
+#define E_SHELL_SWITCHER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_SHELL_SWITCHER, EShellSwitcherClass))
+
+#define E_SHELL_SWITCHER_DEFAULT_TOOLBAR_STYLE GTK_TOOLBAR_BOTH_HORIZ
+
+G_BEGIN_DECLS
+
+typedef struct _EShellSwitcher EShellSwitcher;
+typedef struct _EShellSwitcherClass EShellSwitcherClass;
+typedef struct _EShellSwitcherPrivate EShellSwitcherPrivate;
+
+/**
+ * EShellSwitcher:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ **/
+struct _EShellSwitcher {
+ GtkBin parent;
+ EShellSwitcherPrivate *priv;
+};
+
+struct _EShellSwitcherClass {
+ GtkBinClass parent_class;
+
+ void (*style_changed) (EShellSwitcher *switcher,
+ GtkToolbarStyle style);
+};
+
+GType e_shell_switcher_get_type (void);
+GtkWidget * e_shell_switcher_new (void);
+void e_shell_switcher_add_action (EShellSwitcher *switcher,
+ GtkAction *action);
+GtkToolbarStyle e_shell_switcher_get_style (EShellSwitcher *switcher);
+void e_shell_switcher_set_style (EShellSwitcher *switcher,
+ GtkToolbarStyle style);
+void e_shell_switcher_unset_style (EShellSwitcher *switcher);
+gboolean e_shell_switcher_get_visible (EShellSwitcher *switcher);
+void e_shell_switcher_set_visible (EShellSwitcher *switcher,
+ gboolean visible);
+
+G_END_DECLS
+
+#endif /* E_SHELL_SWITCHER_H */
diff --git a/shell/e-shell-taskbar.c b/shell/e-shell-taskbar.c
new file mode 100644
index 0000000000..9b9978d65e
--- /dev/null
+++ b/shell/e-shell-taskbar.c
@@ -0,0 +1,421 @@
+/*
+ * e-shell-taskbar.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-shell-taskbar.h"
+
+#include <e-shell-view.h>
+
+#include <widgets/misc/e-activity-proxy.h>
+
+#define E_SHELL_TASKBAR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SHELL_TASKBAR, EShellTaskbarPrivate))
+
+struct _EShellTaskbarPrivate {
+
+ gpointer shell_view; /* weak pointer */
+
+ GtkWidget *label;
+ GtkWidget *hbox;
+
+ GHashTable *proxy_table;
+};
+
+enum {
+ PROP_0,
+ PROP_MESSAGE,
+ PROP_SHELL_VIEW
+};
+
+static gpointer parent_class;
+
+static void
+shell_taskbar_activity_remove (EShellTaskbar *shell_taskbar,
+ EActivity *activity)
+{
+ GtkBox *box;
+ GtkWidget *proxy;
+ GHashTable *proxy_table;
+
+ box = GTK_BOX (shell_taskbar->priv->hbox);
+ proxy_table = shell_taskbar->priv->proxy_table;
+ proxy = g_hash_table_lookup (proxy_table, activity);
+ g_return_if_fail (proxy != NULL);
+
+ g_hash_table_remove (proxy_table, activity);
+ gtk_container_remove (GTK_CONTAINER (box), proxy);
+
+ if (box->children == NULL)
+ gtk_widget_hide (GTK_WIDGET (box));
+}
+
+static void
+shell_taskbar_activity_add (EShellTaskbar *shell_taskbar,
+ EActivity *activity)
+{
+ GtkBox *box;
+ GtkWidget *proxy;
+
+ proxy = e_activity_proxy_new (activity);
+ box = GTK_BOX (shell_taskbar->priv->hbox);
+ gtk_box_pack_start (box, proxy, TRUE, TRUE, 0);
+ gtk_box_reorder_child (box, proxy, 0);
+ gtk_widget_show (GTK_WIDGET (box));
+ gtk_widget_show (proxy);
+
+ g_hash_table_insert (
+ shell_taskbar->priv->proxy_table,
+ g_object_ref (activity), g_object_ref (proxy));
+
+ g_signal_connect_swapped (
+ activity, "cancelled",
+ G_CALLBACK (shell_taskbar_activity_remove), shell_taskbar);
+
+ g_signal_connect_swapped (
+ activity, "completed",
+ G_CALLBACK (shell_taskbar_activity_remove), shell_taskbar);
+}
+
+static void
+shell_taskbar_set_shell_view (EShellTaskbar *shell_taskbar,
+ EShellView *shell_view)
+{
+ g_return_if_fail (shell_taskbar->priv->shell_view == NULL);
+
+ shell_taskbar->priv->shell_view = shell_view;
+
+ g_object_add_weak_pointer (
+ G_OBJECT (shell_view),
+ &shell_taskbar->priv->shell_view);
+}
+
+static void
+shell_taskbar_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_MESSAGE:
+ e_shell_taskbar_set_message (
+ E_SHELL_TASKBAR (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_SHELL_VIEW:
+ shell_taskbar_set_shell_view (
+ E_SHELL_TASKBAR (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+shell_taskbar_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_MESSAGE:
+ g_value_set_string (
+ value, e_shell_taskbar_get_message (
+ E_SHELL_TASKBAR (object)));
+ return;
+
+ case PROP_SHELL_VIEW:
+ g_value_set_object (
+ value, e_shell_taskbar_get_shell_view (
+ E_SHELL_TASKBAR (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+shell_taskbar_dispose (GObject *object)
+{
+ EShellTaskbarPrivate *priv;
+
+ priv = E_SHELL_TASKBAR_GET_PRIVATE (object);
+
+ if (priv->shell_view != NULL) {
+ g_object_remove_weak_pointer (
+ G_OBJECT (priv->shell_view), &priv->shell_view);
+ priv->shell_view = NULL;
+ }
+
+ if (priv->label != NULL) {
+ g_object_unref (priv->label);
+ priv->label = NULL;
+ }
+
+ if (priv->hbox != NULL) {
+ g_object_unref (priv->hbox);
+ priv->hbox = NULL;
+ }
+
+ g_hash_table_remove_all (priv->proxy_table);
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+shell_taskbar_finalize (GObject *object)
+{
+ EShellTaskbarPrivate *priv;
+
+ priv = E_SHELL_TASKBAR_GET_PRIVATE (object);
+
+ g_hash_table_destroy (priv->proxy_table);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+shell_taskbar_constructed (GObject *object)
+{
+ EShellView *shell_view;
+ EShellModule *shell_module;
+ EShellTaskbar *shell_taskbar;
+
+ shell_taskbar = E_SHELL_TASKBAR (object);
+ shell_view = e_shell_taskbar_get_shell_view (shell_taskbar);
+ shell_module = e_shell_view_get_shell_module (shell_view);
+
+ g_signal_connect_swapped (
+ shell_module, "activity-added",
+ G_CALLBACK (shell_taskbar_activity_add), shell_taskbar);
+}
+
+static void
+shell_taskbar_class_init (EShellTaskbarClass *class)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EShellTaskbarPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = shell_taskbar_set_property;
+ object_class->get_property = shell_taskbar_get_property;
+ object_class->dispose = shell_taskbar_dispose;
+ object_class->finalize = shell_taskbar_finalize;
+ object_class->constructed = shell_taskbar_constructed;
+
+ /**
+ * EShellTaskbar:message
+ *
+ * The message to display in the taskbar.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_MESSAGE,
+ g_param_spec_string (
+ "message",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ /**
+ * EShellTaskbar:shell-view
+ *
+ * The #EShellView to which the taskbar widget belongs.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL_VIEW,
+ g_param_spec_object (
+ "shell-view",
+ NULL,
+ NULL,
+ E_TYPE_SHELL_VIEW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+shell_taskbar_init (EShellTaskbar *shell_taskbar)
+{
+ GtkWidget *widget;
+ GHashTable *proxy_table;
+ gint height;
+
+ proxy_table = g_hash_table_new_full (
+ g_direct_hash, g_direct_equal,
+ (GDestroyNotify) g_object_unref,
+ (GDestroyNotify) g_object_unref);
+
+ shell_taskbar->priv = E_SHELL_TASKBAR_GET_PRIVATE (shell_taskbar);
+ shell_taskbar->priv->proxy_table = proxy_table;
+
+ gtk_box_set_spacing (GTK_BOX (shell_taskbar), 12);
+
+ widget = gtk_label_new (NULL);
+ gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
+ gtk_box_pack_start (GTK_BOX (shell_taskbar), widget, TRUE, TRUE, 0);
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+ shell_taskbar->priv->label = g_object_ref (widget);
+ gtk_widget_hide (widget);
+
+ widget = gtk_hbox_new (FALSE, 3);
+ gtk_box_pack_start (GTK_BOX (shell_taskbar), widget, TRUE, TRUE, 0);
+ shell_taskbar->priv->hbox = g_object_ref (widget);
+ gtk_widget_hide (widget);
+
+ /* Make the taskbar large enough to accomodate a small icon.
+ * XXX The "* 2" is a fudge factor to allow for some padding
+ * The true value is probably buried in a style property. */
+ gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, NULL, &height);
+ gtk_widget_set_size_request (
+ GTK_WIDGET (shell_taskbar), -1, (height * 2));
+}
+
+GType
+e_shell_taskbar_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EShellTaskbarClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) shell_taskbar_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EShellTaskbar),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) shell_taskbar_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ GTK_TYPE_HBOX, "EShellTaskbar", &type_info, 0);
+ }
+
+ return type;
+}
+
+/**
+ * e_shell_taskbar_new:
+ * @shell_view: an #EShellView
+ *
+ * Creates a new #EShellTaskbar instance belonging to @shell_view.
+ *
+ * Returns: a new #EShellTaskbar instance
+ **/
+GtkWidget *
+e_shell_taskbar_new (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ return g_object_new (
+ E_TYPE_SHELL_TASKBAR, "shell-view", shell_view, NULL);
+}
+
+/**
+ * e_shell_taskbar_get_shell_view:
+ * @shell_taskbar: an #EShellTaskbar
+ *
+ * Returns the #EShellView that was passed to e_shell_taskbar_new().
+ *
+ * Returns: the #EShellView to which @shell_taskbar belongs
+ **/
+EShellView *
+e_shell_taskbar_get_shell_view (EShellTaskbar *shell_taskbar)
+{
+ g_return_val_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar), NULL);
+
+ return shell_taskbar->priv->shell_view;
+}
+
+/**
+ * e_shell_taskbar_get_message:
+ * @shell_taskbar: an #EShellTaskbar
+ *
+ * Returns the message currently shown in the taskbar, or an empty string
+ * if no message is shown. Taskbar messages are used primarily for menu
+ * tooltips.
+ *
+ * Returns: the current taskbar message
+ **/
+const gchar *
+e_shell_taskbar_get_message (EShellTaskbar *shell_taskbar)
+{
+ GtkWidget *label;
+
+ g_return_val_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar), NULL);
+
+ label = shell_taskbar->priv->label;
+
+ return gtk_label_get_text (GTK_LABEL (label));
+}
+
+/**
+ * e_shell_taskbar_set_message:
+ * @shell_taskbar: an #EShellTaskbar
+ * @message: the message to show
+ *
+ * Shows a message in the taskbar. If @message is %NULL or an empty string,
+ * the taskbar message is cleared. Taskbar messages are used primarily for
+ * menu tooltips.
+ **/
+void
+e_shell_taskbar_set_message (EShellTaskbar *shell_taskbar,
+ const gchar *message)
+{
+ GtkWidget *label;
+
+ g_return_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar));
+
+ label = shell_taskbar->priv->label;
+ gtk_label_set_text (GTK_LABEL (label), message);
+
+ if (message != NULL && *message != '\0')
+ gtk_widget_show (label);
+ else
+ gtk_widget_hide (label);
+
+ g_object_notify (G_OBJECT (shell_taskbar), "message");
+}
+
+/**
+ * e_shell_taskbar_unset_message:
+ * @shell_taskbar: an #EShellTaskbar
+ *
+ * This is equivalent to passing a %NULL message to
+ * e_shell_taskbar_set_message().
+ **/
+void
+e_shell_taskbar_unset_message (EShellTaskbar *shell_taskbar)
+{
+ g_return_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar));
+
+ e_shell_taskbar_set_message (shell_taskbar, NULL);
+}
diff --git a/shell/e-shell-taskbar.h b/shell/e-shell-taskbar.h
new file mode 100644
index 0000000000..b0aab3bdde
--- /dev/null
+++ b/shell/e-shell-taskbar.h
@@ -0,0 +1,87 @@
+/*
+ * e-shell-taskbar.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+/**
+ * SECTION: e-shell-taskbar
+ * @short_description: the bottom of the main window
+ * @include: shell/e-shell-taskbar.h
+ **/
+
+#ifndef E_SHELL_TASKBAR_H
+#define E_SHELL_TASKBAR_H
+
+#include <shell/e-shell-common.h>
+
+/* Standard GObject macros */
+#define E_TYPE_SHELL_TASKBAR \
+ (e_shell_taskbar_get_type ())
+#define E_SHELL_TASKBAR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_SHELL_TASKBAR, EShellTaskbar))
+#define E_SHELL_TASKBAR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_SHELL_TASKBAR, EShellTaskbarClass))
+#define E_IS_SHELL_TASKBAR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_SHELL_TASKBAR))
+#define E_IS_SHELL_TASKBAR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_SHELL_TASKBAR))
+#define E_SHELL_TASKBAR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_SHELL_TASKBAR, EShellTaskbarClass))
+
+G_BEGIN_DECLS
+
+/* Avoid including <e-shell-view.h>, because it includes us! */
+struct _EShellView;
+
+typedef struct _EShellTaskbar EShellTaskbar;
+typedef struct _EShellTaskbarClass EShellTaskbarClass;
+typedef struct _EShellTaskbarPrivate EShellTaskbarPrivate;
+
+/**
+ * EShellTaskbar:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ **/
+struct _EShellTaskbar {
+ GtkHBox parent;
+ EShellTaskbarPrivate *priv;
+};
+
+struct _EShellTaskbarClass {
+ GtkHBoxClass parent_class;
+};
+
+GType e_shell_taskbar_get_type (void);
+GtkWidget * e_shell_taskbar_new (struct _EShellView *shell_view);
+struct _EShellView *
+ e_shell_taskbar_get_shell_view (EShellTaskbar *shell_taskbar);
+const gchar * e_shell_taskbar_get_message (EShellTaskbar *shell_taskbar);
+void e_shell_taskbar_set_message (EShellTaskbar *shell_taskbar,
+ const gchar *message);
+void e_shell_taskbar_unset_message (EShellTaskbar *shell_taskbar);
+
+G_END_DECLS
+
+#endif /* E_SHELL_TASKBAR_H */
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 022e7ecca1..d7a564c567 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -1,5 +1,5 @@
/*
- * Helper class for evolution shells to setup a view
+ * e-shell-view.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -15,126 +15,1034 @@
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*
- * Authors:
- * Michael Zucchi <notzed@ximian.com>
- *
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "e-shell-view.h"
-#include <gtk/gtk.h>
+#include <string.h>
#include <glib/gi18n.h>
-#include "e-shell-view.h"
+#include "e-util/e-util.h"
+#include "e-util/e-plugin-ui.h"
+
+#include "e-shell-content.h"
+#include "e-shell-module.h"
+#include "e-shell-sidebar.h"
+#include "e-shell-taskbar.h"
#include "e-shell-window.h"
+#include "e-shell-window-actions.h"
-static BonoboObjectClass *parent_class = NULL;
+#define E_SHELL_VIEW_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SHELL_VIEW, EShellViewPrivate))
struct _EShellViewPrivate {
- int dummy;
+
+ gpointer shell_window; /* weak pointer */
+
+ gchar *title;
+ gchar *view_id;
+ gint page_num;
+ guint merge_id;
+
+ GtkAction *action;
+ GtkSizeGroup *size_group;
+ GtkWidget *shell_content;
+ GtkWidget *shell_sidebar;
+ GtkWidget *shell_taskbar;
};
+enum {
+ PROP_0,
+ PROP_ACTION,
+ PROP_PAGE_NUM,
+ PROP_TITLE,
+ PROP_SHELL_CONTENT,
+ PROP_SHELL_MODULE,
+ PROP_SHELL_SIDEBAR,
+ PROP_SHELL_TASKBAR,
+ PROP_SHELL_WINDOW,
+ PROP_VIEW_ID
+};
+
+enum {
+ TOGGLED,
+ UPDATE_ACTIONS,
+ LAST_SIGNAL
+};
+
+static gpointer parent_class;
+static gulong signals[LAST_SIGNAL];
+
static void
-impl_ShellView_setTitle(PortableServer_Servant _servant, const CORBA_char *id, const CORBA_char * title, CORBA_Environment * ev)
+shell_view_init_view_collection (EShellViewClass *class)
{
- EShellView *esw = (EShellView *)bonobo_object_from_servant(_servant);
- /* To translators: This is the window title and %s is the
- component name. Most translators will want to keep it as is. */
- char *tmp = g_strdup_printf(_("%s - Evolution"), title);
+ EShellModule *shell_module;
+ const gchar *base_dir;
+ const gchar *module_name;
+ gchar *system_dir;
+ gchar *local_dir;
+
+ shell_module = E_SHELL_MODULE (class->type_module);
+ module_name = class->type_module->name;
+
+ base_dir = EVOLUTION_GALVIEWSDIR;
+ system_dir = g_build_filename (base_dir, module_name, NULL);
- e_shell_window_set_title(esw->window, id, tmp);
- g_free(tmp);
+ base_dir = e_shell_module_get_data_dir (shell_module);
+ local_dir = g_build_filename (base_dir, "views", NULL);
+
+ /* The view collection is never destroyed. */
+ class->view_collection = gal_view_collection_new ();
+
+ gal_view_collection_set_title (
+ class->view_collection, class->label);
+
+ gal_view_collection_set_storage_directories (
+ class->view_collection, system_dir, local_dir);
+
+ g_free (system_dir);
+ g_free (local_dir);
+
+ /* This is all we can do. It's up to the subclasses to
+ * add the appropriate factories to the view collection. */
}
static void
-impl_ShellView_setComponent(PortableServer_Servant _servant, const CORBA_char *id, CORBA_Environment * ev)
+shell_view_update_view_id (EShellView *shell_view,
+ GalViewInstance *view_instance)
{
- EShellView *esw = (EShellView *)bonobo_object_from_servant(_servant);
+ gchar *view_id;
- e_shell_window_switch_to_component(esw->window, id);
+ view_id = gal_view_instance_get_current_view_id (view_instance);
+ e_shell_view_set_view_id (shell_view, view_id);
+ g_free (view_id);
}
-struct change_icon_struct {
- const char *component_name;
- const char *icon_name;
-};
+static void
+shell_view_emit_toggled (EShellView *shell_view)
+{
+ g_signal_emit (shell_view, signals[TOGGLED], 0);
+}
+
+static void
+shell_view_set_action (EShellView *shell_view,
+ GtkAction *action)
+{
+ gchar *label;
+
+ g_return_if_fail (shell_view->priv->action == NULL);
+
+ shell_view->priv->action = g_object_ref (action);
+
+ g_object_get (action, "label", &label, NULL);
+ e_shell_view_set_title (shell_view, label);
+ g_free (label);
+
+ g_signal_connect_swapped (
+ action, "toggled",
+ G_CALLBACK (shell_view_emit_toggled), shell_view);
+}
+
+static void
+shell_view_set_shell_window (EShellView *shell_view,
+ GtkWidget *shell_window)
+{
+ g_return_if_fail (shell_view->priv->shell_window == NULL);
+
+ shell_view->priv->shell_window = shell_window;
+
+ g_object_add_weak_pointer (
+ G_OBJECT (shell_window),
+ &shell_view->priv->shell_window);
+}
+
+static void
+shell_view_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_ACTION:
+ shell_view_set_action (
+ E_SHELL_VIEW (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_PAGE_NUM:
+ e_shell_view_set_page_num (
+ E_SHELL_VIEW (object),
+ g_value_get_int (value));
+ return;
+
+ case PROP_TITLE:
+ e_shell_view_set_title (
+ E_SHELL_VIEW (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_SHELL_WINDOW:
+ shell_view_set_shell_window (
+ E_SHELL_VIEW (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_VIEW_ID:
+ e_shell_view_set_view_id (
+ E_SHELL_VIEW (object),
+ g_value_get_string (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+shell_view_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_ACTION:
+ g_value_set_object (
+ value, e_shell_view_get_action (
+ E_SHELL_VIEW (object)));
+ return;
+
+ case PROP_PAGE_NUM:
+ g_value_set_int (
+ value, e_shell_view_get_page_num (
+ E_SHELL_VIEW (object)));
+ return;
+
+ case PROP_TITLE:
+ g_value_set_string (
+ value, e_shell_view_get_title (
+ E_SHELL_VIEW (object)));
+ return;
+
+ case PROP_SHELL_CONTENT:
+ g_value_set_object (
+ value, e_shell_view_get_shell_content (
+ E_SHELL_VIEW (object)));
+ return;
+
+ case PROP_SHELL_MODULE:
+ g_value_set_object (
+ value, e_shell_view_get_shell_module (
+ E_SHELL_VIEW (object)));
+
+ case PROP_SHELL_SIDEBAR:
+ g_value_set_object (
+ value, e_shell_view_get_shell_sidebar (
+ E_SHELL_VIEW (object)));
+ return;
+
+ case PROP_SHELL_TASKBAR:
+ g_value_set_object (
+ value, e_shell_view_get_shell_taskbar (
+ E_SHELL_VIEW (object)));
+ return;
-static gboolean
-change_button_icon_func (EShell *shell, EShellWindow *window, gpointer user_data)
+ case PROP_SHELL_WINDOW:
+ g_value_set_object (
+ value, e_shell_view_get_shell_window (
+ E_SHELL_VIEW (object)));
+ return;
+
+ case PROP_VIEW_ID:
+ g_value_set_string (
+ value, e_shell_view_get_view_id (
+ E_SHELL_VIEW (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+shell_view_dispose (GObject *object)
{
- struct change_icon_struct *cis = (struct change_icon_struct*)user_data;
+ EShellViewPrivate *priv;
+
+ priv = E_SHELL_VIEW_GET_PRIVATE (object);
+
+ if (priv->shell_window != NULL) {
+ g_object_remove_weak_pointer (
+ G_OBJECT (priv->shell_window), &priv->shell_window);
+ priv->shell_window = NULL;
+ }
- g_return_val_if_fail (window != NULL, FALSE);
- g_return_val_if_fail (cis != NULL, FALSE);
+ if (priv->size_group != NULL) {
+ g_object_unref (priv->size_group);
+ priv->size_group = NULL;
+ }
- e_shell_window_change_component_button_icon (window, cis->component_name, cis->icon_name);
+ if (priv->shell_content != NULL) {
+ g_object_unref (priv->shell_content);
+ priv->shell_content = NULL;
+ }
- return TRUE;
+ if (priv->shell_sidebar != NULL) {
+ g_object_unref (priv->shell_sidebar);
+ priv->shell_sidebar = NULL;
+ }
+
+ if (priv->shell_taskbar != NULL) {
+ g_object_unref (priv->shell_taskbar);
+ priv->shell_taskbar = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-impl_ShellView_setButtonIcon (PortableServer_Servant _servant, const CORBA_char *id, const CORBA_char * iconName, CORBA_Environment * ev)
+shell_view_finalize (GObject *object)
{
- EShellView *esw = (EShellView *)bonobo_object_from_servant(_servant);
- EShell *shell = e_shell_window_peek_shell (esw->window);
+ EShellViewPrivate *priv;
- struct change_icon_struct cis;
- cis.component_name = id;
- cis.icon_name = iconName;
+ priv = E_SHELL_VIEW_GET_PRIVATE (object);
- e_shell_foreach_shell_window (shell, change_button_icon_func, &cis);
+ g_free (priv->title);
+ g_free (priv->view_id);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-impl_dispose (GObject *object)
+shell_view_constructed (GObject *object)
{
- /*EShellView *esv = (EShellView *)object;*/
+ EShellWindow *shell_window;
+ EShellView *shell_view;
+ EShellViewClass *class;
+ GtkUIManager *ui_manager;
+ GtkWidget *widget;
+ const gchar *id;
+
+ shell_view = E_SHELL_VIEW (object);
+ class = E_SHELL_VIEW_GET_CLASS (object);
+
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ ui_manager = e_shell_window_get_ui_manager (shell_window);
+ id = class->ui_manager_id;
+
+ e_plugin_ui_register_manager (ui_manager, id, shell_view);
+
+ /* Invoke factory methods. */
- ((GObjectClass *)parent_class)->dispose(object);
+ widget = class->new_shell_content (shell_view);
+ shell_view->priv->shell_content = g_object_ref_sink (widget);
+ gtk_widget_show (widget);
+
+ widget = class->new_shell_sidebar (shell_view);
+ shell_view->priv->shell_sidebar = g_object_ref_sink (widget);
+ gtk_widget_show (widget);
+
+ widget = class->new_shell_taskbar (shell_view);
+ shell_view->priv->shell_taskbar = g_object_ref_sink (widget);
+ gtk_widget_show (widget);
}
static void
-impl_finalise (GObject *object)
+shell_view_toggled (EShellView *shell_view)
{
- ((GObjectClass *)parent_class)->finalize(object);
+ EShellViewPrivate *priv = shell_view->priv;
+ EShellViewClass *class;
+ EShellWindow *shell_window;
+ GtkUIManager *ui_manager;
+ const gchar *basename;
+ gboolean view_is_active;
+
+ class = E_SHELL_VIEW_GET_CLASS (shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ ui_manager = e_shell_window_get_ui_manager (shell_window);
+ view_is_active = e_shell_view_is_active (shell_view);
+ basename = class->ui_definition;
+
+ if (view_is_active && priv->merge_id == 0) {
+ priv->merge_id = e_load_ui_definition (ui_manager, basename);
+ e_plugin_ui_enable_manager (ui_manager, class->ui_manager_id);
+
+ } else if (!view_is_active && priv->merge_id != 0) {
+ e_plugin_ui_disable_manager (ui_manager, class->ui_manager_id);
+ gtk_ui_manager_remove_ui (ui_manager, priv->merge_id);
+ priv->merge_id = 0;
+ }
+
+ gtk_ui_manager_ensure_update (ui_manager);
}
static void
-e_shell_view_class_init (EShellViewClass *klass)
+shell_view_class_init (EShellViewClass *class)
{
GObjectClass *object_class;
- POA_GNOME_Evolution_ShellView__epv *epv;
- parent_class = g_type_class_ref(bonobo_object_get_type());
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EShellViewPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = shell_view_set_property;
+ object_class->get_property = shell_view_get_property;
+ object_class->dispose = shell_view_dispose;
+ object_class->finalize = shell_view_finalize;
+ object_class->constructed = shell_view_constructed;
+
+ /* Default Factories */
+ class->new_shell_content = e_shell_content_new;
+ class->new_shell_sidebar = e_shell_sidebar_new;
+ class->new_shell_taskbar = e_shell_taskbar_new;
+
+ class->toggled = shell_view_toggled;
+
+ /**
+ * EShellView:action:
+ *
+ * The #GtkRadioAction registered with #EShellSwitcher.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_ACTION,
+ g_param_spec_object (
+ "action",
+ _("Switcher Action"),
+ _("The switcher action for this shell view"),
+ GTK_TYPE_RADIO_ACTION,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ /**
+ * EShellView:page-num
+ *
+ * The #GtkNotebook page number of the shell view.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_PAGE_NUM,
+ g_param_spec_int (
+ "page-num",
+ _("Page Number"),
+ _("The notebook page number of the shell view"),
+ -1,
+ G_MAXINT,
+ -1,
+ G_PARAM_READWRITE));
+
+ /**
+ * EShellView:title
+ *
+ * The title of the shell view. Also serves as the #EShellWindow
+ * title when the shell view is active.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_TITLE,
+ g_param_spec_string (
+ "title",
+ _("Title"),
+ _("The title of the shell view"),
+ NULL,
+ G_PARAM_READWRITE));
+
+ /**
+ * EShellView:shell-content
+ *
+ * The content widget appears in an #EShellWindow<!-- -->'s
+ * right pane.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL_CONTENT,
+ g_param_spec_object (
+ "shell-content",
+ _("Shell Content Widget"),
+ _("The content widget appears in "
+ "a shell window's right pane"),
+ E_TYPE_SHELL_CONTENT,
+ G_PARAM_READABLE));
+
+ /**
+ * EShellView::shell-module
+ *
+ * The #EShellModule for this shell view.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL_MODULE,
+ g_param_spec_object (
+ "shell-module",
+ _("Shell Module"),
+ _("The EShellModule for this shell view"),
+ E_TYPE_SHELL_MODULE,
+ G_PARAM_READABLE));
- object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalise;
+ /**
+ * EShellView:shell-sidebar
+ *
+ * The sidebar widget appears in an #EShellWindow<!-- -->'s
+ * left pane.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL_SIDEBAR,
+ g_param_spec_object (
+ "shell-sidebar",
+ _("Shell Sidebar Widget"),
+ _("The sidebar widget appears in "
+ "a shell window's left pane"),
+ E_TYPE_SHELL_SIDEBAR,
+ G_PARAM_READABLE));
- epv = & klass->epv;
- epv->setTitle = impl_ShellView_setTitle;
- epv->setComponent = impl_ShellView_setComponent;
- epv->setButtonIcon = impl_ShellView_setButtonIcon;
+ /**
+ * EShellView:shell-taskbar
+ *
+ * The taskbar widget appears at the bottom of an #EShellWindow.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL_TASKBAR,
+ g_param_spec_object (
+ "shell-taskbar",
+ _("Shell Taskbar Widget"),
+ _("The taskbar widget appears at "
+ "the bottom of a shell window"),
+ E_TYPE_SHELL_TASKBAR,
+ G_PARAM_READABLE));
+
+ /**
+ * EShellView:shell-window
+ *
+ * The #EShellWindow to which the shell view belongs.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL_WINDOW,
+ g_param_spec_object (
+ "shell-window",
+ _("Shell Window"),
+ _("The window to which the shell view belongs"),
+ E_TYPE_SHELL_WINDOW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ /**
+ * EShellView:view-id
+ *
+ * The current #GalView ID.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_VIEW_ID,
+ g_param_spec_string (
+ "view-id",
+ _("Current View ID"),
+ _("The current GAL view ID"),
+ NULL,
+ G_PARAM_READWRITE));
+
+ /**
+ * EShellView::toggled
+ * @shell_view: the #EShellView which emitted the signal
+ *
+ * Emitted when @shell_view is activated or deactivated.
+ * Use e_shell_view_is_active() to find out which event has
+ * occurred. The shell view being deactivated is always
+ * notified before the shell view being activated.
+ *
+ * By default, #EShellView adds the UI definition file
+ * given in the <structfield>ui_definition</structfield>
+ * field of #EShellViewClass on activation, and removes the
+ * UI definition on deactivation.
+ **/
+ signals[TOGGLED] = g_signal_new (
+ "toggled",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EShellViewClass, toggled),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
+ * EShellView::update-actions
+ * @shell_view: the #EShellView which emitted the signal
+ *
+ * #EShellView subclasses should override the
+ * <structfield>update_actions</structfield> method in
+ * #EShellViewClass to update sensitivities, labels, or any
+ * other aspect of the #GtkAction<!-- -->s they have registered.
+ *
+ * Plugins can also connect to this signal to be notified
+ * when to update their own #GtkAction<!-- -->s.
+ **/
+ signals[UPDATE_ACTIONS] = g_signal_new (
+ "update-actions",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EShellViewClass, update_actions),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
-e_shell_view_init (EShellView *shell)
+shell_view_init (EShellView *shell_view,
+ EShellViewClass *class)
+{
+ GtkSizeGroup *size_group;
+
+ size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
+
+ shell_view->priv = E_SHELL_VIEW_GET_PRIVATE (shell_view);
+ shell_view->priv->size_group = size_group;
+
+ if (class->view_collection == NULL)
+ shell_view_init_view_collection (class);
+}
+
+GType
+e_shell_view_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo type_info = {
+ sizeof (EShellViewClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) shell_view_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EShellView),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) shell_view_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ G_TYPE_OBJECT, "EShellView",
+ &type_info, G_TYPE_FLAG_ABSTRACT);
+ }
+
+ return type;
+}
+
+/**
+ * e_shell_view_get_name:
+ * @shell_view: an #EShellView
+ *
+ * Returns the view name for @shell_view, which is also the name of
+ * the corresponding #EShellModule (see the <structfield>name</structfield>
+ * field in #EShellModuleInfo).
+ *
+ * Returns: the view name for @shell_view
+ **/
+const gchar *
+e_shell_view_get_name (EShellView *shell_view)
+{
+ GtkAction *action;
+
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ action = e_shell_view_get_action (shell_view);
+
+ /* Switcher actions have a secret "view-name" data value.
+ * This gets set in e_shell_window_create_switcher_actions(). */
+ return g_object_get_data (G_OBJECT (action), "view-name");
+}
+
+/**
+ * e_shell_view_get_action:
+ * @shell_view: an #EShellView
+ *
+ * Returns the switcher action for @shell_view.
+ *
+ * An #EShellWindow creates a #GtkRadioAction for each registered subclass
+ * of #EShellView. This action gets passed to the #EShellSwitcher, which
+ * displays a button that proxies the action. The icon at the top of the
+ * sidebar also proxies the action. When @shell_view is active, the
+ * action's icon becomes the #EShellWindow icon.
+ *
+ * Returns: the switcher action for @shell_view
+ **/
+GtkAction *
+e_shell_view_get_action (EShellView *shell_view)
{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ return shell_view->priv->action;
+}
+
+/**
+ * e_shell_view_get_title:
+ * @shell_view: an #EShellView
+ *
+ * Returns the title for @shell_view. When @shell_view is active, the
+ * shell view's title becomes the #EShellWindow title.
+ *
+ * Returns: the title for @shell_view
+ **/
+const gchar *
+e_shell_view_get_title (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ return shell_view->priv->title;
+}
+
+/**
+ * e_shell_view_set_title:
+ * @shell_view: an #EShellView
+ * @title: a title for @shell_view
+ *
+ * Sets the title for @shell_view. When @shell_view is active, the
+ * shell view's title becomes the #EShellWindow title.
+ **/
+void
+e_shell_view_set_title (EShellView *shell_view,
+ const gchar *title)
+{
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+
+ if (title == NULL)
+ title = E_SHELL_VIEW_GET_CLASS (shell_view)->label;
+
+ if (g_strcmp0 (shell_view->priv->title, title) == 0)
+ return;
+
+ g_free (shell_view->priv->title);
+ shell_view->priv->title = g_strdup (title);
+
+ g_object_notify (G_OBJECT (shell_view), "title");
+}
+
+/**
+ * e_shell_view_get_view_id:
+ * @shell_view: an #EShellView
+ *
+ * Returns the ID of the currently selected #GalView.
+ *
+ * #EShellView subclasses are responsible for keeping this property in
+ * sync with their #GalViewInstance. #EShellView itself just provides
+ * a place to store the view ID, and emits a #GObject::notify signal
+ * when the property changes.
+ *
+ * Returns: the ID of the current #GalView
+ **/
+const gchar *
+e_shell_view_get_view_id (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ return shell_view->priv->view_id;
+}
+
+/**
+ * e_shell_view_set_view_id:
+ * @shell_view: an #EShellView
+ * @view_id: a #GalView ID
+ *
+ * Selects the #GalView whose ID is equal to @view_id.
+ *
+ * #EShellView subclasses are responsible for keeping this property in
+ * sync with their #GalViewInstance. #EShellView itself just provides
+ * a place to store the view ID, and emits a #GObject::notify signal
+ * when the property changes.
+ **/
+void
+e_shell_view_set_view_id (EShellView *shell_view,
+ const gchar *view_id)
+{
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+
+ if (g_strcmp0 (shell_view->priv->view_id, view_id) == 0)
+ return;
+
+ g_free (shell_view->priv->view_id);
+ shell_view->priv->view_id = g_strdup (view_id);
+
+ g_object_notify (G_OBJECT (shell_view), "view-id");
+}
+
+/**
+ * e_shell_view_get_shell_window:
+ * @shell_view: an #EShellView
+ *
+ * Returns the #EShellWindow to which @shell_view belongs.
+ *
+ * Returns: the #EShellWindow to which @shell_view belongs
+ **/
+EShellWindow *
+e_shell_view_get_shell_window (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ return E_SHELL_WINDOW (shell_view->priv->shell_window);
+}
+
+/**
+ * e_shell_view_get_shell_module:
+ * @shell_view: an #EShellView
+ *
+ * Returns the corresponding #EShellModule for @shell_view.
+ *
+ * Returns: the corresponding #EShellModule for @shell_view
+ **/
+EShellModule *
+e_shell_view_get_shell_module (EShellView *shell_view)
+{
+ EShellViewClass *class;
+
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ /* Calling this function during the shell view's instance
+ * initialization function will return the wrong result,
+ * so watch for that and emit a warning. */
+ class = E_SHELL_VIEW_GET_CLASS (shell_view);
+ g_return_val_if_fail (E_IS_SHELL_VIEW_CLASS (class), NULL);
+
+ return E_SHELL_MODULE (class->type_module);
+}
+
+/**
+ * e_shell_view_is_active:
+ * @shell_view: an #EShellView
+ *
+ * Returns %TRUE if @shell_view is active. That is, if it's currently
+ * visible in its #EShellWindow. An #EShellWindow can only display one
+ * shell view at a time.
+ *
+ * Technically this just checks the #GtkToggleAction:active property of
+ * the shell view's switcher action. See e_shell_view_get_action().
+ *
+ * Returns: %TRUE if @shell_view is active
+ **/
+gboolean
+e_shell_view_is_active (EShellView *shell_view)
+{
+ GtkAction *action;
+
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE);
+
+ action = e_shell_view_get_action (shell_view);
+
+ return gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+}
+
+/**
+ * e_shell_view_get_page_num:
+ * @shell_view: an #EShellView
+ *
+ * This function is only interesting to #EShellWindow. It returns the
+ * #GtkNotebook page number for @shell_view. The rest of the application
+ * should have no need for this.
+ *
+ * Returns: the notebook page number for @shell_view
+ **/
+gint
+e_shell_view_get_page_num (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), -1);
+
+ return shell_view->priv->page_num;
+}
+
+/**
+ * e_shell_view_set_page_num:
+ * @shell_view: an #EShellView
+ * @page_num: a notebook page number
+ *
+ * This function is only interesting to #EShellWindow. It sets the
+ * #GtkNotebook page number for @shell_view. The rest of the application
+ * must never call this because it could mess up shell view switching.
+ **/
+void
+e_shell_view_set_page_num (EShellView *shell_view,
+ gint page_num)
+{
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+
+ shell_view->priv->page_num = page_num;
+
+ g_object_notify (G_OBJECT (shell_view), "page-num");
}
-EShellView *e_shell_view_new(struct _EShellWindow *window)
+/**
+ * e_shell_view_get_size_group:
+ * @shell_view: an #EShellView
+ *
+ * Returns a #GtkSizeGroup that #EShellContent and #EShellSidebar use
+ * to keep the search bar and sidebar banner vertically aligned. The
+ * rest of the application should have no need for this.
+ *
+ * Returns: a #GtkSizeGroup for internal use
+ **/
+GtkSizeGroup *
+e_shell_view_get_size_group (EShellView *shell_view)
{
- EShellView *new = g_object_new (e_shell_view_get_type (), NULL);
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ return shell_view->priv->size_group;
+}
- /* TODO: listen to destroy? */
- new->window = window;
+/**
+ * e_shell_view_get_shell_content:
+ * @shell_view: an #EShellView
+ *
+ * Returns the #EShellContent instance for @shell_view.
+ *
+ * By default, #EShellView creates a plain #EShellContent during
+ * initialization. But #EShellView subclasses can override the
+ * <structfield>new_shell_content</structfield> factory method
+ * in #EShellViewClass to create a custom #EShellContent.
+ *
+ * Returns: the #EShellContent instance for @shell_view
+ **/
+EShellContent *
+e_shell_view_get_shell_content (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
- return new;
+ return E_SHELL_CONTENT (shell_view->priv->shell_content);
}
-BONOBO_TYPE_FUNC_FULL (EShellView, GNOME_Evolution_ShellView, bonobo_object_get_type(), e_shell_view)
+/**
+ * e_shell_view_get_shell_sidebar:
+ * @shell_view: an #EShellView
+ *
+ * Returns the #EShellSidebar instance for @shell_view.
+ *
+ * By default, #EShellView creates a plain #EShellSidebar during
+ * initialization. But #EShellView subclasses can override the
+ * <structfield>new_shell_sidebar</structfield> factory method
+ * in #EShellViewClass to create a custom #EShellSidebar.
+ *
+ * Returns: the #EShellSidebar instance for @shell_view
+ **/
+EShellSidebar *
+e_shell_view_get_shell_sidebar (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ return E_SHELL_SIDEBAR (shell_view->priv->shell_sidebar);
+}
+/**
+ * e_shell_view_get_shell_taskbar:
+ * @shell_view: an #EShellView
+ *
+ * Returns the #EShellTaskbar instance for @shell_view.
+ *
+ * By default, #EShellView creates a plain #EShellTaskbar during
+ * initialization. But #EShellView subclasses can override the
+ * <structfield>new_shell_taskbar</structfield> factory method
+ * in #EShellViewClass to create a custom #EShellTaskbar.
+ *
+ * Returns: the #EShellTaskbar instance for @shell_view
+ **/
+EShellTaskbar *
+e_shell_view_get_shell_taskbar (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ return E_SHELL_TASKBAR (shell_view->priv->shell_taskbar);
+}
+
+/**
+ * e_shell_view_update_actions:
+ * @shell_view: an #EShellView
+ *
+ * Emits the #EShellView::update-actions signal.
+ *
+ * #EShellView subclasses should implement the
+ * <structfield>update_actions</structfield> method in #EShellViewClass
+ * to update the various #GtkAction<!-- -->s based on the current
+ * #EShellSidebar and #EShellContent selections. The
+ * #EShellView::update-actions signal is typically emitted just before
+ * showing a popup menu or just after the user selects an item in the
+ * shell view.
+ **/
+void
+e_shell_view_update_actions (EShellView *shell_view)
+{
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+
+ g_signal_emit (shell_view, signals[UPDATE_ACTIONS], 0);
+}
+
+/**
+ * e_shell_view_show_popup_menu:
+ * @shell_view: an #EShellView
+ * @widget_path: path in the UI definition
+ * @event: a #GdkEventButton
+ *
+ * Displays a context-sensitive (or "popup") menu that is described in
+ * the UI definition loaded into @shell_view<!-- -->'s user interface
+ * manager. The menu will be shown at the current mouse cursor position.
+ *
+ * The #EShellView::update-actions signal is emitted just prior to
+ * showing the menu to give @shell_view and any plugins that extend
+ * @shell_view a chance to update the menu's actions.
+ **/
+void
+e_shell_view_show_popup_menu (EShellView *shell_view,
+ const gchar *widget_path,
+ GdkEventButton *event)
+{
+ EShellWindow *shell_window;
+ GtkWidget *menu;
+
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+
+ e_shell_view_update_actions (shell_view);
+
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ menu = e_shell_window_get_managed_widget (shell_window, widget_path);
+ g_return_if_fail (GTK_IS_MENU (menu));
+
+ if (event != NULL)
+ gtk_menu_popup (
+ GTK_MENU (menu), NULL, NULL, NULL, NULL,
+ event->button, event->time);
+ else
+ gtk_menu_popup (
+ GTK_MENU (menu), NULL, NULL, NULL, NULL,
+ 0, gtk_get_current_event_time ());
+}
+
+/**
+ * e_shell_view_new_view_instance:
+ * @shell_view: an #EShellView
+ * @instance_id: a name for the #GalViewInstance
+ *
+ * Creates a new #GalViewInstance and configures it to keep
+ * @shell_view<!-- -->'s #EShellView:view-id property up-to-date.
+ *
+ * Returns: a new #GalViewInstance
+ **/
+GalViewInstance *
+e_shell_view_new_view_instance (EShellView *shell_view,
+ const gchar *instance_id)
+{
+ EShellViewClass *class;
+ GalViewCollection *view_collection;
+ GalViewInstance *view_instance;
+
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ class = E_SHELL_VIEW_GET_CLASS (shell_view);
+
+ view_collection = class->view_collection;
+ view_instance = gal_view_instance_new (view_collection, instance_id);
+
+ g_signal_connect_swapped (
+ view_instance, "changed",
+ G_CALLBACK (shell_view_update_view_id), shell_view);
+
+ return view_instance;
+}
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index f284604d92..1392acfa0a 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -1,6 +1,5 @@
/*
- *
- * This is only a CORBA wrapper around e_shell_window.
+ * e-shell-view.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,51 +19,173 @@
*
*/
-#ifndef _E_SHELL_VIEW_H_
-#define _E_SHELL_VIEW_H_
+/**
+ * SECTION: e-shell-view
+ * @short_description: views within the main window
+ * @include: shell/e-shell-view.h
+ **/
+
+#ifndef E_SHELL_VIEW_H
+#define E_SHELL_VIEW_H
+
+#include <shell/e-shell-common.h>
+#include <shell/e-shell-content.h>
+#include <shell/e-shell-module.h>
+#include <shell/e-shell-sidebar.h>
+#include <shell/e-shell-taskbar.h>
+#include <shell/e-shell-window.h>
+
+#include <widgets/menus/gal-view-collection.h>
+#include <widgets/menus/gal-view-instance.h>
+
+/* Standard GObject macros */
+#define E_TYPE_SHELL_VIEW \
+ (e_shell_view_get_type ())
+#define E_SHELL_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_SHELL_VIEW, EShellView))
+#define E_SHELL_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_SHELL_VIEW, EShellViewClass))
+#define E_IS_SHELL_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_SHELL_VIEW))
+#define E_IS_SHELL_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_SHELL_VIEW))
+#define E_SHELL_VIEW_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_SHELL_VIEW, EShellViewClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EShellView EShellView;
+typedef struct _EShellViewClass EShellViewClass;
+typedef struct _EShellViewPrivate EShellViewPrivate;
-#include <bonobo-activation/bonobo-activation.h>
-#include <bonobo/bonobo-object.h>
+/**
+ * EShellView:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ **/
+struct _EShellView {
+ GObject parent;
+ EShellViewPrivate *priv;
+};
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
+/**
+ * EShellViewClass:
+ * @parent_class: The parent class structure.
+ * @label: The initial value for the switcher action's
+ * #GtkAction:label property. See
+ * e_shell_view_get_action().
+ * @icon_name: The initial value for the switcher action's
+ * #GtkAction:icon-name property. See
+ * e_shell_view_get_action().
+ * @ui_definition: Base name of the UI definintion file to add
+ * when the shell view is activated.
+ * @ui_manager_id: The #GtkUIManager ID for #EPluginUI. Plugins
+ * should use to this ID in their "eplug" files to
+ * add menu and toolbar items to the shell view.
+ * @search_options: Widget path in the UI definition to the search
+ * options popup menu. The menu gets shown when the
+ * user clicks the "find" icon in the search entry.
+ * @search_rules: Base name of the XML file containing predefined
+ * search rules for this shell view. The XML files
+ * are usually named something like <filename>
+ * <emphasis>view</emphasis>types.xml</filename>.
+ * @type_module: The corresponding #GTypeModule for this shell
+ * view. Subclasses are responsible for setting
+ * this. An easy way do so is to pass it to the
+ * shell view's #GClassInitFunc via the
+ * <structfield>class_data</structfield> field in
+ * #GTypeInfo.
+ * @view_collection: A unique #GalViewCollection instance is created
+ * for each subclass and shared across all instances
+ * of that subclass. That much is done automatically
+ * for subclasses, but subclasses are still responsible
+ * for adding the appropriate #GalView factories to the
+ * view collection.
+ * @new_shell_content: Factory method for the shell view's #EShellContent.
+ * See e_shell_view_get_shell_content().
+ * @new_shell_sidebar: Factory method for the shell view's #EShellSidebar.
+ * See e_shell_view_get_shell_sidebar().
+ * @new_shell_taskbar: Factory method for the shell view's #EShellTaskbar.
+ * See e_shell_view_get_shell_taskbar().
+ * @toggled: Class method for the #EShellView::toggled signal.
+ * Subclasses should rarely need to override the
+ * default behavior.
+ * @update_actions: Class method for the #EShellView::update_actions
+ * signal. There is no default behavior; subclasses
+ * should override this.
+ *
+ * #EShellViewClass contains a number of important settings for subclasses.
+ **/
+struct _EShellViewClass {
+ GObjectClass parent_class;
-struct _EShell;
+ /* Initial switcher action values. */
+ const gchar *label;
+ const gchar *icon_name;
-typedef struct _EShellView EShellView;
-typedef struct _EShellViewPrivate EShellViewPrivate;
-typedef struct _EShellViewClass EShellViewClass;
+ /* Base name of the UI definition file. */
+ const gchar *ui_definition;
-#include "Evolution.h"
+ /* GtkUIManager identifier for use with EPluginUI.
+ * Usually "org.gnome.evolution.$(VIEW_NAME)". */
+ const gchar *ui_manager_id;
-#define E_TYPE_SHELL_VIEW (e_shell_view_get_type ())
-#define E_SHELL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SHELL_VIEW, EShellView))
-#define E_SHELL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SHELL_VIEW, EShellViewClass))
-#define E_IS_SHELL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SHELL_VIEW))
-#define E_IS_SHELL_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SHELL_VIEW))
+ /* Widget path to the search options popup menu. */
+ const gchar *search_options;
-struct _EShellView {
- BonoboObject parent;
+ /* Base name of the search rule definition file. */
+ const gchar *search_rules;
- struct _EShellWindow *window;
+ /* Subclasses should set this via the "class_data" field in
+ * the GTypeInfo they pass to g_type_module_register_type(). */
+ GTypeModule *type_module;
- EShellViewPrivate *priv;
-};
+ /* A unique instance is created for each subclass. */
+ GalViewCollection *view_collection;
-struct _EShellViewClass {
- BonoboObjectClass parent_class;
+ /* Factory Methods */
+ GtkWidget * (*new_shell_content) (EShellView *shell_view);
+ GtkWidget * (*new_shell_sidebar) (EShellView *shell_view);
+ GtkWidget * (*new_shell_taskbar) (EShellView *shell_view);
- POA_GNOME_Evolution_ShellView__epv epv;
+ /* Signals */
+ void (*toggled) (EShellView *shell_view);
+ void (*update_actions) (EShellView *shell_view);
};
-GType e_shell_view_get_type (void);
-EShellView *e_shell_view_new(struct _EShellWindow *window);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_SHELL_VIEW_H_ */
-
+GType e_shell_view_get_type (void);
+const gchar * e_shell_view_get_name (EShellView *shell_view);
+GtkAction * e_shell_view_get_action (EShellView *shell_view);
+const gchar * e_shell_view_get_title (EShellView *shell_view);
+void e_shell_view_set_title (EShellView *shell_view,
+ const gchar *title);
+const gchar * e_shell_view_get_view_id (EShellView *shell_view);
+void e_shell_view_set_view_id (EShellView *shell_view,
+ const gchar *view_id);
+gboolean e_shell_view_is_active (EShellView *shell_view);
+gint e_shell_view_get_page_num (EShellView *shell_view);
+void e_shell_view_set_page_num (EShellView *shell_view,
+ gint page_num);
+GtkSizeGroup * e_shell_view_get_size_group (EShellView *shell_view);
+EShellContent * e_shell_view_get_shell_content (EShellView *shell_view);
+EShellSidebar * e_shell_view_get_shell_sidebar (EShellView *shell_view);
+EShellTaskbar * e_shell_view_get_shell_taskbar (EShellView *shell_view);
+EShellWindow * e_shell_view_get_shell_window (EShellView *shell_view);
+EShellModule * e_shell_view_get_shell_module (EShellView *shell_view);
+void e_shell_view_update_actions (EShellView *shell_view);
+void e_shell_view_show_popup_menu (EShellView *shell_view,
+ const gchar *widget_path,
+ GdkEventButton *event);
+GalViewInstance *
+ e_shell_view_new_view_instance (EShellView *shell_view,
+ const gchar *instance_id);
+
+G_END_DECLS
+
+#endif /* E_SHELL_VIEW_H */
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
new file mode 100644
index 0000000000..3577e5b9bc
--- /dev/null
+++ b/shell/e-shell-window-actions.c
@@ -0,0 +1,2230 @@
+/*
+ * e-shell-window-actions.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-shell-window-private.h"
+
+#include <e-util/e-dialog-utils.h>
+#include <e-util/e-error.h>
+#include <e-util/e-print.h>
+#include <gal-define-views-dialog.h>
+
+#include <libedataserverui/e-passwords.h>
+
+#include "e-shell-importer.h"
+
+#define EVOLUTION_COPYRIGHT \
+ "Copyright \xC2\xA9 1999 - 2008 Novell, Inc. and Others"
+
+#define EVOLUTION_FAQ \
+ "http://www.go-evolution.org/FAQ"
+
+#define EVOLUTION_WEBSITE \
+ "http://www.gnome.org/projects/evolution/"
+
+/* Authors and Documenters
+ *
+ * The names below must be in UTF-8. The breaking of escaped strings
+ * is so the hexadecimal sequences don't swallow too many characters.
+ *
+ * SO THAT MEANS, FOR 8-BIT CHARACTERS USE \xXX HEX ENCODING ONLY!
+ *
+ * Not all environments are UTF-8 and not all editors can handle it.
+ */
+static const gchar *authors[] = {
+ "Aaron Weber",
+ "Abel Cheung",
+ "Abhishek Parwal",
+ "Adam Weinberger",
+ "Adi Attar",
+ "Ahmad Riza H Nst",
+ "Aidan Delaney",
+ "Aishwarya K",
+ "Akagic Amila",
+ "Akhil Laddha",
+ "Akira Tagoh",
+ "Alastair McKinstry",
+ "Alastair Tse",
+ "Alejandro Andres",
+ "Alessandro Decina",
+ "Alex Graveley",
+ "Alex Jiang",
+ "Alex Jones",
+ "Alex Kloss",
+ "Alexander Shopov",
+ "Alfred Peng",
+ "Ali Abdin",
+ "Ali Akcaagac",
+ "Almer S. Tigelaar",
+ "Amish",
+ "Anand V M",
+ "Anders Carlsson",
+ "Andre Klapper",
+ "Andrea Campi",
+ "Andreas Henriksson",
+ "Andreas Hyden",
+ "Andreas J. Guelzow",
+ "Andreas K\xC3\xB6hler",
+ "Andreas Köhler",
+ "Andrew Ruthven",
+ "Andrew T. Veliath",
+ "Andrew Wu",
+ "Ankit Patel",
+ "Anna Marie Dirks",
+ "Antonio Xu",
+ "Arafat Medini",
+ "Arangel Angov",
+ "Archit Baweja",
+ "Ariel Rios",
+ "Arik Devens",
+ "Armin Bauer",
+ "Arturo Espinosa Aldama",
+ "Arulanandan P",
+ "Arun Prakash",
+ "Arvind Sundararajan",
+ "Arvind",
+ "Ashish",
+ "B S Srinidhi",
+ "Bastien Nocera",
+ "Behnam Esfahbod",
+ "Ben Gamari",
+ "Benjamin Berg",
+ "Benjamin Kahn",
+ "Benoît Dejean",
+ "Bernard Leach",
+ "Bertrand Guiheneuf",
+ "Bharath Acharya",
+ "Bill Zhu",
+ "Bj\xC3\xB6rn Torkelsson",
+ "Björn Lindqvist",
+ "Bob Doan",
+ "Bob Mauchin",
+ "Boby Wang",
+ "Bolian Yin",
+ "Brian Mury",
+ "Brian Pepple",
+ "Bruce Tao",
+ "Calvin Liu",
+ "Cantona Su",
+ "Carl Sun",
+ "Carlos Garcia Campos",
+ "Carlos Garnacho Parro",
+ "Carlos Perell\xC3\xB3" " Mar\xC3\xAD" "n",
+ "Carsten Guenther",
+ "Carsten Schaar",
+ "Changwoo Ryu",
+ "Chao-Hsiung Liao",
+ "Charles Zhang",
+ "Chema Celorio",
+ "Chenthill Palanisamy",
+ "Chpe",
+ "Chris Halls",
+ "Chris Heath",
+ "Chris Phelps",
+ "Chris Toshok",
+ "Christian Hammond",
+ "Christian Kellner",
+ "Christian Kirbach",
+ "Christian Krause",
+ "Christian Kreibich",
+ "Christian Neumair",
+ "Christophe Fergeau",
+ "Christophe Merlet",
+ "Christopher Blizzard",
+ "Christopher J. Lahey",
+ "Christopher R. Gabriel",
+ "Claude Paroz",
+ "Claudio Saavedra",
+ "Clifford R. Conover",
+ "Cody Russell",
+ "Colin Leroy",
+ "Craig Small",
+ "Dafydd Harries",
+ "Damian Ivereigh",
+ "Damien Carbery",
+ "Damon Chaplin",
+ "Dan Berger",
+ "Dan Damian",
+ "Dan Nguyen",
+ "Dan Winship",
+ "Daniel Gryniewicz",
+ "Daniel Nylander",
+ "Daniel van Eeden",
+ "Daniel Veillard",
+ "Daniel Yacob",
+ "Danilo \xC5\xA0" "egan",
+ "Danilo Segan",
+ "Darin Adler",
+ "Dave Benson",
+ "Dave Camp",
+ "Dave Fallon",
+ "Dave Malcolm",
+ "Dave West",
+ "David Farning",
+ "David Kaelbling",
+ "David Malcolm",
+ "David Moore",
+ "David Mosberger",
+ "David Richards",
+ "David Trowbridge",
+ "David Turner",
+ "David Woodhouse",
+ "Denis Washington",
+ "Devashish Sharma",
+ "Diego Escalante Urrelo",
+ "Diego Gonzalez",
+ "Diego Sevilla Ruiz",
+ "Dietmar Maurer",
+ "Dinesh Layek",
+ "Djihed Afifi",
+ "Dmitry Mastrukov",
+ "Dodji Seketeli",
+ "Duarte Loreto",
+ "Dulmandakh Sukhbaatar",
+ "Duncan Mak",
+ "Ebby Wiselyn",
+ "Ed Catmur",
+ "Edd Dumbill",
+ "Edgar Luna Díaz",
+ "Edward Rudd",
+ "Elijah Newren",
+ "Elizabeth Greene",
+ "Elliot Lee",
+ "Elliot Turner",
+ "Eneko Lacunza",
+ "Enver Altin",
+ "Erdal Ronahi",
+ "Eric Busboom",
+ "Eric Zhao",
+ "Eskil Heyn Olsen",
+ "Ettore Perazzoli",
+ "Evan Yan",
+ "Fatih Demir",
+ "Fazlu & Hannah",
+ "Federico Mena Quintero",
+ "Fernando Herrera",
+ "Francisco Javier F. Serrador",
+ "Frank Arnold",
+ "Frank Belew",
+ "Frederic Crozat",
+ "Frederic Peters",
+ "Funda Wang",
+ "Gabor Kelemen",
+ "Ganesh",
+ "Gareth Owen",
+ "Gary Coady",
+ "Gary Ekker",
+ "Gavin Scott",
+ "Gediminas Paulauskas",
+ "Gerg\xC5\x91 \xC3\x89rdi",
+ "George Lebl",
+ "Gerardo Marin",
+ "Gert Kulyk",
+ "Giancarlo Capella",
+ "Gil Osher",
+ "Gilbert Fang",
+ "Gilles Dartiguelongue",
+ "Grahame Bowland",
+ "Greg Hudson",
+ "Gregory Leblanc",
+ "Gregory McLean",
+ "Grzegorz Goawski",
+ "Gustavo Gir\xC3\x8E" "ldez",
+ "Gustavo Maciel Dias Vieira",
+ "H P Nadig",
+ "H\xC3\xA9" "ctor Garc\xC3\xAD" "a \xC3\x81" "lvarez",
+ "Hans Petter Jansson",
+ "Hao Sheng",
+ "Hari Prasad Nadig",
+ "Harish K",
+ "Harish Krishnaswamy",
+ "Harry Lu",
+ "Hasbullah Bin Pit",
+ "Havoc Pennington",
+ "Heath Harrelson",
+ "Hein-Pieter van Braam",
+ "Herbert V. Riedel",
+ "Hiroyuki Ikezoe",
+ "Iain Buchanan",
+ "Iain Holmes",
+ "Ian Campbell",
+ "Ilkka Tuohela",
+ "Irene Huang",
+ "Ismael Olea",
+ "Israel Escalante",
+ "Iv\xC3\xA1" "n Frade",
+ "Iván Frade",
+ "J.H.M. Dassen (Ray)",
+ "JP Rosevear",
+ "J\xC3\xBC" "rg Billeter",
+ "Jürg Billeter",
+ "Jack Jia",
+ "Jacob Ulysses Berkman",
+ "Jacob Berkman",
+ "Jaka Mocnik",
+ "Jakub Steiner",
+ "James Doc Livingston",
+ "James Bowes",
+ "James Henstridge",
+ "James Willcox",
+ "Jan Arne Petersen",
+ "Jan Tichavsky",
+ "Jan Van Buggenhout",
+ "Jared Moore",
+ "Jarkko Ranta",
+ "Jason Leach",
+ "Jason Tackaberry",
+ "Jayaradha",
+ "Jean-Noel Guiheneuf",
+ "Jedy Wang",
+ "Jeff Bailey",
+ "Jeff Cai",
+ "Jeff Garzik",
+ "Jeffrey Stedfast",
+ "Jens Granseuer",
+ "Jens Seidel",
+ "Jeremy Katz",
+ "Jeremy Wise",
+ "Jerome Lacoste",
+ "Jerry Yu",
+ "Jes\xC3\xBA" "s Bravo \xC3\x81" "lvarez",
+ "Jesse Pavel",
+ "Ji Lee",
+ "Joan Sanfeliu",
+ "Jody Goldberg",
+ "Joe Marcus Clarke",
+ "Joe Shaw",
+ "John Gotts",
+ "Johnny Jacob",
+ "Johnny",
+ "Jon Ander Hernandez",
+ "Jon K Hellan",
+ "Jon Oberheide",
+ "Jon Trowbridge",
+ "Jonas Borgstr",
+ "Jonathan Blandford",
+ "Jonathan Dieter",
+ "Jos Dehaes",
+ "Josselin Mouette",
+ "JP Rosvear",
+ "Jukka Zitting",
+ "Jules Colding",
+ "Julian Missig",
+ "Julio M. Merino Vidal",
+ "Jürg Billeter",
+ "Karl Eichwalder",
+ "Karl Relton",
+ "Karsten Br\xC3\xA4" "ckelmann",
+ "Kaushal Kumar",
+ "Kenneth Christiansen",
+ "Kenny Graunke",
+ "Keshav Upadhyaya",
+ "Kevin Breit",
+ "Kevin Piche",
+ "Kevin Vandersloot",
+ "Khasim Shaheed",
+ "Kidd Wang",
+ "Kjartan Maraas",
+ "Krishnan R",
+ "Krisztian Pifko",
+ "Kyle Ambroff",
+ "Larry Ewing",
+ "Laszlo (Laca) Peter",
+ "Laurent Dhima",
+ "Lauris Kaplinski",
+ "Leon Zhang",
+ "Li Yuan",
+ "Loïc Minier",
+ "Loïc Minier",
+ "Lorenzo Gil Sanchez",
+ "Luca Ferretti",
+ "Lucky Wankhede",
+ "Luis Villa",
+ "Lutz M",
+ "M Victor Aloysius J",
+ "Maciej Stachowiak",
+ "Makuchaku",
+ "Malcolm Tredinnick",
+ "Marco Pesenti Gritti",
+ "Marius Andreiana",
+ "Marius Vollmer",
+ "Mark Crichton",
+ "Mark G. Adams",
+ "Mark Gordon",
+ "Mark McLoughlin",
+ "Mark Moulder",
+ "Mark Tearle",
+ "Martha Burke",
+ "Martin Baulig",
+ "Martin Hicks",
+ "Martin Meyer",
+ "Martin Norb\xC3\xA4" "ck",
+ "Martyn Russell",
+ "Masahiro Sakai",
+ "Mathieu Lacage",
+ "Matias Mutchinick",
+ "Matt Bissiri",
+ "Matt Brown",
+ "Matt Loper",
+ "Matt Martin",
+ "Matt Wilson",
+ "Matthew Barnes",
+ "Matthew Daniel",
+ "Matthew Hall",
+ "Matthew Loper",
+ "Matthew Wilson",
+ "Matthias Clasen",
+ "Max Horn",
+ "Maxx Cao",
+ "Mayank Jain",
+ "Meilof Veeningen",
+ "Mengjie Yu",
+ "Michael Granger",
+ "Michael M. Morrison",
+ "Michael MacDonald",
+ "Michael Meeks",
+ "Michael Monreal",
+ "Michael Terry",
+ "Michael Zucchi",
+ "Michel Daenzer",
+ "Miguel Angel Lopez Hernandez",
+ "Miguel de Icaza",
+ "Mikael Hallendal",
+ "Mikael Nilsson",
+ "Mike Castle",
+ "Mike Kestner",
+ "Mike McEwan",
+ "Mikhail Zabaluev",
+ "Milan Crha",
+ "Miles Lane",
+ "Mohammad Damt",
+ "Morten Welinder",
+ "Mubeen Jukaku",
+ "Murray Cumming",
+ "Naba Kumar",
+ "Nagappan Alagappan",
+ "Nancy Cai",
+ "Nat Friedman",
+ "Nathan Owens",
+ "Nicel KM",
+ "Nicholas J Kreucher",
+ "Nicholas Miell",
+ "Nick Sukharev",
+ "Nickolay V. Shmyrev",
+ "Nike Gerdts",
+ "Noel",
+ "Nuno Ferreira",
+ "Nyall Dawson",
+ "Ondrej Jirman",
+ "Oswald Rodrigues",
+ "Owen Taylor",
+ "Oystein Gisnas",
+ "P Chenthill",
+ "P S Chakravarthi",
+ "Pablo Gonzalo del Campo",
+ "Pablo Saratxaga",
+ "Pamplona Hackers",
+ "Paolo Molaro",
+ "Parag Goel",
+ "Parthasarathi Susarla",
+ "Pascal Terjan",
+ "Patrick Ohly",
+ "Paul Bolle",
+ "Paul Lindner",
+ "Pavel Cisler",
+ "Pavel Roskin",
+ "Pavithran",
+ "Pawan Chitrakar",
+ "Pedro Villavicencio",
+ "Peter Pouliot",
+ "Peter Teichman",
+ "Peter Williams",
+ "Peteris Krisjanis",
+ "Petta Pietikainen",
+ "Phil Goembel",
+ "Philip Van Hoof",
+ "Philip Zhao",
+ "Poornima Nayak",
+ "Pratik V. Parikh",
+ "Praveen Kumar",
+ "Priit Laes",
+ "Priyanshu Raj",
+ "Radek Doul\xC3\xADk",
+ "Raghavendran R",
+ "Raja R Harinath",
+ "Rajeev Ramanathan",
+ "Rajesh Ranjan",
+ "Rakesh k.g",
+ "Ramiro Estrugo",
+ "Ranjan Somani",
+ "Ray Strode",
+ "Rhys Jones",
+ "Ricardo Markiewicz",
+ "Richard Boulton",
+ "Richard Hult",
+ "Richard Li",
+ "Rob Bradford",
+ "Robert Brady",
+ "Robert Sedak",
+ "Robin Slomkowski",
+ "Rodney Dawes",
+ "Rodrigo Moya",
+ "Rohini S",
+ "Rohini",
+ "Roland Illig",
+ "Ronald Kuetemeier",
+ "Roozbeh Pournader",
+ "Ross Burton",
+ "Rouslan Solomakhin",
+ "Runa Bhattacharjee",
+ "Russell Steinthal",
+ "Rusty Conover",
+ "Ryan P. Skadberg",
+ "S Antony Vincent Pandian",
+ "S N Tejasvi",
+ "S. \xC3\x87" "a\xC4\x9F" "lar Onur",
+ "S.Antony Vincent Pandian",
+ "S. Caglar Onur",
+ "Sam Creasey",
+ "Sam Yang",
+ "Sam\xC3\xBA" "el J\xC3\xB3" "n Gunnarsson",
+ "Sankar P",
+ "Sanlig Badral",
+ "Sanshao Jiang",
+ "Sarfraaz Ahmed",
+ "Sayamindu Dasgupta",
+ "Sean Atkinson",
+ "Sean Gao",
+ "Sebastian Rittau",
+ "Sebastian Wilhelmi",
+ "Sebastien Bacher",
+ "Sergey Panov",
+ "Seth Alves",
+ "Seth Nickell",
+ "Shakti Sen",
+ "Shi Pu",
+ "Shilpa C",
+ "Shree Krishnan",
+ "Shreyas Srinivasan",
+ "Simon Zheng",
+ "Simos Xenitellis",
+ "Sivaiah Nallagatla",
+ "Srinivasa Ragavan",
+ "Stanislav Brabec",
+ "Stanislav Visnovsky",
+ "Stéphane Raimbault",
+ "Stephen Cook",
+ "Steve Murphy",
+ "Steven Zhang",
+ "Stuart Parmenter",
+ "Subodh Soni",
+ "Suman Manjunath",
+ "Sunil Mohan Adapa",
+ "Suresh Chandrasekharan",
+ "Sushma Rai",
+ "Sven Herzberg",
+ "Szabolcs Ban",
+ "T\xC3\xB5" "ivo Leedj\xC3\xA4" "rv",
+ "Takao Fujiwara",
+ "Takayuki Kusano",
+ "Takeshi Aihana",
+ "Tambet Ingo",
+ "Taylor Hayward",
+ "Ted Percival",
+ "Theppitak Karoonboonyanan",
+ "Thomas Cataldo",
+ "Thomas Klausner",
+ "Thomas Mirlacher",
+ "Thouis R. Jones",
+ "Tim Wo",
+ "Tim Yamin",
+ "Timo Hoenig",
+ "Timo Sirainen",
+ "Timothy Lee",
+ "Timur Bakeyev",
+ "Tino Meinen",
+ "Tobias Mueller",
+ "Tõivo Leedjärv",
+ "Tom Tromey",
+ "Tomas Ogren",
+ "Tomasz K\xC5\x82" "oczko",
+ "Tomislav Vujec",
+ "Tommi Komulainen",
+ "Tommi Vainikainen",
+ "Tony Tsui",
+ "Tor Lillqvist",
+ "Trent Lloyd",
+ "Tuomas J. Lukka",
+ "Tuomas Kuosmanen",
+ "Ulrich Neumann",
+ "Umesh Tiwari",
+ "Umeshtej",
+ "Ushveen Kaur",
+ "V Ravi Kumar Raju",
+ "Vadim Strizhevsky",
+ "Valek Filippov",
+ "Vandana Shenoy .B",
+ "Vardhman Jain",
+ "Veerapuram Varadhan",
+ "Vincent Noel",
+ "Vincent van Adrighem",
+ "Viren",
+ "Vivek Jain",
+ "Vladimer Sichinava",
+ "Vladimir Vukicevic",
+ "Wadim Dziedzic",
+ "Wang Jian",
+ "Wang Xin",
+ "Wayne Davis",
+ "William Jon McCann",
+ "Wouter Bolsterlee",
+ "Xan Lopez",
+ "Xiurong Simon Zheng",
+ "Yanko Kaneti",
+ "Yi Jin",
+ "Yong Sun",
+ "Yu Mengjie",
+ "Yuedong Du",
+ "Yukihiro Nakai",
+ "Yuri Pankov",
+ "Yuri Syrota",
+ "Zach Frey",
+ "Zan Lynx",
+ "Zbigniew Chyla",
+ "\xC3\x98ystein Gisn\xC3\xA5s",
+ "\xC5\xBDygimantas Beru\xC4\x8Dka",
+ NULL
+};
+
+static const gchar *documenters[] = {
+ "Aaron Weber",
+ "Binika Preet",
+ "Dan Winship",
+ "David Trowbridge",
+ "Jessica Prabhakar",
+ "JP Rosevear",
+ "Radhika Nair",
+ NULL
+};
+
+/**
+ * E_SHELL_WINDOW_ACTION_ABOUT:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action displays the application's About dialog.
+ *
+ * Main menu item: Help -> About
+ **/
+static void
+action_about_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ gchar *translator_credits;
+
+ /* The translator-credits string is for translators to list
+ * per-language credits for translation, displayed in the
+ * about dialog. */
+ translator_credits = _("translator-credits");
+ if (strcmp (translator_credits, "translator-credits") == 0)
+ translator_credits = NULL;
+
+ gtk_show_about_dialog (
+ GTK_WINDOW (shell_window),
+ "program-name", "Evolution",
+ "version", VERSION,
+ "copyright", EVOLUTION_COPYRIGHT,
+ "comments", _("Groupware Suite"),
+ "website", EVOLUTION_WEBSITE,
+ "website-label", _("Evolution Website"),
+ "authors", authors,
+ "documenters", documenters,
+ "translator-credits", translator_credits,
+ "logo-icon-name", "evolution",
+ NULL);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_CLOSE:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action closes @window. If this is the last window,
+ * the application initiates shutdown.
+ *
+ * Main menu item: File -> Close
+ **/
+static void
+action_close_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ GtkWidget *widget = GTK_WIDGET (shell_window);
+ GdkEvent *event;
+
+ /* Synthesize a delete_event on this window. */
+ event = gdk_event_new (GDK_DELETE);
+ event->any.window = g_object_ref (widget->window);
+ event->any.send_event = TRUE;
+ gtk_main_do_event (event);
+ gdk_event_free (event);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_CONTENTS:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action opens the application's user manual.
+ *
+ * Main menu item: Help -> Contents
+ **/
+static void
+action_contents_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ e_display_help (GTK_WINDOW (shell_window), NULL);
+}
+
+static void
+action_custom_rule_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ FilterRule *rule;
+ EShellView *shell_view;
+ EShellContent *shell_content;
+ const gchar *view_name;
+
+ rule = g_object_get_data (G_OBJECT (action), "rule");
+ g_return_if_fail (rule != NULL);
+
+ view_name = e_shell_window_get_active_view (shell_window);
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+
+ rule = g_object_get_data (G_OBJECT (action), "rule");
+ g_return_if_fail (IS_FILTER_RULE (rule));
+
+ e_shell_content_set_search_rule (shell_content, rule);
+ gtk_action_activate (ACTION (SEARCH_EXECUTE));
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_FAQ:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action opens a web page with answers to frequently
+ * asked questions about this application.
+ *
+ * Main menu item: Help -> Evolution FAQ
+ **/
+static void
+action_faq_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ e_show_uri (GTK_WINDOW (shell_window), EVOLUTION_FAQ);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_FORGET_PASSWORDS:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action deletes all stored passwords.
+ *
+ * Main menu item: File -> Forget Passwords
+ **/
+static void
+action_forget_passwords_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ gint response;
+
+ response = e_error_run (
+ GTK_WINDOW (shell_window), "shell:forget-passwords", NULL);
+
+ if (response == GTK_RESPONSE_OK)
+ e_passwords_forget_passwords ();
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_GAL_DEFINE_VIEWS:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action opens a dialog for editing GAL views for
+ * the current shell view.
+ *
+ * Main menu item: View -> Current View -> Define Views...
+ **/
+static void
+action_gal_define_views_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ EShellViewClass *shell_view_class;
+ GalViewCollection *view_collection;
+ GtkWidget *dialog;
+ const gchar *view_name;
+
+ view_name = e_shell_window_get_active_view (shell_window);
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+ shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
+ view_collection = shell_view_class->view_collection;
+ g_return_if_fail (view_collection != NULL);
+
+ dialog = gal_define_views_dialog_new (view_collection);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gal_view_collection_save (view_collection);
+ gtk_widget_destroy (dialog);
+
+ e_shell_window_update_view_menu (shell_window);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_GAL_CUSTOM_VIEW:
+ * @window: an #EShellWindow
+ *
+ * This radio action is selected when using a custom GAL view that has
+ * not been saved.
+ *
+ * Main menu item: View -> Current View -> Custom View
+ **/
+static void
+action_gal_view_cb (GtkRadioAction *action,
+ GtkRadioAction *current,
+ EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ const gchar *view_name;
+ const gchar *view_id;
+
+ view_name = e_shell_window_get_active_view (shell_window);
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+ view_id = g_object_get_data (G_OBJECT (current), "view-id");
+ e_shell_view_set_view_id (shell_view, view_id);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_GAL_SAVE_CUSTOM_VIEW:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action saves a custom GAL view.
+ *
+ * Main menu item: View -> Current View -> Save Custom View...
+ **/
+
+/**
+ * E_SHELL_WINDOW_ACTION_IMPORT:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action opens the Evolution Import Assistant.
+ *
+ * Main menu item: File -> Import...
+ **/
+static void
+action_import_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ e_shell_importer_start_import (shell_window);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_NEW_WINDOW:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action opens a new shell window.
+ *
+ * Main menu item: File -> New Window
+ **/
+static void
+action_new_window_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShell *shell;
+ const gchar *view_name;
+
+ shell = e_shell_window_get_shell (shell_window);
+ view_name = e_shell_window_get_active_view (shell_window);
+
+ e_shell_create_shell_window (shell, view_name);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_PAGE_SETUP:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action opens the application's Page Setup dialog.
+ *
+ * Main menu item: File -> Page Setup...
+ **/
+static void
+action_page_setup_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ e_print_run_page_setup_dialog (GTK_WINDOW (shell_window));
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_PREFERENCES:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action opens the application's Preferences window.
+ *
+ * Main menu item: Edit -> Preferences
+ **/
+static void
+action_preferences_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShell *shell;
+ GtkWidget *preferences_window;
+
+ shell = e_shell_window_get_shell (shell_window);
+ preferences_window = e_shell_get_preferences_window (shell);
+
+ gtk_window_set_transient_for (
+ GTK_WINDOW (preferences_window),
+ GTK_WINDOW (shell_window));
+ gtk_window_set_position (
+ GTK_WINDOW (preferences_window),
+ GTK_WIN_POS_CENTER_ON_PARENT);
+ gtk_window_present (GTK_WINDOW (preferences_window));
+
+ /* FIXME Switch to a page appropriate for the current view. */
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_QUICK_REFERENCE:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action opens a printable table of useful shortcut
+ * keys for this application.
+ *
+ * Main menu item: Help -> Quick Reference
+ **/
+static void
+action_quick_reference_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ const gchar * const *language_names;
+
+ language_names = g_get_language_names ();
+ while (*language_names != NULL) {
+ const gchar *language = *language_names++;
+ gchar *filename;
+
+ /* This must be a valid language AND a language with
+ * no encoding suffix. The next language should have
+ * no encoding suffix. */
+ if (language == NULL || strchr (language, '.') != NULL)
+ continue;
+
+ filename = g_build_filename (
+ EVOLUTION_HELPDIR, "quickref",
+ language, "quickref.pdf", NULL);
+
+ if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ GFile *file;
+ gchar *uri;
+ GError *error = NULL;
+
+ file = g_file_new_for_path (filename);
+ uri = g_file_get_uri (file);
+
+ g_app_info_launch_default_for_uri (uri, NULL, &error);
+
+ if (error != NULL) {
+ /* FIXME Show an error dialog. */
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
+ g_object_unref (file);
+ g_free (uri);
+ }
+
+ g_free (filename);
+ }
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_QUIT:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action initiates application shutdown.
+ *
+ * Main menu item: File -> Quit
+ **/
+static void
+action_quit_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShell *shell;
+
+ shell = e_shell_window_get_shell (shell_window);
+ e_shell_quit (shell);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_SEARCH_ADVANCED:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action opens an Advanced Search dialog.
+ *
+ * Main menu item: Search -> Advanced Search...
+ **/
+static void
+action_search_advanced_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ EShellContent *shell_content;
+ const gchar *view_name;
+
+ view_name = e_shell_window_get_active_view (shell_window);
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+
+ e_shell_content_run_advanced_search_dialog (shell_content);
+ e_shell_window_update_search_menu (shell_window);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_SEARCH_CLEAR:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action clears the most recent search results.
+ *
+ * Main menu item: Search -> Clear
+ **/
+static void
+action_search_clear_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ EShellContent *shell_content;
+ const gchar *view_name;
+
+ view_name = e_shell_window_get_active_view (shell_window);
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+
+ e_shell_content_set_search_rule (shell_content, NULL);
+ e_shell_content_set_search_text (shell_content, NULL);
+
+ gtk_action_activate (ACTION (SEARCH_EXECUTE));
+
+ e_shell_window_update_search_menu (shell_window);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_SEARCH_EDIT:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action opens a dialog for editing saved searches.
+ *
+ * Main menu item: Search -> Edit Saved Searches...
+ **/
+static void
+action_search_edit_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ EShellContent *shell_content;
+ const gchar *view_name;
+
+ view_name = e_shell_window_get_active_view (shell_window);
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+
+ e_shell_content_run_edit_searches_dialog (shell_content);
+ e_shell_window_update_search_menu (shell_window);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_SEARCH_EXECUTE:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action executes the current search conditions.
+ *
+ * Main menu item: Search -> Find Now
+ **/
+
+/**
+ * E_SHELL_WINDOW_ACTION_SEARCH_OPTIONS:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action displays a menu of search options.
+ * This appears as a "find" icon in the window's search entry.
+ **/
+static void
+action_search_options_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ EShellViewClass *shell_view_class;
+ const gchar *view_name;
+ const gchar *widget_path;
+
+ view_name = e_shell_window_get_active_view (shell_window);
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+ shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
+
+ widget_path = shell_view_class->search_options;
+ e_shell_view_show_popup_menu (shell_view, widget_path, NULL);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_SEARCH_SAVE:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action saves the current search conditions.
+ *
+ * Main menu item: Search -> Save Search...
+ **/
+static void
+action_search_save_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ EShellContent *shell_content;
+ const gchar *view_name;
+
+ view_name = e_shell_window_get_active_view (shell_window);
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+
+ e_shell_content_run_save_search_dialog (shell_content);
+ e_shell_window_update_search_menu (shell_window);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_SEND_RECEIVE:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action opens the Send &amp; Receive Mail dialog.
+ *
+ * Main menu item: File -> Send / Receive
+ **/
+static void
+action_send_receive_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShell *shell;
+
+ shell = e_shell_window_get_shell (shell_window);
+ e_shell_send_receive (shell, GTK_WINDOW (shell_window));
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_SHOW_SIDEBAR:
+ * @window: an #EShellWindow
+ *
+ * This toggle action controls whether the side bar is visible.
+ *
+ * Main menu item: View -> Layout -> Show Side Bar
+ **/
+static void
+action_show_sidebar_cb (GtkToggleAction *action,
+ EShellWindow *shell_window)
+{
+ GtkPaned *paned;
+ GtkWidget *widget;
+ gboolean active;
+
+ paned = GTK_PANED (shell_window->priv->content_pane);
+
+ widget = gtk_paned_get_child1 (paned);
+ active = gtk_toggle_action_get_active (action);
+ g_object_set (widget, "visible", active, NULL);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_SHOW_STATUSBAR:
+ * @window: an #EShellWindow
+ *
+ * This toggle action controls whether the status bar is visible.
+ *
+ * Main menu item: View -> Layout -> Show Status Bar
+ **/
+static void
+action_show_statusbar_cb (GtkToggleAction *action,
+ EShellWindow *shell_window)
+{
+ GtkWidget *widget;
+ gboolean active;
+
+ widget = shell_window->priv->status_area;
+ active = gtk_toggle_action_get_active (action);
+ g_object_set (widget, "visible", active, NULL);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_SHOW_SWITCHER:
+ * @window: an #EShellWindow
+ *
+ * This toggle action controls whether the switcher buttons are visible.
+ *
+ * Main menu item: View -> Switcher Appearance -> Show Buttons
+ **/
+static void
+action_show_switcher_cb (GtkToggleAction *action,
+ EShellWindow *shell_window)
+{
+ EShellSwitcher *switcher;
+ gboolean active;
+
+ switcher = E_SHELL_SWITCHER (shell_window->priv->switcher);
+ active = gtk_toggle_action_get_active (action);
+ e_shell_switcher_set_visible (switcher, active);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_SHOW_TOOLBAR:
+ * @window: an #EShellWindow
+ *
+ * This toggle action controls whether the tool bar is visible.
+ *
+ * Main menu item: View -> Layout -> Show Tool Bar
+ **/
+static void
+action_show_toolbar_cb (GtkToggleAction *action,
+ EShellWindow *shell_window)
+{
+ GtkWidget *widget;
+ gboolean active;
+
+ widget = shell_window->priv->main_toolbar;
+ active = gtk_toggle_action_get_active (action);
+ g_object_set (widget, "visible", active, NULL);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_SUBMIT_BUG:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action allows users to report a bug using
+ * Bug Buddy.
+ *
+ * Main menu item: Help -> Submit Bug Report
+ **/
+static void
+action_submit_bug_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ const gchar *command_line;
+ GError *error = NULL;
+
+ command_line = "bug-buddy --sm-disable --package=Evolution";
+
+ g_debug ("Spawning: %s", command_line);
+ g_spawn_command_line_async (command_line, &error);
+
+ if (error != NULL) {
+ const gchar *message;
+
+ if (error->code == G_SPAWN_ERROR_NOENT)
+ message = _("Bug Buddy is not installed.");
+ else
+ message = _("Bug Buddy could not be run.");
+ e_notice (shell_window, GTK_MESSAGE_ERROR, message);
+ g_error_free (error);
+ }
+}
+
+static void
+action_switcher_cb (GtkRadioAction *action,
+ GtkRadioAction *current,
+ EShellWindow *shell_window)
+{
+ const gchar *view_name;
+
+ view_name = g_object_get_data (G_OBJECT (current), "view-name");
+ e_shell_window_switch_to_view (shell_window, view_name);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_SWITCHER_STYLE_BOTH:
+ * @window: an #EShellWindow
+ *
+ * This radio action displays switcher buttons with icons and text.
+ *
+ * Main menu item: View -> Switcher Appearance -> Icons and Text
+ **/
+
+/**
+ * E_SHELL_WINDOW_ACTION_SWITCHER_STYLE_ICONS:
+ * @window: an #EShellWindow
+ *
+ * This radio action displays switcher buttons with icons only.
+ *
+ * Main menu item: View -> Switcher Appearance -> Icons Only
+ **/
+
+/**
+ * E_SHELL_WINDOW_ACTION_SWITCHER_STYLE_TEXT:
+ * @window: an #EShellWindow
+ *
+ * This radio action displays switcher buttons with text only.
+ *
+ * Main menu item: View -> Switcher Appearance -> Text Only
+ **/
+
+/**
+ * E_SHELL_WINDOW_ACTION_SWITCHER_STYLE_USER:
+ * @window: an #EShellWindow
+ *
+ * This radio action displays switcher buttons according to the desktop
+ * toolbar setting.
+ *
+ * Main menu item: View -> Switcher Appearance -> Toolbar Style
+ **/
+static void
+action_switcher_style_cb (GtkRadioAction *action,
+ GtkRadioAction *current,
+ EShellWindow *shell_window)
+{
+ EShellSwitcher *switcher;
+ GtkToolbarStyle style;
+
+ switcher = E_SHELL_SWITCHER (shell_window->priv->switcher);
+ style = gtk_radio_action_get_current_value (action);
+
+ switch (style) {
+ case GTK_TOOLBAR_ICONS:
+ case GTK_TOOLBAR_TEXT:
+ case GTK_TOOLBAR_BOTH:
+ case GTK_TOOLBAR_BOTH_HORIZ:
+ e_shell_switcher_set_style (switcher, style);
+ break;
+
+ default:
+ e_shell_switcher_unset_style (switcher);
+ break;
+ }
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_SYNC_OPTIONS:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action opens the Gnome Pilot settings.
+ *
+ * Main menu item: Edit -> Synchronization Options...
+ **/
+static void
+action_sync_options_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ const gchar *command_line;
+ GError *error = NULL;
+
+ command_line = "gpilotd-control-applet";
+
+ g_debug ("Spawning: %s", command_line);
+ g_spawn_command_line_async (command_line, &error);
+
+ if (error != NULL) {
+ const gchar *message;
+
+ if (error->code == G_SPAWN_ERROR_NOENT)
+ message = _("GNOME Pilot is not installed.");
+ else
+ message = _("GNOME Pilot could not be run.");
+ e_notice (shell_window, GTK_MESSAGE_ERROR, message);
+ g_error_free (error);
+ }
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_WORK_OFFLINE:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action puts the application into offline mode.
+ *
+ * Main menu item: File -> Work Offline
+ **/
+static void
+action_work_offline_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShell *shell;
+
+ shell = e_shell_window_get_shell (shell_window);
+ e_shell_set_online (shell, FALSE);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_WORK_ONLINE:
+ * @window: an #EShellWindow
+ *
+ * Activation of this action puts the application into online mode.
+ *
+ * Main menu item: File -> Work Online
+ **/
+static void
+action_work_online_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ EShell *shell;
+
+ shell = e_shell_window_get_shell (shell_window);
+ e_shell_set_online (shell, TRUE);
+}
+
+/**
+ * E_SHELL_WINDOW_ACTION_GROUP_CUSTOM_RULES:
+ * @window: an #EShellWindow
+ **/
+
+/**
+ * E_SHELL_WINDOW_ACTION_GROUP_GAL_VIEW:
+ * @window: an #EShellWindow
+ **/
+
+/**
+ * E_SHELL_WINDOW_ACTION_GROUP_NEW_ITEM:
+ * @window: an #EShellWindow
+ **/
+
+/**
+ * E_SHELL_WINDOW_ACTION_GROUP_NEW_SOURCE:
+ * @window: an #EShellWindow
+ **/
+
+/**
+ * E_SHELL_WINDOW_ACTION_GROUP_SHELL:
+ * @window: an #EShellWindow
+ **/
+
+/**
+ * E_SHELL_WINDOW_ACTION_GROUP_SWITCHER:
+ * @window: an #EShellWindow
+ **/
+
+static GtkActionEntry shell_entries[] = {
+
+ { "about",
+ GTK_STOCK_ABOUT,
+ NULL,
+ NULL,
+ N_("Show information about Evolution"),
+ G_CALLBACK (action_about_cb) },
+
+ { "close",
+ GTK_STOCK_CLOSE,
+ N_("_Close Window"),
+ "<Control>w",
+ N_("Close this window"),
+ G_CALLBACK (action_close_cb) },
+
+ { "contents",
+ GTK_STOCK_HELP,
+ N_("_Contents"),
+ "F1",
+ N_("Open the Evolution User Guide"),
+ G_CALLBACK (action_contents_cb) },
+
+ { "faq",
+ "help-faq",
+ N_("Evolution _FAQ"),
+ NULL,
+ N_("Open the Frequently Asked Questions webpage"),
+ G_CALLBACK (action_faq_cb) },
+
+ { "forget-passwords",
+ NULL,
+ N_("_Forget Passwords"),
+ NULL,
+ N_("Forget all remembered passwords"),
+ G_CALLBACK (action_forget_passwords_cb) },
+
+ { "import",
+ "stock_mail-import",
+ N_("I_mport..."),
+ NULL,
+ N_("Import data from other programs"),
+ G_CALLBACK (action_import_cb) },
+
+ { "new-window",
+ "window-new",
+ N_("New _Window"),
+ "<Control><Shift>w",
+ N_("Create a new window displaying this view"),
+ G_CALLBACK (action_new_window_cb) },
+
+ { "preferences",
+ GTK_STOCK_PREFERENCES,
+ NULL,
+ "<Control><Shift>s",
+ N_("Configure Evolution"),
+ G_CALLBACK (action_preferences_cb) },
+
+ { "quick-reference",
+ NULL,
+ N_("_Quick Reference"),
+ NULL,
+ N_("Show Evolution's shortcut keys"),
+ G_CALLBACK (action_quick_reference_cb) },
+
+ { "quit",
+ GTK_STOCK_QUIT,
+ NULL,
+ NULL,
+ N_("Exit the program"),
+ G_CALLBACK (action_quit_cb) },
+
+ { "search-advanced",
+ NULL,
+ N_("_Advanced Search..."),
+ NULL,
+ N_("Construct a more advanced search"),
+ G_CALLBACK (action_search_advanced_cb) },
+
+ { "search-clear",
+ GTK_STOCK_CLEAR,
+ NULL,
+ "<Control><Shift>q",
+ N_("Clear the current search parameters"),
+ G_CALLBACK (action_search_clear_cb) },
+
+ { "search-edit",
+ NULL,
+ N_("_Edit Saved Searches..."),
+ NULL,
+ N_("Manage your saved searches"),
+ G_CALLBACK (action_search_edit_cb) },
+
+ { "search-execute",
+ GTK_STOCK_FIND,
+ N_("_Find Now"),
+ "", /* Block the default Ctrl+F. */
+ N_("Execute the current search parameters"),
+ NULL }, /* Handled by EShellContent and subclasses. */
+
+ { "search-options",
+ GTK_STOCK_FIND,
+ NULL,
+ NULL,
+ N_("Click here to change the search type"),
+ G_CALLBACK (action_search_options_cb) },
+
+ { "search-save",
+ NULL,
+ N_("_Save Search..."),
+ NULL,
+ N_("Save the current search parameters"),
+ G_CALLBACK (action_search_save_cb) },
+
+ { "send-receive",
+ "mail-send-receive",
+ N_("Send / _Receive"),
+ "F9",
+ N_("Send queued items and retrieve new items"),
+ G_CALLBACK (action_send_receive_cb) },
+
+ { "submit-bug",
+ NULL,
+ N_("Submit _Bug Report"),
+ NULL,
+ N_("Submit a bug report using Bug Buddy"),
+ G_CALLBACK (action_submit_bug_cb) },
+
+ { "sync-options",
+ NULL,
+ N_("_Synchronization Options..."),
+ NULL,
+ N_("Set up Pilot configuration"),
+ G_CALLBACK (action_sync_options_cb) },
+
+ { "work-offline",
+ "stock_disconnect",
+ N_("_Work Offline"),
+ NULL,
+ N_("Put Evolution into offline mode"),
+ G_CALLBACK (action_work_offline_cb) },
+
+ { "work-online",
+ "stock_connect",
+ N_("_Work Online"),
+ NULL,
+ N_("Put Evolution into online mode"),
+ G_CALLBACK (action_work_online_cb) },
+
+ /*** Menus ***/
+
+ { "edit-menu",
+ NULL,
+ N_("_Edit"),
+ NULL,
+ NULL,
+ NULL },
+
+ { "file-menu",
+ NULL,
+ N_("_File"),
+ NULL,
+ NULL,
+ NULL },
+
+ { "help-menu",
+ NULL,
+ N_("_Help"),
+ NULL,
+ NULL,
+ NULL },
+
+ { "layout-menu",
+ NULL,
+ N_("Lay_out"),
+ NULL,
+ NULL,
+ NULL },
+
+ { "new-menu",
+ GTK_STOCK_NEW,
+ N_("_New"),
+ "",
+ NULL,
+ NULL },
+
+ { "search-menu",
+ NULL,
+ N_("_Search"),
+ NULL,
+ NULL,
+ NULL },
+
+ { "switcher-menu",
+ NULL,
+ N_("_Switcher Appearance"),
+ NULL,
+ NULL,
+ NULL },
+
+ { "view-menu",
+ NULL,
+ N_("_View"),
+ NULL,
+ NULL,
+ NULL },
+
+ { "window-menu",
+ NULL,
+ N_("_Window"),
+ NULL,
+ NULL,
+ NULL }
+};
+
+static GtkToggleActionEntry shell_toggle_entries[] = {
+
+ { "show-sidebar",
+ NULL,
+ N_("Show Side _Bar"),
+ NULL,
+ N_("Show the side bar"),
+ G_CALLBACK (action_show_sidebar_cb),
+ TRUE },
+
+ { "show-statusbar",
+ NULL,
+ N_("Show _Status Bar"),
+ NULL,
+ N_("Show the status bar"),
+ G_CALLBACK (action_show_statusbar_cb),
+ TRUE },
+
+ { "show-switcher",
+ NULL,
+ N_("Show _Buttons"),
+ NULL,
+ N_("Show the switcher buttons"),
+ G_CALLBACK (action_show_switcher_cb),
+ TRUE },
+
+ { "show-toolbar",
+ NULL,
+ N_("Show _Tool Bar"),
+ NULL,
+ N_("Show the toolbar"),
+ G_CALLBACK (action_show_toolbar_cb),
+ TRUE }
+};
+
+static GtkRadioActionEntry shell_switcher_entries[] = {
+
+ /* This action represents the initial active shell view.
+ * It should not be visible in the UI, nor should it be
+ * possible to switch to it from another shell view. */
+ { "switcher-initial",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ -1 }
+};
+
+static GtkRadioActionEntry shell_switcher_style_entries[] = {
+
+ { "switcher-style-icons",
+ NULL,
+ N_("_Icons Only"),
+ NULL,
+ N_("Display window buttons with icons only"),
+ GTK_TOOLBAR_ICONS },
+
+ { "switcher-style-text",
+ NULL,
+ N_("_Text Only"),
+ NULL,
+ N_("Display window buttons with text only"),
+ GTK_TOOLBAR_TEXT },
+
+ { "switcher-style-both",
+ NULL,
+ N_("Icons _and Text"),
+ NULL,
+ N_("Display window buttons with icons and text"),
+ GTK_TOOLBAR_BOTH_HORIZ },
+
+ { "switcher-style-user",
+ NULL,
+ N_("Tool_bar Style"),
+ NULL,
+ N_("Display window buttons using the desktop toolbar setting"),
+ -1 }
+};
+
+static GtkActionEntry shell_gal_view_entries[] = {
+
+ { "gal-define-views",
+ NULL,
+ N_("Define Views..."),
+ NULL,
+ N_("Create or edit views"),
+ G_CALLBACK (action_gal_define_views_cb) },
+
+ { "gal-save-custom-view",
+ NULL,
+ N_("Save Custom View..."),
+ NULL,
+ N_("Save current custom view"),
+ NULL }, /* Handled by subclasses. */
+
+ /*** Menus ***/
+
+ { "gal-view-menu",
+ NULL,
+ N_("C_urrent View"),
+ NULL,
+ NULL,
+ NULL }
+};
+
+static GtkRadioActionEntry shell_gal_view_radio_entries[] = {
+
+ { "gal-custom-view",
+ NULL,
+ N_("Custom View"),
+ NULL,
+ N_("Current view is a customized view"),
+ -1 }
+};
+
+static GtkActionEntry shell_lockdown_print_setup_entries[] = {
+
+ { "page-setup",
+ GTK_STOCK_PAGE_SETUP,
+ NULL,
+ NULL,
+ N_("Change the page settings for your current printer"),
+ G_CALLBACK (action_page_setup_cb) }
+};
+
+static void
+shell_window_extract_actions (EShellWindow *shell_window,
+ GList **source_list,
+ GList **destination_list)
+{
+ const gchar *current_view;
+ GList *match_list = NULL;
+ GList *iter;
+
+ /* Pick out the actions from the source list that are tagged
+ * as belonging to the current EShellView and move them to the
+ * destination list. */
+
+ current_view = e_shell_window_get_active_view (shell_window);
+
+ /* Example: Suppose [A] and [C] are tagged for this EShellView.
+ *
+ * source_list = [A] -> [B] -> [C]
+ * ^ ^
+ * | |
+ * match_list = [ ] --------> [ ]
+ *
+ *
+ * destination_list = [1] -> [2] (other actions)
+ */
+ for (iter = *source_list; iter != NULL; iter = iter->next) {
+ GtkAction *action = iter->data;
+ const gchar *module_name;
+
+ module_name = g_object_get_data (
+ G_OBJECT (action), "module-name");
+
+ if (strcmp (module_name, current_view) != 0)
+ continue;
+
+ if (g_object_get_data (G_OBJECT (action), "primary"))
+ match_list = g_list_prepend (match_list, iter);
+ else
+ match_list = g_list_append (match_list, iter);
+ }
+
+ /* source_list = [B] match_list = [A] -> [C] */
+ for (iter = match_list; iter != NULL; iter = iter->next) {
+ GList *link = iter->data;
+
+ iter->data = link->data;
+ *source_list = g_list_delete_link (*source_list, link);
+ }
+
+ /* destination_list = [1] -> [2] -> [A] -> [C] */
+ *destination_list = g_list_concat (*destination_list, match_list);
+}
+
+void
+e_shell_window_actions_init (EShellWindow *shell_window)
+{
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_manager;
+
+ g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
+
+ ui_manager = e_shell_window_get_ui_manager (shell_window);
+
+ e_load_ui_definition (ui_manager, "evolution-shell.ui");
+
+ /* Shell Actions */
+ action_group = ACTION_GROUP (SHELL);
+ gtk_action_group_add_actions (
+ action_group, shell_entries,
+ G_N_ELEMENTS (shell_entries), shell_window);
+ gtk_action_group_add_toggle_actions (
+ action_group, shell_toggle_entries,
+ G_N_ELEMENTS (shell_toggle_entries), shell_window);
+ gtk_action_group_add_radio_actions (
+ action_group, shell_switcher_style_entries,
+ G_N_ELEMENTS (shell_switcher_style_entries),
+ E_SHELL_SWITCHER_DEFAULT_TOOLBAR_STYLE,
+ G_CALLBACK (action_switcher_style_cb), shell_window);
+ gtk_action_group_add_actions (
+ action_group, shell_gal_view_entries,
+ G_N_ELEMENTS (shell_gal_view_entries), shell_window);
+ gtk_action_group_add_radio_actions (
+ action_group, shell_gal_view_radio_entries,
+ G_N_ELEMENTS (shell_gal_view_radio_entries),
+ 0, G_CALLBACK (action_gal_view_cb), shell_window);
+
+ /* Switcher Actions */
+ action_group = ACTION_GROUP (SWITCHER);
+ gtk_action_group_add_radio_actions (
+ action_group, shell_switcher_entries,
+ G_N_ELEMENTS (shell_switcher_entries),
+ -1, G_CALLBACK (action_switcher_cb), shell_window);
+
+ /* Lockdown Print Setup Actions */
+ action_group = ACTION_GROUP (LOCKDOWN_PRINT_SETUP);
+ gtk_action_group_add_actions (
+ action_group, shell_lockdown_print_setup_entries,
+ G_N_ELEMENTS (shell_lockdown_print_setup_entries),
+ shell_window);
+
+ /* Fine tuning. */
+
+ g_object_set (ACTION (SEND_RECEIVE), "is-important", TRUE, NULL);
+}
+
+GtkWidget *
+e_shell_window_create_new_menu (EShellWindow *shell_window)
+{
+ GtkActionGroup *action_group;
+ GList *new_item_actions;
+ GList *new_source_actions;
+ GList *iter, *list = NULL;
+ GtkWidget *menu;
+ GtkWidget *separator;
+
+ /* Get sorted lists of "new item" and "new source" actions. */
+
+ action_group = ACTION_GROUP (NEW_ITEM);
+
+ new_item_actions = g_list_sort (
+ gtk_action_group_list_actions (action_group),
+ (GCompareFunc) e_action_compare_by_label);
+
+ action_group = ACTION_GROUP (NEW_SOURCE);
+
+ new_source_actions = g_list_sort (
+ gtk_action_group_list_actions (action_group),
+ (GCompareFunc) e_action_compare_by_label);
+
+ /* Give priority to actions that belong to this shell view. */
+
+ shell_window_extract_actions (
+ shell_window, &new_item_actions, &list);
+
+ shell_window_extract_actions (
+ shell_window, &new_source_actions, &list);
+
+ /* Convert the actions to menu item proxy widgets. */
+
+ for (iter = list; iter != NULL; iter = iter->next)
+ iter->data = gtk_action_create_menu_item (iter->data);
+
+ for (iter = new_item_actions; iter != NULL; iter = iter->next)
+ iter->data = gtk_action_create_menu_item (iter->data);
+
+ for (iter = new_source_actions; iter != NULL; iter = iter->next)
+ iter->data = gtk_action_create_menu_item (iter->data);
+
+ /* Add menu separators. */
+
+ separator = gtk_separator_menu_item_new ();
+ new_item_actions = g_list_prepend (new_item_actions, separator);
+ gtk_widget_show (GTK_WIDGET (separator));
+
+ separator = gtk_separator_menu_item_new ();
+ new_source_actions = g_list_prepend (new_source_actions, separator);
+ gtk_widget_show (GTK_WIDGET (separator));
+
+ /* Merge everything into one list, reflecting the menu layout. */
+
+ list = g_list_concat (list, new_item_actions);
+ new_item_actions = NULL; /* just for clarity */
+
+ list = g_list_concat (list, new_source_actions);
+ new_source_actions = NULL; /* just for clarity */
+
+ /* And finally, build the menu. */
+
+ menu = gtk_menu_new ();
+
+ for (iter = list; iter != NULL; iter = iter->next)
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), iter->data);
+
+ g_list_free (list);
+
+ return menu;
+}
+
+void
+e_shell_window_create_switcher_actions (EShellWindow *shell_window)
+{
+ GSList *group = NULL;
+ GtkRadioAction *action;
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_manager;
+ EShellSwitcher *switcher;
+ EShell *shell;
+ GList *list, *iter;
+ guint merge_id;
+ guint ii = 0;
+
+ g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
+
+ action_group = ACTION_GROUP (SWITCHER);
+ switcher = E_SHELL_SWITCHER (shell_window->priv->switcher);
+ ui_manager = e_shell_window_get_ui_manager (shell_window);
+ merge_id = gtk_ui_manager_new_merge_id (ui_manager);
+ shell = e_shell_window_get_shell (shell_window);
+ list = e_shell_get_shell_modules (shell);
+
+ /* Construct a group of radio actions from the various EShellView
+ * subclasses and register them with the EShellSwitcher. These
+ * actions are manifested as switcher buttons and View->Window
+ * menu items. */
+
+ action = GTK_RADIO_ACTION (ACTION (SWITCHER_INITIAL));
+ gtk_radio_action_set_group (action, group);
+ group = gtk_radio_action_get_group (action);
+
+ for (iter = list; iter != NULL; iter = iter->next) {
+ EShellModule *shell_module = iter->data;
+ EShellViewClass *class;
+ GType type;
+ const gchar *view_name;
+ gchar *accelerator;
+ gchar *action_name;
+ gchar *tooltip;
+
+ type = e_shell_module_get_shell_view_type (shell_module);
+
+ if (!g_type_is_a (type, E_TYPE_SHELL_VIEW)) {
+ g_critical (
+ "%s is not a subclass of %s",
+ g_type_name (type),
+ g_type_name (E_TYPE_SHELL_VIEW));
+ continue;
+ }
+
+ class = g_type_class_ref (type);
+
+ if (class->label == NULL) {
+ g_critical (
+ "Label member not set on %s",
+ G_OBJECT_CLASS_NAME (class));
+ continue;
+ }
+
+ if (class->type_module == NULL) {
+ g_critical (
+ "Module member not set on %s",
+ G_OBJECT_CLASS_NAME (class));
+ continue;
+ }
+
+ view_name = class->type_module->name;
+ action_name = g_strdup_printf (SWITCHER_FORMAT, view_name);
+ tooltip = g_strdup_printf (_("Switch to %s"), class->label);
+
+ /* Note, we have to set "icon-name" separately because
+ * gtk_radio_action_new() expects a "stock-id". Sadly,
+ * GTK+ still distinguishes between the two. */
+
+ action = gtk_radio_action_new (
+ action_name, class->label,
+ tooltip, NULL, ii++);
+
+ g_object_set (
+ G_OBJECT (action),
+ "icon-name", class->icon_name, NULL);
+
+ g_object_set_data (
+ G_OBJECT (action),
+ "view-name", (gpointer) view_name);
+
+ gtk_radio_action_set_group (action, group);
+ group = gtk_radio_action_get_group (action);
+
+ /* The first nine views have accelerators Ctrl+(1-9). */
+ if (ii < 10)
+ accelerator = g_strdup_printf ("<Control>%d", ii);
+ else
+ accelerator = g_strdup ("");
+
+ gtk_action_group_add_action_with_accel (
+ action_group, GTK_ACTION (action), accelerator);
+
+ e_shell_switcher_add_action (switcher, GTK_ACTION (action));
+
+ gtk_ui_manager_add_ui (
+ ui_manager, merge_id,
+ "/main-menu/view-menu/window-menu",
+ action_name, action_name,
+ GTK_UI_MANAGER_AUTO, FALSE);
+
+ g_free (accelerator);
+ g_free (action_name);
+ g_free (tooltip);
+
+ g_type_class_unref (class);
+ }
+}
+
+void
+e_shell_window_update_view_menu (EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ EShellViewClass *shell_view_class;
+ GtkUIManager *ui_manager;
+ GtkActionGroup *action_group;
+ GalViewCollection *view_collection;
+ GtkRadioAction *radio_action;
+ GtkAction *action;
+ GSList *radio_group;
+ gboolean visible;
+ const gchar *path;
+ const gchar *view_id;
+ const gchar *view_name;
+ guint merge_id;
+ gint count, ii;
+
+ ui_manager = e_shell_window_get_ui_manager (shell_window);
+ view_name = e_shell_window_get_active_view (shell_window);
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+ g_return_if_fail (shell_view != NULL);
+
+ shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
+ view_collection = shell_view_class->view_collection;
+ view_id = e_shell_view_get_view_id (shell_view);
+ g_return_if_fail (view_collection != NULL);
+
+ action_group = ACTION_GROUP (GAL_VIEW);
+ merge_id = shell_window->priv->gal_view_merge_id;
+
+ /* Unmerge the previous menu. */
+ gtk_ui_manager_remove_ui (ui_manager, merge_id);
+ e_action_group_remove_all_actions (action_group);
+
+ /* We have a view ID, so forge ahead. */
+ count = gal_view_collection_get_count (view_collection);
+ path = "/main-menu/view-menu/gal-view-menu/gal-view-list";
+
+ /* Prevent spurious activations. */
+ action = ACTION (GAL_CUSTOM_VIEW);
+ g_signal_handlers_block_matched (
+ action, G_SIGNAL_MATCH_FUNC, 0, 0,
+ NULL, action_gal_view_cb, NULL);
+
+ /* Default to "Custom View", unless we find our view ID. */
+ radio_action = GTK_RADIO_ACTION (ACTION (GAL_CUSTOM_VIEW));
+ gtk_radio_action_set_group (radio_action, NULL);
+ radio_group = gtk_radio_action_get_group (radio_action);
+ gtk_radio_action_set_current_value (radio_action, -1);
+
+ /* Add a menu item for each view collection item. */
+ for (ii = 0; ii < count; ii++) {
+ GalViewCollectionItem *item;
+ gchar *action_name;
+ gchar *tooltip;
+
+ item = gal_view_collection_get_view_item (view_collection, ii);
+
+ action_name = g_strdup_printf (
+ "gal-view-%s-%d", view_name, ii);
+ tooltip = g_strdup_printf ("Select view: %s", item->title);
+
+ radio_action = gtk_radio_action_new (
+ action_name, item->title, tooltip, NULL, ii);
+
+ action = GTK_ACTION (radio_action);
+ gtk_radio_action_set_group (radio_action, radio_group);
+ radio_group = gtk_radio_action_get_group (radio_action);
+
+ g_object_set_data_full (
+ G_OBJECT (radio_action), "view-id",
+ g_strdup (item->id), (GDestroyNotify) g_free);
+
+ if (view_id != NULL && strcmp (item->id, view_id) == 0)
+ gtk_radio_action_set_current_value (radio_action, ii);
+
+ gtk_action_group_add_action (action_group, action);
+
+ gtk_ui_manager_add_ui (
+ ui_manager, merge_id, path, action_name,
+ action_name, GTK_UI_MANAGER_AUTO, FALSE);
+
+ g_free (action_name);
+ g_free (tooltip);
+ }
+
+ /* Doesn't matter which radio action we check. */
+ visible = (gtk_radio_action_get_current_value (radio_action) < 0);
+
+ action = ACTION (GAL_CUSTOM_VIEW);
+ gtk_action_set_visible (action, visible);
+ g_signal_handlers_unblock_matched (
+ action, G_SIGNAL_MATCH_FUNC, 0, 0,
+ NULL, action_gal_view_cb, NULL);
+
+ action = ACTION (GAL_SAVE_CUSTOM_VIEW);
+ gtk_action_set_visible (action, visible);
+}
+
+void
+e_shell_window_update_search_menu (EShellWindow *shell_window)
+{
+ EShellContent *shell_content;
+ EShellView *shell_view;
+ EShellViewClass *shell_view_class;
+ RuleContext *context;
+ FilterRule *rule;
+ GtkUIManager *ui_manager;
+ GtkActionGroup *action_group;
+ const gchar *source;
+ const gchar *view_name;
+ gboolean sensitive;
+ guint merge_id;
+ gint ii = 0;
+
+ ui_manager = e_shell_window_get_ui_manager (shell_window);
+ view_name = e_shell_window_get_active_view (shell_window);
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+ context = e_shell_content_get_search_context (shell_content);
+ shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
+ source = FILTER_SOURCE_INCOMING;
+
+ /* Update sensitivity of search actions. */
+
+ sensitive = (e_shell_content_get_search_rule (shell_content) != NULL);
+ gtk_action_set_sensitive (ACTION (SEARCH_CLEAR), sensitive);
+ gtk_action_set_sensitive (ACTION (SEARCH_SAVE), sensitive);
+
+ sensitive = (shell_view_class->search_options != NULL);
+ gtk_action_set_sensitive (ACTION (SEARCH_OPTIONS), sensitive);
+
+ /* Add custom rules to the Search menu. */
+
+ action_group = ACTION_GROUP (CUSTOM_RULES);
+ merge_id = shell_window->priv->custom_rule_merge_id;
+
+ /* Unmerge the previous menu. */
+ gtk_ui_manager_remove_ui (ui_manager, merge_id);
+ e_action_group_remove_all_actions (action_group);
+
+ rule = rule_context_next_rule (context, NULL, source);
+ while (rule != NULL) {
+ GtkAction *action;
+ gchar *action_name;
+ gchar *action_label;
+
+ action_name = g_strdup_printf ("custom-rule-%d", ii++);
+ if (ii < 10)
+ action_label = g_strdup_printf (
+ "_%d. %s", ii, rule->name);
+ else
+ action_label = g_strdup (rule->name);
+
+ action = gtk_action_new (
+ action_name, action_label,
+ _("Execute these search parameters"), NULL);
+
+ g_object_set_data_full (
+ G_OBJECT (action),
+ "rule", g_object_ref (rule),
+ (GDestroyNotify) g_object_unref);
+
+ g_signal_connect (
+ action, "activate",
+ G_CALLBACK (action_custom_rule_cb), shell_window);
+
+ gtk_action_group_add_action (action_group, action);
+
+ gtk_ui_manager_add_ui (
+ ui_manager, merge_id,
+ "/main-menu/search-menu/custom-rules",
+ action_name, action_name,
+ GTK_UI_MANAGER_AUTO, FALSE);
+
+ g_free (action_name);
+ g_free (action_label);
+
+ rule = rule_context_next_rule (context, rule, source);
+ }
+}
diff --git a/shell/e-shell-window-actions.h b/shell/e-shell-window-actions.h
new file mode 100644
index 0000000000..87ae13221c
--- /dev/null
+++ b/shell/e-shell-window-actions.h
@@ -0,0 +1,123 @@
+/*
+ * e-shell-window-actions.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef E_SHELL_WINDOW_ACTIONS_H
+#define E_SHELL_WINDOW_ACTIONS_H
+
+#define E_SHELL_WINDOW_ACTION(window, name) \
+ (e_shell_window_get_action (E_SHELL_WINDOW (window), (name)))
+
+#define E_SHELL_WINDOW_ACTION_GROUP(window, name) \
+ (e_shell_window_get_action_group (E_SHELL_WINDOW (window), (name)))
+
+/* Actions */
+#define E_SHELL_WINDOW_ACTION_ABOUT(window) \
+ E_SHELL_WINDOW_ACTION ((window), "about")
+#define E_SHELL_WINDOW_ACTION_CLOSE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "close")
+#define E_SHELL_WINDOW_ACTION_CONTENTS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "contents")
+#define E_SHELL_WINDOW_ACTION_FAQ(window) \
+ E_SHELL_WINDOW_ACTION ((window), "faq")
+#define E_SHELL_WINDOW_ACTION_FORGET_PASSWORDS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "forget-passwords")
+#define E_SHELL_WINDOW_ACTION_GAL_CUSTOM_VIEW(window) \
+ E_SHELL_WINDOW_ACTION ((window), "gal-custom-view")
+#define E_SHELL_WINDOW_ACTION_GAL_DEFINE_VIEWS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "gal-define-views")
+#define E_SHELL_WINDOW_ACTION_GAL_SAVE_CUSTOM_VIEW(window) \
+ E_SHELL_WINDOW_ACTION ((window), "gal-save-custom-view")
+#define E_SHELL_WINDOW_ACTION_IMPORT(window) \
+ E_SHELL_WINDOW_ACTION ((window), "import")
+#define E_SHELL_WINDOW_ACTION_NEW_WINDOW(window) \
+ E_SHELL_WINDOW_ACTION ((window), "new-window")
+#define E_SHELL_WINDOW_ACTION_PAGE_SETUP(window) \
+ E_SHELL_WINDOW_ACTION ((window), "page-setup")
+#define E_SHELL_WINDOW_ACTION_PREFERENCES(window) \
+ E_SHELL_WINDOW_ACTION ((window), "preferences")
+#define E_SHELL_WINDOW_ACTION_QUICK_REFERENCE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "quick-reference")
+#define E_SHELL_WINDOW_ACTION_QUIT(window) \
+ E_SHELL_WINDOW_ACTION ((window), "quit")
+#define E_SHELL_WINDOW_ACTION_SEARCH_ADVANCED(window) \
+ E_SHELL_WINDOW_ACTION ((window), "search-advanced")
+#define E_SHELL_WINDOW_ACTION_SEARCH_CLEAR(window) \
+ E_SHELL_WINDOW_ACTION ((window), "search-clear")
+#define E_SHELL_WINDOW_ACTION_SEARCH_EDIT(window) \
+ E_SHELL_WINDOW_ACTION ((window), "search-edit")
+#define E_SHELL_WINDOW_ACTION_SEARCH_EXECUTE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "search-execute")
+#define E_SHELL_WINDOW_ACTION_SEARCH_OPTIONS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "search-options")
+#define E_SHELL_WINDOW_ACTION_SEARCH_SAVE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "search-save")
+#define E_SHELL_WINDOW_ACTION_SEND_RECEIVE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "send-receive")
+#define E_SHELL_WINDOW_ACTION_SHOW_SIDEBAR(window) \
+ E_SHELL_WINDOW_ACTION ((window), "show-sidebar")
+#define E_SHELL_WINDOW_ACTION_SHOW_STATUSBAR(window) \
+ E_SHELL_WINDOW_ACTION ((window), "show-statusbar")
+#define E_SHELL_WINDOW_ACTION_SHOW_SWITCHER(window) \
+ E_SHELL_WINDOW_ACTION ((window), "show-switcher")
+#define E_SHELL_WINDOW_ACTION_SHOW_TOOLBAR(window) \
+ E_SHELL_WINDOW_ACTION ((window), "show-toolbar")
+#define E_SHELL_WINDOW_ACTION_SUBMIT_BUG(window) \
+ E_SHELL_WINDOW_ACTION ((window), "submit-bug")
+#define E_SHELL_WINDOW_ACTION_SWITCHER_INITIAL(window) \
+ E_SHELL_WINDOW_ACTION ((window), "switcher-initial")
+#define E_SHELL_WINDOW_ACTION_SWITCHER_STYLE_BOTH(window) \
+ E_SHELL_WINDOW_ACTION ((window), "switcher-style-both")
+#define E_SHELL_WINDOW_ACTION_SWITCHER_STYLE_ICONS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "switcher-style-icons")
+#define E_SHELL_WINDOW_ACTION_SWITCHER_STYLE_TEXT(window) \
+ E_SHELL_WINDOW_ACTION ((window), "switcher-style-text")
+#define E_SHELL_WINDOW_ACTION_SWITCHER_STYLE_USER(window) \
+ E_SHELL_WINDOW_ACTION ((window), "switcher-style-user")
+#define E_SHELL_WINDOW_ACTION_SYNC_OPTIONS(window) \
+ E_SHELL_WINDOW_ACTION ((window), "sync-options")
+#define E_SHELL_WINDOW_ACTION_WORK_OFFLINE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "work-offline")
+#define E_SHELL_WINDOW_ACTION_WORK_ONLINE(window) \
+ E_SHELL_WINDOW_ACTION ((window), "work-online")
+
+/* Action Groups */
+#define E_SHELL_WINDOW_ACTION_GROUP_CUSTOM_RULES(window) \
+ E_SHELL_WINDOW_ACTION_GROUP ((window), "custom-rules")
+#define E_SHELL_WINDOW_ACTION_GROUP_GAL_VIEW(window) \
+ E_SHELL_WINDOW_ACTION_GROUP ((window), "gal-view")
+#define E_SHELL_WINDOW_ACTION_GROUP_LOCKDOWN_APPLICATION_HANDLERS(window) \
+ E_SHELL_WINDOW_ACTION_GROUP ((window), "lockdown-application-handlers")
+#define E_SHELL_WINDOW_ACTION_GROUP_LOCKDOWN_PRINTING(window) \
+ E_SHELL_WINDOW_ACTION_GROUP ((window), "lockdown-printing")
+#define E_SHELL_WINDOW_ACTION_GROUP_LOCKDOWN_PRINT_SETUP(window) \
+ E_SHELL_WINDOW_ACTION_GROUP ((window), "lockdown-print-setup")
+#define E_SHELL_WINDOW_ACTION_GROUP_LOCKDOWN_SAVE_TO_DISK(window) \
+ E_SHELL_WINDOW_ACTION_GROUP ((window), "lockdown-save-to-disk")
+#define E_SHELL_WINDOW_ACTION_GROUP_NEW_ITEM(window) \
+ E_SHELL_WINDOW_ACTION_GROUP ((window), "new-item")
+#define E_SHELL_WINDOW_ACTION_GROUP_NEW_SOURCE(window) \
+ E_SHELL_WINDOW_ACTION_GROUP ((window), "new-source")
+#define E_SHELL_WINDOW_ACTION_GROUP_SHELL(window) \
+ E_SHELL_WINDOW_ACTION_GROUP ((window), "shell")
+#define E_SHELL_WINDOW_ACTION_GROUP_SWITCHER(window) \
+ E_SHELL_WINDOW_ACTION_GROUP ((window), "switcher")
+
+#endif /* E_SHELL_WINDOW_ACTIONS_H */
diff --git a/shell/e-shell-window-commands.c b/shell/e-shell-window-commands.c
deleted file mode 100644
index 224dd67171..0000000000
--- a/shell/e-shell-window-commands.c
+++ /dev/null
@@ -1,1396 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#include <config.h>
-
-#include <string.h>
-
-#include <gtk/gtk.h>
-#include <glib/gprintf.h>
-
-#include <libgnome/gnome-exec.h>
-#include <glib/gi18n.h>
-
-#include <gio/gio.h>
-
-#include <bonobo/bonobo-ui-component.h>
-
-#include <libedataserverui/e-passwords.h>
-
-#include <gconf/gconf-client.h>
-
-#include "e-util/e-dialog-utils.h"
-#include "e-util/e-error.h"
-#include "e-util/e-icon-factory.h"
-#include "e-util/e-print.h"
-#include "e-util/e-util.h"
-#include "e-util/e-util-private.h"
-
-#include "e-shell-window-commands.h"
-#include "e-shell-window.h"
-#include "evolution-shell-component-utils.h"
-
-#include "e-shell-importer.h"
-
-#define EVOLUTION_COPYRIGHT \
- "Copyright \xC2\xA9 1999 - 2009 Novell, Inc. and Others"
-
-#define EVOLUTION_WEBSITE \
- "http://www.gnome.org/projects/evolution/"
-
-/* Utility functions. */
-
-static void
-launch_pilot_settings (const char *extra_arg)
-{
- char *args[] = {
- "gpilotd-control-applet",
- (char *) extra_arg,
- NULL
- };
- int pid;
-
- args[0] = g_find_program_in_path ("gpilotd-control-applet");
- if (!args[0]) {
- e_notice (NULL, GTK_MESSAGE_ERROR,
- _("The GNOME Pilot tools do not appear to be installed on this system."));
- return;
- }
-
- pid = gnome_execute_async (NULL, extra_arg ? 2 : 1, args);
- g_free (args[0]);
-
- if (pid == -1)
- e_notice (NULL, GTK_MESSAGE_ERROR, _("Error executing %s."), args[0]);
-}
-
-
-/* Command callbacks. */
-
-static void
-command_import (BonoboUIComponent *uih,
- EShellWindow *window,
- const char *path)
-{
- e_shell_importer_start_import (window);
-}
-
-static void
-command_page_setup (BonoboUIComponent *uih,
- EShellWindow *window,
- const char *path)
-{
- e_print_run_page_setup_dialog (GTK_WINDOW (window));
-}
-
-static void
-command_close (BonoboUIComponent *uih,
- EShellWindow *window,
- const char *path)
-{
- if (e_shell_request_close_window (e_shell_window_peek_shell (window), window))
- gtk_widget_destroy (GTK_WIDGET (window));
-}
-
-static void
-command_quit (BonoboUIComponent *uih,
- EShellWindow *window,
- const char *path)
-{
- EShell *shell = e_shell_window_peek_shell (window);
-
- e_shell_quit(shell);
-}
-
-static void
-command_submit_bug (BonoboUIComponent *uih,
- EShellWindow *window,
- const char *path)
-{
- gchar *command_line;
- GError *error = NULL;
-
- command_line = "bug-buddy --sm-disable --package=Evolution";
-
- g_debug ("Spawning: %s", command_line);
-
- if (!g_spawn_command_line_async (command_line, &error)) {
- if (error->code == G_SPAWN_ERROR_NOENT)
- e_notice (NULL, GTK_MESSAGE_ERROR,
- _("Bug buddy is not installed."));
- else
- e_notice (NULL, GTK_MESSAGE_ERROR,
- _("Bug buddy could not be run."));
- g_error_free (error);
- }
-}
-
-/* must be in utf8, the weird breaking of escaped strings
- is so the hex escape strings dont swallow too many chars
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- So that means, 8 bit characters, use \xXX hex encoding ONLY
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
- No all environments are utf8 and not all editors can handle it.
-*/
-static const char *authors[] = {
- "Aaron Weber",
- "Abel Cheung",
- "Abhishek Parwal",
- "Adam Weinberger",
- "Adi Attar",
- "Ahmad Riza H Nst",
- "Aidan Delaney",
- "Aishwarya K",
- "Akagic Amila",
- "Akhil Laddha",
- "Akira Tagoh",
- "Alastair McKinstry",
- "Alastair Tse",
- "Alejandro Andres",
- "Ales Nyakhaychyk",
- "Alessandro Decina",
- "Alessio Frusciante",
- "Alex Graveley",
- "Alex Jiang",
- "Alex Jones",
- "Alex Kloss",
- "Alex Rostovtsev",
- "Alexander Didebulidze",
- "Alexander Shopov",
- "Alexander Winston",
- "Alexandre Folle de Menezes",
- "Alfred Peng",
- "Ali Abdin",
- "Ali Akcaagac",
- "Alireza Kheirkhahan",
- "Almer S. Tigelaar",
- "Alp Toker",
- "Amanpreet Singh Alam",
- "Ambuj Chitranshi",
- "Amish",
- "Amitakhya Phukan",
- "Anand V M",
- "Anders Carlsson",
- "Andras Timar",
- "Andrea Campi",
- "Andreas Henriksson",
- "Andreas Hyden",
- "Andreas J. Guelzow",
- "Andreas Köhler",
- "Andrew Ruthven",
- "Andre Klapper",
- "Andrew T. Veliath",
- "Andrew V. Samoilov",
- "Andrew Wu",
- "Ani Peter",
- "Ankit Patel",
- "Anna Marie Dirks",
- "Antonio Xu",
- "Arafat Medini",
- "Arangel Angov",
- "Archit Baweja",
- "Ariel Rios",
- "Arik Devens",
- "Armin Bauer",
- "Arjan Scherpenisse",
- "Arkadiusz Lipiec",
- "Artis Trops",
- "Artur Flinta",
- "Arturo Espinosa Aldama",
- "Arulanandan P",
- "Arun Prakash",
- "Arvind Sundararajan",
- "Ashish Shrivastava",
- "Åsmund Skjæveland",
- "Audrey Simons",
- "Baptiste Mille-Mathias",
- "Baris Cicek",
- "Bastien Nocera",
- "Behnam Esfahbod",
- "Benedikt Roth",
- "Ben Gamari",
- "Benjamin Berg",
- "Benjamin Kahn",
- "Benoît Dejean",
- "Bernard Leach",
- "Bertrand Guiheneuf",
- "Bharath Acharya",
- "Bharat Kumar",
- "Bharathi Gauthaman",
- "Big Iain Holmes",
- "Bill Zhu",
- "Björn Torkelsson",
- "Björn Lindqvist",
- "Bob Doan",
- "Bob Mauchin",
- "Boby Wang",
- "Bolian Yin",
- "Borislav Aleksandrov",
- "Boulton",
- "Brian Mury",
- "Brian Pepple",
- "Brigitte Le Grand",
- "Bruce Tao",
- "B S Srinidhi",
- "Calvin Liu",
- "Cantona Su",
- "Carlos Garcia Campos",
- "Carlos Garnacho Parro",
- "Carlos Perelló Marín",
- "Carl Sun",
- "Carsten Guenther",
- "Carsten Schaar",
- "Changwoo Ryu",
- "Chao-Hsiung Liao",
- "Charles Zhang",
- "Chema Celorio",
- "Chenthill Palanisamy",
- "Christian Persch",
- "Chris Halls",
- "Chris Heath",
- "Chris Lahey",
- "Christian Hammond",
- "Christian Kellner",
- "Christian Kintner",
- "Christian Kirbach",
- "Christian Krause",
- "Christian Kreibich",
- "Christian Meyer",
- "Christian Neumair",
- "Christian Persch",
- "Christian Rose",
- "Christophe Fergeau",
- "Christophe Merlet",
- "Christopher Blizzard",
- "Christopher James Lahey",
- "Christopher R. Gabriel",
- "Chris Phelps",
- "Chris Toshok",
- "Clara Tattoni",
- "Claude Paroz",
- "Claudio Saavedra",
- "Clifford R. Conover",
- "Clytie Siddall",
- "Cody Russell",
- "Colin Leroy",
- "Craig Jeffares",
- "Craig Small",
- "Cyprien Le Pannérer",
- "Dafydd Harries",
- "Damian Ivereigh",
- "Damien Carbery",
- "Damon Chaplin",
- "Daniel Gryniewicz",
- "Daniel Nylander",
- "Daniel van Eeden",
- "Daniel Veillard",
- "Daniel Yacob",
- "Danilo Šegan",
- "Danishka Navin",
- "Dan Korostelev",
- "Danny Baumann",
- "Dan Berger",
- "Dan Damian",
- "Dan Nguyen",
- "Dan Williams",
- "Dan Winship",
- "Darin Adler",
- "Dave Benson",
- "Dave Camp",
- "Dave Fallon",
- "Dave Malcolm",
- "Dave West",
- "David Farning",
- "David Kaelbling",
- "David Lodge",
- "David Malcolm",
- "David Moore",
- "David Mosberger",
- "David O'Callaghan",
- "David Richards",
- "David Trowbridge",
- "David Turner",
- "David Woodhouse",
- "Denis Washington",
- "Devashish Sharma",
- "Diego Escalante Urrelo",
- "Diego Gonzalez",
- "Diego Sevilla Ruiz",
- "Dietmar Maurer",
- "Dinesh Layek",
- "Dirk-Jan C. Binnema",
- "Djihed Afifi",
- "Dmitrijs Ledkovs",
- "Dmitry Mastrukov",
- "Dodji Seketeli",
- "Duarte Loreto",
- "Dulmandakh Sukhbaatar",
- "Duncan Mak",
- "Ebby Wiselyn",
- "Ed Catmur",
- "Edd Dumbill",
- "Edgar Luna Díaz",
- "Edward Rudd",
- "Elijah Newren",
- "Elizabeth Greene",
- "Elliot Lee",
- "Elliot Turner",
- "Emil Hessman",
- "Eneko Lacunza",
- "Enver Altin",
- "Erdal Ronahi",
- "Erdi Gergo",
- "Eric Busboom",
- "Eric Zhao",
- "Eskild Hustvedt"
- "Eskil Heyn Olsen",
- "Espen Stefansen",
- "Ettore Perazzoli",
- "Evandro Fernandes Giovanini",
- "Evan Yan",
- "Fatih Demir",
- "Fazlu & Hannah",
- "Federico Mena Quintero",
- "Fernando Herrera",
- "Ferretti",
- "F. Priyadharshini",
- "Francisco Javier Fernandez Serrador",
- "Frank Arnold",
- "Frank Belew",
- "Frederic Crozat",
- "Frederic Peters",
- "Frederic Riss",
- "Fredrik Wendt",
- "Funda Wang",
- "Gabor Kelemen",
- "Ganesh",
- "Göran Uddeborg",
- "Gareth Owen",
- "Gary Coady",
- "Gary Ekker",
- "Gavin Scott",
- "Gediminas Paulauskas",
- "George Lebl",
- "Gerardo Marin",
- "Gergő Érdi",
- "Gert Kulyk",
- "Giancarlo Capella",
- "Gilbert Fang",
- "Gildas Guillemot",
- "Gil Forcada",
- "Gilles Dartiguelongue",
- "Gil Osher",
- "Gintautas Miliauskas",
- "Goran Rakić",
- "Grahame Bowland",
- "Greg Hudson",
- "Gregory Leblanc",
- "Gregory McLean",
- "Grzegorz Goawski",
- "Guilherme de S. Pastore",
- "Guntupalli Karunakar",
- "Gustavo GirÎldez",
- "Gustavo Maciel Dias Vieira",
- "Gustavo Noronha Silva",
- "Hamed Malek",
- "Hannah & Fazlu",
- "Hans Petter Jansson",
- "Hao Sheng",
- "Hari Prasad Nadig",
- "Harish Krishnaswamy",
- "Harry Lu",
- "Hasbullah Bin Pit",
- "Havoc Pennington",
- "Heath Harrelson",
- "Hein-Pieter van Braam",
- "Héctor García Álvarez",
- "Helgi Þormar Þorbjörnsson",
- "Hendrik Brandt",
- "Hendrik Richter",
- "Herbert V. Riedel",
- "Hessam M. Armandehi",
- "Hiroyuki Ikezoe",
- "Iain Buchanan",
- "Iain Holmes",
- "Ian Campbell",
- "Iassen Pramatarov",
- "Iestyn Pryce",
- "I.Felix",
- "Ignacio Casal Quinteiro",
- "Igor Nestorović",
- "Ihar Hrachyshka",
- "Ilkka Tuohela",
- "Imam Musthaqim",
- "Iñaki Larrañaga",
- "Inaki Larranaga Murgoitio",
- "Indu",
- "Irene Huang",
- "Ismael Olea",
- "Israel Escalante",
- "Ivan Stojmirov",
- "Ivar Smolin",
- "Ivelina Karcheva",
- "Iván Frade",
- "J.H.M. Dassen (Ray)",
- "Jaap A. Haitsma",
- "Jack Jia",
- "Jacob Berkman",
- "Jacob Brown",
- "Jacobo Tarrio Barreiro",
- "Jacob Ulysses Berkman",
- "Jaka Mocnik",
- "Jakub Friedl",
- "Jakub Steiner",
- "James Bowes",
- "James Doc Livingston",
- "James Henstridge",
- "James Westby",
- "James Willcox",
- "Jamil Ahmed",
- "Jan Arne Petersen",
- "Jan Tichavsky",
- "Jan Van Buggenhout",
- "J�rg Billeter",
- "Jared Moore",
- "Jarkko Ranta",
- "Jason Leach",
- "Jason Tackaberry",
- "Jayaradha",
- "Jean-Noel Guiheneuf",
- "Jedy Wang",
- "Jeff Bailey",
- "Jeff Cai",
- "Jeff Garzik",
- "Jeffrey Stedfast",
- "Jens Granseuer",
- "Jens Seidel",
- "Jeremy Katz",
- "Jeremy Messenger",
- "Jeremy Wise",
- "Jerome Lacoste",
- "Jerry Yu",
- "Jesse Pavel",
- "Jesus Bravo Alvarez",
- "Jesse Pavel",
- "Ji Lee",
- "Joan Sanfeliu",
- "João Vale",
- "Joaquim Fellmann",
- "Jody Goldberg",
- "Joe Man",
- "Joe Marcus Clarke",
- "Joe Shaw",
- "Johan Dahlin",
- "Johan Euphrosine",
- "John Gotts",
- "Johnny Jacob",
- "Jon Ander Hernandez",
- "Jonas Borgstr�m",
- "Jonathan Blandford",
- "Jonathan Dieter",
- "Jonathan Ernst",
- "Jonh Wendell",
- "Jon K Hellan",
- "Jon Oberheide",
- "Jon Trowbridge",
- "Jonas Borgstr",
- "Jonathan Blandford",
- "Jonathan Dieter",
- "Joop Stakenborg",
- "Jordi Mallach",
- "Jordi Mas",
- "Jorge Gonzalez",
- "Jörgen Scheibengruber",
- "Jos Dehaes",
- "Josep Puigdemont Casamajó",
- "Josselin Mouette",
- "Jovan Naumovski",
- "JP Rosevear",
- "Juan Manuel García Molina",
- "Juan Pizarro",
- "Jukka Zitting",
- "Jules Colding",
- "Julian Missig",
- "Julien Puydt",
- "Julio M. Merino Vidal",
- "Juraj Kubelka",
- "Jürg Billeter",
- "Justina Klingaitė",
- "Kai Lahmann",
- "Kang Jeong-Hee",
- "Karl Eichwalder",
- "Karl Relton",
- "Karsten Bräckelmann",
- "Kaushal Kumar",
- "Keith Packard",
- "Keld Simonsen",
- "Kenneth Christiansen",
- "Kenneth Nielsen",
- "Kenneth Rohde Christiansen",
- "Kenny Graunke",
- "Keshav Upadhyaya",
- "Kevin Breit",
- "Kevin Piche",
- "Kevin Vandersloot",
- "Khasim Shaheed",
- "Kidd Wang",
- "Kjartan Maraas",
- "Krishnan R",
- "Kostas Papadimas",
- "Krishna Babu K",
- "Krisztian Pifko",
- "Kyle Ambroff",
- "Larry Ewing",
- "Laszlo Dvornik",
- "Laszlo (Laca) Peter",
- "Laurent Dhima",
- "Lauris Kaplinski",
- "Leonardo Ferreira Fontenelle",
- "Leonid Kanter",
- "Leon Zhang",
- "Li Yuan",
- "Loïc Minier",
- "Lorenzo Gil Sanchez",
- "Luca Ferretti",
- "Lucas Rocha",
- "Lucian Langa",
- "Lucky Wankhede",
- "Luis Villa",
- "Lukas Novotny",
- "Lutz M",
- "Maciej Piechotka",
- "Maciej Stachowiak",
- "Makuchaku",
- "Malcolm Tredinnick",
- "Manuel A. Fernández Montecelo",
- "Manuel Borchers",
- "Marcel Telka",
- "Marco Ciampa",
- "Marco Pesenti Gritti",
- "Marius Andreiana",
- "Marius Vollmer",
- "Mark Crichton",
- "Mark G. Adams",
- "Mark Gordon",
- "Mark McLoughlin",
- "Mark Moulder",
- "Mark Tearle",
- "Martha Burke",
- "Martin Baulig",
- "Martin Hicks",
- "Martin Meyer",
- "Martin Norbäck",
- "Martin Willemoes Hansen",
- "Martyn Russell",
- "Masahiro Sakai",
- "Matej Urbančič",
- "Mathieu Lacage",
- "Matias Mutchinick",
- "Matic Žgur",
- "Matt Bissiri",
- "Matt Brown",
- "Matthew Barnes",
- "Matthew Daniel",
- "Matthew Hall",
- "Matthew Loper",
- "Matthew Wilson",
- "Matthias Braun",
- "Matthias Clasen",
- "Matthias Warkus",
- "Matt Loper",
- "Matt Martin",
- "Matt McCutchen",
- "Matt Wilson",
- "Max Horn",
- "Maxim Dziumanenko",
- "Maxx Cao",
- "Mayank Jain",
- "Meelad Zakaria",
- "Meilof Veeningen",
- "Mendel Mobach",
- "Mengjie Yu",
- "Metin Amiroff",
- "Michael Granger",
- "Michael M. Morrison",
- "Michael MacDonald",
- "Michael Meeks",
- "Michael Monreal",
- "Michael Terry",
- "Michael Zucchi",
- "Michal Bukovjan",
- "Michel Daenzer",
- "Miguel Angel Lopez Hernandez",
- "Miguel de Icaza",
- "Mikael Hallendal",
- "Mikael Nilsson",
- "Mike Castle",
- "Mike Kestner",
- "Mike McEwan",
- "Mikhail Zabaluev",
- "Milan Crha",
- "Miles Lane",
- "Miloslav Trmač",
- "MIMOS Open Source Development Group",
- "Mohammad Damt",
- "Moritz Mertinkat",
- "Morten Welinder",
- "Mubeen Jukaku",
- "Mugurel Tudor",
- "Murray Cumming",
- "M Victor Aloysius J",
- "Naba Kumar",
- "Nagappan Alagappan",
- "Nancy Cai",
- "Naresh N",
- "Nat Friedman",
- "Nathan Owens",
- "Nguyễn Thái Ngọc Duy",
- "Nicel KM",
- "Nicholas J Kreucher",
- "Nicholas Miell",
- "Nickolay V. Shmyrev",
- "Nick Sukharev",
- "Nike Gerdts",
- "Nikos Charonitakis",
- "Noel",
- "Nuno Ferreira",
- "Nyall Dawson",
- "Og Maciel",
- "Ole Laursen",
- "Ondrej Jirman",
- "Oswald Rodrigues",
- "Owen Taylor",
- "Øystein Gisnås",
- "Pablo Gonzalo del Campo",
- "Pablo Saratxaga",
- "Pamplona Hackers",
- "Pauli Virtanen",
- "Paolo Borelli",
- "Paolo Molaro",
- "Parag Goel",
- "Parthasarathi Susarla",
- "Pascal Terjan",
- "Patrick Ohly",
- "Paul Bolle",
- "Paul Duffy",
- "Paul Iadonisi",
- "Paul Lindner",
- "Paul Smith",
- "Paulo Gomes Vanzuita",
- "Pavel Cholakov",
- "Pavel Cisler",
- "Pavel Roskin",
- "Pavithran",
- "Pawan Chitrakar",
- "Pedro Villavicencio",
- "Pema Geyleg",
- "Peteris Krisjanis",
- "Peter Bach",
- "Peter Pouliot",
- "Peter Teichman",
- "Peter Williams",
- "Petr Kovar",
- "Petta Pietikainen",
- "Phil Goembel",
- "Philipp Kerling",
- "Philip Van Hoof",
- "Philip Withnall",
- "Philip Zhao",
- "Poornima Nayak",
- "Pramod",
- "Prasad Kandepu",
- "Pratik V. Parikh",
- "Praveen Arimbrathodiyil",
- "Praveen Kumar",
- "Priit Laes",
- "Priyanshu Raj",
- "P S Chakravarthi",
- "Radek Doulik",
- "Raghavendran R",
- "Rahul Bhalerao",
- "Raivis Dejus",
- "Raja R Harinath",
- "Rajeev Ramanathan",
- "Rajesh Ranjan",
- "Rakesh k.g",
- "Ramiro Estrugo",
- "Ranjan Somani",
- "Raphael Higino",
- "Ray Strode",
- "Reinout van Schouwen",
- "Rhys Jones",
- "Ricardo Markiewicz",
- "Richard Boulton",
- "Richard Hult",
- "Richard Li",
- "Rob Bradford",
- "Robert-André Mauchin",
- "Robert Brady",
- "Robert Sedak",
- "Robin Slomkowski",
- "Rodney Dawes",
- "Rodrigo Moya",
- "Roger Zauner",
- "Rohini S",
- "Roland Illig",
- "Ronald Kuetemeier",
- "Roozbeh Pournader",
- "Roshan Kumar Singh",
- "Ross Burton",
- "Rostislav Raykov",
- "Rouslan Solomakhin",
- "Roy-Magne Mo",
- "Runa Bhattacharjee",
- "Russell Steinthal",
- "Russian team",
- "Rusty Conover",
- "Ryan P. Skadberg",
- "Sam Creasey",
- "Sami Pesonen",
- "Samúel Jón Gunnarsson",
- "Sam Yang",
- "Sankar P",
- "Sanlig Badral",
- "Sanshao Jiang",
- "S.Antony Vincent Pandian",
- "Sarfraaz Ahmed",
- "Satoru SATOH",
- "Sayamindu Dasgupta",
- "S. Caglar Onur",
- "Sean Atkinson",
- "Seán de Búrca",
- "Sean Gao",
- "Sebastian Rittau",
- "Sebastian Wilhelmi",
- "Sebastien Bacher",
- "Sergey Panov",
- "Sergio Villar Senín",
- "Seth Alves",
- "Seth Nickell",
- "Shakti Sen",
- "Shankar Prasad",
- "Shi Pu",
- "Shilpa C",
- "Shree Krishnan",
- "Shreyas Srinivasan",
- "Shuai Liu",
- "Sigurd Gartmann",
- "Simon Zheng",
- "Simos Xenitellis",
- "Sitic Vulnerability Advisory",
- "Sivaiah Nallagatla",
- "Slobodan D. Sredojevic",
- "S N Tejasvi",
- "Spiros Papadimitriou",
- "Srinivasa Ragavan",
- "Stanislav Brabec",
- "Stanislav Slusny",
- "Stanislav Visnovsky",
- "Stéphane Raimbault",
- "Stephen Cook",
- "Steve Murphy",
- "Steven Zhang",
- "Stuart Parmenter",
- "Subhransu Behera",
- "Subodh Soni",
- "Suman Manjunath",
- "Sunil Mohan Adapa",
- "Supranee Thirawatthanasuk",
- "Suresh Chandrasekharan",
- "Sushma Rai",
- "Sven Herzberg",
- "Sweta Kothari",
- "Szabolcs Ban",
- "Takao Fujiwara",
- "Takayuki Kusano",
- "Takeshi Aihana",
- "Takuo Kitame",
- "Tambet Ingo",
- "Taylor Hayward",
- "Ted Percival",
- "Telsa Gwynne",
- "Terance Sola",
- "Theppitak Karoonboonyanan",
- "Thierry Moisan",
- "Thierry Randrianiriana",
- "Thomas Cataldo",
- "Thomas Klausner",
- "Thomas Mirlacher",
- "Thouis R. Jones",
- "Tiago Antao",
- "Timo Jyrinki",
- "Timur Bakeyev",
- "Tim Wo",
- "Tim Yamin",
- "Timo Hoenig",
- "Timo Sirainen",
- "Timothy Lee",
- "Timur Bakeyev",
- "Tino Meinen",
- "Tobias Mueller",
- "Tõivo Leedjärv",
- "Tom Tromey",
- "Tomas Ogren",
- "Tomasz Kłoczko",
- "Tomislav Vujec",
- "Tommi Komulainen",
- "Tommi Vainikainen",
- "Tony Tsui",
- "Tor Lillqvist",
- "Trent Lloyd",
- "Tristan Tarrant",
- "Tuomas J. Lukka",
- "Tuomas Kuosmanen",
- "Udomsak Chundang",
- "Ulrich Neumann",
- "Umeshtej",
- "Umesh Tiwari",
- "Ushveen Kaur",
- "Vadim Strizhevsky",
- "Valek Filippov",
- "Vandana Shenoy .B",
- "Vardhman Jain",
- "Vasiliy Faronov",
- "Veerapuram Varadhan",
- "Vincent Carriere",
- "Vincent Noel",
- "Vincent Renardias",
- "Vincent Untz",
- "Vincent van Adrighem",
- "Viren.L",
- "Vivek Jain",
- "Vladimer Sichinava",
- "Vladimir Petkov",
- "Vladimir Vukicevic",
- "Vladimir Melo",
- "V Ravi Kumar Raju",
- "Wadim Dziedzic",
- "Wang Jian",
- "Wang Li",
- "Wang Xin",
- "Washington Lins",
- "Wayne Davis",
- "William Jon McCann",
- "Woodman Tuen",
- "Wouter Bolsterlee",
- "Xan Lopez",
- "Xavier Conde Rueda",
- "Xiurong Simon Zheng",
- "Yair Hershkovitz",
- "Yanko Kaneti",
- "Yannig Marchegay",
- "Yavor Doganov",
- "Yi Jin",
- "Yong Sun",
- "Yuedong Du",
- "Yukihiro Nakai",
- "Yu Mengjie",
- "Yuri Pankov",
- "Yuri Syrota",
- "Yuriy Penkin",
- "Zach Frey",
- "Zan Lynx",
- "Zbigniew Chyla",
- "Zhe Su",
- "Zipeco",
- "Žygimantas Beručka",
- NULL
-};
-
-static const char *documentors[] = {
- "Aaron Weber",
- "Binika Preet",
- "Dan Winship",
- "David Trowbridge",
- "Jessica Prabhakar",
- "JP Rosevear",
- "Radhika Nair",
- NULL
-};
-
-static void
-command_about (BonoboUIComponent *uih,
- EShellWindow *window,
- const char *path)
-{
- gchar *translator_credits;
-
- /* The translator-credits string is for translators to list
- * per-language credits for translation, displayed in the
- * about dialog. */
- translator_credits = _("translator-credits");
- if (strcmp (translator_credits, "translator-credits") == 0)
- translator_credits = NULL;
-
- gtk_show_about_dialog (
- GTK_WINDOW (window),
- "program-name", "Evolution",
- "version", VERSION,
- "copyright", EVOLUTION_COPYRIGHT,
- "comments", _("Groupware Suite"),
- "website", EVOLUTION_WEBSITE,
- "website-label", _("Evolution Website"),
- "authors", authors,
- "documenters", documentors,
- "translator-credits", translator_credits,
- "logo-icon-name", "evolution",
- NULL);
-}
-
-static void
-command_open_faq (BonoboUIComponent *uih,
- EShellWindow *window,
- const char *path)
-{
- const gchar *uri;
-
- uri = "http://www.go-evolution.org/FAQ";
- e_show_uri (GTK_WINDOW (window), uri);
-}
-
-static void
-command_quick_reference (BonoboUIComponent *uih,
- EShellWindow *window,
- const char *path)
-{
- char *quickref;
- const gchar * const *language_names;
-
- language_names = g_get_language_names ();
- while (*language_names != NULL) {
- const gchar *lang = *language_names++;
-
- /* This has to be a valid language AND a language with
- * no encoding postfix. The language will come up without
- * encoding next */
- if (lang == NULL || strchr (lang, '.') != NULL)
- continue;
-
- quickref = g_build_filename (EVOLUTION_HELPDIR, "quickref", lang, "quickref.pdf", NULL);
- if (g_file_test (quickref, G_FILE_TEST_EXISTS)) {
- GFile *file = g_file_new_for_path (quickref);
-
- if (file) {
- GError *error = NULL;
- char *uri = g_file_get_uri (file);
-
- g_app_info_launch_default_for_uri (uri, NULL, &error);
-
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-
- g_object_unref (file);
- g_free (uri);
- }
-
- g_free (quickref);
- return;
- }
-
- g_free (quickref);
- }
-}
-
-
-static void
-command_work_offline (BonoboUIComponent *uih,
- EShellWindow *window,
- const char *path)
-{
- EShell *shell;
-
- shell = e_shell_window_peek_shell (window);
- e_shell_set_line_status (shell, GNOME_Evolution_USER_OFFLINE);
-}
-
-static void
-command_work_online (BonoboUIComponent *uih,
- EShellWindow *window,
- const char *path)
-{
- EShell *shell;
-
- shell = e_shell_window_peek_shell (window);
- e_shell_set_line_status (shell, GNOME_Evolution_USER_ONLINE);
-}
-
-static void
-command_open_new_window (BonoboUIComponent *uih,
- EShellWindow *window,
- const char *path)
-{
- e_shell_create_window (e_shell_window_peek_shell (window),
- e_shell_window_peek_current_component_id (window),
- window);
-}
-
-
-/* Actions menu. */
-
-static void
-command_send_receive (BonoboUIComponent *uih,
- EShellWindow *window,
- const char *path)
-{
- e_shell_send_receive (e_shell_window_peek_shell (window));
-}
-
-static void
-command_forget_passwords (BonoboUIComponent *ui_component,
- void *data,
- const char *path)
-{
- if (e_error_run (NULL, "shell:forget-passwords", NULL) == GTK_RESPONSE_OK)
- e_passwords_forget_passwords();
-}
-
-/* Tools menu. */
-
-static void
-command_settings (BonoboUIComponent *uih,
- EShellWindow *window,
- const char *path)
-{
- e_shell_window_show_settings (window);
-}
-
-static void
-command_pilot_settings (BonoboUIComponent *uih,
- EShellWindow *window,
- const char *path)
-{
- launch_pilot_settings (NULL);
-}
-
-
-static BonoboUIVerb file_verbs [] = {
- BONOBO_UI_VERB ("FileImporter", (BonoboUIVerbFn) command_import),
- BONOBO_UI_VERB ("FilePageSetup", (BonoboUIVerbFn) command_page_setup),
- BONOBO_UI_VERB ("FileClose", (BonoboUIVerbFn) command_close),
- BONOBO_UI_VERB ("FileExit", (BonoboUIVerbFn) command_quit),
-
- BONOBO_UI_VERB ("WorkOffline", (BonoboUIVerbFn) command_work_offline),
- BONOBO_UI_VERB ("WorkOnline", (BonoboUIVerbFn) command_work_online),
-
- BONOBO_UI_VERB_END
-};
-
-static BonoboUIVerb new_verbs [] = {
- BONOBO_UI_VERB ("OpenNewWindow", (BonoboUIVerbFn) command_open_new_window),
-
- BONOBO_UI_VERB_END
-};
-
-static BonoboUIVerb actions_verbs[] = {
- BONOBO_UI_VERB ("SendReceive", (BonoboUIVerbFn) command_send_receive),
- BONOBO_UI_VERB ("ForgetPasswords", command_forget_passwords),
-
- BONOBO_UI_VERB_END
-};
-
-static BonoboUIVerb tools_verbs[] = {
- BONOBO_UI_VERB ("Settings", (BonoboUIVerbFn) command_settings),
- BONOBO_UI_VERB ("PilotSettings", (BonoboUIVerbFn) command_pilot_settings),
-
- BONOBO_UI_VERB_END
-};
-
-static BonoboUIVerb help_verbs [] = {
- BONOBO_UI_VERB ("QuickReference", (BonoboUIVerbFn) command_quick_reference),
- BONOBO_UI_VERB ("HelpOpenFAQ", (BonoboUIVerbFn) command_open_faq),
- BONOBO_UI_VERB ("HelpSubmitBug", (BonoboUIVerbFn) command_submit_bug),
- BONOBO_UI_VERB ("HelpAbout", (BonoboUIVerbFn) command_about),
-
- BONOBO_UI_VERB_END
-};
-
-static EPixmap pixmaps [] = {
- E_PIXMAP ("/Toolbar/SendReceive", "mail-send-receive", E_ICON_SIZE_LARGE_TOOLBAR),
- E_PIXMAP ("/menu/File/OpenNewWindow", "window-new", E_ICON_SIZE_MENU),
- E_PIXMAP ("/menu/File/SendReceive", "mail-send-receive", E_ICON_SIZE_MENU),
- E_PIXMAP ("/menu/File/FileImporter", "stock_mail-import", E_ICON_SIZE_MENU),
- E_PIXMAP ("/menu/File/Print/FilePageSetup", "stock_print-setup", E_ICON_SIZE_MENU),
- E_PIXMAP ("/menu/File/ToggleOffline", "stock_disconnect", E_ICON_SIZE_MENU),
- E_PIXMAP ("/menu/File/FileClose", "window-close", E_ICON_SIZE_MENU),
- E_PIXMAP ("/menu/File/FileExit", "application-exit", E_ICON_SIZE_MENU),
- E_PIXMAP ("/menu/Edit/Settings", "preferences-desktop", E_ICON_SIZE_MENU),
- E_PIXMAP ("/menu/Help/HelpOpenFAQ", "help-faq", E_ICON_SIZE_MENU),
-
- E_PIXMAP_END
-};
-
-static EPixmap offline_pixmaps [] = {
- E_PIXMAP ("/menu/File/ToggleOffline", "stock_disconnect", E_ICON_SIZE_MENU),
- E_PIXMAP_END
-};
-
-static EPixmap online_pixmaps [] = {
- E_PIXMAP ("/menu/File/ToggleOffline", "stock_connect", E_ICON_SIZE_MENU),
- E_PIXMAP_END
-};
-
-
-/* The Work Online / Work Offline menu item. */
-
-static void
-update_offline_menu_item (EShellWindow *shell_window,
- EShellLineStatus line_status)
-{
- BonoboUIComponent *ui_component;
-
- ui_component = e_shell_window_peek_bonobo_ui_component (shell_window);
-
- switch (line_status) {
- case E_SHELL_LINE_STATUS_OFFLINE:
- case E_SHELL_LINE_STATUS_FORCED_OFFLINE:
- bonobo_ui_component_set_prop (ui_component,
- "/menu/File/ToggleOffline",
- "label", _("_Work Online"), NULL);
- bonobo_ui_component_set_prop (ui_component,
- "/menu/File/ToggleOffline",
- "verb", "WorkOnline", NULL);
- bonobo_ui_component_set_prop (ui_component,
- "/commands/ToggleOffline",
- "sensitive", "1", NULL);
- e_pixmaps_update (ui_component, online_pixmaps);
- break;
-
- case E_SHELL_LINE_STATUS_ONLINE:
- bonobo_ui_component_set_prop (ui_component,
- "/menu/File/ToggleOffline",
- "label", _("_Work Offline"), NULL);
- bonobo_ui_component_set_prop (ui_component,
- "/menu/File/ToggleOffline",
- "verb", "WorkOffline", NULL);
- bonobo_ui_component_set_prop (ui_component,
- "/commands/ToggleOffline",
- "sensitive", "1", NULL);
- e_pixmaps_update (ui_component, offline_pixmaps);
- break;
-
- case E_SHELL_LINE_STATUS_GOING_OFFLINE:
- bonobo_ui_component_set_prop (ui_component,
- "/menu/File/ToggleOffline",
- "label", _("Work Offline"), NULL);
- bonobo_ui_component_set_prop (ui_component,
- "/menu/File/ToggleOffline",
- "verb", "WorkOffline", NULL);
- bonobo_ui_component_set_prop (ui_component,
- "/commands/ToggleOffline",
- "sensitive", "0", NULL);
- e_pixmaps_update (ui_component, offline_pixmaps);
- break;
-
- default:
- g_return_if_reached();
- }
-}
-
-static void
-shell_line_status_changed_cb (EShell *shell,
- EShellLineStatus new_status,
- EShellWindow *shell_window)
-{
- update_offline_menu_item (shell_window, new_status);
-}
-
-static void
-view_buttons_icontext_item_toggled_handler (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- EShellWindow *shell_window)
-{
- ESidebar *sidebar;
-
- sidebar = e_shell_window_peek_sidebar (shell_window);
- e_sidebar_set_mode (sidebar, E_SIDEBAR_MODE_BOTH);
-}
-
-static void
-view_buttons_icon_item_toggled_handler (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- EShellWindow *shell_window)
-{
- ESidebar *sidebar;
-
- sidebar = e_shell_window_peek_sidebar (shell_window);
- e_sidebar_set_mode (sidebar, E_SIDEBAR_MODE_ICON);
-}
-
-static void
-view_buttons_text_item_toggled_handler (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- EShellWindow *shell_window)
-{
- ESidebar *sidebar;
-
- sidebar = e_shell_window_peek_sidebar (shell_window);
- e_sidebar_set_mode (sidebar, E_SIDEBAR_MODE_TEXT);
-}
-
-static void
-view_buttons_toolbar_item_toggled_handler (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- EShellWindow *shell_window)
-{
- ESidebar *sidebar;
-
- sidebar = e_shell_window_peek_sidebar (shell_window);
- e_sidebar_set_mode (sidebar, E_SIDEBAR_MODE_TOOLBAR);
-}
-
-static void
-view_buttons_hide_item_toggled_handler (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- EShellWindow *shell_window)
-{
- ESidebar *sidebar;
- gboolean is_visible;
-
- sidebar = e_shell_window_peek_sidebar (shell_window);
-
- is_visible = state[0] == '0';
-
- e_sidebar_set_show_buttons (sidebar, is_visible);
-}
-
-static void
-view_toolbar_item_toggled_handler (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- EShellWindow *shell_window)
-{
- gboolean is_visible;
-
- is_visible = state[0] == '1';
-
- bonobo_ui_component_set_prop (ui_component, "/Toolbar",
- "hidden", is_visible ? "0" : "1", NULL);
-}
-
-static void
-view_statusbar_item_toggled_handler (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- EShellWindow *shell_window)
-{
- GtkWidget *status_bar = e_shell_window_peek_statusbar (shell_window);
- gboolean is_visible;
- GConfClient *gconf_client;
-
- is_visible = state[0] == '1';
- if(is_visible)
- gtk_widget_show (status_bar);
- else
- gtk_widget_hide (status_bar);
- gconf_client = gconf_client_get_default ();
- gconf_client_set_bool (gconf_client,"/apps/evolution/shell/view_defaults/statusbar_visible", is_visible, NULL);
- g_object_unref (gconf_client);
-}
-
-static void
-view_sidebar_item_toggled_handler (BonoboUIComponent *ui_component,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- EShellWindow *shell_window)
-{
- GtkWidget *side_bar = GTK_WIDGET(e_shell_window_peek_sidebar (shell_window));
- gboolean is_visible;
- GConfClient *gconf_client;
-
- is_visible = state[0] == '1';
- if(is_visible)
- gtk_widget_show (side_bar);
- else
- gtk_widget_hide (side_bar);
- gconf_client = gconf_client_get_default ();
- gconf_client_set_bool (gconf_client_get_default (),"/apps/evolution/shell/view_defaults/sidebar_visible", is_visible, NULL);
- g_object_unref (gconf_client);
-}
-
-/* Public API. */
-
-void
-e_shell_window_commands_setup (EShellWindow *shell_window)
-{
- BonoboUIComponent *uic;
- EShell *shell;
-
- g_return_if_fail (shell_window != NULL);
- g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
-
- uic = e_shell_window_peek_bonobo_ui_component (shell_window);
- shell = e_shell_window_peek_shell (shell_window);
-
- bonobo_ui_component_add_verb_list_with_data (uic, file_verbs, shell_window);
- bonobo_ui_component_add_verb_list_with_data (uic, new_verbs, shell_window);
- bonobo_ui_component_add_verb_list_with_data (uic, actions_verbs, shell_window);
- bonobo_ui_component_add_verb_list_with_data (uic, tools_verbs, shell_window);
- bonobo_ui_component_add_verb_list_with_data (uic, help_verbs, shell_window);
- bonobo_ui_component_add_listener (uic, "ViewButtonsIconText",
- (BonoboUIListenerFn)view_buttons_icontext_item_toggled_handler,
- (gpointer)shell_window);
- bonobo_ui_component_add_listener (uic, "ViewButtonsIcon",
- (BonoboUIListenerFn)view_buttons_icon_item_toggled_handler,
- (gpointer)shell_window);
- bonobo_ui_component_add_listener (uic, "ViewButtonsText",
- (BonoboUIListenerFn)view_buttons_text_item_toggled_handler,
- (gpointer)shell_window);
- bonobo_ui_component_add_listener (uic, "ViewButtonsToolbar",
- (BonoboUIListenerFn)view_buttons_toolbar_item_toggled_handler,
- (gpointer)shell_window);
- bonobo_ui_component_add_listener (uic, "ViewButtonsHide",
- (BonoboUIListenerFn)view_buttons_hide_item_toggled_handler,
- (gpointer)shell_window);
- bonobo_ui_component_add_listener (uic, "ViewToolbar",
- (BonoboUIListenerFn)view_toolbar_item_toggled_handler,
- (gpointer)shell_window);
- bonobo_ui_component_add_listener (uic, "ViewStatusBar",
- (BonoboUIListenerFn)view_statusbar_item_toggled_handler,
- (gpointer)shell_window);
- bonobo_ui_component_add_listener (uic, "ViewSideBar",
- (BonoboUIListenerFn)view_sidebar_item_toggled_handler,
- (gpointer)shell_window);
-
- e_pixmaps_update (uic, pixmaps);
-
- /* Set up the work online / work offline menu item. */
- g_signal_connect_object (shell, "line_status_changed",
- G_CALLBACK (shell_line_status_changed_cb), shell_window, 0);
- update_offline_menu_item (shell_window, e_shell_get_line_status (shell));
-}
diff --git a/shell/e-shell-window-commands.h b/shell/e-shell-window-commands.h
deleted file mode 100644
index 3d3843c8f0..0000000000
--- a/shell/e-shell-window-commands.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_SHELL_WINDOW_COMMANDS_H_
-#define _E_SHELL_WINDOW_COMMANDS_H_
-
-#include "e-shell-window.h"
-
-void e_shell_window_commands_setup (EShellWindow *window);
-
-#endif /* _E_SHELL_WINDOW_COMMANDS_H_ */
diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c
new file mode 100644
index 0000000000..38d3926d67
--- /dev/null
+++ b/shell/e-shell-window-private.c
@@ -0,0 +1,575 @@
+/*
+ * e-shell-window-private.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-shell-window-private.h"
+
+static void
+shell_window_save_switcher_style_cb (GtkRadioAction *action,
+ GtkRadioAction *current,
+ EShellWindow *shell_window)
+{
+ EShell *shell;
+ GConfClient *client;
+ GtkToolbarStyle style;
+ const gchar *key;
+ const gchar *string;
+ GError *error = NULL;
+
+ shell = e_shell_window_get_shell (shell_window);
+ client = e_shell_get_gconf_client (shell);
+
+ style = gtk_radio_action_get_current_value (action);
+ key = "/apps/evolution/shell/view_defaults/buttons_style";
+
+ switch (style) {
+ case GTK_TOOLBAR_ICONS:
+ string = "icons";
+ break;
+
+ case GTK_TOOLBAR_TEXT:
+ string = "text";
+ break;
+
+ case GTK_TOOLBAR_BOTH:
+ case GTK_TOOLBAR_BOTH_HORIZ:
+ string = "both";
+ break;
+
+ default:
+ string = "toolbar";
+ break;
+ }
+
+ if (!gconf_client_set_string (client, key, string, &error)) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+}
+
+static void
+shell_window_init_switcher_style (EShellWindow *shell_window)
+{
+ EShell *shell;
+ GtkAction *action;
+ GConfClient *client;
+ GtkToolbarStyle style;
+ const gchar *key;
+ gchar *string;
+ GError *error = NULL;
+
+ /* XXX GConfBridge doesn't let you convert between numeric properties
+ * and string keys, so we have to create the binding manually. */
+
+ shell = e_shell_window_get_shell (shell_window);
+ client = e_shell_get_gconf_client (shell);
+
+ action = ACTION (SWITCHER_STYLE_ICONS);
+ key = "/apps/evolution/shell/view_defaults/buttons_style";
+ string = gconf_client_get_string (client, key, &error);
+
+ if (string != NULL) {
+ if (strcmp (string, "icons") == 0)
+ style = GTK_TOOLBAR_ICONS;
+ else if (strcmp (string, "text") == 0)
+ style = GTK_TOOLBAR_TEXT;
+ else if (strcmp (string, "both") == 0)
+ style = GTK_TOOLBAR_BOTH_HORIZ;
+ else
+ style = -1;
+
+ gtk_radio_action_set_current_value (
+ GTK_RADIO_ACTION (action), style);
+ }
+
+ g_signal_connect (
+ action, "changed",
+ G_CALLBACK (shell_window_save_switcher_style_cb),
+ shell_window);
+}
+
+static void
+shell_window_menu_item_select_cb (EShellWindow *shell_window,
+ GtkWidget *menu_item)
+{
+ GtkAction *action;
+ GtkLabel *label;
+ gchar *tooltip = NULL;
+
+ action = g_object_get_data (G_OBJECT (menu_item), "action");
+ g_return_if_fail (GTK_IS_ACTION (action));
+
+ g_object_get (action, "tooltip", &tooltip, NULL);
+
+ if (tooltip == NULL)
+ return;
+
+ label = GTK_LABEL (shell_window->priv->tooltip_label);
+ gtk_label_set_text (label, tooltip);
+ g_free (tooltip);
+
+ gtk_widget_show (shell_window->priv->tooltip_label);
+ gtk_widget_hide (shell_window->priv->status_notebook);
+}
+
+static void
+shell_window_menu_item_deselect_cb (EShellWindow *shell_window)
+{
+ gtk_widget_hide (shell_window->priv->tooltip_label);
+ gtk_widget_show (shell_window->priv->status_notebook);
+}
+
+static void
+shell_window_connect_proxy_cb (EShellWindow *shell_window,
+ GtkAction *action,
+ GtkWidget *proxy)
+{
+ if (!GTK_IS_MENU_ITEM (proxy))
+ return;
+
+ g_object_set_data_full (
+ G_OBJECT (proxy),
+ "action", g_object_ref (action),
+ (GDestroyNotify) g_object_unref);
+
+ g_signal_connect_swapped (
+ proxy, "select",
+ G_CALLBACK (shell_window_menu_item_select_cb),
+ shell_window);
+
+ g_signal_connect_swapped (
+ proxy, "deselect",
+ G_CALLBACK (shell_window_menu_item_deselect_cb),
+ shell_window);
+}
+
+static void
+shell_window_online_button_clicked_cb (EOnlineButton *button,
+ EShellWindow *shell_window)
+{
+ if (e_online_button_get_online (button))
+ gtk_action_activate (ACTION (WORK_OFFLINE));
+ else
+ gtk_action_activate (ACTION (WORK_ONLINE));
+}
+
+void
+e_shell_window_private_init (EShellWindow *shell_window)
+{
+ EShellWindowPrivate *priv = shell_window->priv;
+ GHashTable *loaded_views;
+ GArray *signal_handler_ids;
+ GtkAccelGroup *accel_group;
+ GtkToolItem *item;
+ GtkWidget *container;
+ GtkWidget *widget;
+ guint merge_id;
+ gint height;
+
+ loaded_views = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_object_unref);
+
+ signal_handler_ids = g_array_new (FALSE, FALSE, sizeof (gulong));
+
+ priv->ui_manager = gtk_ui_manager_new ();
+ priv->loaded_views = loaded_views;
+ priv->active_view = "unknown";
+ priv->signal_handler_ids = signal_handler_ids;
+
+ e_shell_window_add_action_group (shell_window, "shell");
+ e_shell_window_add_action_group (shell_window, "gal-view");
+ e_shell_window_add_action_group (shell_window, "new-item");
+ e_shell_window_add_action_group (shell_window, "new-source");
+ e_shell_window_add_action_group (shell_window, "custom-rules");
+ e_shell_window_add_action_group (shell_window, "switcher");
+ e_shell_window_add_action_group (shell_window, "lockdown-application-handlers");
+ e_shell_window_add_action_group (shell_window, "lockdown-printing");
+ e_shell_window_add_action_group (shell_window, "lockdown-print-setup");
+ e_shell_window_add_action_group (shell_window, "lockdown-save-to-disk");
+
+ merge_id = gtk_ui_manager_new_merge_id (priv->ui_manager);
+ priv->custom_rule_merge_id = merge_id;
+
+ merge_id = gtk_ui_manager_new_merge_id (priv->ui_manager);
+ priv->gal_view_merge_id = merge_id;
+
+ e_shell_window_actions_init (shell_window);
+
+ accel_group = gtk_ui_manager_get_accel_group (priv->ui_manager);
+ gtk_window_add_accel_group (GTK_WINDOW (shell_window), accel_group);
+
+ g_signal_connect_swapped (
+ priv->ui_manager, "connect-proxy",
+ G_CALLBACK (shell_window_connect_proxy_cb), shell_window);
+
+ /* Construct window widgets. */
+
+ widget = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (shell_window), widget);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = e_shell_window_get_managed_widget (
+ shell_window, "/main-menu");
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ priv->main_menu = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ widget = e_shell_window_get_managed_widget (
+ shell_window, "/main-toolbar");
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ priv->main_toolbar = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ /* XXX Having this separator in the UI definition doesn't work
+ * because GtkUIManager is unaware of the "New" button, so
+ * it makes the separator invisible. One possibility is to
+ * define a GtkAction subclass for which create_tool_item()
+ * returns an EMenuToolButton. Then both this separator
+ * and the "New" button could be added to the UI definition.
+ * Tempting, but the "New" button and its dynamically
+ * generated menu is already a complex beast, and I'm not
+ * convinced having it proxy some new type of GtkAction
+ * is worth the extra effort. */
+ item = gtk_separator_tool_item_new ();
+ gtk_toolbar_insert (GTK_TOOLBAR (widget), item, 0);
+ gtk_widget_show (GTK_WIDGET (item));
+
+ item = e_menu_tool_button_new (_("New"));
+ gtk_tool_item_set_is_important (GTK_TOOL_ITEM (item), TRUE);
+ gtk_widget_add_accelerator (
+ GTK_WIDGET (item), "clicked",
+ gtk_ui_manager_get_accel_group (priv->ui_manager),
+ GDK_N, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+ gtk_toolbar_insert (GTK_TOOLBAR (widget), item, 0);
+ priv->menu_tool_button = g_object_ref (item);
+ gtk_widget_show (GTK_WIDGET (item));
+
+ widget = gtk_hpaned_new ();
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ priv->content_pane = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ widget = gtk_hbox_new (FALSE, 3);
+ gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ priv->status_area = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ /* Make the status area as large as the task bar. */
+ gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, NULL, &height);
+ gtk_widget_set_size_request (widget, -1, (height * 2) + 6);
+
+ container = priv->content_pane;
+
+ widget = e_shell_switcher_new ();
+ gtk_paned_pack1 (GTK_PANED (container), widget, FALSE, FALSE);
+ priv->switcher = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ widget = gtk_notebook_new ();
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
+ gtk_paned_pack2 (GTK_PANED (container), widget, TRUE, TRUE);
+ priv->content_notebook = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ container = priv->switcher;
+
+ widget = gtk_notebook_new ();
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
+ gtk_container_add (GTK_CONTAINER (container), widget);
+ priv->sidebar_notebook = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ container = priv->status_area;
+
+ widget = e_online_button_new ();
+ g_signal_connect (
+ widget, "clicked",
+ G_CALLBACK (shell_window_online_button_clicked_cb),
+ shell_window);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
+ priv->online_button = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ widget = gtk_label_new ("");
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ priv->tooltip_label = g_object_ref (widget);
+ gtk_widget_hide (widget);
+
+ widget = gtk_notebook_new ();
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ priv->status_notebook = g_object_ref (widget);
+ gtk_widget_show (widget);
+}
+
+void
+e_shell_window_private_constructed (EShellWindow *shell_window)
+{
+ EShellWindowPrivate *priv = shell_window->priv;
+ EShellSettings *shell_settings;
+ EShell *shell;
+ GConfBridge *bridge;
+ GtkActionGroup *action_group;
+ GtkAction *action;
+ GObject *object;
+ const gchar *key;
+
+ shell = e_shell_window_get_shell (shell_window);
+ shell_settings = e_shell_get_shell_settings (shell);
+
+ e_shell_watch_window (shell, GTK_WINDOW (shell_window));
+
+ /* Create the switcher actions before we set the initial
+ * shell view, because the shell view relies on them for
+ * default settings during construction. */
+ e_shell_window_create_switcher_actions (shell_window);
+
+ /* Support lockdown. */
+
+ action_group = ACTION_GROUP (LOCKDOWN_PRINTING);
+
+ e_binding_new_with_negation (
+ G_OBJECT (shell_settings), "disable-printing",
+ G_OBJECT (action_group), "sensitive");
+
+ action_group = ACTION_GROUP (LOCKDOWN_PRINT_SETUP);
+
+ e_binding_new_with_negation (
+ G_OBJECT (shell_settings), "disable-print-setup",
+ G_OBJECT (action_group), "sensitive");
+
+ action_group = ACTION_GROUP (LOCKDOWN_SAVE_TO_DISK);
+
+ e_binding_new_with_negation (
+ G_OBJECT (shell_settings), "disable-save-to-disk",
+ G_OBJECT (action_group), "sensitive");
+
+ /* Bind GObject properties to GObject properties. */
+
+ action = ACTION (SEND_RECEIVE);
+
+ e_binding_new (
+ G_OBJECT (shell), "online",
+ G_OBJECT (action), "sensitive");
+
+ action = ACTION (WORK_OFFLINE);
+
+ e_binding_new (
+ G_OBJECT (shell), "online",
+ G_OBJECT (action), "visible");
+
+ action = ACTION (WORK_ONLINE);
+
+ e_binding_new_with_negation (
+ G_OBJECT (shell), "online",
+ G_OBJECT (action), "visible");
+
+ e_binding_new (
+ G_OBJECT (shell), "online",
+ G_OBJECT (shell_window->priv->online_button), "online");
+
+ /* Bind GObject properties to GConf keys. */
+
+ bridge = gconf_bridge_get ();
+
+ key = "/apps/evolution/shell/view_defaults/window";
+ gconf_bridge_bind_window (
+ bridge, key, GTK_WINDOW (shell_window), TRUE, FALSE);
+
+ object = G_OBJECT (shell_window);
+ key = "/apps/evolution/shell/view_defaults/component_id";
+ gconf_bridge_bind_property (bridge, key, object, "active-view");
+
+ object = G_OBJECT (priv->content_pane);
+ key = "/apps/evolution/shell/view_defaults/folder_bar/width";
+ gconf_bridge_bind_property_delayed (bridge, key, object, "position");
+
+ object = G_OBJECT (ACTION (SHOW_SIDEBAR));
+ key = "/apps/evolution/shell/view_defaults/sidebar_visible";
+ gconf_bridge_bind_property (bridge, key, object, "active");
+
+ object = G_OBJECT (ACTION (SHOW_STATUSBAR));
+ key = "/apps/evolution/shell/view_defaults/statusbar_visible";
+ gconf_bridge_bind_property (bridge, key, object, "active");
+
+ object = G_OBJECT (ACTION (SHOW_SWITCHER));
+ key = "/apps/evolution/shell/view_defaults/buttons_visible";
+ gconf_bridge_bind_property (bridge, key, object, "active");
+
+ object = G_OBJECT (ACTION (SHOW_TOOLBAR));
+ key = "/apps/evolution/shell/view_defaults/toolbar_visible";
+ gconf_bridge_bind_property (bridge, key, object, "active");
+
+ shell_window_init_switcher_style (shell_window);
+}
+
+void
+e_shell_window_private_dispose (EShellWindow *shell_window)
+{
+ EShellWindowPrivate *priv = shell_window->priv;
+
+ /* Need to disconnect handlers before we unref the shell. */
+ if (priv->signal_handler_ids != NULL) {
+ GArray *array = priv->signal_handler_ids;
+ gulong handler_id;
+ guint ii;
+
+ for (ii = 0; ii < array->len; ii++) {
+ handler_id = g_array_index (array, gulong, ii);
+ g_signal_handler_disconnect (priv->shell, handler_id);
+ }
+
+ g_array_free (array, TRUE);
+ priv->signal_handler_ids = NULL;
+ }
+
+ DISPOSE (priv->ui_manager);
+
+ g_hash_table_remove_all (priv->loaded_views);
+
+ DISPOSE (priv->main_menu);
+ DISPOSE (priv->main_toolbar);
+ DISPOSE (priv->menu_tool_button);
+ DISPOSE (priv->content_pane);
+ DISPOSE (priv->content_notebook);
+ DISPOSE (priv->sidebar_notebook);
+ DISPOSE (priv->switcher);
+ DISPOSE (priv->status_area);
+ DISPOSE (priv->online_button);
+ DISPOSE (priv->tooltip_label);
+ DISPOSE (priv->status_notebook);
+
+ priv->destroyed = TRUE;
+}
+
+void
+e_shell_window_private_finalize (EShellWindow *shell_window)
+{
+ EShellWindowPrivate *priv = shell_window->priv;
+
+ g_hash_table_destroy (priv->loaded_views);
+}
+
+void
+e_shell_window_switch_to_view (EShellWindow *shell_window,
+ const gchar *view_name)
+{
+ GtkNotebook *notebook;
+ EShellView *shell_view;
+ gint page_num;
+
+ g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
+ g_return_if_fail (view_name != NULL);
+
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+
+ page_num = e_shell_view_get_page_num (shell_view);
+ g_return_if_fail (page_num >= 0);
+
+ notebook = GTK_NOTEBOOK (shell_window->priv->content_notebook);
+ gtk_notebook_set_current_page (notebook, page_num);
+
+ notebook = GTK_NOTEBOOK (shell_window->priv->sidebar_notebook);
+ gtk_notebook_set_current_page (notebook, page_num);
+
+ notebook = GTK_NOTEBOOK (shell_window->priv->status_notebook);
+ gtk_notebook_set_current_page (notebook, page_num);
+
+ shell_window->priv->active_view = view_name;
+ g_object_notify (G_OBJECT (shell_window), "active-view");
+
+ e_shell_window_update_icon (shell_window);
+ e_shell_window_update_title (shell_window);
+ e_shell_window_update_new_menu (shell_window);
+ e_shell_window_update_view_menu (shell_window);
+ e_shell_window_update_search_menu (shell_window);
+
+ e_shell_view_update_actions (shell_view);
+}
+
+void
+e_shell_window_update_icon (EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ GtkAction *action;
+ const gchar *view_name;
+ gchar *icon_name = NULL;
+
+ g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
+
+ view_name = e_shell_window_get_active_view (shell_window);
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+
+ action = e_shell_view_get_action (shell_view);
+ g_object_get (action, "icon-name", &icon_name, NULL);
+ gtk_window_set_icon_name (GTK_WINDOW (shell_window), icon_name);
+ g_free (icon_name);
+}
+
+void
+e_shell_window_update_title (EShellWindow *shell_window)
+{
+ EShellView *shell_view;
+ const gchar *view_title;
+ const gchar *view_name;
+ gchar *window_title;
+
+ g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
+
+ view_name = e_shell_window_get_active_view (shell_window);
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+ view_title = e_shell_view_get_title (shell_view);
+
+ /* Translators: This is used for the main window title. */
+ window_title = g_strdup_printf (_("%s - Evolution"), view_title);
+ gtk_window_set_title (GTK_WINDOW (shell_window), window_title);
+ g_free (window_title);
+}
+
+void
+e_shell_window_update_new_menu (EShellWindow *shell_window)
+{
+ GtkWidget *menu;
+ GtkWidget *widget;
+ const gchar *path;
+
+ g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
+
+ /* Update the "File -> New" submenu. */
+ path = "/main-menu/file-menu/new-menu";
+ menu = e_shell_window_create_new_menu (shell_window);
+ widget = e_shell_window_get_managed_widget (shell_window, path);
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (widget), menu);
+ gtk_widget_show (widget);
+
+ /* Update the "New" menu tool button submenu. */
+ menu = e_shell_window_create_new_menu (shell_window);
+ widget = shell_window->priv->menu_tool_button;
+ gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (widget), menu);
+}
diff --git a/shell/e-shell-window-private.h b/shell/e-shell-window-private.h
new file mode 100644
index 0000000000..1f0bec799b
--- /dev/null
+++ b/shell/e-shell-window-private.h
@@ -0,0 +1,128 @@
+/*
+ * e-shell-window-private.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef E_SHELL_WINDOW_PRIVATE_H
+#define E_SHELL_WINDOW_PRIVATE_H
+
+#include "e-shell-window.h"
+
+#include <string.h>
+#include <glib/gi18n.h>
+
+#include <e-util/e-util.h>
+#include <e-util/e-binding.h>
+#include <e-util/gconf-bridge.h>
+#include <widgets/misc/e-menu-tool-button.h>
+#include <widgets/misc/e-online-button.h>
+#include <widgets/misc/e-search-bar.h>
+
+#include <e-shell.h>
+#include <e-shell-content.h>
+#include <e-shell-view.h>
+#include <e-shell-switcher.h>
+#include <e-shell-window-actions.h>
+
+#define E_SHELL_WINDOW_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SHELL_WINDOW, EShellWindowPrivate))
+
+/* Shorthand, requires a variable named "shell_window". */
+#define ACTION(name) \
+ (E_SHELL_WINDOW_ACTION_##name (shell_window))
+#define ACTION_GROUP(name) \
+ (E_SHELL_WINDOW_ACTION_GROUP_##name (shell_window))
+
+/* For use in dispose() methods. */
+#define DISPOSE(obj) \
+ G_STMT_START { \
+ if ((obj) != NULL) { g_object_unref (obj); (obj) = NULL; } \
+ } G_STMT_END
+
+/* Format for switcher action names.
+ * The last part is the shell view name.
+ * (e.g. switch-to-mail, switch-to-calendar) */
+#define SWITCHER_FORMAT "switch-to-%s"
+
+G_BEGIN_DECLS
+
+struct _EShellWindowPrivate {
+
+ gpointer shell; /* weak pointer */
+
+ /*** UI Management ***/
+
+ GtkUIManager *ui_manager;
+ guint custom_rule_merge_id;
+ guint gal_view_merge_id;
+
+ /*** Shell Views ***/
+
+ GHashTable *loaded_views;
+ const gchar *active_view;
+
+ /*** Widgetry ***/
+
+ GtkWidget *main_menu;
+ GtkWidget *main_toolbar;
+ GtkWidget *menu_tool_button;
+ GtkWidget *content_pane;
+ GtkWidget *content_notebook;
+ GtkWidget *sidebar_notebook;
+ GtkWidget *switcher;
+ GtkWidget *status_area;
+ GtkWidget *online_button;
+ GtkWidget *tooltip_label;
+ GtkWidget *status_notebook;
+
+ /* Miscellaneous */
+
+ /* Shell signal handlers. */
+ GArray *signal_handler_ids;
+
+ guint destroyed : 1; /* XXX Do we still need this? */
+ guint safe_mode : 1;
+};
+
+void e_shell_window_private_init (EShellWindow *shell_window);
+void e_shell_window_private_constructed
+ (EShellWindow *shell_window);
+void e_shell_window_private_dispose (EShellWindow *shell_window);
+void e_shell_window_private_finalize (EShellWindow *shell_window);
+
+/* Private Utilities */
+
+void e_shell_window_actions_init (EShellWindow *shell_window);
+void e_shell_window_switch_to_view (EShellWindow *shell_window,
+ const gchar *view_name);
+GtkWidget * e_shell_window_create_new_menu (EShellWindow *shell_window);
+void e_shell_window_create_switcher_actions
+ (EShellWindow *shell_window);
+void e_shell_window_update_gal_view (EShellWindow *shell_window);
+void e_shell_window_update_icon (EShellWindow *shell_window);
+void e_shell_window_update_title (EShellWindow *shell_window);
+void e_shell_window_update_new_menu (EShellWindow *shell_window);
+void e_shell_window_update_view_menu (EShellWindow *shell_window);
+void e_shell_window_update_search_menu
+ (EShellWindow *shell_window);
+
+G_END_DECLS
+
+#endif /* E_SHELL_WINDOW_PRIVATE_H */
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index 9d6905203b..c054d6a8a0 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -1,4 +1,6 @@
/*
+ * e-shell-window.c
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -13,1260 +15,893 @@
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-shell-window.h"
-#include "e-shell-view.h"
-
-#include "Evolution.h"
-
-#include "e-util/e-util-private.h"
-#include "widgets/misc/e-online-button.h"
-
-#include "e-component-registry.h"
-#include "e-shell-window-commands.h"
-#include "e-sidebar.h"
-#include "es-menu.h"
-#include "es-event.h"
-
-#include <gtk/gtk.h>
-
-#include <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-ui-util.h>
-#include <bonobo/bonobo-widget.h>
-
-#include <glib/gi18n.h>
+#include "e-shell-window-private.h"
#include <gconf/gconf-client.h>
-#include <string.h>
+#include <es-event.h>
-#if NM_SUPPORT
-gboolean e_shell_dbus_initialise (EShell *shell);
-#endif
+#include <e-util/e-plugin-ui.h>
+#include <e-util/e-util-private.h>
-/* A view for each component. These are all created when EShellWindow is
- instantiated, but with the widget pointers to NULL and the page number set
- to -1. When the views are created the first time, the widget pointers as
- well as the notebook page value get set. */
-struct _ComponentView {
- int button_id;
- char *component_id;
- char *component_alias;
-
- GNOME_Evolution_ComponentView component_view;
- char *title;
-
- GtkWidget *sidebar_widget;
- GtkWidget *view_widget;
- GtkWidget *statusbar_widget;
-
- int notebook_page_num;
+enum {
+ PROP_0,
+ PROP_ACTIVE_VIEW,
+ PROP_SAFE_MODE,
+ PROP_SHELL,
+ PROP_UI_MANAGER
};
-typedef struct _ComponentView ComponentView;
-
-
-struct _EShellWindowPrivate {
- union {
- EShell *eshell;
- gpointer pointer;
- } shell;
-
- EShellView *shell_view; /* CORBA wrapper for this, just a placeholder */
-
- /* plugin menu manager */
- ESMenu *menu;
- /* All the ComponentViews. */
- GSList *component_views;
+static gpointer parent_class;
- /* The paned widget for the sidebar and component views */
- GtkWidget *paned;
-
- /* The sidebar. */
- GtkWidget *sidebar;
-
- /* Notebooks used to switch between components. */
- GtkWidget *sidebar_notebook;
- GtkWidget *view_notebook;
- GtkWidget *statusbar_notebook;
-
- /* Bonobo foo. */
- BonoboUIComponent *ui_component;
-
- /* The current view (can be NULL initially). */
- ComponentView *current_view;
-
- /* The status bar widgetry. */
- GtkWidget *status_bar;
- GtkWidget *offline_toggle;
- GtkWidget *menu_hint_label;
-
- /* The timeout for saving the window size */
- guint store_window_size_timer;
- gboolean destroyed;
-};
+static EShellView *
+shell_window_new_view (EShellWindow *shell_window,
+ GType shell_view_type,
+ const gchar *view_name,
+ const gchar *title)
+{
+ GHashTable *loaded_views;
+ EShell *shell;
+ EShellModule *shell_module;
+ EShellView *shell_view;
+ GtkNotebook *notebook;
+ GtkAction *action;
+ GtkWidget *widget;
+ gint page_num;
+ /* First off, start the shell module. */
+ shell = e_shell_window_get_shell (shell_window);
+ shell_module = e_shell_get_module_by_name (shell, view_name);
+ e_shell_module_start (shell_module);
-enum {
- COMPONENT_CHANGED,
- LAST_SIGNAL
-};
+ /* Determine the page number for the new shell view. */
+ notebook = GTK_NOTEBOOK (shell_window->priv->content_notebook);
+ page_num = gtk_notebook_get_n_pages (notebook);
-static guint signals[LAST_SIGNAL] = { 0 };
+ /* Get the switcher action for this view. */
+ action = e_shell_window_get_shell_view_action (
+ shell_window, view_name);
-G_DEFINE_TYPE (EShellWindow, e_shell_window, BONOBO_TYPE_WINDOW)
+ /* Create the shell view. */
+ shell_view = g_object_new (
+ shell_view_type, "action", action, "page-num",
+ page_num, "shell-window", shell_window, NULL);
-static gboolean store_window_size (GtkWidget* widget);
+ /* Register the shell view. */
+ loaded_views = shell_window->priv->loaded_views;
+ g_hash_table_insert (loaded_views, g_strdup (view_name), shell_view);
-/* ComponentView handling. */
+ /* Add pages to the various shell window notebooks. */
-static ComponentView *
-component_view_new (const char *id, const char *alias, int button_id)
-{
- ComponentView *view = g_new0 (ComponentView, 1);
+ /* We can't determine the shell view's page number until after the
+ * shell view is fully initialized because the shell view may load
+ * other shell views during initialization, and those other shell
+ * views will append their widgets to the notebooks before us. */
+ page_num = gtk_notebook_get_n_pages (notebook);
+ e_shell_view_set_page_num (shell_view, page_num);
- view->component_id = g_strdup (id);
- view->component_alias = g_strdup (alias);
- view->button_id = button_id;
- view->notebook_page_num = -1;
+ notebook = GTK_NOTEBOOK (shell_window->priv->content_notebook);
+ widget = GTK_WIDGET (e_shell_view_get_shell_content (shell_view));
+ gtk_notebook_append_page (notebook, widget, NULL);
- return view;
-}
+ notebook = GTK_NOTEBOOK (shell_window->priv->sidebar_notebook);
+ widget = GTK_WIDGET (e_shell_view_get_shell_sidebar (shell_view));
+ gtk_notebook_append_page (notebook, widget, NULL);
-static void
-component_view_free (ComponentView *view)
-{
- if (view->component_view) {
- CORBA_Environment ev = { NULL };
+ notebook = GTK_NOTEBOOK (shell_window->priv->status_notebook);
+ widget = GTK_WIDGET (e_shell_view_get_shell_taskbar (shell_view));
+ gtk_notebook_append_page (notebook, widget, NULL);
- CORBA_Object_release(view->component_view, &ev);
- CORBA_exception_free(&ev);
- }
+ /* Listen for changes that affect the shell window. */
- g_free (view->component_id);
- g_free (view->component_alias);
- g_free (view->title);
- g_free (view);
-}
-
-static void
-component_view_deactivate (ComponentView *view)
-{
- BonoboControlFrame *view_control_frame;
- BonoboControlFrame *sidebar_control_frame;
+ g_signal_connect_swapped (
+ action, "notify::icon-name",
+ G_CALLBACK (e_shell_window_update_icon), shell_window);
- g_return_if_fail (view->sidebar_widget != NULL);
- g_return_if_fail (view->view_widget != NULL);
+ g_signal_connect_swapped (
+ shell_view, "notify::title",
+ G_CALLBACK (e_shell_window_update_title), shell_window);
- view_control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (view->view_widget));
- bonobo_control_frame_control_deactivate (view_control_frame);
+ g_signal_connect_swapped (
+ shell_view, "notify::view-id",
+ G_CALLBACK (e_shell_window_update_view_menu), shell_window);
- sidebar_control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (view->sidebar_widget));
- bonobo_control_frame_control_deactivate (sidebar_control_frame);
+ return shell_view;
}
static void
-component_view_activate (ComponentView *view)
+shell_window_update_close_action_cb (EShellWindow *shell_window)
{
- BonoboControlFrame *view_control_frame;
- BonoboControlFrame *sidebar_control_frame;
+ EShell *shell;
+ GList *watched_windows;
+ gint n_shell_windows = 0;
- g_return_if_fail (view->sidebar_widget != NULL);
- g_return_if_fail (view->view_widget != NULL);
+ shell = e_shell_window_get_shell (shell_window);
+ watched_windows = e_shell_get_watched_windows (shell);
- view_control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (view->view_widget));
- bonobo_control_frame_control_activate (view_control_frame);
+ /* Count the shell windows. */
+ while (watched_windows != NULL) {
+ if (E_IS_SHELL_WINDOW (watched_windows->data))
+ n_shell_windows++;
+ watched_windows = g_list_next (watched_windows);
+ }
- sidebar_control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (view->sidebar_widget));
- bonobo_control_frame_control_activate (sidebar_control_frame);
+ /* Disable Close Window if there's only one shell window.
+ * Helps prevent users from accidentally quitting. */
+ gtk_action_set_sensitive (ACTION (CLOSE), n_shell_windows > 1);
}
static void
-init_view (EShellWindow *window,
- ComponentView *view)
+shell_window_set_shell (EShellWindow *shell_window,
+ EShell *shell)
{
- EShellWindowPrivate *priv = window->priv;
- EComponentRegistry *registry = e_shell_peek_component_registry (window->priv->shell.eshell);
- GNOME_Evolution_Component component_iface;
- GNOME_Evolution_ComponentView component_view;
- Bonobo_UIContainer container;
- Bonobo_Control sidebar_control;
- Bonobo_Control view_control;
- Bonobo_Control statusbar_control;
- CORBA_boolean select_item;
- CORBA_Environment ev;
- int sidebar_notebook_page_num;
- int view_notebook_page_num;
-
- g_return_if_fail (view->view_widget == NULL);
- g_return_if_fail (view->sidebar_widget == NULL);
- g_return_if_fail (view->notebook_page_num == -1);
-
- select_item = !e_shell_get_crash_recovery (priv->shell.eshell);
- e_shell_set_crash_recovery (priv->shell.eshell, FALSE);
-
- CORBA_exception_init (&ev);
-
- /* 1. Activate component. (FIXME: Shouldn't do this here.) */
-
- component_iface = e_component_registry_activate (registry, view->component_id, &ev);
- if (BONOBO_EX (&ev) || component_iface == CORBA_OBJECT_NIL) {
- char *ex_text = bonobo_exception_get_text (&ev);
- g_warning ("Cannot activate component %s: %s", view->component_id, ex_text);
- g_free (ex_text);
- CORBA_exception_free (&ev);
- return;
- }
-
- /* 2. Set up view. */
-
- /* The rest of the code assumes that the component is valid and can create
- controls; if this fails something is really wrong in the component
- (e.g. methods not implemented)... So handle it as if there was no
- component at all. */
-
- component_view = GNOME_Evolution_Component_createView(component_iface, BONOBO_OBJREF(priv->shell_view), select_item, &ev);
- if (component_view == NULL || BONOBO_EX (&ev)) {
- g_warning ("Cannot create view for %s", view->component_id);
- bonobo_object_release_unref (component_iface, NULL);
- CORBA_exception_free (&ev);
- return;
- }
-
- GNOME_Evolution_ComponentView_getControls(component_view, &sidebar_control, &view_control, &statusbar_control, &ev);
- if (BONOBO_EX (&ev)) {
- g_warning ("Cannot create view for %s", view->component_id);
- bonobo_object_release_unref (component_iface, NULL);
- CORBA_exception_free (&ev);
- return;
- }
-
- view->component_view = component_view;
+ GArray *array;
+ gulong handler_id;
- CORBA_exception_free (&ev);
+ g_return_if_fail (shell_window->priv->shell == NULL);
- container = bonobo_ui_component_get_container (priv->ui_component);
+ shell_window->priv->shell = shell;
- view->sidebar_widget = bonobo_widget_new_control_from_objref (sidebar_control, container);
- gtk_widget_show (view->sidebar_widget);
- bonobo_object_release_unref (sidebar_control, NULL);
+ g_object_add_weak_pointer (
+ G_OBJECT (shell_window),
+ &shell_window->priv->shell);
- view->view_widget = bonobo_widget_new_control_from_objref (view_control, container);
- gtk_widget_show (view->view_widget);
- bonobo_object_release_unref (view_control, NULL);
+ /* Need to disconnect these when the window is closing. */
- view->statusbar_widget = bonobo_widget_new_control_from_objref (statusbar_control, container);
- gtk_widget_show (view->statusbar_widget);
- bonobo_object_release_unref (statusbar_control, NULL);
+ array = shell_window->priv->signal_handler_ids;
- gtk_notebook_append_page (GTK_NOTEBOOK (priv->sidebar_notebook), view->sidebar_widget, NULL);
- gtk_notebook_append_page (GTK_NOTEBOOK (priv->view_notebook), view->view_widget, NULL);
- gtk_notebook_append_page (GTK_NOTEBOOK (priv->statusbar_notebook), view->statusbar_widget, NULL);
+ handler_id = g_signal_connect_swapped (
+ shell, "window-created",
+ G_CALLBACK (shell_window_update_close_action_cb),
+ shell_window);
- sidebar_notebook_page_num = gtk_notebook_page_num (GTK_NOTEBOOK (priv->sidebar_notebook), view->sidebar_widget);
- view_notebook_page_num = gtk_notebook_page_num (GTK_NOTEBOOK (priv->view_notebook), view->view_widget);
+ g_array_append_val (array, handler_id);
- /* Since we always add a view page and a sidebar page at the same time... */
- g_return_if_fail (sidebar_notebook_page_num == view_notebook_page_num);
+ handler_id = g_signal_connect_swapped (
+ shell, "window-destroyed",
+ G_CALLBACK (shell_window_update_close_action_cb),
+ shell_window);
- view->notebook_page_num = view_notebook_page_num;
+ g_array_append_val (array, handler_id);
- /* 3. Switch to the new page. */
-
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->view_notebook), view_notebook_page_num);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->sidebar_notebook), view_notebook_page_num);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->statusbar_notebook), view_notebook_page_num);
-
- if (priv->current_view != NULL)
- component_view_deactivate (priv->current_view);
- priv->current_view = view;
- component_view_activate (view);
-
- bonobo_object_release_unref (component_iface, NULL);
+ g_object_notify (G_OBJECT (shell), "online");
}
static void
-switch_view (EShellWindow *window, ComponentView *component_view)
+shell_window_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EShellWindowPrivate *priv = window->priv;
- GConfClient *gconf_client = gconf_client_get_default ();
- EComponentRegistry *registry = e_shell_peek_component_registry (window->priv->shell.eshell);
- EComponentInfo *info = e_component_registry_peek_info (registry,
- ECR_FIELD_ID,
- component_view->component_id);
- char *title;
-
- if (component_view->sidebar_widget == NULL) {
- init_view (window, component_view);
- } else {
- if (priv->current_view != NULL)
- component_view_deactivate (priv->current_view);
- priv->current_view = component_view;
- component_view_activate (component_view);
-
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->view_notebook), component_view->notebook_page_num);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->sidebar_notebook), component_view->notebook_page_num);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->statusbar_notebook), component_view->notebook_page_num);
- }
-
- if (component_view->title == NULL) {
- /* To translators: This is the window title and %s is the
- component name. Most translators will want to keep it as is. */
- title = g_strdup_printf (_("%s - Evolution"), info->button_label);
- gtk_window_set_title (GTK_WINDOW (window), title);
- g_free (title);
- } else
- gtk_window_set_title (GTK_WINDOW (window), component_view->title);
-
- if (info->icon_name)
- gtk_window_set_icon_name (GTK_WINDOW (window), info->icon_name);
-
- gconf_client_set_string (gconf_client, "/apps/evolution/shell/view_defaults/component_id",
- (component_view->component_alias != NULL
- ? component_view->component_alias
- : component_view->component_id),
- NULL);
-
- g_object_unref (gconf_client);
-
- /** @Event: Shell component activated or switched to.
- * @Id: component.activated
- * @Target: ESEventTargetComponent
- *
- * This event is emitted whenever the shell successfully activates component
- * view.
- */
- e_event_emit ((EEvent *) es_event_peek (), "component.activated", (EEventTarget *) es_event_target_new_component (es_event_peek (), component_view->component_id));
-
- g_signal_emit (window, signals[COMPONENT_CHANGED], 0);
-}
+ switch (property_id) {
+ case PROP_ACTIVE_VIEW:
+ e_shell_window_set_active_view (
+ E_SHELL_WINDOW (object),
+ g_value_get_string (value));
+ return;
+ case PROP_SAFE_MODE:
+ e_shell_window_set_safe_mode (
+ E_SHELL_WINDOW (object),
+ g_value_get_boolean (value));
+ return;
-/* Functions to update the sensitivity of buttons and menu items depending on the status. */
-
-static void
-update_offline_toggle_status (EShellWindow *window)
-{
- EShellWindowPrivate *priv;
- GtkWidget *widget;
- const gchar *tooltip;
- gboolean online;
- gboolean sensitive;
- guint32 flags = 0;
- ESMenuTargetShell *t;
-
- priv = window->priv;
-
- switch (e_shell_get_line_status (priv->shell.eshell)) {
- case E_SHELL_LINE_STATUS_ONLINE:
- online = TRUE;
- sensitive = TRUE;
- tooltip = _("Evolution is currently online.\n"
- "Click on this button to work offline.");
- flags = ES_MENU_SHELL_ONLINE;
- break;
- case E_SHELL_LINE_STATUS_GOING_OFFLINE:
- online = TRUE;
- sensitive = FALSE;
- tooltip = _("Evolution is in the process of going offline.");
- flags = ES_MENU_SHELL_OFFLINE;
- break;
- case E_SHELL_LINE_STATUS_OFFLINE:
- case E_SHELL_LINE_STATUS_FORCED_OFFLINE:
- online = FALSE;
- sensitive = TRUE;
- tooltip = _("Evolution is currently offline.\n"
- "Click on this button to work online.");
- flags = ES_MENU_SHELL_OFFLINE;
- break;
- default:
- g_return_if_reached ();
+ case PROP_SHELL:
+ shell_window_set_shell (
+ E_SHELL_WINDOW (object),
+ g_value_get_object (value));
+ return;
}
- widget = window->priv->offline_toggle;
- gtk_widget_set_sensitive (widget, sensitive);
- gtk_widget_set_tooltip_text (widget, tooltip);
- e_online_button_set_online (E_ONLINE_BUTTON (widget), online);
-
- /* TODO: If we get more shell flags, this should be centralised */
- t = es_menu_target_new_shell(priv->menu, flags);
- t->target.widget = (GtkWidget *)window;
- e_menu_update_target((EMenu *)priv->menu, t);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
-update_send_receive_sensitivity (EShellWindow *window)
+shell_window_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- if (e_shell_get_line_status (window->priv->shell.eshell) == E_SHELL_LINE_STATUS_OFFLINE ||
- e_shell_get_line_status (window->priv->shell.eshell) == E_SHELL_LINE_STATUS_FORCED_OFFLINE)
- bonobo_ui_component_set_prop (window->priv->ui_component,
- "/commands/SendReceive",
- "sensitive", "0", NULL);
- else
- bonobo_ui_component_set_prop (window->priv->ui_component,
- "/commands/SendReceive",
- "sensitive", "1", NULL);
-}
+ switch (property_id) {
+ case PROP_ACTIVE_VIEW:
+ g_value_set_string (
+ value, e_shell_window_get_active_view (
+ E_SHELL_WINDOW (object)));
+ return;
+ case PROP_SAFE_MODE:
+ g_value_set_boolean (
+ value, e_shell_window_get_safe_mode (
+ E_SHELL_WINDOW (object)));
+ return;
-/* Callbacks. */
+ case PROP_SHELL:
+ g_value_set_object (
+ value, e_shell_window_get_shell (
+ E_SHELL_WINDOW (object)));
+ return;
-static ComponentView *
-get_component_view (EShellWindow *window, int id)
-{
- GSList *p;
-
- for (p = window->priv->component_views; p; p = p->next) {
- if (((ComponentView *) p->data)->button_id == id)
- return p->data;
+ case PROP_UI_MANAGER:
+ g_value_set_object (
+ value, e_shell_window_get_ui_manager (
+ E_SHELL_WINDOW (object)));
+ return;
}
- g_warning ("Unknown component button id %d", id);
- return NULL;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
-sidebar_button_selected_callback (ESidebar *sidebar,
- int button_id,
- EShellWindow *window)
+shell_window_dispose (GObject *object)
{
- ComponentView *component_view;
+ e_shell_window_private_dispose (E_SHELL_WINDOW (object));
- if ((component_view = get_component_view (window, button_id)))
- switch_view (window, component_view);
-}
-
-static gboolean
-sidebar_button_pressed_callback (ESidebar *sidebar,
- GdkEventButton *event,
- int button_id,
- EShellWindow *window)
-{
- if (event->type == GDK_BUTTON_PRESS &&
- event->button == 2) {
- /* open it in a new window */
- ComponentView *component_view;
-
- if ((component_view = get_component_view (window, button_id))) {
- e_shell_create_window (window->priv->shell.eshell,
- component_view->component_id,
- window);
- }
- return TRUE;
- }
- return FALSE;
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-offline_toggle_clicked_cb (EShellWindow *window)
+shell_window_finalize (GObject *object)
{
- EShell *shell;
- GNOME_Evolution_ShellState shell_state;
-
- shell = window->priv->shell.eshell;
-
- switch (e_shell_get_line_status (shell)) {
- case E_SHELL_LINE_STATUS_ONLINE:
- shell_state = GNOME_Evolution_USER_OFFLINE;
- break;
- case E_SHELL_LINE_STATUS_OFFLINE:
- case E_SHELL_LINE_STATUS_FORCED_OFFLINE:
- shell_state = GNOME_Evolution_USER_ONLINE;
- break;
- default:
- g_return_if_reached();
- }
+ e_shell_window_private_finalize (E_SHELL_WINDOW (object));
- e_shell_set_line_status (shell, shell_state);
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-shell_line_status_changed_callback (EShell *shell,
- EShellLineStatus new_status,
- EShellWindow *window)
+shell_window_constructed (GObject *object)
{
- update_offline_toggle_status (window);
- update_send_receive_sensitivity (window);
+ e_shell_window_private_constructed (E_SHELL_WINDOW (object));
}
static void
-ui_engine_add_hint_callback (BonoboUIEngine *engine,
- const char *hint,
- EShellWindow *window)
+shell_window_class_init (EShellWindowClass *class)
{
- gtk_label_set_text (GTK_LABEL (window->priv->menu_hint_label), hint);
- gtk_widget_show (window->priv->menu_hint_label);
- gtk_widget_hide (window->priv->statusbar_notebook);
-}
+ GObjectClass *object_class;
-static void
-ui_engine_remove_hint_callback (BonoboUIEngine *engine,
- EShellWindow *window)
-{
- gtk_widget_hide (window->priv->menu_hint_label);
- gtk_widget_show (window->priv->statusbar_notebook);
-}
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EShellWindowPrivate));
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = shell_window_set_property;
+ object_class->get_property = shell_window_get_property;
+ object_class->dispose = shell_window_dispose;
+ object_class->finalize = shell_window_finalize;
+ object_class->constructed = shell_window_constructed;
-/* Widgetry. */
+ /**
+ * EShellWindow:active-view
+ *
+ * Name of the active #EShellView.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_ACTIVE_VIEW,
+ g_param_spec_string (
+ "active-view",
+ _("Active Shell View"),
+ _("Name of the active shell view"),
+ NULL,
+ G_PARAM_READWRITE));
+
+ /**
+ * EShellWindow:safe-mode
+ *
+ * Whether the shell window is in safe mode.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_SAFE_MODE,
+ g_param_spec_boolean (
+ "safe-mode",
+ _("Safe Mode"),
+ _("Whether the shell window is in safe mode"),
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ /**
+ * EShellWindow:shell
+ *
+ * The #EShell singleton.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL,
+ g_param_spec_object (
+ "shell",
+ _("Shell"),
+ _("The EShell singleton"),
+ E_TYPE_SHELL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ /**
+ * EShellWindow:ui-manager
+ *
+ * The shell window's #GtkUIManager.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_UI_MANAGER,
+ g_param_spec_object (
+ "ui-manager",
+ _("UI Manager"),
+ _("The shell window's GtkUIManager"),
+ GTK_TYPE_UI_MANAGER,
+ G_PARAM_READABLE));
+}
static void
-setup_offline_toggle (EShellWindow *window)
+shell_window_init (EShellWindow *shell_window)
{
- GtkWidget *widget;
+ GtkUIManager *ui_manager;
+ const gchar *id;
- g_return_if_fail (window->priv->status_bar != NULL);
+ shell_window->priv = E_SHELL_WINDOW_GET_PRIVATE (shell_window);
- widget = e_online_button_new ();
- g_signal_connect_swapped (
- widget, "clicked",
- G_CALLBACK (offline_toggle_clicked_cb), window);
- gtk_box_pack_start (
- GTK_BOX (window->priv->status_bar),
- widget, FALSE, TRUE, 0);
- window->priv->offline_toggle = widget;
- gtk_widget_show (widget);
-
- update_offline_toggle_status (window);
-}
+ gtk_window_set_title (GTK_WINDOW (shell_window), _("Evolution"));
-static void
-setup_menu_hint_label (EShellWindow *window)
-{
- EShellWindowPrivate *priv;
+ e_shell_window_private_init (shell_window);
- priv = window->priv;
+ ui_manager = e_shell_window_get_ui_manager (shell_window);
- priv->menu_hint_label = gtk_label_new ("");
- gtk_misc_set_alignment (GTK_MISC (priv->menu_hint_label), 0.0, 0.5);
-
- gtk_box_pack_start (GTK_BOX (priv->status_bar), priv->menu_hint_label, TRUE, TRUE, 0);
+ id = "org.gnome.evolution.shell";
+ e_plugin_ui_register_manager (ui_manager, id, shell_window);
+ e_plugin_ui_enable_manager (ui_manager, id);
}
-static void
-setup_statusbar_notebook (EShellWindow *window)
+GType
+e_shell_window_get_type (void)
{
- EShellWindowPrivate *priv;
+ static GType type = 0;
- priv = window->priv;
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo type_info = {
+ sizeof (EShellWindowClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) shell_window_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EShellWindow),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) shell_window_init,
+ NULL /* value_table */
+ };
- priv->statusbar_notebook = gtk_notebook_new ();
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->statusbar_notebook), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->statusbar_notebook), FALSE);
-
- gtk_box_pack_start (GTK_BOX (priv->status_bar), priv->statusbar_notebook, TRUE, TRUE, 0);
- gtk_widget_show (priv->statusbar_notebook);
-}
+ type = g_type_register_static (
+ GTK_TYPE_WINDOW, "EShellWindow", &type_info, 0);
+ }
-static void
-setup_nm_support (EShellWindow *window)
-{
-#if NM_SUPPORT
- e_shell_dbus_initialise (window->priv->shell.eshell);
-#endif
+ return type;
}
-static void
-setup_status_bar (EShellWindow *window)
+/**
+ * e_shell_window_new:
+ * @shell: an #EShell
+ * @safe_mode: whether to initialize the window to "safe mode"
+ *
+ * Returns a new #EShellWindow.
+ *
+ * It's up to the various #EShellView<!-- -->'s to define exactly
+ * what "safe mode" means, but the #EShell usually puts the initial
+ * #EShellWindow into "safe mode" if detects the previous Evolution
+ * session crashed.
+ *
+ * The initial view for the window is determined by GConf key
+ * <filename>/apps/evolution/shell/view_defaults/component_id</filename>.
+ * Or, if the GConf key is not set or can't be read, the first view
+ * in the switcher is used.
+ *
+ * Returns: a new #EShellWindow
+ **/
+GtkWidget *
+e_shell_window_new (EShell *shell,
+ gboolean safe_mode)
{
- EShellWindowPrivate *priv;
- BonoboUIEngine *ui_engine;
- GConfClient *gconf_client;
- gint height;
-
- priv = window->priv;
-
- priv->status_bar = gtk_hbox_new (FALSE, 2);
-
- /* Make the status bar as large as the task bar. */
- gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, NULL, &height);
- gtk_widget_set_size_request (GTK_WIDGET (priv->status_bar), -1, height * 2);
-
- gconf_client = gconf_client_get_default ();
- if(gconf_client_get_bool (gconf_client,"/apps/evolution/shell/view_defaults/statusbar_visible",NULL))
- gtk_widget_show (priv->status_bar);
- g_object_unref (gconf_client);
-
- /* setup dbus interface here*/
- setup_nm_support (window);
-
- setup_offline_toggle (window);
- setup_menu_hint_label (window);
- setup_statusbar_notebook (window);
-
- ui_engine = bonobo_window_get_ui_engine (BONOBO_WINDOW (window));
-
- g_signal_connect (ui_engine, "add_hint", G_CALLBACK (ui_engine_add_hint_callback), window);
- g_signal_connect (ui_engine, "remove_hint", G_CALLBACK (ui_engine_remove_hint_callback), window);
+ return g_object_new (
+ E_TYPE_SHELL_WINDOW,
+ "shell", shell, "safe-mode", safe_mode, NULL);
}
-static void
-menu_component_selected (BonoboUIComponent *uic,
- EShellWindow *window,
- const char *path)
+/**
+ * e_shell_window_get_shell:
+ * @shell_window: an #EShellWindow
+ *
+ * Returns the #EShell that was passed to e_shell_window_new().
+ *
+ * Returns: the #EShell
+ **/
+EShell *
+e_shell_window_get_shell (EShellWindow *shell_window)
{
- char *component_id;
+ g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL);
- component_id = strchr(path, '-');
- if (component_id)
- e_shell_window_switch_to_component (window, component_id+1);
+ return E_SHELL (shell_window->priv->shell);
}
-static GConfEnumStringPair button_styles[] = {
- { E_SIDEBAR_MODE_TEXT, "text" },
- { E_SIDEBAR_MODE_ICON, "icons" },
- { E_SIDEBAR_MODE_BOTH, "both" },
- { E_SIDEBAR_MODE_TOOLBAR, "toolbar" },
- { -1, NULL }
-};
-
-static void
-setup_widgets (EShellWindow *window)
+/**
+ * e_shell_window_get_shell_view:
+ * @shell_window: an #EShellWindow
+ * @view_name: name of a shell view
+ *
+ * Returns the #EShellView named @view_name (see the
+ * <structfield>name</structfield> field in #EShellModuleInfo). This
+ * will also instantiate the #EShellView the first time it's requested.
+ * To reduce resource consumption, Evolution tries to delay instantiating
+ * shell views until the user switches to them. So in general, only the
+ * active view name, as returned by e_shell_window_get_active_view(),
+ * should be requested.
+ *
+ * Returns: the requested #EShellView, or %NULL if no such view is
+ * registered
+ **/
+EShellView *
+e_shell_window_get_shell_view (EShellWindow *shell_window,
+ const gchar *view_name)
{
- EShellWindowPrivate *priv = window->priv;
- EComponentRegistry *registry = e_shell_peek_component_registry (priv->shell.eshell);
- GConfClient *gconf_client = gconf_client_get_default ();
- GtkWidget *contents_vbox;
- GSList *p;
- GString *xml;
- int button_id;
- gboolean visible;
- char *style;
- int mode;
-
- priv->paned = gtk_hpaned_new ();
- gtk_widget_show (priv->paned);
-
- priv->sidebar = e_sidebar_new ();
- g_signal_connect (priv->sidebar, "button_selected",
- G_CALLBACK (sidebar_button_selected_callback), window);
- g_signal_connect (priv->sidebar, "button_pressed",
- G_CALLBACK (sidebar_button_pressed_callback), window);
- gtk_paned_pack1 (GTK_PANED (priv->paned), priv->sidebar, FALSE, FALSE);
- gtk_widget_show (priv->sidebar);
-
- priv->sidebar_notebook = gtk_notebook_new ();
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->sidebar_notebook), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->sidebar_notebook), FALSE);
- e_sidebar_set_selection_widget (E_SIDEBAR (priv->sidebar), priv->sidebar_notebook);
- gtk_widget_show (priv->sidebar_notebook);
-
- priv->view_notebook = gtk_notebook_new ();
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->view_notebook), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->view_notebook), FALSE);
- gtk_paned_pack2 (GTK_PANED (priv->paned), priv->view_notebook, TRUE, FALSE);
- gtk_widget_show (priv->view_notebook);
-
- gtk_paned_set_position (GTK_PANED (priv->paned),
- gconf_client_get_int (gconf_client, "/apps/evolution/shell/view_defaults/folder_bar/width", NULL));
-
- /* The buttons */
- visible = gconf_client_get_bool (gconf_client,
- "/apps/evolution/shell/view_defaults/buttons_visible",
- NULL);
- bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
- "/commands/ViewButtonsHide",
- "state",
- visible ? "0" : "1",
- NULL);
-
- e_sidebar_set_show_buttons (E_SIDEBAR (priv->sidebar), visible);
-
- style = gconf_client_get_string (gconf_client,
- "/apps/evolution/shell/view_defaults/buttons_style",
- NULL);
-
- if (gconf_string_to_enum (button_styles, style, &mode)) {
- switch (mode) {
- case E_SIDEBAR_MODE_TEXT:
- bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
- "/commands/ViewButtonsText",
- "state", "1", NULL);
- break;
- case E_SIDEBAR_MODE_ICON:
- bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
- "/commands/ViewButtonsIcon",
- "state", "1", NULL);
- break;
- case E_SIDEBAR_MODE_BOTH:
- bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
- "/commands/ViewButtonsIconText",
- "state", "1", NULL);
- break;
-
- case E_SIDEBAR_MODE_TOOLBAR:
- bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
- "/commands/ViewButtonsToolbar",
- "state", "1", NULL);
- break;
- }
-
- e_sidebar_set_mode (E_SIDEBAR (priv->sidebar), mode);
- }
- g_free (style);
-
- /* Status Bar*/
- visible = gconf_client_get_bool (gconf_client,
- "/apps/evolution/shell/view_defaults/statusbar_visible",
- NULL);
- bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
- "/commands/ViewStatusBar",
- "state",
- visible ? "1" : "0",
- NULL);
-
- /* Side Bar*/
- visible = gconf_client_get_bool (gconf_client,
- "/apps/evolution/shell/view_defaults/sidebar_visible",
- NULL);
- bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
- "/commands/ViewSideBar",
- "state",
- visible ? "1" : "0",
- NULL);
-
- /* The tool bar */
- visible = gconf_client_get_bool (gconf_client,
- "/apps/evolution/shell/view_defaults/toolbar_visible",
- NULL);
- bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
- "/commands/ViewToolbar",
- "state",
- visible ? "1" : "0",
- NULL);
- bonobo_ui_component_set_prop (e_shell_window_peek_bonobo_ui_component (window),
- "/Toolbar",
- "hidden",
- visible ? "0" : "1",
- NULL);
-
- button_id = 0;
- xml = g_string_new("");
- for (p = e_component_registry_peek_list (registry); p != NULL; p = p->next) {
- char *tmp, *tmp2;
- EComponentInfo *info = p->data;
- ComponentView *view = component_view_new (info->id, info->alias, button_id);
- GtkIconInfo *icon_info;
- gint width;
-
- window->priv->component_views = g_slist_prepend (window->priv->component_views, view);
-
- if (!info->button_label || !info->menu_label)
- continue;
- e_sidebar_add_button (E_SIDEBAR (priv->sidebar), info->button_label, info->button_tooltips, info->icon_name, button_id);
-
- g_string_printf(xml, "SwitchComponent-%s", info->alias);
- bonobo_ui_component_add_verb (e_shell_window_peek_bonobo_ui_component (window),
- xml->str,
- (BonoboUIVerbFn)menu_component_selected,
- window);
-
- g_string_printf(xml, "<submenu name=\"View\">"
- "<submenu name=\"Window\">"
- "<placeholder name=\"WindowComponent\">"
- "<menuitem name=\"SwitchComponent-%s\" "
- "verb=\"\" label=\"%s\" accel=\"%s\" tip=\"",
- info->alias,
- info->menu_label,
- info->menu_accelerator);
- tmp = g_strdup_printf (_("Switch to %s"), info->button_label);
- tmp2 = g_markup_escape_text (tmp, -1);
- g_string_append (xml, tmp2);
- g_free (tmp2);
- g_free (tmp);
-
- gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, NULL);
- icon_info = gtk_icon_theme_lookup_icon (
- gtk_icon_theme_get_default (),
- info->icon_name, width, 0);
- g_string_append_printf(xml, "\" pixtype=\"filename\" pixname=\"%s\"/>"
- "</placeholder></submenu></submenu>\n",
- icon_info ? gtk_icon_info_get_filename (icon_info) : "");
- gtk_icon_info_free (icon_info);
- bonobo_ui_component_set_translate (e_shell_window_peek_bonobo_ui_component (window),
- "/menu",
- xml->str,
- NULL);
- g_string_printf(xml, "<cmd name=\"SwitchComponent-%s\"/>\n", info->alias);
- bonobo_ui_component_set_translate (e_shell_window_peek_bonobo_ui_component (window),
- "/commands",
- xml->str,
- NULL);
- button_id ++;
- }
- g_string_free(xml, TRUE);
-
- setup_status_bar (window);
+ GHashTable *loaded_views;
+ EShellView *shell_view;
+ GType *children;
+ guint n_children, ii;
- contents_vbox = gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (contents_vbox), priv->paned, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (contents_vbox), priv->status_bar, FALSE, TRUE, 0);
- gtk_widget_show (contents_vbox);
+ g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL);
+ g_return_val_if_fail (view_name != NULL, NULL);
- /* We only display this when a menu item is actually selected. */
- gtk_widget_hide (priv->menu_hint_label);
+ loaded_views = shell_window->priv->loaded_views;
+ shell_view = g_hash_table_lookup (loaded_views, view_name);
- bonobo_window_set_contents (BONOBO_WINDOW (window), contents_vbox);
- g_object_unref (gconf_client);
-}
+ if (shell_view != NULL)
+ return shell_view;
+ children = g_type_children (E_TYPE_SHELL_VIEW, &n_children);
-/* GObject methods. */
+ for (ii = 0; ii < n_children && shell_view == NULL; ii++) {
+ GType shell_view_type = children[ii];
+ EShellViewClass *class;
-static void
-impl_dispose (GObject *object)
-{
- EShellWindow *self = E_SHELL_WINDOW (object);
- EShellWindowPrivate *priv = self->priv;
+ class = g_type_class_ref (shell_view_type);
- priv->destroyed = TRUE;
+ if (class->type_module == NULL) {
+ g_critical (
+ "Module member not set on %s",
+ G_OBJECT_CLASS_NAME (class));
+ continue;
+ }
- if (priv->shell.eshell != NULL) {
- g_object_remove_weak_pointer (G_OBJECT (priv->shell.eshell), &priv->shell.pointer);
- priv->shell.eshell = NULL;
- }
+ if (strcmp (view_name, class->type_module->name) == 0)
+ shell_view = shell_window_new_view (
+ shell_window, shell_view_type,
+ view_name, class->label);
- if (priv->ui_component != NULL) {
- bonobo_object_unref (BONOBO_OBJECT (priv->ui_component));
- priv->ui_component = NULL;
+ g_type_class_unref (class);
}
- if (priv->store_window_size_timer) {
- g_source_remove (priv->store_window_size_timer);
- self->priv->store_window_size_timer = 0;
+ if (shell_view == NULL)
+ g_critical ("Unknown shell view name: %s", view_name);
- /* There was a timer. Let us store the settings.*/
- store_window_size (GTK_WIDGET (self));
- }
-
- (* G_OBJECT_CLASS (e_shell_window_parent_class)->dispose) (object);
+ return shell_view;
}
-static void
-impl_finalize (GObject *object)
+/**
+ * e_shell_window_get_shell_view_action:
+ * @shell_window: an #EShellWindow
+ * @view_name: name of a shell view
+ *
+ * Returns the switcher action for @view_name.
+ *
+ * An #EShellWindow creates a #GtkRadioAction for each registered subclass
+ * of #EShellView. This action gets passed to the #EShellSwitcher, which
+ * displays a button that proxies the action. When the #EShellView named
+ * @view_name is active, the action's icon becomes the @shell_window icon.
+ *
+ * Returns: the switcher action for the #EShellView named @view_name,
+ * or %NULL if no such shell view exists
+ **/
+GtkAction *
+e_shell_window_get_shell_view_action (EShellWindow *shell_window,
+ const gchar *view_name)
{
- EShellWindowPrivate *priv = E_SHELL_WINDOW (object)->priv;
-
- g_slist_foreach (priv->component_views, (GFunc) component_view_free, NULL);
- g_slist_free (priv->component_views);
+ GtkAction *action;
+ gchar *action_name;
- g_object_unref(priv->menu);
+ g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL);
+ g_return_val_if_fail (view_name != NULL, NULL);
- g_free (priv);
-
- (* G_OBJECT_CLASS (e_shell_window_parent_class)->finalize) (object);
-}
+ action_name = g_strdup_printf (SWITCHER_FORMAT, view_name);
+ action = e_shell_window_get_action (shell_window, action_name);
+ g_free (action_name);
-/* GtkWidget methods */
-static void
-e_shell_window_remove_resize_timer (EShellWindow* self)
-{
- if (self->priv->store_window_size_timer) {
- g_source_remove (self->priv->store_window_size_timer);
- self->priv->store_window_size_timer = 0;
- }
+ return action;
}
-static gboolean
-impl_window_state (GtkWidget *widget, GdkEventWindowState* ev)
+/**
+ * e_shell_window_get_ui_manager:
+ * @shell_window: an #EShellWindow
+ *
+ * Returns @shell_window<!-- -->'s user interface manager, which
+ * manages the window's menus and toolbars via #GtkAction<!-- -->s.
+ * This is the mechanism by which shell views and plugins can extend
+ * Evolution's menus and toolbars.
+ *
+ * Returns: the #GtkUIManager for @shell_window
+ **/
+GtkUIManager *
+e_shell_window_get_ui_manager (EShellWindow *shell_window)
{
- gboolean retval = FALSE;
-
- /* store only if the window state really changed */
- if ((ev->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) != 0) {
- GConfClient* client = gconf_client_get_default ();
- gconf_client_set_bool (client, "/apps/evolution/shell/view_defaults/maximized",
- (ev->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0, NULL);
- g_object_unref(client);
- }
+ g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL);
- if ((ev->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0) {
- e_shell_window_remove_resize_timer (E_SHELL_WINDOW (widget));
- }
-
- if (GTK_WIDGET_CLASS (e_shell_window_parent_class)->window_state_event) {
- retval |= GTK_WIDGET_CLASS (e_shell_window_parent_class)->window_state_event (widget, ev);
- }
-
- return retval;
+ return shell_window->priv->ui_manager;
}
-static gboolean
-store_window_size (GtkWidget* widget)
+/**
+ * e_shell_window_get_action:
+ * @shell_window: an #EShellWindow
+ * @action_name: the name of an action
+ *
+ * Returns the #GtkAction named @action_name in @shell_window<!-- -->'s
+ * user interface manager, or %NULL if no such action exists.
+ *
+ * Returns: the #GtkAction named @action_name
+ **/
+GtkAction *
+e_shell_window_get_action (EShellWindow *shell_window,
+ const gchar *action_name)
{
- GConfClient* client = gconf_client_get_default ();
- gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/width",
- widget->allocation.width, NULL);
- gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/height",
- widget->allocation.height, NULL);
- g_object_unref(client);
-
- E_SHELL_WINDOW (widget)->priv->store_window_size_timer = 0;
- return FALSE; // remove this timeout
-}
+ GtkUIManager *ui_manager;
-static void
-impl_size_alloc (GtkWidget* widget, GtkAllocation* alloc)
-{
- EShellWindow* self = E_SHELL_WINDOW (widget);
- e_shell_window_remove_resize_timer(self);
+ g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL);
+ g_return_val_if_fail (action_name != NULL, NULL);
- if (GTK_WIDGET_REALIZED(widget) && !(gdk_window_get_state(widget->window) & GDK_WINDOW_STATE_MAXIMIZED)) {
- /* update the size storage timer */
- self->priv->store_window_size_timer = g_timeout_add_seconds (1, (GSourceFunc)store_window_size, self);
- }
+ ui_manager = e_shell_window_get_ui_manager (shell_window);
- if (GTK_WIDGET_CLASS (e_shell_window_parent_class)->size_allocate) {
- GTK_WIDGET_CLASS (e_shell_window_parent_class)->size_allocate (widget, alloc);
- }
+ return e_lookup_action (ui_manager, action_name);
}
-/* Initialization. */
-
-static void
-e_shell_window_class_init (EShellWindowClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-
- widget_class->window_state_event = impl_window_state;
- widget_class->size_allocate = impl_size_alloc;
-
- signals[COMPONENT_CHANGED] = g_signal_new ("component_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EShellWindowClass, component_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-e_shell_window_init (EShellWindow *shell_window)
+/**
+ * e_shell_window_get_action_group:
+ * @shell_window: an #EShellWindow
+ * @group_name: the name of an action group
+ *
+ * Returns the #GtkActionGroup named @group_name in
+ * @shell_window<!-- -->'s user interface manager, or %NULL if no
+ * such action group exists.
+ *
+ * Returns: the #GtkActionGroup named @group_name
+ **/
+GtkActionGroup *
+e_shell_window_get_action_group (EShellWindow *shell_window,
+ const gchar *group_name)
{
- EShellWindowPrivate *priv = g_new0 (EShellWindowPrivate, 1);
-
- priv->shell_view = e_shell_view_new(shell_window);
- priv->destroyed = FALSE;
+ GtkUIManager *ui_manager;
- shell_window->priv = priv;
+ g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL);
+ g_return_val_if_fail (group_name != NULL, NULL);
- /** @HookPoint: Shell Main Menu
- * @Id: org.gnome.evolution.shell
- * @Type: ESMenu
- * @Target: ESMenuTargetShell
- *
- * This hook point is used to add bonobo menu's to the main
- * evolution shell window, used for global commands not
- * requiring a specific component.
- */
- priv->menu = es_menu_new("org.gnome.evolution.shell");
+ ui_manager = e_shell_window_get_ui_manager (shell_window);
+ return e_lookup_action_group (ui_manager, group_name);
}
-
-/* Instantiation. */
-
+/**
+ * e_shell_window_get_managed_widget:
+ * @shell_window: an #EShellWindow
+ * @widget_path: path in the UI definintion
+ *
+ * Looks up a widget in @shell_window<!-- -->'s user interface manager by
+ * following a path. See gtk_ui_manager_get_widget() for more information
+ * about paths.
+ *
+ * Returns: the widget found by following the path, or %NULL if no widget
+ * was found
+ **/
GtkWidget *
-e_shell_window_new (EShell *shell,
- const char *component_id)
+e_shell_window_get_managed_widget (EShellWindow *shell_window,
+ const gchar *widget_path)
{
- EShellWindow *window = g_object_new (e_shell_window_get_type (), NULL);
- EShellWindowPrivate *priv = window->priv;
- GConfClient *gconf_client = gconf_client_get_default ();
- BonoboUIContainer *ui_container;
- char *default_component_id = NULL;
- char *xmlfile;
- gint width, height;
-
- if (bonobo_window_construct (BONOBO_WINDOW (window),
- bonobo_ui_container_new (),
- "evolution", "Evolution") == NULL) {
- g_object_unref (window);
- g_object_unref (gconf_client);
- return NULL;
- }
-
- window->priv->shell.eshell = shell;
- g_object_add_weak_pointer (G_OBJECT (shell), &window->priv->shell.pointer);
-
- /* FIXME TODO: Add system_exception signal handling and all the other
- stuff from e_shell_view_construct(). */
-
- ui_container = bonobo_window_get_ui_container (BONOBO_WINDOW (window));
-
- priv->ui_component = bonobo_ui_component_new ("evolution");
- bonobo_ui_component_set_container (priv->ui_component,
- bonobo_object_corba_objref (BONOBO_OBJECT (ui_container)),
- NULL);
-
- xmlfile = g_build_filename (EVOLUTION_UIDIR, "evolution.xml", NULL);
- bonobo_ui_util_set_ui (priv->ui_component,
- PREFIX,
- xmlfile,
- "evolution", NULL);
- g_free (xmlfile);
-
- e_shell_window_commands_setup (window);
- e_menu_activate((EMenu *)priv->menu, priv->ui_component, TRUE);
-
- setup_widgets (window);
-
- if(gconf_client_get_bool (gconf_client,"/apps/evolution/shell/view_defaults/sidebar_visible",NULL))
- gtk_widget_show (priv->sidebar);
- else
- gtk_widget_hide (priv->sidebar);
-
- update_send_receive_sensitivity (window);
- g_signal_connect_object (shell, "line_status_changed", G_CALLBACK (shell_line_status_changed_callback), window, 0);
-
- gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
+ GtkUIManager *ui_manager;
+ GtkWidget *widget;
- if (component_id == NULL) {
- component_id = default_component_id =
- gconf_client_get_string (gconf_client,
- "/apps/evolution/shell/view_defaults/component_id",
- NULL);
- if (component_id == NULL)
- component_id = "mail";
- }
+ g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL);
+ g_return_val_if_fail (widget_path != NULL, NULL);
- e_shell_window_switch_to_component (window, component_id);
- g_free(default_component_id);
- g_object_unref (gconf_client);
+ ui_manager = e_shell_window_get_ui_manager (shell_window);
+ widget = gtk_ui_manager_get_widget (ui_manager, widget_path);
- width = gconf_client_get_int (gconf_client, "/apps/evolution/shell/view_defaults/width", NULL);
- height = gconf_client_get_int (gconf_client, "/apps/evolution/shell/view_defaults/height", NULL);
- gtk_window_set_default_size (GTK_WINDOW (window), (width >= 0) ? width : 0,
- (height >= 0) ? height : 0);
- if (gconf_client_get_bool (gconf_client, "/apps/evolution/shell/view_defaults/maximized", NULL)) {
- gtk_window_maximize (GTK_WINDOW (window));
- }
+ g_return_val_if_fail (widget != NULL, NULL);
- g_object_unref (gconf_client);
- return GTK_WIDGET (window);
+ return widget;
}
-
-void
-e_shell_window_switch_to_component (EShellWindow *window, const char *component_id)
+/**
+ * e_shell_window_get_active_view:
+ * @shell_window: an #EShellWindow
+ *
+ * Returns the name of the active #EShellView.
+ *
+ * Returns: the name of the active view
+ **/
+const gchar *
+e_shell_window_get_active_view (EShellWindow *shell_window)
{
- EShellWindowPrivate *priv = window->priv;
- ComponentView *view = NULL;
- GSList *p;
-
- g_return_if_fail (E_IS_SHELL_WINDOW (window));
- g_return_if_fail (component_id != NULL);
-
- for (p = priv->component_views; p != NULL; p = p->next) {
- ComponentView *this_view = p->data;
-
- if (strcmp (this_view->component_id, component_id) == 0
- || (this_view->component_alias != NULL
- && strcmp (this_view->component_alias, component_id) == 0))
- {
- view = p->data;
- break;
- }
- }
+ g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL);
- if (view == NULL) {
- g_warning ("Unknown component %s", component_id);
- return;
- }
-
- e_sidebar_select_button (E_SIDEBAR (priv->sidebar), view->button_id);
+ return shell_window->priv->active_view;
}
-
-const char *
-e_shell_window_peek_current_component_id (EShellWindow *window)
+/**
+ * e_shell_window_set_active_view:
+ * @shell_window: an #EShellWindow
+ * @view_name: the name of the shell view to switch to
+ *
+ * Switches @shell_window to the #EShellView named @view_name, causing
+ * the entire content of @shell_window to change. This is typically
+ * called as a result of the user clicking one of the switcher buttons.
+ *
+ * The name of the newly activated shell view is also written to GConf key
+ * <filename>/apps/evolution/shell/view_defaults/component_id</filename>.
+ * This makes the active shell view persistent across Evolution sessions.
+ * It also causes new shell windows created within the current Evolution
+ * session to open to the most recently selected shell view.
+ **/
+void
+e_shell_window_set_active_view (EShellWindow *shell_window,
+ const gchar *view_name)
{
- g_return_val_if_fail (E_IS_SHELL_WINDOW (window), NULL);
+ GtkAction *action;
+ EShellView *shell_view;
- if (window->priv->current_view == NULL)
- return NULL;
+ g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
+ g_return_if_fail (view_name != NULL);
- return window->priv->current_view->component_id;
-}
+ shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+ g_return_if_fail (shell_view != NULL);
-
-EShell *
-e_shell_window_peek_shell (EShellWindow *window)
-{
- g_return_val_if_fail (E_IS_SHELL_WINDOW (window), NULL);
-
- return window->priv->shell.eshell;
+ action = e_shell_view_get_action (shell_view);
+ gtk_action_activate (action);
}
-
-BonoboUIComponent *
-e_shell_window_peek_bonobo_ui_component (EShellWindow *window)
+/**
+ * e_shell_window_get_safe_mode:
+ * @shell_window: an #EShellWindow
+ *
+ * Returns %TRUE if @shell_window is in "safe mode".
+ *
+ * It's up to the various #EShellView<!-- -->'s to define exactly
+ * what "safe mode" means. The @shell_window simply manages the
+ * "safe mode" state.
+ *
+ * Returns: %TRUE if @shell_window is in "safe mode"
+ **/
+gboolean
+e_shell_window_get_safe_mode (EShellWindow *shell_window)
{
- g_return_val_if_fail (E_IS_SHELL_WINDOW (window), NULL);
+ g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), FALSE);
- return window->priv->ui_component;
+ return shell_window->priv->safe_mode;
}
-ESidebar *
-e_shell_window_peek_sidebar (EShellWindow *window)
+/**
+ * e_shell_window_set_safe_mode:
+ * @shell_window: an #EShellWindow
+ * @safe_mode: whether to put @shell_window into "safe mode"
+ *
+ * If %TRUE, puts @shell_window into "safe mode".
+ *
+ * It's up to the various #EShellView<!-- -->'s to define exactly
+ * what "safe mode" means. The @shell_window simply manages the
+ * "safe mode" state.
+ **/
+void
+e_shell_window_set_safe_mode (EShellWindow *shell_window,
+ gboolean safe_mode)
{
- g_return_val_if_fail (E_IS_SHELL_WINDOW (window), NULL);
+ g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
- return E_SIDEBAR (window->priv->sidebar);
-}
+ shell_window->priv->safe_mode = safe_mode;
-GtkWidget *
-e_shell_window_peek_statusbar (EShellWindow *window)
-{
- return window->priv->status_bar;
+ g_object_notify (G_OBJECT (shell_window), "safe-mode");
}
+/**
+ * e_shell_window_add_action_group:
+ * @shell_window: an #EShellWindow
+ * @group_name: the name of the new action group
+ *
+ * Creates a new #GtkActionGroup and adds it to @shell_window<!-- -->'s
+ * user interface manager. This also takes care of details like setting
+ * the translation domain.
+ **/
void
-e_shell_window_save_defaults (EShellWindow *window)
+e_shell_window_add_action_group (EShellWindow *shell_window,
+ const gchar *group_name)
{
- GConfClient *client = gconf_client_get_default ();
- char *prop;
- const char *style;
- gboolean visible;
-
- gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/folder_bar/width",
- gtk_paned_get_position (GTK_PANED (window->priv->paned)), NULL);
-
- /* The button styles */
- if ((style = gconf_enum_to_string (button_styles, e_sidebar_get_mode (E_SIDEBAR (window->priv->sidebar))))) {
- gconf_client_set_string (client,
- "/apps/evolution/shell/view_defaults/buttons_style",
- style, NULL);
- }
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_manager;
+ const gchar *domain;
- /* Button hiding setting */
- prop = bonobo_ui_component_get_prop (e_shell_window_peek_bonobo_ui_component (window),
- "/commands/ViewButtonsHide",
- "state",
- NULL);
- if (prop) {
- visible = prop[0] == '0';
- gconf_client_set_bool (client,
- "/apps/evolution/shell/view_defaults/buttons_visible",
- visible,
- NULL);
- g_free (prop);
- }
+ g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
+ g_return_if_fail (group_name != NULL);
- /* Toolbar visibility setting */
- prop = bonobo_ui_component_get_prop (e_shell_window_peek_bonobo_ui_component (window),
- "/commands/ViewToolbar",
- "state",
- NULL);
- if (prop) {
- visible = prop[0] == '1';
- gconf_client_set_bool (client,
- "/apps/evolution/shell/view_defaults/toolbar_visible",
- visible,
- NULL);
- g_free (prop);
- }
+ ui_manager = e_shell_window_get_ui_manager (shell_window);
+ domain = GETTEXT_PACKAGE;
- /* SideBar visibility setting */
- prop = bonobo_ui_component_get_prop (e_shell_window_peek_bonobo_ui_component (window),
- "/commands/ViewSideBar",
- "state",
- NULL);
- if (prop) {
- visible = prop[0] == '1';
- gconf_client_set_bool (client,
- "/apps/evolution/shell/view_defaults/sidebar_visible",
- visible,
- NULL);
- g_free (prop);
- }
-
-
- g_object_unref (client);
+ action_group = gtk_action_group_new (group_name);
+ gtk_action_group_set_translation_domain (action_group, domain);
+ gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+ g_object_unref (action_group);
}
+/**
+ * e_shell_window_register_new_item_actions:
+ * @shell_window: an #EShellWindow
+ * @module_name: name of an #EShellModule
+ * @entries: an array of #GtkActionEntry<!-- -->s
+ * @n_entries: number of elements in the array
+ *
+ * Registers a list of #GtkAction<!-- -->s to appear in
+ * @shell_window<!-- -->'s "New" menu and toolbar button. This
+ * function should be called from an #EShell<!-- -->'s
+ * #EShell::window-created signal handler. The #EShellModule calling
+ * this function should pass its own name for the @module_name argument
+ * (i.e. the <structfield>name</structfield> field from its own
+ * #EShellModuleInfo).
+ *
+ * The registered #GtkAction<!-- -->s should be for creating individual
+ * items such as an email message or a calendar appointment. The action
+ * labels should be marked for translation with the "New" context using
+ * the NC_() macro.
+ **/
void
-e_shell_window_show_settings (EShellWindow *window)
-{
- g_return_if_fail (E_IS_SHELL_WINDOW (window));
+e_shell_window_register_new_item_actions (EShellWindow *shell_window,
+ const gchar *module_name,
+ GtkActionEntry *entries,
+ guint n_entries)
+{
+ GtkActionGroup *action_group;
+ GtkAccelGroup *accel_group;
+ GtkUIManager *ui_manager;
+ guint ii;
+
+ g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
+ g_return_if_fail (module_name != NULL);
+ g_return_if_fail (entries != NULL);
+
+ action_group = ACTION_GROUP (NEW_ITEM);
+ ui_manager = e_shell_window_get_ui_manager (shell_window);
+ accel_group = gtk_ui_manager_get_accel_group (ui_manager);
+ module_name = g_intern_string (module_name);
+
+ /* XXX The action label translations are retrieved from the
+ * message context "New", but gtk_action_group_add_actions()
+ * does not support message contexts. So we have to fetch
+ * the label translations ourselves before adding them to
+ * the action group.
+ *
+ * gtk_action_group_set_translate_func() does not help here
+ * because the action tooltips do not use a message context
+ * (though I suppose they could). */
+ for (ii = 0; ii < n_entries; ii++)
+ entries[ii].label = g_dpgettext2 (
+ GETTEXT_PACKAGE, "New", entries[ii].label);
- e_shell_show_settings (window->priv->shell.eshell, window->priv->current_view ? window->priv->current_view->component_alias : NULL, window);
-}
+ gtk_action_group_add_actions (
+ action_group, entries, n_entries, shell_window);
-void
-e_shell_window_set_title(EShellWindow *window, const char *component_id, const char *title)
-{
- EShellWindowPrivate *priv = window->priv;
- ComponentView *view = NULL;
- GSList *p;
+ /* Tag each action with the name of the shell module that
+ * registered it. This is used to help sort actions in the
+ * "New" menu. */
- if (priv->destroyed)
- return;
+ for (ii = 0; ii < n_entries; ii++) {
+ const gchar *action_name;
+ GtkAction *action;
- for (p = priv->component_views; p != NULL; p = p->next) {
- ComponentView *this_view = p->data;
+ action_name = entries[ii].name;
- if (strcmp (this_view->component_id, component_id) == 0
- || (this_view->component_alias != NULL
- && strcmp (this_view->component_alias, component_id) == 0)) {
- view = p->data;
- break;
- }
- }
+ action = gtk_action_group_get_action (
+ action_group, action_name);
+
+ gtk_action_set_accel_group (action, accel_group);
- if (view) {
- g_free(view->title);
- view->title = g_strdup(title);
- if (view->title && view == priv->current_view)
- gtk_window_set_title((GtkWindow *)window, title);
+ g_object_set_data (
+ G_OBJECT (action),
+ "module-name", (gpointer) module_name);
+
+ /* The first action becomes the first item in the "New"
+ * menu, and consequently its icon is shown in the "New"
+ * button when the shell module's view is active. This
+ * is all sorted out in shell_window_extract_actions().
+ * Note, the data value just needs to be non-zero. */
+ if (ii == 0)
+ g_object_set_data (
+ G_OBJECT (action),
+ "primary", GINT_TO_POINTER (TRUE));
}
+
+ e_shell_window_update_new_menu (shell_window);
}
/**
- * e_shell_window_change_component_button_icon
- * Changes icon of components button at sidebar. For more info how this behaves see
- * info at @ref e_sidebar_change_button_icon.
- * @param window EShellWindow instance.
- * @param component_id ID of the component.
- * @param icon Icon buffer.
+ * e_shell_window_register_new_source_actions:
+ * @shell_window: an #EShellWindow
+ * @module_name: name of an #EShellModule
+ * @entries: an array of #GtkActionEntry<!-- -->s
+ * @n_entries: number of elements in the array
+ *
+ * Registers a list of #GtkAction<!-- -->s to appear in
+ * @shell_window<!-- -->'s "New" menu and toolbar button. This
+ * function should be called from an #EShell<!-- -->'s
+ * #EShell::window-created signal handler. The #EShellModule calling
+ * this function should pass its own name for the @module_name argument
+ * (i.e. the <structfield>name</structfield> field from its own
+ * #EShellModuleInfo).
+ *
+ * The registered #GtkAction<!-- -->s should be for creating item
+ * containers such as an email folder or a calendar. The action labels
+ * should be marked for translation with the "New" context using the
+ * NC_() macro.
**/
void
-e_shell_window_change_component_button_icon (EShellWindow *window, const char *component_id, const char *icon_name)
-{
- EShellWindowPrivate *priv;
- GSList *p;
+e_shell_window_register_new_source_actions (EShellWindow *shell_window,
+ const gchar *module_name,
+ GtkActionEntry *entries,
+ guint n_entries)
+{
+ GtkActionGroup *action_group;
+ GtkAccelGroup *accel_group;
+ GtkUIManager *ui_manager;
+ guint ii;
+
+ g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
+ g_return_if_fail (module_name != NULL);
+ g_return_if_fail (entries != NULL);
+
+ action_group = ACTION_GROUP (NEW_SOURCE);
+ ui_manager = e_shell_window_get_ui_manager (shell_window);
+ accel_group = gtk_ui_manager_get_accel_group (ui_manager);
+ module_name = g_intern_string (module_name);
+
+ /* XXX The action label translations are retrieved from the
+ * message context "New", but gtk_action_group_add_actions()
+ * does not support message contexts. So we have to fetch
+ * the label translations ourselves before adding them to
+ * the action group.
+ *
+ * gtk_action_group_set_translate_func() does not help here
+ * because the action tooltips do not use a message context
+ * (though I suppose they could). */
+ for (ii = 0; ii < n_entries; ii++)
+ entries[ii].label = g_dpgettext2 (
+ GETTEXT_PACKAGE, "New", entries[ii].label);
- g_return_if_fail (window != NULL);
- g_return_if_fail (component_id != NULL);
+ gtk_action_group_add_actions (
+ action_group, entries, n_entries, shell_window);
- priv = window->priv;
+ /* Tag each action with the name of the shell module that
+ * registered it. This is used to help sort actions in the
+ * "New" menu. */
- if (priv->destroyed)
- return;
+ for (ii = 0; ii < n_entries; ii++) {
+ const gchar *action_name;
+ GtkAction *action;
- for (p = priv->component_views; p != NULL; p = p->next) {
- ComponentView *this_view = p->data;
+ action_name = entries[ii].name;
- if (strcmp (this_view->component_id, component_id) == 0
- || (this_view->component_alias != NULL
- && strcmp (this_view->component_alias, component_id) == 0)) {
- e_sidebar_change_button_icon (E_SIDEBAR (priv->sidebar), icon_name, this_view->button_id);
- break;
- }
+ action = gtk_action_group_get_action (
+ action_group, action_name);
+
+ gtk_action_set_accel_group (action, accel_group);
+
+ g_object_set_data (
+ G_OBJECT (action),
+ "module-name", (gpointer) module_name);
}
+
+ e_shell_window_update_new_menu (shell_window);
}
diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h
index d94aef0f4f..f9cdb60cf4 100644
--- a/shell/e-shell-window.h
+++ b/shell/e-shell-window.h
@@ -1,4 +1,5 @@
/*
+ * e-shell-window.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -14,66 +15,104 @@
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
-#ifndef _E_SHELL_WINDOW_H_
-#define _E_SHELL_WINDOW_H_
-
-#include <bonobo/bonobo-window.h>
-#include <bonobo/bonobo-ui-component.h>
-#include "e-sidebar.h"
-
-#define E_TYPE_SHELL_WINDOW (e_shell_window_get_type ())
-#define E_SHELL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SHELL_WINDOW, EShellWindow))
-#define E_SHELL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SHELL_WINDOW, EShellWindowClass))
-#define E_IS_SHELL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SHELL_WINDOW))
-#define E_IS_SHELL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SHELL_WINDOW))
-
-
-typedef struct _EShellWindow EShellWindow;
+/**
+ * SECTION: e-shell-window
+ * @short_description: the main window
+ * @include: shell/e-shell-window.h
+ **/
+
+#ifndef E_SHELL_WINDOW_H
+#define E_SHELL_WINDOW_H
+
+#include <shell/e-shell.h>
+
+/* Standard GObject macros */
+#define E_TYPE_SHELL_WINDOW \
+ (e_shell_window_get_type ())
+#define E_SHELL_WINDOW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_SHELL_WINDOW, EShellWindow))
+#define E_SHELL_WINDOW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_SHELL_WINDOW, EShellWindowClass))
+#define E_IS_SHELL_WINDOW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_SHELL_WINDOW))
+#define E_IS_SHELL_WINDOW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((obj), E_TYPE_SHELL_WINDOW))
+#define E_SHELL_WINDOW_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_SHELL_WINDOW, EShellWindowClass))
+
+G_BEGIN_DECLS
+
+/* Avoid including <e-shell-view.h>, because it includes us! */
+struct _EShellView;
+
+typedef struct _EShellWindow EShellWindow;
+typedef struct _EShellWindowClass EShellWindowClass;
typedef struct _EShellWindowPrivate EShellWindowPrivate;
-typedef struct _EShellWindowClass EShellWindowClass;
+/**
+ * EShellWindow:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ **/
struct _EShellWindow {
- BonoboWindow parent;
-
+ GtkWindow parent;
EShellWindowPrivate *priv;
};
struct _EShellWindowClass {
- BonoboWindowClass parent_class;
-
- void (* component_changed) (EShellWindow *window);
+ GtkWindowClass parent_class;
};
-
-#include "e-shell.h"
-
-
-GType e_shell_window_get_type (void);
-
-GtkWidget *e_shell_window_new (EShell *shell,
- const char *component_id);
-
-void e_shell_window_switch_to_component (EShellWindow *shell,
- const char *component_id);
-const char *e_shell_window_peek_current_component_id (EShellWindow *shell);
-
-EShell *e_shell_window_peek_shell (EShellWindow *window);
-BonoboUIComponent *e_shell_window_peek_bonobo_ui_component (EShellWindow *window);
-ESidebar *e_shell_window_peek_sidebar (EShellWindow *window);
-GtkWidget *e_shell_window_peek_statusbar (EShellWindow *window);
-
-void e_shell_window_set_title(EShellWindow *window, const char *component_id, const char *title);
-
-void e_shell_window_save_defaults (EShellWindow *window);
-void e_shell_window_show_settings (EShellWindow *window);
-
-void e_shell_window_change_component_button_icon (EShellWindow *window, const char *component_id, const char *icon_name);
-
-#endif /* _E_SHELL_WINDOW_H_ */
+GType e_shell_window_get_type (void);
+GtkWidget * e_shell_window_new (EShell *shell,
+ gboolean safe_mode);
+EShell * e_shell_window_get_shell (EShellWindow *shell_window);
+struct _EShellView *
+ e_shell_window_get_shell_view (EShellWindow *shell_window,
+ const gchar *view_name);
+GtkAction * e_shell_window_get_shell_view_action
+ (EShellWindow *shell_window,
+ const gchar *view_name);
+GtkUIManager * e_shell_window_get_ui_manager (EShellWindow *shell_window);
+GtkAction * e_shell_window_get_action (EShellWindow *shell_window,
+ const gchar *action_name);
+GtkActionGroup *e_shell_window_get_action_group (EShellWindow *shell_window,
+ const gchar *group_name);
+GtkWidget * e_shell_window_get_managed_widget
+ (EShellWindow *shell_window,
+ const gchar *widget_path);
+const gchar * e_shell_window_get_active_view (EShellWindow *shell_window);
+void e_shell_window_set_active_view (EShellWindow *shell_window,
+ const gchar *view_name);
+gboolean e_shell_window_get_safe_mode (EShellWindow *shell_window);
+void e_shell_window_set_safe_mode (EShellWindow *shell_window,
+ gboolean safe_mode);
+void e_shell_window_add_action_group (EShellWindow *shell_window,
+ const gchar *group_name);
+
+/* These should be called from the shell module's window_created() handler. */
+
+void e_shell_window_register_new_item_actions
+ (EShellWindow *shell_window,
+ const gchar *module_name,
+ GtkActionEntry *entries,
+ guint n_entries);
+void e_shell_window_register_new_source_actions
+ (EShellWindow *shell_window,
+ const gchar *module_name,
+ GtkActionEntry *entries,
+ guint n_entries);
+
+G_END_DECLS
+
+#endif /* E_SHELL_WINDOW_H */
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 061071efb8..2c5f00460a 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -1,4 +1,6 @@
/*
+ * e-shell.c
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -13,1420 +15,1413 @@
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
-#include <config.h>
-
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-#include <gtk/gtk.h>
-#include <glib/gstdio.h>
-
-#ifdef GDK_WINDOWING_X11
-#include <gdk/gdkprivate.h>
-#include <gdk/gdkx.h>
-#include <X11/Xatom.h>
-#include <X11/Xlib.h>
-#elif defined (GDK_WINDOWING_WIN32)
-/* gdkwin32.h includes <windows.h> which stomps over the namespace */
-#undef DATADIR
-#define interface windows_interface
-#include <gdk/gdkwin32.h>
-#undef interface
-#endif
+#include "e-shell.h"
#include <glib/gi18n.h>
-
-#include <gconf/gconf-client.h>
-
-#include <bonobo-activation/bonobo-activation.h>
-#include <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-moniker-util.h>
-
-#include <libedataserver/e-xml-utils.h>
#include <libedataserverui/e-passwords.h>
-#include "e-util/e-bconf-map.h"
-#include "e-util/e-dialog-utils.h"
-#include "e-util/e-error.h"
-#include "e-util/e-fsutils.h"
#include "e-util/e-util.h"
+#include "widgets/misc/e-preferences-window.h"
-#include "Evolution.h"
-#include "e-shell-constants.h"
-#include "e-shell-settings-dialog.h"
-#include "e-shell.h"
-#include "e-shell-view.h"
-#include "es-event.h"
-#include "evolution-listener.h"
-#include "evolution-shell-component-utils.h"
+#include "e-shell-migrate.h"
+#include "e-shell-module.h"
+#include "e-shell-window.h"
-static void set_line_status_complete(EvolutionListener *el, void *data);
+#define SHUTDOWN_TIMEOUT 500 /* milliseconds */
-#define PARENT_TYPE bonobo_object_get_type ()
-static BonoboObjectClass *parent_class = NULL;
-static gboolean session_started = FALSE;
+#define E_SHELL_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SHELL, EShellPrivate))
struct _EShellPrivate {
- /* IID for registering the object on OAF. */
- char *iid;
+ GList *watched_windows;
+ EShellSettings *settings;
+ GConfClient *gconf_client;
+ GtkWidget *preferences_window;
- GList *windows;
+ /* Shell Modules */
+ GList *loaded_modules;
+ GHashTable *modules_by_name;
+ GHashTable *modules_by_scheme;
- /* EUriSchemaRegistry *uri_schema_registry; FIXME */
- EComponentRegistry *component_registry;
+ gpointer preparing_for_line_change; /* weak pointer */
- /* Names for the types of the folders that have maybe crashed. */
- /* FIXME TODO */
- GList *crash_type_names; /* char * */
+ guint auto_reconnect : 1;
+ guint network_available : 1;
+ guint online : 1;
+ guint safe_mode : 1;
+};
- /* Line status and controllers */
- EShellLineStatus line_status;
- int line_status_pending;
- EShellLineStatus line_status_working;
- EvolutionListener *line_status_listener;
+enum {
+ PROP_0,
+ PROP_NETWORK_AVAILABLE,
+ PROP_ONLINE,
+ PROP_SHELL_SETTINGS
+};
- /* Settings Dialog */
- union {
- GtkWidget *widget;
- gpointer pointer;
- } settings_dialog;
+enum {
+ EVENT,
+ HANDLE_URI,
+ PREPARE_FOR_OFFLINE,
+ PREPARE_FOR_ONLINE,
+ SEND_RECEIVE,
+ WINDOW_CREATED,
+ WINDOW_DESTROYED,
+ LAST_SIGNAL
+};
- /* If we're quitting and things are still busy, a timeout handler */
- guint quit_timeout;
+enum {
+ DEBUG_KEY_SETTINGS = 1 << 0
+};
- /* Whether the shell is succesfully initialized. This is needed during
- the start-up sequence, to avoid CORBA calls to do make wrong things
- to happen while the shell is initializing. */
- unsigned int is_initialized : 1;
+static GDebugKey debug_keys[] = {
+ { "settings", DEBUG_KEY_SETTINGS }
+};
- /* Wether the shell is working in "interactive" mode or not.
- (Currently, it's interactive IIF there is at least one active
- view.) */
- unsigned int is_interactive : 1;
+EShell *default_shell = NULL;
+static gpointer parent_class;
+static guint signals[LAST_SIGNAL];
- /* Whether quit has been requested, and the shell is now waiting for
- permissions from all the components to quit. */
- unsigned int preparing_to_quit : 1;
+#if NM_SUPPORT
+void e_shell_dbus_initialize (EShell *shell);
+#endif
- /* Whether we are recovering from a crash in the previous session. */
- unsigned int crash_recovery : 1;
-};
+static void
+shell_parse_debug_string (EShell *shell)
+{
+ guint flags;
+ flags = g_parse_debug_string (
+ g_getenv ("EVOLUTION_DEBUG"),
+ debug_keys, G_N_ELEMENTS (debug_keys));
-/* Signals. */
+ if (flags & DEBUG_KEY_SETTINGS)
+ e_shell_settings_enable_debug (shell->priv->settings);
+}
-enum {
- NO_WINDOWS_LEFT,
- LINE_STATUS_CHANGED,
- NEW_WINDOW_CREATED,
- LAST_SIGNAL
-};
+static void
+shell_notify_online_cb (EShell *shell)
+{
+ gboolean online;
-static guint signals[LAST_SIGNAL] = { 0 };
+ online = e_shell_get_online (shell);
+ e_passwords_set_online (online);
+}
+static gboolean
+shell_window_delete_event_cb (EShell *shell,
+ GtkWindow *window)
+{
+ /* If other windows are open we can safely close this one. */
+ if (g_list_length (shell->priv->watched_windows) > 1)
+ return FALSE;
-/* Utility functions. */
+ /* Otherwise we initiate application shutdown. */
+ return !e_shell_quit (shell);
+}
static gboolean
-get_config_start_offline (void)
+shell_window_focus_in_event_cb (EShell *shell,
+ GdkEventFocus *event,
+ GtkWindow *window)
{
- GConfClient *client;
- gboolean value;
-
- client = gconf_client_get_default ();
+ GList *list, *link;
- value = gconf_client_get_bool (client, "/apps/evolution/shell/start_offline", NULL);
+ /* Keep the watched windows list sorted by most recently focused,
+ * so the first item in the list should always be the currently
+ * focused window. */
- g_object_unref (client);
+ list = shell->priv->watched_windows;
+ link = g_list_find (list, window);
+ g_return_val_if_fail (link != NULL, FALSE);
- return value;
-}
+ if (link != list) {
+ list = g_list_remove_link (list, link);
+ list = g_list_concat (link, list);
+ }
+ shell->priv->watched_windows = list;
-/* Interactivity handling. */
+ return FALSE;
+}
static void
-set_interactive (EShell *shell,
- gboolean interactive)
+shell_window_weak_notify_cb (EShell *shell,
+ GObject *where_the_object_was)
{
- GSList *component_list;
- GSList *p;
- GList *first_element;
- int num_windows;
- GtkWidget *view;
-
- g_return_if_fail (E_IS_SHELL (shell));
+ GList *list;
- shell->priv->is_interactive = interactive;
+ list = shell->priv->watched_windows;
+ list = g_list_remove (list, where_the_object_was);
+ shell->priv->watched_windows = list;
- num_windows = g_list_length (shell->priv->windows);
+ g_signal_emit (shell, signals[WINDOW_DESTROYED], 0);
+}
- /* We want to send the "interactive" message only when the first
- window is created */
- if (num_windows != 1)
+static void
+shell_ready_for_offline (EShell *shell,
+ EActivity *activity,
+ gboolean is_last_ref)
+{
+ if (!is_last_ref)
return;
- first_element = g_list_first (shell->priv->windows);
- view = GTK_WIDGET (first_element->data);
+ /* Increment the reference count so we can safely emit
+ * a signal without triggering the toggle reference. */
+ g_object_ref (activity);
- component_list = e_component_registry_peek_list (shell->priv->component_registry);
+ e_activity_complete (activity);
- for (p = component_list; p != NULL; p = p->next) {
- EComponentInfo *info = p->data;
- CORBA_Environment ev;
+ g_object_remove_toggle_ref (
+ G_OBJECT (activity), (GToggleNotify)
+ shell_ready_for_offline, shell);
- CORBA_exception_init (&ev);
+ /* Finalize the activity. */
+ g_object_unref (activity);
-#ifdef GDK_WINDOWING_X11
- GNOME_Evolution_Component_interactive (info->iface, interactive,GPOINTER_TO_INT (GDK_WINDOW_XWINDOW (view->window)), &ev);
-#elif defined (GDK_WINDOWING_WIN32)
- GNOME_Evolution_Component_interactive (info->iface, interactive,GPOINTER_TO_INT (GDK_WINDOW_HWND (view->window)), &ev);
-#else
-#error Port this to your windowing system
-#endif
-
- /* Ignore errors, the components can decide to not implement
- this interface. */
+ shell->priv->online = FALSE;
+ g_object_notify (G_OBJECT (shell), "online");
- CORBA_exception_free (&ev);
- }
+ g_message ("Offline preparations complete.");
}
+static void
+shell_prepare_for_offline (EShell *shell)
+{
+ /* Are preparations already in progress? */
+ if (shell->priv->preparing_for_line_change != NULL)
+ return;
+
+ g_message ("Preparing for offline mode...");
-/* CORBA interface implementation. */
+ shell->priv->preparing_for_line_change =
+ e_activity_new (_("Preparing to go offline..."));
-static gboolean
-raise_exception_if_not_ready (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- EShell *shell;
+ g_object_add_toggle_ref (
+ G_OBJECT (shell->priv->preparing_for_line_change),
+ (GToggleNotify) shell_ready_for_offline, shell);
- shell = E_SHELL (bonobo_object_from_servant (servant));
+ g_object_add_weak_pointer (
+ G_OBJECT (shell->priv->preparing_for_line_change),
+ &shell->priv->preparing_for_line_change);
- if (! shell->priv->is_initialized) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_GNOME_Evolution_Shell_NotReady, NULL);
- return TRUE;
- }
+ g_signal_emit (
+ shell, signals[PREPARE_FOR_OFFLINE], 0,
+ shell->priv->preparing_for_line_change);
- return FALSE;
+ g_object_unref (shell->priv->preparing_for_line_change);
}
-static GNOME_Evolution_ShellView
-impl_Shell_createNewWindow (PortableServer_Servant servant,
- const CORBA_char *component_id,
- CORBA_Environment *ev)
+static void
+shell_ready_for_online (EShell *shell,
+ EActivity *activity,
+ gboolean is_last_ref)
{
- BonoboObject *bonobo_object;
- EShell *shell;
- EShellWindow *shell_window;
- EShellView *shell_view;
-
- if (raise_exception_if_not_ready (servant, ev))
- return CORBA_OBJECT_NIL;
+ if (!is_last_ref)
+ return;
- bonobo_object = bonobo_object_from_servant (servant);
- shell = E_SHELL (bonobo_object);
+ /* Increment the reference count so we can safely emit
+ * a signal without triggering the toggle reference. */
+ g_object_ref (activity);
- if (component_id[0] == '\0')
- component_id = NULL;
+ e_activity_complete (activity);
- shell_window = e_shell_create_window (shell, component_id, NULL);
- if (shell_window == NULL) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_GNOME_Evolution_Shell_ComponentNotFound, NULL);
- return CORBA_OBJECT_NIL;
- }
+ g_object_remove_toggle_ref (
+ G_OBJECT (activity), (GToggleNotify)
+ shell_ready_for_online, shell);
- /* refs?? */
- shell_view = e_shell_view_new(shell_window);
+ /* Finalize the activity. */
+ g_object_unref (activity);
- return BONOBO_OBJREF(shell_view);
+ shell->priv->online = TRUE;
+ g_object_notify (G_OBJECT (shell), "online");
+ g_message ("Online preparations complete.");
}
static void
-impl_Shell_handleURI (PortableServer_Servant servant,
- const CORBA_char *uri,
- CORBA_Environment *ev)
+shell_prepare_for_online (EShell *shell)
{
- EShell *shell = E_SHELL (bonobo_object_from_servant (servant));
- EComponentInfo *component_info;
- char *schema, *p;
- int show = FALSE;
-
- schema = g_alloca(strlen(uri)+1);
- strcpy(schema, uri);
- p = strchr(schema, ':');
- if (p)
- *p = 0;
-
- component_info = e_component_registry_peek_info(shell->priv->component_registry, ECR_FIELD_SCHEMA, schema);
- if (component_info == NULL) {
- show = TRUE;
- component_info = e_component_registry_peek_info(shell->priv->component_registry, ECR_FIELD_ALIAS, schema);
- }
-
- if (component_info == NULL) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Shell_UnsupportedSchema, NULL);
+ /* Are preparations already in progress? */
+ if (shell->priv->preparing_for_line_change != NULL)
return;
- }
- if (show) {
- GtkWidget *shell_window;
+ g_message ("Preparing for online mode...");
- shell_window = (GtkWidget *)e_shell_create_window (shell, component_info->id, NULL);
- if (shell_window == NULL) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Shell_ComponentNotFound, NULL);
- return;
- }
- }
+ shell->priv->preparing_for_line_change =
+ e_activity_new (_("Preparing to go online..."));
+
+ g_object_add_toggle_ref (
+ G_OBJECT (shell->priv->preparing_for_line_change),
+ (GToggleNotify) shell_ready_for_online, shell);
- GNOME_Evolution_Component_handleURI (component_info->iface, uri, ev);
- /* not an error not to implement it */
- if (ev->_id != NULL && strcmp(ev->_id, ex_CORBA_NO_IMPLEMENT) == 0)
- memset(ev, 0, sizeof(*ev));
+ g_object_add_weak_pointer (
+ G_OBJECT (shell->priv->preparing_for_line_change),
+ &shell->priv->preparing_for_line_change);
+
+ g_signal_emit (
+ shell, signals[PREPARE_FOR_ONLINE], 0,
+ shell->priv->preparing_for_line_change);
+
+ g_object_unref (shell->priv->preparing_for_line_change);
}
+/* Helper for shell_query_module() */
static void
-impl_Shell_setLineStatus (PortableServer_Servant servant,
- CORBA_boolean online,
- CORBA_Environment *ev)
+shell_split_and_insert_items (GHashTable *hash_table,
+ const gchar *items,
+ EShellModule *shell_module)
{
- BonoboObject *bonobo_object;
- EShell *shell;
-
- if (raise_exception_if_not_ready (servant, ev))
- return;
-
- bonobo_object = bonobo_object_from_servant (servant);
- shell = E_SHELL (bonobo_object);
+ gpointer key;
+ gchar **strv;
+ gint ii;
- /* let the password manager know out online status */
- e_passwords_set_online(online);
+ strv = g_strsplit_set (items, ":", -1);
- if (online)
- e_shell_set_line_status (shell, GNOME_Evolution_USER_ONLINE);
- else
- e_shell_set_line_status (shell, GNOME_Evolution_USER_OFFLINE);
-}
-/*
-static GNOME_Evolution_Component
-impl_Shell_findComponent(PortableServer_Servant servant,
- const CORBA_char *id,
- CORBA_Environment *ev)
-{
- EShell *shell;
- EComponentInfo *ci;
-
- if (raise_exception_if_not_ready (servant, ev))
- return CORBA_OBJECT_NIL;
-
- shell = (EShell *)bonobo_object_from_servant (servant);
- ci = e_component_registry_peek_info(shell->priv->component_registry, ECR_FIELD_ALIAS, id);
- if (ci == NULL) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Shell_ComponentNotFound, NULL);
- return CORBA_OBJECT_NIL;
- } else if (ci->iface == NULL) {
- CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Shell_NotReady, NULL);
- return CORBA_OBJECT_NIL;
- } else {
- return ci->iface;
+ for (ii = 0; strv[ii] != NULL; ii++) {
+ key = (gpointer) g_intern_string (strv[ii]);
+ g_hash_table_insert (hash_table, key, shell_module);
}
-}
-*/
-/* EShellWindow handling and bookkeeping. */
+ g_strfreev (strv);
+}
-static int
-window_delete_event_cb (GtkWidget *widget,
- GdkEventAny *ev,
- void *data)
+static void
+shell_query_module (EShell *shell,
+ const gchar *filename)
{
- EShell *shell;
+ EShellModule *shell_module;
+ EShellModuleInfo *info;
+ GHashTable *modules_by_name;
+ GHashTable *modules_by_scheme;
+ const gchar *string;
- g_return_val_if_fail (E_IS_SHELL_WINDOW (widget), TRUE);
- shell = E_SHELL (data);
+ shell_module = e_shell_module_new (shell, filename);
- return ! e_shell_request_close_window (shell, E_SHELL_WINDOW (widget));
-}
+ if (!g_type_module_use (G_TYPE_MODULE (shell_module))) {
+ g_critical ("Failed to load module: %s", filename);
+ g_object_unref (shell_module);
+ return;
+ }
-static gboolean
-notify_no_windows_left_idle_cb (void *data)
-{
- EShell *shell;
- EShellPrivate *priv;
+ shell->priv->loaded_modules = g_list_insert_sorted (
+ shell->priv->loaded_modules, shell_module,
+ (GCompareFunc) e_shell_module_compare);
- shell = E_SHELL (data);
- priv = shell->priv;
+ /* Bookkeeping */
- set_interactive (shell, FALSE);
+ info = (EShellModuleInfo *) shell_module->priv;
+ modules_by_name = shell->priv->modules_by_name;
+ modules_by_scheme = shell->priv->modules_by_scheme;
- g_signal_emit (shell, signals [NO_WINDOWS_LEFT], 0);
+ if ((string = info->name) != NULL)
+ g_hash_table_insert (
+ modules_by_name, (gpointer)
+ g_intern_string (string), shell_module);
- if (priv->iid != NULL)
- bonobo_activation_active_server_unregister (priv->iid,
- bonobo_object_corba_objref (BONOBO_OBJECT (shell)));
- bonobo_object_unref (BONOBO_OBJECT (shell));
+ if ((string = info->aliases) != NULL)
+ shell_split_and_insert_items (
+ modules_by_name, string, shell_module);
- return FALSE;
+ if ((string = info->schemes) != NULL)
+ shell_split_and_insert_items (
+ modules_by_scheme, string, shell_module);
}
static void
-window_weak_notify (void *data,
- GObject *where_the_object_was)
+shell_load_modules (EShell *shell)
{
- EShell *shell;
- int num_windows;
-
- shell = E_SHELL (data);
-
- num_windows = g_list_length (shell->priv->windows);
-
- /* If this is our last window, save settings now because in the callback
- for no_windows_left shell->priv->windows will be NULL and settings won't
- be saved because of that. */
- if (num_windows == 1)
- e_shell_save_settings (shell);
+ GDir *dir;
+ const gchar *dirname;
+ const gchar *basename;
+ GError *error = NULL;
- shell->priv->windows = g_list_remove (shell->priv->windows, where_the_object_was);
+ dirname = EVOLUTION_MODULEDIR;
- if (shell->priv->windows == NULL) {
- bonobo_object_ref (BONOBO_OBJECT (shell));
- g_idle_add (notify_no_windows_left_idle_cb, shell);
+ dir = g_dir_open (dirname, 0, &error);
+ if (dir == NULL) {
+ g_critical ("%s", error->message);
+ g_error_free (error);
+ return;
}
-}
-
-/* GObject methods. */
-static void
-impl_dispose (GObject *object)
-{
- EShell *shell;
- EShellPrivate *priv;
- GList *p;
+ while ((basename = g_dir_read_name (dir)) != NULL) {
+ gchar *filename;
- shell = E_SHELL (object);
- priv = shell->priv;
+ if (!g_str_has_suffix (basename, "." G_MODULE_SUFFIX))
+ continue;
- priv->is_initialized = FALSE;
-
-#if 0 /* FIXME */
- if (priv->uri_schema_registry != NULL) {
- g_object_unref (priv->uri_schema_registry);
- priv->uri_schema_registry = NULL;
+ filename = g_build_filename (dirname, basename, NULL);
+ shell_query_module (shell, filename);
+ g_free (filename);
}
-#endif
- if (priv->component_registry != NULL) {
- g_object_unref (priv->component_registry);
- priv->component_registry = NULL;
- }
+ g_dir_close (dir);
+}
- if (priv->quit_timeout) {
- g_source_remove(priv->quit_timeout);
- priv->quit_timeout = 0;
+static gboolean
+shell_shutdown_timeout (EShell *shell)
+{
+ GList *list, *iter;
+ gboolean proceed = TRUE;
+ static guint source_id = 0;
+ static guint message_timer = 1;
+
+ /* Module list is read-only; do not free. */
+ list = e_shell_get_shell_modules (shell);
+
+ /* Any module can defer shutdown if it's still busy. */
+ for (iter = list; proceed && iter != NULL; iter = iter->next) {
+ EShellModule *shell_module = iter->data;
+ proceed = e_shell_module_shutdown (shell_module);
+
+ /* Emit a message every few seconds to indicate
+ * which module(s) we're still waiting on. */
+ if (proceed || message_timer == 0)
+ continue;
+
+ g_message (
+ _("Waiting for the \"%s\" module to finish..."),
+ G_TYPE_MODULE (shell_module)->name);
}
- for (p = priv->windows; p != NULL; p = p->next) {
- EShellWindow *window;
-
- window = E_SHELL_WINDOW (p->data);
+ message_timer = (message_timer + 1) % 10;
+
+ /* If we're go for shutdown, destroy all shell windows. Note,
+ * we iterate over a /copy/ of the active windows list because
+ * the act of destroying a shell window will modify the active
+ * windows list, which would otherwise derail the iteration. */
+ if (proceed) {
+ list = g_list_copy (shell->priv->watched_windows);
+ g_list_foreach (list, (GFunc) gtk_widget_destroy, NULL);
+ g_list_free (list);
+
+ /* If a module is still busy, try again after a short delay. */
+ } else if (source_id == 0)
+ source_id = g_timeout_add (
+ SHUTDOWN_TIMEOUT, (GSourceFunc)
+ shell_shutdown_timeout, shell);
+
+ /* Return TRUE to repeat the timeout, FALSE to stop it. This
+ * may seem backwards if the function was called directly. */
+ return !proceed;
+}
- g_signal_handlers_disconnect_by_func (window, G_CALLBACK (window_delete_event_cb), shell);
- g_object_weak_unref (G_OBJECT (window), window_weak_notify, shell);
+static void
+shell_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_NETWORK_AVAILABLE:
+ e_shell_set_network_available (
+ E_SHELL (object),
+ g_value_get_boolean (value));
+ return;
- gtk_object_destroy (GTK_OBJECT (window));
+ case PROP_ONLINE:
+ e_shell_set_online (
+ E_SHELL (object),
+ g_value_get_boolean (value));
+ return;
}
- g_list_free (priv->windows);
- priv->windows = NULL;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
- /* No unreffing for these as they are aggregate. */
- /* bonobo_object_unref (BONOBO_OBJECT (priv->corba_storage_registry)); */
+static void
+shell_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_NETWORK_AVAILABLE:
+ g_value_set_boolean (
+ value, e_shell_get_network_available (
+ E_SHELL (object)));
+ return;
- if (priv->settings_dialog.widget != NULL) {
- gtk_widget_destroy (priv->settings_dialog.widget);
- priv->settings_dialog.widget = NULL;
- }
+ case PROP_ONLINE:
+ g_value_set_boolean (
+ value, e_shell_get_online (
+ E_SHELL (object)));
+ return;
- if (priv->line_status_listener) {
- priv->line_status_listener->complete = NULL;
- bonobo_object_unref(BONOBO_OBJECT(priv->line_status_listener));
- priv->line_status_listener = NULL;
+ case PROP_SHELL_SETTINGS:
+ g_value_set_object (
+ value, e_shell_get_shell_settings (
+ E_SHELL (object)));
+ return;
}
- g_free (priv->iid);
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
-impl_finalize (GObject *object)
+shell_dispose (GObject *object)
{
- EShell *shell;
EShellPrivate *priv;
- shell = E_SHELL (object);
- priv = shell->priv;
+ priv = E_SHELL_GET_PRIVATE (object);
- g_list_foreach (priv->crash_type_names, (GFunc) g_free, NULL);
- g_list_free (priv->crash_type_names);
-
- g_free (priv);
+ if (priv->settings != NULL) {
+ g_object_unref (priv->settings);
+ priv->settings = NULL;
+ }
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
+ if (priv->gconf_client != NULL) {
+ g_object_unref (priv->gconf_client);
+ priv->gconf_client = NULL;
+ }
+ if (priv->preferences_window != NULL) {
+ g_object_unref (priv->preferences_window);
+ priv->preferences_window = NULL;
+ }
-/* Initialization. */
+ g_list_foreach (
+ priv->loaded_modules,
+ (GFunc) g_type_module_unuse, NULL);
+ g_list_free (priv->loaded_modules);
+ priv->loaded_modules = NULL;
-static void
-e_shell_class_init (EShellClass *klass)
-{
- GObjectClass *object_class;
- POA_GNOME_Evolution_Shell__epv *epv;
-
- parent_class = g_type_class_ref(PARENT_TYPE);
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-
- signals[NO_WINDOWS_LEFT] =
- g_signal_new ("no_windows_left",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EShellClass, no_windows_left),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- signals[LINE_STATUS_CHANGED] =
- g_signal_new ("line_status_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EShellClass, line_status_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
-
- signals[NEW_WINDOW_CREATED] =
- g_signal_new ("new_window_created",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EShellClass, new_window_created),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
-
- epv = & klass->epv;
- epv->createNewWindow = impl_Shell_createNewWindow;
- epv->handleURI = impl_Shell_handleURI;
- epv->setLineStatus = impl_Shell_setLineStatus;
-/* epv->findComponent = impl_Shell_findComponent;*/
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-e_shell_init (EShell *shell)
+shell_finalize (GObject *object)
{
EShellPrivate *priv;
- priv = g_new0 (EShellPrivate, 1);
- priv->line_status = E_SHELL_LINE_STATUS_OFFLINE;
- priv->component_registry = e_component_registry_new ();
+ priv = E_SHELL_GET_PRIVATE (object);
+
+ g_hash_table_destroy (priv->modules_by_name);
+ g_hash_table_destroy (priv->modules_by_scheme);
- shell->priv = priv;
+ /* Indicates a clean shut down to the next session. */
+ if (!unique_app_is_running (UNIQUE_APP (object)))
+ e_file_lock_destroy ();
- priv->line_status_listener = evolution_listener_new(set_line_status_complete, shell);
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-detect_version (GConfClient *gconf, int *major, int *minor, int *revision)
+shell_constructed (GObject *object)
{
- char *val, *evolution_dir;
- struct stat st;
-
- evolution_dir = g_build_filename (g_get_home_dir (), "evolution", NULL);
-
- val = gconf_client_get_string(gconf, "/apps/evolution/version", NULL);
- if (val) {
- /* Since 1.4.0 We've been keeping the version key in gconf */
- sscanf(val, "%d.%d.%d", major, minor, revision);
- g_free(val);
- } else if (g_lstat (evolution_dir, &st) != 0 || !S_ISDIR (st.st_mode)) {
- /* If ~/evolution does not exit or is not a directory it must be a new installation */
- *major = 0;
- *minor = 0;
- *revision = 0;
- } else {
- xmlDocPtr config_doc;
- xmlNodePtr source;
- char *tmp;
-
- tmp = g_build_filename (evolution_dir, "config.xmldb", NULL);
- config_doc = e_xml_parse_file (tmp);
- g_free (tmp);
- tmp = NULL;
-
- if (config_doc
- && (source = e_bconf_get_path (config_doc, "/Shell"))
- && (tmp = e_bconf_get_value (source, "upgrade_from_1_0_to_1_2_performed"))
- && tmp[0] == '1' ) {
- *major = 1;
- *minor = 2;
- *revision = 0;
- } else {
- *major = 1;
- *minor = 0;
- *revision = 0;
- }
- g_free (tmp);
- if (config_doc)
- xmlFreeDoc (config_doc);
- }
+ /* UniqueApp will have by this point determined whether we're
+ * the only Evolution process running. If so, proceed normally.
+ * Otherwise we just issue commands to the other process. */
+ if (unique_app_is_running (UNIQUE_APP (object)))
+ return;
- g_free (evolution_dir);
+ e_file_lock_create ();
+
+ shell_load_modules (E_SHELL (object));
+ e_shell_migrate_attempt (E_SHELL (object));
}
-/* calls components to perform upgrade */
static gboolean
-attempt_upgrade (EShell *shell, int major, int minor, int revision)
+shell_message_handle_new (EShell *shell,
+ UniqueMessageData *data)
{
- GSList *component_infos, *p;
- gboolean success;
- int res;
-
- success = TRUE;
-
- component_infos = e_component_registry_peek_list (shell->priv->component_registry);
- for (p = component_infos; success && p != NULL; p = p->next) {
- const EComponentInfo *info = p->data;
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- GNOME_Evolution_Component_upgradeFromVersion (info->iface, major, minor, revision, &ev);
-
- if (BONOBO_EX (&ev)) {
- char *exception_text;
- CORBA_char *id = CORBA_exception_id(&ev);
-
- if (strcmp (id, ex_CORBA_NO_IMPLEMENT) == 0) {
- /* Ignore components that do not implement this version, it
- might just mean that they don't need an upgrade path. */
- } else if (strcmp (id, ex_GNOME_Evolution_Component_UpgradeFailed) == 0) {
- GNOME_Evolution_Component_UpgradeFailed *ex = CORBA_exception_value(&ev);
-
- res = e_error_run(NULL, "shell:upgrade-failed", ex->what, ex->why, NULL);
- if (res == GTK_RESPONSE_CANCEL)
- success = FALSE;
- } else if (strcmp (id, ex_GNOME_Evolution_Component_UnsupportedVersion) == 0) {
- /* This is non-fatal */
- /* DO WE CARE??? */
- printf("Upgrade of component failed, unsupported prior version\n");
- } else {
- exception_text = bonobo_exception_get_text (&ev);
- res = e_error_run(NULL, "shell:upgrade-failed", exception_text, _("Unknown system error."), NULL);
- g_free (exception_text);
- if (res == GTK_RESPONSE_CANCEL)
- success = FALSE;
- }
- }
- CORBA_exception_free (&ev);
- }
+ gchar *view_name;
- return success;
+ view_name = unique_message_data_get_text (data);
+ e_shell_create_shell_window (shell, view_name);
+ g_free (view_name);
+
+ return TRUE;
}
-/**
- * e_shell_construct:
- * @shell: An EShell object to construct
- * @iid: OAFIID for registering the shell into the name server
- * @startup_line_mode: How to set up the line mode (online or offline) initally.
- *
- * Construct @shell so that it uses the specified @corba_object.
- *
- * Return value: The result of the operation.
- **/
-EShellConstructResult
-e_shell_construct (EShell *shell,
- const char *iid,
- EShellStartupLineMode startup_line_mode)
+static gboolean
+shell_message_handle_open (EShell *shell,
+ UniqueMessageData *data)
{
- EShellPrivate *priv;
- CORBA_Object corba_object;
- gboolean start_online;
- GSList *component;
-
- g_return_val_if_fail (E_IS_SHELL (shell), E_SHELL_CONSTRUCT_RESULT_INVALIDARG);
- g_return_val_if_fail (startup_line_mode == E_SHELL_STARTUP_LINE_MODE_CONFIG
- || startup_line_mode == E_SHELL_STARTUP_LINE_MODE_ONLINE
- || startup_line_mode == E_SHELL_STARTUP_LINE_MODE_OFFLINE,
- E_SHELL_CONSTRUCT_RESULT_INVALIDARG);
-
- priv = shell->priv;
- priv->iid = g_strdup (iid);
-
- /* Now we can register into OAF. Notice that we shouldn't be
- registering into OAF until we are sure we can complete. */
-
- /* FIXME: Multi-display stuff. */
- corba_object = bonobo_object_corba_objref (BONOBO_OBJECT (shell));
- if (bonobo_activation_active_server_register (iid, corba_object) != Bonobo_ACTIVATION_REG_SUCCESS)
- return E_SHELL_CONSTRUCT_RESULT_CANNOTREGISTER;
-
- while (gtk_events_pending ())
- gtk_main_iteration ();
-
- /* activate all the components (peek list does this implictly) */
- /* Do we really need to assign the result of this to the list? */
- component = e_component_registry_peek_list (shell->priv->component_registry);
-
- e_shell_attempt_upgrade(shell);
-
- priv->is_initialized = TRUE;
-
- switch (startup_line_mode) {
- case E_SHELL_STARTUP_LINE_MODE_CONFIG:
- start_online = ! get_config_start_offline ();
- break;
- case E_SHELL_STARTUP_LINE_MODE_ONLINE:
- start_online = TRUE;
- break;
- case E_SHELL_STARTUP_LINE_MODE_OFFLINE:
- start_online = FALSE;
- break;
- default:
- start_online = FALSE; /* Make compiler happy. */
- g_return_val_if_reached(E_SHELL_CONSTRUCT_RESULT_OK);
- }
+ gchar **uris;
- e_passwords_set_online(start_online);
+ uris = unique_message_data_get_uris (data);
+ e_shell_handle_uris (shell, uris);
+ g_strfreev (uris);
- if (start_online)
- e_shell_set_line_status (shell, GNOME_Evolution_USER_ONLINE);
- else
- e_shell_set_line_status (shell, GNOME_Evolution_USER_OFFLINE);
+ return TRUE;
+}
- return E_SHELL_CONSTRUCT_RESULT_OK;
+static gboolean
+shell_message_handle_close (EShell *shell,
+ UniqueMessageData *data)
+{
+ e_shell_quit (shell);
+
+ return TRUE;
}
-/**
- * e_shell_new:
- * @start_online: Whether to start in on-line mode or not.
- * @construct_result_return: A pointer to an EShellConstructResult variable into
- * which the result of the operation will be stored.
- *
- * Create a new EShell.
- *
- * Return value:
- **/
-EShell *
-e_shell_new (EShellStartupLineMode startup_line_mode,
- EShellConstructResult *construct_result_return)
+static UniqueResponse
+shell_message_received (UniqueApp *app,
+ gint command,
+ UniqueMessageData *data,
+ guint time_)
{
- EShell *new;
- EShellConstructResult construct_result;
+ EShell *shell = E_SHELL (app);
- new = g_object_new (e_shell_get_type (), NULL);
+ switch (command) {
+ case UNIQUE_ACTIVATE:
+ break; /* use the default behavior */
- construct_result = e_shell_construct (new, E_SHELL_OAFIID, startup_line_mode);
+ case UNIQUE_NEW:
+ if (shell_message_handle_new (shell, data))
+ return UNIQUE_RESPONSE_OK;
+ break;
- if (construct_result != E_SHELL_CONSTRUCT_RESULT_OK) {
- *construct_result_return = construct_result;
- bonobo_object_unref (BONOBO_OBJECT (new));
- return NULL;
- }
+ case UNIQUE_OPEN:
+ if (shell_message_handle_open (shell, data))
+ return UNIQUE_RESPONSE_OK;
+ break;
- *construct_result_return = E_SHELL_CONSTRUCT_RESULT_OK;
- return new;
-}
+ case UNIQUE_CLOSE:
+ if (shell_message_handle_close (shell, data))
+ return UNIQUE_RESPONSE_OK;
+ break;
-static int
-remove_dir(const char *root, const char *path)
-{
- GDir *dir;
- const char *dname;
- int res = -1;
- char *new = NULL;
- struct stat st;
-
- dir = g_dir_open(path, 0, NULL);
- if (dir == NULL)
- return -1;
-
- while ( (dname = g_dir_read_name(dir)) ) {
- new = g_build_filename(path, dname, NULL);
- if (g_stat(new, &st) == -1)
- goto fail;
-
- /* make sure we're really removing something from evolution dir */
- g_return_val_if_fail (strlen(path) >= strlen(root)
- && strncmp(root, path, strlen(root)) == 0, -1);
-
- if (S_ISDIR(st.st_mode)) {
- if (remove_dir(root, new) == -1)
- goto fail;
- } else {
- if (g_unlink(new) == -1)
- goto fail;
- }
- g_free(new);
- new = NULL;
+ default:
+ break;
}
- res = g_rmdir(path);
-fail:
- g_free(new);
- g_dir_close(dir);
- return res;
+ /* Chain up to parent's message_received() method. */
+ return UNIQUE_APP_CLASS (parent_class)->
+ message_received (app, command, data, time_);
}
-/**
- * e_shell_attempt_upgrade:
- * @shell:
- *
- * Upgrade config and components from the currently installed version.
- *
- * Return value: %TRUE If it works. If it fails the application will exit.
- **/
-gboolean
-e_shell_attempt_upgrade (EShell *shell)
+static void
+shell_class_init (EShellClass *class)
{
- GConfClient *gconf_client;
- int major = 0, minor = 0, revision = 0;
- int lmajor, lminor, lrevision;
- int cmajor, cminor, crevision;
- char *version_string, *last_version = NULL;
- int done_upgrade = FALSE;
- char *oldpath;
- struct stat st;
- ESEvent *ese;
-
- gconf_client = gconf_client_get_default();
-
- oldpath = g_build_filename(g_get_home_dir(), "evolution", NULL);
-
- g_return_val_if_fail (sscanf(BASE_VERSION, "%u.%u", &cmajor, &cminor) == 2, TRUE);
- crevision = atoi(UPGRADE_REVISION);
-
- detect_version (gconf_client, &major, &minor, &revision);
-
- if (!(cmajor > major
- || (cmajor == major && cminor > minor)
- || (cminor == minor && crevision > revision)))
- goto check_old;
-
- /* if upgrading from < 1.5, we need to copy most data from ~/evolution to ~/.evolution */
- if (major == 1 && minor < 5) {
- long size, space;
-
- size = e_fsutils_usage(oldpath);
- space = e_fsutils_avail(g_get_home_dir());
- if (size != -1 && space != -1 && space < size) {
- char *required = g_strdup_printf(_("%ld KB"), size);
- char *have = g_strdup_printf(_("%ld KB"), space);
-
- e_error_run(NULL, "shell:upgrade-nospace", required, have, NULL);
- g_free(required);
- g_free(have);
- _exit(0);
- }
- }
+ GObjectClass *object_class;
+ UniqueAppClass *unique_app_class;
- if (!attempt_upgrade (shell, major, minor, revision))
- _exit(0);
-
- /* mark as upgraded */
- version_string = g_strdup_printf ("%s.%s", BASE_VERSION, UPGRADE_REVISION);
- gconf_client_set_string (gconf_client, "/apps/evolution/version", version_string, NULL);
- done_upgrade = TRUE;
-
-check_old:
- /* if the last upgraded version was old, check for stuff to remove */
- if (done_upgrade
- || (last_version = gconf_client_get_string (gconf_client, "/apps/evolution/last_version", NULL)) == NULL
- || sscanf(last_version, "%d.%d.%d", &lmajor, &lminor, &lrevision) != 3) {
- lmajor = major;
- lminor = minor;
- lrevision = revision;
- }
- g_free(last_version);
-
- if (lmajor == 1 && lminor < 5
- && g_stat(oldpath, &st) == 0
- && S_ISDIR(st.st_mode)) {
- int res;
-
- last_version = g_strdup_printf("%d.%d.%d", lmajor, lminor, lrevision);
- res = e_error_run(NULL, "shell:upgrade-remove-1-4", last_version, NULL);
- g_free(last_version);
-
- switch (res) {
- case GTK_RESPONSE_OK: /* 'delete' */
- if (e_error_run(NULL, "shell:upgrade-remove-1-4-confirm", NULL) == GTK_RESPONSE_OK)
- remove_dir(oldpath, oldpath);
- else
- break;
- /* falls through */
- case GTK_RESPONSE_ACCEPT: /* 'keep' */
- lmajor = cmajor;
- lminor = cminor;
- lrevision = crevision;
- break;
- default:
- /* cancel - noop */
- break;
- }
- } else {
- /* otherwise 'last version' is now the same as current */
- lmajor = cmajor;
- lminor = cminor;
- lrevision = crevision;
- }
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EShellPrivate));
- last_version = g_strdup_printf("%d.%d.%d", lmajor, lminor, lrevision);
- gconf_client_set_string (gconf_client, "/apps/evolution/last_version", last_version, NULL);
- g_free(last_version);
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = shell_set_property;
+ object_class->get_property = shell_get_property;
+ object_class->dispose = shell_dispose;
+ object_class->finalize = shell_finalize;
+ object_class->constructed = shell_constructed;
- g_free(oldpath);
- g_object_unref (gconf_client);
+ unique_app_class = UNIQUE_APP_CLASS (class);
+ unique_app_class->message_received = shell_message_received;
- /** @Event: Shell attempted upgrade
- * @Id: upgrade.done
- * @Target: ESMenuTargetState
+ /**
+ * EShell:network-available
*
- * This event is emitted whenever the shell successfully attempts an upgrade.
+ * Whether the network is available.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_NETWORK_AVAILABLE,
+ g_param_spec_boolean (
+ "network-available",
+ _("Network Available"),
+ _("Whether the network is available"),
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ /**
+ * EShell:online
*
- */
- ese = es_event_peek();
- e_event_emit((EEvent *)ese, "upgrade.done", (EEventTarget *)es_event_target_new_upgrade(ese, cmajor, cminor, crevision));
-
- return TRUE;
+ * Whether the shell is online.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_ONLINE,
+ g_param_spec_boolean (
+ "online",
+ _("Online"),
+ _("Whether the shell is online"),
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ /**
+ * EShell:settings
+ *
+ * The #EShellSettings object stores application settings.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL_SETTINGS,
+ g_param_spec_object (
+ "shell-settings",
+ _("Shell Settings"),
+ _("Application-wide settings"),
+ E_TYPE_SHELL_SETTINGS,
+ G_PARAM_READABLE));
+
+ /**
+ * EShell::event
+ * @shell: the #EShell which emitted the signal
+ * @event_data: data associated with the event
+ *
+ * This signal is used to broadcast custom events to the entire
+ * application. The nature of @event_data depends on the event
+ * being broadcast. The signal's detail denotes the event.
+ **/
+ signals[EVENT] = g_signal_new (
+ "event",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_DETAILED | G_SIGNAL_ACTION,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
+
+ /**
+ * EShell::handle-uri
+ * @shell: the #EShell which emitted the signal
+ * @uri: the URI to be handled
+ *
+ * Emitted when @shell receives a URI to be handled, usually by
+ * way of a command-line argument. An #EShellModule should listen
+ * for this signal and try to handle the URI, usually by opening an
+ * editor window for the identified resource.
+ *
+ * Returns: %TRUE if the URI could be handled, %FALSE otherwise
+ **/
+ signals[HANDLE_URI] = g_signal_new (
+ "handle-uri",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0, g_signal_accumulator_true_handled, NULL,
+ e_marshal_BOOLEAN__STRING,
+ G_TYPE_BOOLEAN, 1,
+ G_TYPE_STRING);
+
+ /**
+ * EShell::prepare-for-offline
+ * @shell: the #EShell which emitted the signal
+ * @activity: the #EActivity for offline preparations
+ *
+ * Emitted when the user elects to work offline. An #EShellModule
+ * should listen for this signal and make preparations for working
+ * in offline mode.
+ *
+ * If preparations for working offline cannot immediately be
+ * completed (such as when synchronizing with a remote server),
+ * the #EShellModule should reference the @activity until
+ * preparations are complete, and then unreference the @activity.
+ * This will delay Evolution from actually going to offline mode
+ * until all modules have unreferenced @activity.
+ **/
+ signals[PREPARE_FOR_OFFLINE] = g_signal_new (
+ "prepare-for-offline",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ E_TYPE_ACTIVITY);
+
+ /**
+ * EShell::prepare-for-online
+ * @shell: the #EShell which emitted the signal
+ * @activity: the #EActivity for offline preparations
+ *
+ * Emitted when the user elects to work online. An #EShellModule
+ * should listen for this signal and make preparations for working
+ * in online mode.
+ *
+ * If preparations for working online cannot immediately be
+ * completed (such as when re-connecting to a remote server), the
+ * #EShellModule should reference the @activity until preparations
+ * are complete, and then unreference the @activity. This will
+ * delay Evolution from actually going to online mode until all
+ * modules have unreferenced @activity.
+ **/
+ signals[PREPARE_FOR_ONLINE] = g_signal_new (
+ "prepare-for-online",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ E_TYPE_ACTIVITY);
+
+ /**
+ * EShell::send-receive
+ * @shell: the #EShell which emitted the signal
+ * @parent: a parent #GtkWindow
+ *
+ * Emitted when the user chooses the "Send / Receive" action.
+ * The parent window can be used for showing transient windows.
+ **/
+ signals[SEND_RECEIVE] = g_signal_new (
+ "send-receive",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_WINDOW);
+
+ /**
+ * EShell::window-created
+ * @shell: the #EShell which emitted the signal
+ * @window: the newly created #GtkWindow
+ *
+ * Emitted when @shell begins watching a newly created window.
+ **/
+ signals[WINDOW_CREATED] = g_signal_new (
+ "window-created",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_WINDOW);
+
+ /**
+ * EShell::window-destroyed
+ * @shell: the #EShell which emitted the signal
+ *
+ * Emitted when a watched is destroyed.
+ **/
+ signals[WINDOW_DESTROYED] = g_signal_new (
+ "window-destroyed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /* Install some application-wide settings. */
+
+ e_shell_settings_install_property (
+ g_param_spec_boolean (
+ "disable-application-handlers",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+
+ e_shell_settings_install_property (
+ g_param_spec_boolean (
+ "disable-command-line",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+
+ e_shell_settings_install_property (
+ g_param_spec_boolean (
+ "disable-printing",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+
+ e_shell_settings_install_property (
+ g_param_spec_boolean (
+ "disable-print-setup",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+
+ e_shell_settings_install_property (
+ g_param_spec_boolean (
+ "disable-save-to-disk",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
+
+ e_shell_settings_install_property (
+ g_param_spec_string (
+ "file-chooser-folder",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
}
-/**
- * e_shell_create_window:
- * @shell: The shell for which to create a new window.
- * @component_id: Id or alias of the component to display in the new window.
- * @template_window: Window from which to copy the window settings (can be %NULL).
- *
- * Create a new window for @uri.
- *
- * Return value: The new window.
- **/
-EShellWindow *
-e_shell_create_window (EShell *shell,
- const char *component_id,
- EShellWindow *template_window)
+static void
+shell_init (EShell *shell)
{
- EShellWindow *window;
+ GHashTable *modules_by_name;
+ GHashTable *modules_by_scheme;
- /* FIXME need to actually copy settings from template_window. */
+ shell->priv = E_SHELL_GET_PRIVATE (shell);
- g_return_val_if_fail (shell != NULL, NULL);
- g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+ modules_by_name = g_hash_table_new (g_str_hash, g_str_equal);
+ modules_by_scheme = g_hash_table_new (g_str_hash, g_str_equal);
- window = E_SHELL_WINDOW (e_shell_window_new (shell, component_id));
+ shell->priv->settings = g_object_new (E_TYPE_SHELL_SETTINGS, NULL);
+ shell->priv->gconf_client = gconf_client_get_default ();
+ shell->priv->preferences_window = e_preferences_window_new ();
+ shell->priv->modules_by_name = modules_by_name;
+ shell->priv->modules_by_scheme = modules_by_scheme;
+ shell->priv->safe_mode = e_file_lock_exists ();
- g_signal_connect (window, "delete_event", G_CALLBACK (window_delete_event_cb), shell);
- g_object_weak_ref (G_OBJECT (window), window_weak_notify, shell);
- shell->priv->windows = g_list_prepend (shell->priv->windows, window);
+ g_object_ref_sink (shell->priv->preferences_window);
- g_signal_emit (shell, signals[NEW_WINDOW_CREATED], 0, window);
+#if NM_SUPPORT
+ e_shell_dbus_initialize (shell);
+#endif
- gtk_widget_show (GTK_WIDGET (window));
+ shell_parse_debug_string (shell);
- e_error_default_parent((GtkWindow *)window);
+ g_signal_connect (
+ shell, "notify::online",
+ G_CALLBACK (shell_notify_online_cb), NULL);
- set_interactive (shell, TRUE);
+ e_shell_settings_bind_to_gconf (
+ shell->priv->settings, "disable-application-handlers",
+ "/desktop/gnome/lockdown/disable_application_handlers");
- if (!session_started) {
- ESEvent *ese;
+ e_shell_settings_bind_to_gconf (
+ shell->priv->settings, "disable-command-line",
+ "/desktop/gnome/lockdown/disable_command_line");
- session_started = TRUE;
- ese = es_event_peek();
- e_event_emit((EEvent *)ese, "started.done", (EEventTarget *)es_event_target_new_shell(ese, shell));
- }
- return window;
-}
+ e_shell_settings_bind_to_gconf (
+ shell->priv->settings, "disable-printing",
+ "/desktop/gnome/lockdown/disable_printing");
-gboolean
-e_shell_request_close_window (EShell *shell,
- EShellWindow *shell_window)
-{
- g_return_val_if_fail (E_IS_SHELL (shell), FALSE);
- g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), FALSE);
+ e_shell_settings_bind_to_gconf (
+ shell->priv->settings, "disable-print-setup",
+ "/desktop/gnome/lockdown/disable_print_setup");
- e_shell_save_settings (shell);
+ e_shell_settings_bind_to_gconf (
+ shell->priv->settings, "disable-save-to-disk",
+ "/desktop/gnome/lockdown/disable_save_to_disk");
+}
- if (g_list_length (shell->priv->windows) != 1) {
- /* Not the last window. */
- return TRUE;
+GType
+e_shell_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo type_info = {
+ sizeof (EShellClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) shell_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EShell),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) shell_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ UNIQUE_TYPE_APP, "EShell", &type_info, 0);
}
- return e_shell_quit(shell);
+ return type;
}
-#if 0 /* FIXME */
/**
- * e_shell_peek_uri_schema_registry:
- * @shell: An EShell object.
+ * e_shell_get_default:
+ *
+ * Returns the #EShell created by <function>main()</function>.
*
- * Get the schema registry associated to @shell.
+ * Try to obtain the #EShell from elsewhere if you can. This function
+ * is intended as a temporary workaround for when that proves difficult.
*
- * Return value: A pointer to the EUriSchemaRegistry associated to @shell.
+ * Returns: the #EShell singleton
**/
-EUriSchemaRegistry *
-e_shell_peek_uri_schema_registry (EShell *shell)
+EShell *
+e_shell_get_default (void)
{
- g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+ /* Emit a warning if we call this too early. */
+ g_return_val_if_fail (default_shell != NULL, NULL);
- return shell->priv->uri_schema_registry;
+ return default_shell;
}
-#endif
-
/**
- * e_shell_peek_component_registry:
- * @shell:
+ * e_shell_get_shell_modules:
+ * @shell: an #EShell
*
- * Get the component registry associated to @shell.
+ * Returns a list of loaded #EShellModule instances. The list is
+ * owned by @shell and should not be modified or freed.
*
- * Return value:
+ * Returns: a list of loaded #EShellModule instances
**/
-EComponentRegistry *
-e_shell_peek_component_registry (EShell *shell)
+GList *
+e_shell_get_shell_modules (EShell *shell)
{
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
- return shell->priv->component_registry;
+ return shell->priv->loaded_modules;
}
-
/**
- * e_shell_save_settings:
- * @shell:
+ * e_shell_get_canonical_name:
+ * @shell: an #EShell
+ * @name: the name or alias of an #EShellModule
*
- * Save the settings for this shell.
+ * Returns the canonical name for the #EShellModule whose name or alias
+ * is @name.
*
- * Return value: %TRUE if it worked, %FALSE otherwise. Even if %FALSE is
- * returned, it is possible that at least part of the settings for the windows
- * have been saved.
+ * Returns: the canonical #EShellModule name
**/
-gboolean
-e_shell_save_settings (EShell *shell)
+const gchar *
+e_shell_get_canonical_name (EShell *shell,
+ const gchar *name)
{
- GConfClient *client;
- gboolean is_offline;
+ EShellModule *shell_module;
- is_offline = ( e_shell_get_line_status (shell) == E_SHELL_LINE_STATUS_OFFLINE || e_shell_get_line_status (shell) == E_SHELL_LINE_STATUS_FORCED_OFFLINE);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
- client = gconf_client_get_default ();
- gconf_client_set_bool (client, "/apps/evolution/shell/start_offline", is_offline, NULL);
- g_object_unref (client);
+ /* Handle NULL name arguments silently. */
+ if (name == NULL)
+ return NULL;
- return TRUE;
+ shell_module = e_shell_get_module_by_name (shell, name);
+
+ if (shell_module == NULL)
+ return NULL;
+
+ return G_TYPE_MODULE (shell_module)->name;
}
/**
- * e_shell_close_all_windows:
- * @shell:
+ * e_shell_get_module_by_name:
+ * @shell: an #EShell
+ * @name: the name or alias of an #EShellModule
*
- * Destroy all the windows in @shell.
+ * Returns the corresponding #EShellModule for the given name or alias,
+ * or %NULL if @name is not recognized.
+ *
+ * Returns: the #EShellModule named @name, or %NULL
**/
-void
-e_shell_close_all_windows (EShell *shell)
+EShellModule *
+e_shell_get_module_by_name (EShell *shell,
+ const gchar *name)
{
- EShellPrivate *priv;
- GList *p, *pnext;
+ GHashTable *hash_table;
- g_return_if_fail (shell != NULL);
- g_return_if_fail (E_IS_SHELL (shell));
-
- if (shell->priv->windows)
- e_shell_save_settings (shell);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
- priv = shell->priv;
- for (p = priv->windows; p != NULL; p = pnext) {
- pnext = p->next;
+ hash_table = shell->priv->modules_by_name;
- /* Note that this will also remove the window from the list... Hence the
- need for the pnext variable. */
- gtk_widget_destroy (GTK_WIDGET (p->data));
- }
+ return g_hash_table_lookup (hash_table, name);
}
/**
- * e_shell_get_line_status:
- * @shell: A pointer to an EShell object.
+ * e_shell_get_module_by_scheme:
+ * @shell: an #EShell
+ * @scheme: a URI scheme
*
- * Get the line status for @shell.
+ * Returns the #EShellModule that implements the given URI scheme,
+ * or %NULL if @scheme is not recognized.
*
- * Return value: The current line status for @shell.
+ * Returns: the #EShellModule that implements @scheme, or %NULL
**/
-EShellLineStatus
-e_shell_get_line_status (EShell *shell)
+EShellModule *
+e_shell_get_module_by_scheme (EShell *shell,
+ const gchar *scheme)
{
- g_return_val_if_fail (shell != NULL, E_SHELL_LINE_STATUS_OFFLINE);
- g_return_val_if_fail (E_IS_SHELL (shell), E_SHELL_LINE_STATUS_OFFLINE);
-
- return shell->priv->line_status;
-}
+ GHashTable *hash_table;
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+ g_return_val_if_fail (scheme != NULL, NULL);
-/* Offline/online handling. */
+ hash_table = shell->priv->modules_by_scheme;
-static void
-set_line_status_finished(EShell *shell)
+ return g_hash_table_lookup (hash_table, scheme);
+}
+/**
+ * e_shell_get_shell_settings:
+ * @shell: an #EShell
+ *
+ * Returns the #EShellSettings instance for @shell.
+ *
+ * Returns: the #EShellSettings instance for @shell
+ **/
+EShellSettings *
+e_shell_get_shell_settings (EShell *shell)
{
- EShellPrivate *priv = shell->priv;
- ESEvent *ese;
-
- priv->line_status = priv->line_status_working;
-
- e_passwords_set_online (priv->line_status == E_SHELL_LINE_STATUS_ONLINE);
- g_signal_emit (shell, signals[LINE_STATUS_CHANGED], 0, priv->line_status);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
- /** @Event: Shell online state changed
- * @Id: state.changed
- * @Target: ESMenuTargetState
- *
- * This event is emitted whenever the shell online state changes.
- *
- * Only the online and offline states are emitted.
- */
- ese = es_event_peek();
- e_event_emit((EEvent *)ese, "state.changed", (EEventTarget *)es_event_target_new_state(ese, priv->line_status == E_SHELL_LINE_STATUS_ONLINE));
+ return shell->priv->settings;
}
-static void
-set_line_status_complete(EvolutionListener *el, void *data)
+/**
+ * e_shell_get_gconf_client:
+ * @shell: an #EShell
+ *
+ * Returns the default #GConfClient. This function is purely for
+ * convenience. The @shell owns the reference so you don't have to.
+ *
+ * Returns: the default #GConfClient
+ **/
+GConfClient *
+e_shell_get_gconf_client (EShell *shell)
{
- EShell *shell = data;
- EShellPrivate *priv = shell->priv;
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
- if (priv->line_status_pending > 0) {
- priv->line_status_pending--;
- if (priv->line_status_pending == 0)
- set_line_status_finished(shell);
- }
+ return shell->priv->gconf_client;
}
-void
-e_shell_set_line_status (EShell *shell,
- GNOME_Evolution_ShellState shell_state)
+/**
+ * e_shell_create_shell_window:
+ * @shell: an #EShell
+ * @view_name: name of the initial shell view, or %NULL
+ *
+ * Creates a new #EShellWindow and emits the #EShell::window-created
+ * signal. Use this function instead of e_shell_window_new() so that
+ * @shell can track the window.
+ *
+ * Returns: a new #EShellWindow
+ **/
+GtkWidget *
+e_shell_create_shell_window (EShell *shell,
+ const gchar *view_name)
{
- EShellPrivate *priv;
- GSList *component_infos;
- GSList *p;
- CORBA_Environment ev;
- GConfClient *client;
- gboolean status;
- gboolean forced = FALSE;
-
- priv = shell->priv;
-
- if (shell_state == GNOME_Evolution_FORCED_OFFLINE || shell_state == GNOME_Evolution_USER_OFFLINE) {
- status = FALSE;
- if (shell_state == GNOME_Evolution_FORCED_OFFLINE)
- forced = TRUE;
- } else
- status = TRUE;
-
- if ((status && priv->line_status == E_SHELL_LINE_STATUS_ONLINE)
- || (!status && priv->line_status == E_SHELL_LINE_STATUS_OFFLINE && !forced))
- return;
+ GtkWidget *shell_window;
+ UniqueMessageData *data;
+ UniqueApp *app;
- /* we use 'going offline' to mean 'changing status' now */
- priv->line_status = E_SHELL_LINE_STATUS_GOING_OFFLINE;
- g_signal_emit (shell, signals[LINE_STATUS_CHANGED], 0, priv->line_status);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
- client = gconf_client_get_default ();
- gconf_client_set_bool (client, "/apps/evolution/shell/start_offline", !status, NULL);
- g_object_unref (client);
+ app = UNIQUE_APP (shell);
- priv->line_status_working = status?E_SHELL_LINE_STATUS_ONLINE: forced?E_SHELL_LINE_STATUS_FORCED_OFFLINE:E_SHELL_LINE_STATUS_OFFLINE;
- /* we start at 2: setLineStatus could recursively call back, we therefore
- `need to not complete till we're really complete */
- priv->line_status_pending += 2;
+ if (unique_app_is_running (app))
+ goto unique;
- component_infos = e_component_registry_peek_list (priv->component_registry);
- for (p = component_infos; p != NULL; p = p->next) {
- EComponentInfo *info = p->data;
+ view_name = e_shell_get_canonical_name (shell, view_name);
- CORBA_exception_init (&ev);
+ /* EShellWindow initializes its active view from a GConf key,
+ * so set the key ahead of time to control the intial view. */
+ if (view_name != NULL) {
+ GConfClient *client;
+ const gchar *key;
+ GError *error = NULL;
- GNOME_Evolution_Component_setLineStatus(info->iface, shell_state, bonobo_object_corba_objref((BonoboObject *)priv->line_status_listener), &ev);
- if (ev._major == CORBA_NO_EXCEPTION)
- priv->line_status_pending++;
+ client = e_shell_get_gconf_client (shell);
+ key = "/apps/evolution/shell/view_defaults/component_id";
+ gconf_client_set_string (client, key, view_name, &error);
- CORBA_exception_free (&ev);
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
}
- priv->line_status_pending -= 2;
- if (priv->line_status_pending == 0)
- set_line_status_finished(shell);
-}
+ shell_window = e_shell_window_new (shell, shell->priv->safe_mode);
-gboolean
-e_shell_get_crash_recovery (EShell *shell)
-{
- g_return_val_if_fail (E_IS_SHELL (shell), FALSE);
+ gtk_widget_show (shell_window);
- return shell->priv->crash_recovery;
-}
+ return shell_window;
-void
-e_shell_set_crash_recovery (EShell *shell,
- gboolean crash_recovery)
-{
- g_return_if_fail (E_IS_SHELL (shell));
+unique: /* Send a message to the other Evolution process. */
+
+ /* XXX Do something with UniqueResponse? */
- shell->priv->crash_recovery = crash_recovery;
+ if (view_name != NULL) {
+ data = unique_message_data_new ();
+ unique_message_data_set_text (data, view_name, -1);
+ unique_app_send_message (app, UNIQUE_NEW, data);
+ unique_message_data_free (data);
+ } else
+ unique_app_send_message (app, UNIQUE_ACTIVATE, NULL);
+
+ return NULL;
}
-void
-e_shell_send_receive (EShell *shell)
+/**
+ * e_shell_handle_uris:
+ * @shell: an #EShell
+ * @uris: %NULL-terminated list of URIs
+ *
+ * Emits the #EShell::handle-uri signal for each URI.
+ *
+ * Returns: the number of URIs successfully handled
+ **/
+guint
+e_shell_handle_uris (EShell *shell,
+ gchar **uris)
{
- GSList *component_list;
- GSList *p;
+ UniqueApp *app;
+ UniqueMessageData *data;
+ guint n_handled = 0;
+ gint ii;
- g_return_if_fail (E_IS_SHELL (shell));
+ g_return_val_if_fail (E_IS_SHELL (shell), FALSE);
+ g_return_val_if_fail (uris != NULL, FALSE);
- component_list = e_component_registry_peek_list (shell->priv->component_registry);
+ app = UNIQUE_APP (shell);
- for (p = component_list; p != NULL; p = p->next) {
- EComponentInfo *info = p->data;
- CORBA_Environment ev;
+ if (unique_app_is_running (app))
+ goto unique;
- CORBA_exception_init (&ev);
+ for (ii = 0; uris[ii] != NULL; ii++) {
+ gboolean handled;
- GNOME_Evolution_Component_sendAndReceive (info->iface, &ev);
+ g_signal_emit (
+ shell, signals[HANDLE_URI],
+ 0, uris[ii], &handled);
+ n_handled += handled ? 1 : 0;
+ }
- /* Ignore errors, the components can decide to not implement
- this interface. */
+ return n_handled;
- CORBA_exception_free (&ev);
- }
-}
+unique: /* Send a message to the other Evolution process. */
+ /* XXX Do something with UniqueResponse? */
+
+ data = unique_message_data_new ();
+ unique_message_data_set_uris (data, uris);
+ unique_app_send_message (app, UNIQUE_OPEN, data);
+ unique_message_data_free (data);
+
+ return 0;
+}
+/**
+ * e_shell_watch_window:
+ * @shell: an #EShell
+ * @window: a #GtkWindow
+ *
+ * Makes @shell "watch" a newly created toplevel window, and emits the
+ * #EShell::window-created signal. All #EShellWindow<!-- -->s should be
+ * watched, along with any editor or viewer windows that may be shown in
+ * response to e_shell_handle_uris(). When the last watched window is
+ * closed, Evolution terminates.
+ **/
void
-e_shell_show_settings (EShell *shell,
- const char *type,
- EShellWindow *shell_window)
+e_shell_watch_window (EShell *shell,
+ GtkWindow *window)
{
- EShellPrivate *priv;
+ GList *list;
- g_return_if_fail (shell != NULL);
g_return_if_fail (E_IS_SHELL (shell));
+ g_return_if_fail (GTK_IS_WINDOW (window));
- priv = shell->priv;
+ list = shell->priv->watched_windows;
- if (priv->settings_dialog.widget != NULL) {
- gdk_window_show (priv->settings_dialog.widget->window);
- gtk_widget_grab_focus (priv->settings_dialog.widget);
+ /* Ignore duplicates. */
+ if (g_list_find (list, window) != NULL)
return;
- }
- priv->settings_dialog.widget = e_shell_settings_dialog_new ();
+ list = g_list_prepend (list, window);
+ shell->priv->watched_windows = list;
- if (type != NULL)
- e_shell_settings_dialog_show_type (E_SHELL_SETTINGS_DIALOG (priv->settings_dialog.widget), type);
+ unique_app_watch_window (UNIQUE_APP (shell), window);
- g_object_add_weak_pointer (G_OBJECT (priv->settings_dialog.widget), &priv->settings_dialog.pointer);
+ g_signal_connect_swapped (
+ window, "delete-event",
+ G_CALLBACK (shell_window_delete_event_cb), shell);
- gtk_window_set_transient_for (GTK_WINDOW (priv->settings_dialog.widget), GTK_WINDOW (shell_window));
- gtk_widget_show (priv->settings_dialog.widget);
-}
+ g_signal_connect_swapped (
+ window, "focus-in-event",
+ G_CALLBACK (shell_window_focus_in_event_cb), shell);
+ g_object_weak_ref (
+ G_OBJECT (window), (GWeakNotify)
+ shell_window_weak_notify_cb, shell);
-const char *
-e_shell_construct_result_to_string (EShellConstructResult result)
-{
- switch (result) {
- case E_SHELL_CONSTRUCT_RESULT_OK:
- return _("OK");
- case E_SHELL_CONSTRUCT_RESULT_INVALIDARG:
- return _("Invalid arguments");
- case E_SHELL_CONSTRUCT_RESULT_CANNOTREGISTER:
- return _("Cannot register on OAF");
- case E_SHELL_CONSTRUCT_RESULT_NOCONFIGDB:
- return _("Configuration Database not found");
- case E_SHELL_CONSTRUCT_RESULT_GENERICERROR:
- return _("Generic error");
- default:
- return _("Unknown error");
- }
+ g_signal_emit (shell, signals[WINDOW_CREATED], 0, window);
}
-/* timeout handler, so returns TRUE if we can't quit yet */
-static gboolean
-es_run_quit(EShell *shell)
+/**
+ * e_shell_get_watched_windows:
+ * @shell: an #EShell
+ *
+ * Returns a list of windows being watched by @shell. The list is sorted
+ * by the most recently focused window, such that the first instance is the
+ * currently focused window. (Useful for choosing a parent for a transient
+ * window.) The list is owned by @shell and should not be modified or freed.
+ *
+ * Returns: a list of watched windows
+ **/
+GList *
+e_shell_get_watched_windows (EShell *shell)
{
- EShellPrivate *priv;
- GSList *component_infos;
- GSList *sp;
- CORBA_boolean done_quit;
-
- g_return_val_if_fail (E_IS_SHELL (shell), FALSE);
-
- priv = shell->priv;
- priv->preparing_to_quit = TRUE;
-
- component_infos = e_component_registry_peek_list (priv->component_registry);
- done_quit = TRUE;
- for (sp = component_infos; sp != NULL; sp = sp->next) {
- EComponentInfo *info = sp->data;
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- done_quit = GNOME_Evolution_Component_quit(info->iface, &ev);
- if (BONOBO_EX (&ev)) {
- /* The component might not implement the interface, in which case we assume we can quit. */
- done_quit = TRUE;
- }
-
- CORBA_exception_free (&ev);
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
- if (!done_quit)
- break;
- }
+ return shell->priv->watched_windows;
+}
- if (done_quit) {
- if (priv->quit_timeout) {
- g_source_remove(priv->quit_timeout);
- priv->quit_timeout = 0;
- }
- e_shell_close_all_windows(shell);
- } else if (priv->quit_timeout == 0) {
- priv->quit_timeout = g_timeout_add(500, (GSourceFunc)es_run_quit, shell);
- }
+/**
+ * e_shell_send_receive:
+ * @shell: an #EShell
+ * @parent: the parent #GtkWindow
+ *
+ * Emits the #EShell::send-receive signal.
+ **/
+void
+e_shell_send_receive (EShell *shell,
+ GtkWindow *parent)
+{
+ g_return_if_fail (E_IS_SHELL (shell));
+ g_return_if_fail (GTK_IS_WINDOW (parent));
- return !done_quit;
+ g_signal_emit (shell, signals[SEND_RECEIVE], 0, parent);
}
+/**
+ * e_shell_get_network_available:
+ * @shell: an #EShell
+ *
+ * Returns %TRUE if a network is available.
+ *
+ * Returns: %TRUE if a network is available
+ **/
gboolean
-e_shell_can_quit (EShell *shell)
+e_shell_get_network_available (EShell *shell)
{
- EShellPrivate *priv;
- GSList *component_infos;
- GSList *sp;
- CORBA_boolean can_quit;
-
g_return_val_if_fail (E_IS_SHELL (shell), FALSE);
- priv = shell->priv;
-
- if (priv->preparing_to_quit)
- return FALSE;
-
- component_infos = e_component_registry_peek_list (priv->component_registry);
- can_quit = TRUE;
- for (sp = component_infos; sp != NULL; sp = sp->next) {
- EComponentInfo *info = sp->data;
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
+ return shell->priv->network_available;
+}
- can_quit = GNOME_Evolution_Component_requestQuit (info->iface, &ev);
- if (BONOBO_EX (&ev)) {
- /* The component might not implement the interface, in which case we assume we can quit. */
- can_quit = TRUE;
- }
+/**
+ * e_shell_set_network_available:
+ * @shell: an #EShell
+ * @network_available: whether a network is available
+ *
+ * Sets whether a network is available. This is usually called in
+ * response to a status change signal from NetworkManager. If the
+ * network becomes unavailable while #EShell:online is %TRUE, the
+ * @shell will force #EShell:online to %FALSE until the network
+ * becomes available again.
+ **/
+void
+e_shell_set_network_available (EShell *shell,
+ gboolean network_available)
+{
+ g_return_if_fail (E_IS_SHELL (shell));
- CORBA_exception_free (&ev);
+ if (network_available == shell->priv->network_available)
+ return;
- if (! can_quit)
- break;
+ shell->priv->network_available = network_available;
+ g_object_notify (G_OBJECT (shell), "network-available");
+
+ /* If we're being forced offline, perhaps due to a network outage,
+ * reconnect automatically when the network becomes available. */
+ if (!network_available && shell->priv->online) {
+ g_message ("Network disconnected. Forced offline.");
+ e_shell_set_online (shell, FALSE);
+ shell->priv->auto_reconnect = TRUE;
+ } else if (network_available && shell->priv->auto_reconnect) {
+ g_message ("Connection established. Going online.");
+ e_shell_set_online (shell, TRUE);
+ shell->priv->auto_reconnect = FALSE;
}
-
- return can_quit;
}
+/**
+ * e_shell_get_online:
+ * @shell: an #EShell
+ *
+ * Returns %TRUE if Evolution is online, %FALSE if Evolution is offline.
+ * Evolution may be offline because the user elected to work offline, or
+ * because the network has become unavailable.
+ *
+ * Returns: %TRUE if Evolution is online
+ **/
gboolean
-e_shell_do_quit (EShell *shell)
+e_shell_get_online (EShell *shell)
{
- EShellPrivate *priv;
- GList *p;
- gboolean can_quit;
-
g_return_val_if_fail (E_IS_SHELL (shell), FALSE);
- priv = shell->priv;
-
- if (priv->preparing_to_quit)
- return FALSE;
-
- for (p = shell->priv->windows; p != NULL; p = p->next) {
- gtk_widget_set_sensitive (GTK_WIDGET (p->data), FALSE);
-
- if (p == shell->priv->windows)
- e_shell_window_save_defaults (p->data);
- }
-
- can_quit = !es_run_quit (shell);
-
- /* Mark a safe quit by destroying the lock. */
- e_file_lock_destroy ();
-
- return can_quit;
+ return shell->priv->online;
}
-gboolean
-e_shell_quit (EShell *shell)
+/**
+ * e_shell_set_online:
+ * @shell: an #EShell
+ * @online: %TRUE to go online, %FALSE to go offline
+ *
+ * Asynchronously places Evolution in online or offline mode.
+ **/
+void
+e_shell_set_online (EShell *shell,
+ gboolean online)
{
- return e_shell_can_quit (shell) && e_shell_do_quit (shell);
+ g_return_if_fail (E_IS_SHELL (shell));
+
+ if (online == shell->priv->online)
+ return;
+
+ if (online)
+ shell_prepare_for_online (shell);
+ else
+ shell_prepare_for_offline (shell);
}
/**
- * gboolean (*EMainShellFunc) (EShell *shell, EShellWindow *window, gpointer user_data);
- * Function used in @ref e_shell_foreach_shell_window.
- * @param shell Pointer to EShell.
- * @param window Pointer to EShellWindow.
- * @param user_data User's data passed to @ref main_shell_foreach_shell_window.
- * @return TRUE if need to go to next window, FALSE when stop looking for next window.
+ * e_shell_get_preferences_window:
+ * @shell: an #EShell
+ *
+ * Returns the Evolution Preferences window.
+ *
+ * Returns: the preferences window
**/
+GtkWidget *
+e_shell_get_preferences_window (EShell *shell)
+{
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
+ return shell->priv->preferences_window;
+}
/**
- * e_shell_foreach_shell_window
- * This will call function callback for all known EShellWindow of main shell.
- * When there is no shell active, then this will do nothing.
- * @param shell EShell instance.
- * @param func Function to be called.
- * @param user_data User data to pass to func.
+ * e_shell_event:
+ * @shell: an #EShell
+ * @event_name: the name of the event
+ * @event_data: data associated with the event
+ *
+ * The #EShell::event signal acts as a cheap mechanism for broadcasting
+ * events to the rest of the application, such as new mail arriving. The
+ * @event_name is used as the signal detail, and @event_data may point to
+ * an object or data structure associated with the event.
**/
void
-e_shell_foreach_shell_window (EShell *shell, EMainShellFunc func, gpointer user_data)
+e_shell_event (EShell *shell,
+ const gchar *event_name,
+ gpointer event_data)
{
- EShellPrivate *priv;
- GList *p;
-
- if (!shell)
- return;
+ GQuark detail;
- priv = shell->priv;
+ g_return_if_fail (E_IS_SHELL (shell));
+ g_return_if_fail (event_name != NULL);
- for (p = priv->windows; p != NULL; p = p->next) {
- EShellWindow *window;
+ detail = g_quark_from_string (event_name);
+ g_signal_emit (shell, signals[EVENT], detail, event_data);
+}
- window = E_SHELL_WINDOW (p->data);
+gboolean
+e_shell_is_busy (EShell *shell)
+{
+ /* FIXME */
+ return FALSE;
+}
- if (window && !func (shell, window, user_data))
- break;
- }
+gboolean
+e_shell_do_quit (EShell *shell)
+{
+ /* FIXME */
+ return TRUE;
}
-BONOBO_TYPE_FUNC_FULL (EShell, GNOME_Evolution_Shell, PARENT_TYPE, e_shell)
+gboolean
+e_shell_quit (EShell *shell)
+{
+ /* FIXME */
+ return TRUE;
+}
diff --git a/shell/e-shell.h b/shell/e-shell.h
index ab16ea819e..35095e1352 100644
--- a/shell/e-shell.h
+++ b/shell/e-shell.h
@@ -1,4 +1,6 @@
/*
+ * e-shell.h
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -13,136 +15,99 @@
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
-#ifndef _E_SHELL_H_
-#define _E_SHELL_H_
-
-#include <bonobo-activation/bonobo-activation.h>
-#include <bonobo/bonobo-object.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-typedef struct _EShell EShell;
+/**
+ * SECTION: e-shell
+ * @short_description: the backbone of Evolution
+ * @include: shell/e-shell.h
+ **/
+
+#ifndef E_SHELL_H
+#define E_SHELL_H
+
+#include <unique/unique.h>
+#include <gconf/gconf-client.h>
+#include <shell/e-shell-common.h>
+#include <shell/e-shell-module.h>
+#include <shell/e-shell-settings.h>
+
+/* Standard GObject macros */
+#define E_TYPE_SHELL \
+ (e_shell_get_type ())
+#define E_SHELL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_SHELL, EShell))
+#define E_SHELL_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_SHELL, EShellClass))
+#define E_IS_SHELL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_SHELL))
+#define E_IS_SHELL_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_SHELL))
+#define E_SHELL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_SHELL, EShellClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EShell EShell;
+typedef struct _EShellClass EShellClass;
typedef struct _EShellPrivate EShellPrivate;
-typedef struct _EShellClass EShellClass;
-
-#include "Evolution.h"
-
-#include "e-component-registry.h"
-#include "e-shell-window.h"
-
-
-#define E_TYPE_SHELL (e_shell_get_type ())
-#define E_SHELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SHELL, EShell))
-#define E_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SHELL, EShellClass))
-#define E_IS_SHELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SHELL))
-#define E_IS_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SHELL))
-
-
-enum _EShellLineStatus {
- E_SHELL_LINE_STATUS_ONLINE,
- E_SHELL_LINE_STATUS_GOING_OFFLINE, /* NB: really means changing state in either direction */
- E_SHELL_LINE_STATUS_OFFLINE,
- E_SHELL_LINE_STATUS_FORCED_OFFLINE
-};
-typedef enum _EShellLineStatus EShellLineStatus;
-
-enum _EShellStartupLineMode {
- E_SHELL_STARTUP_LINE_MODE_CONFIG,
- E_SHELL_STARTUP_LINE_MODE_ONLINE,
- E_SHELL_STARTUP_LINE_MODE_OFFLINE
-};
-typedef enum _EShellStartupLineMode EShellStartupLineMode;
+/**
+ * EShell:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ **/
struct _EShell {
- BonoboObject parent;
-
+ UniqueApp parent;
EShellPrivate *priv;
};
struct _EShellClass {
- BonoboObjectClass parent_class;
-
- POA_GNOME_Evolution_Shell__epv epv;
-
- void (* no_windows_left) (EShell *shell);
- void (* line_status_changed) (EShell *shell, EShellLineStatus status);
- void (* new_window_created) (EShell *shell, EShellWindow *window);
-};
-
-
-/* ID for registering the shell in the OAF name service. */
-#define E_SHELL_OAFIID "OAFIID:GNOME_Evolution_Shell:" BASE_VERSION
-
-enum _EShellConstructResult {
- E_SHELL_CONSTRUCT_RESULT_OK,
- E_SHELL_CONSTRUCT_RESULT_INVALIDARG,
- E_SHELL_CONSTRUCT_RESULT_CANNOTREGISTER,
- E_SHELL_CONSTRUCT_RESULT_NOCONFIGDB,
- E_SHELL_CONSTRUCT_RESULT_GENERICERROR
+ UniqueAppClass parent_class;
};
-typedef enum _EShellConstructResult EShellConstructResult;
-
-
-GType e_shell_get_type (void);
-EShellConstructResult e_shell_construct (EShell *shell,
- const char *iid,
- EShellStartupLineMode startup_line_mode);
-EShell *e_shell_new (EShellStartupLineMode startup_line_mode,
- EShellConstructResult *construct_result_return);
-
-gboolean e_shell_attempt_upgrade (EShell *shell);
-
-EShellWindow *e_shell_create_window (EShell *shell,
- const char *component_id,
- EShellWindow *template_window);
-gboolean e_shell_request_close_window (EShell *shell,
- EShellWindow *window);
-
-
-#if 0
-EUriSchemaRegistry *e_shell_peek_uri_schema_registry (EShell *shell);
-#endif
-
-EComponentRegistry *e_shell_peek_component_registry (EShell *shell);
-
-gboolean e_shell_save_settings (EShell *shell);
-void e_shell_close_all_windows (EShell *shell);
-
-EShellLineStatus e_shell_get_line_status (EShell *shell);
-void e_shell_set_line_status (EShell *shell,
- GNOME_Evolution_ShellState shell_state);
-
-gboolean e_shell_get_crash_recovery (EShell *shell);
-void e_shell_set_crash_recovery (EShell *shell,
- gboolean crash_recovery);
-
-void e_shell_send_receive (EShell *shell);
-
-void e_shell_show_settings (EShell *shell,
- const char *type,
- EShellWindow *shell_window);
-
-gboolean e_shell_can_quit (EShell *shell);
-gboolean e_shell_do_quit (EShell *shell);
-gboolean e_shell_quit (EShell *shell);
-
-const char *e_shell_construct_result_to_string (EShellConstructResult result);
-
-typedef gboolean (*EMainShellFunc) (EShell *shell, EShellWindow *window, gpointer user_data);
-void e_shell_foreach_shell_window (EShell *shell, EMainShellFunc func, gpointer user_data);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* _E_SHELL_H_ */
+GType e_shell_get_type (void);
+EShell * e_shell_get_default (void);
+GList * e_shell_get_shell_modules (EShell *shell);
+const gchar * e_shell_get_canonical_name (EShell *shell,
+ const gchar *name);
+EShellModule * e_shell_get_module_by_name (EShell *shell,
+ const gchar *name);
+EShellModule * e_shell_get_module_by_scheme (EShell *shell,
+ const gchar *scheme);
+EShellSettings *e_shell_get_shell_settings (EShell *shell);
+GConfClient * e_shell_get_gconf_client (EShell *shell);
+GtkWidget * e_shell_create_shell_window (EShell *shell,
+ const gchar *view_name);
+guint e_shell_handle_uris (EShell *shell,
+ gchar **uris);
+void e_shell_watch_window (EShell *shell,
+ GtkWindow *window);
+GList * e_shell_get_watched_windows (EShell *shell);
+void e_shell_send_receive (EShell *shell,
+ GtkWindow *parent);
+gboolean e_shell_get_network_available (EShell *shell);
+void e_shell_set_network_available (EShell *shell,
+ gboolean network_available);
+gboolean e_shell_get_online (EShell *shell);
+void e_shell_set_online (EShell *shell,
+ gboolean online);
+GtkWidget * e_shell_get_preferences_window (EShell *shell);
+void e_shell_event (EShell *shell,
+ const gchar *event_name,
+ gpointer event_data);
+gboolean e_shell_is_busy (EShell *shell);
+gboolean e_shell_do_quit (EShell *shell);
+gboolean e_shell_quit (EShell *shell);
+
+G_END_DECLS
+
+#endif /* E_SHELL_H */
diff --git a/shell/e-sidebar.c b/shell/e-sidebar.c
deleted file mode 100644
index 7b8ba1a53a..0000000000
--- a/shell/e-sidebar.c
+++ /dev/null
@@ -1,795 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-sidebar.h"
-
-#include "e-util/e-util.h"
-
-#include <gconf/gconf-client.h>
-
-typedef struct {
- GtkWidget *button_widget;
- GtkWidget *label;
- GtkWidget *icon;
- GtkWidget *hbox;
- gchar *default_icon_name;
- int id;
-} Button;
-
-struct _ESidebarPrivate {
- ESidebarMode mode;
- ESidebarMode toolbar_mode;
-
- gboolean show;
-
- GtkWidget *selection_widget;
- GSList *buttons;
-
- guint style_changed_id;
-
- gboolean in_toggle;
-};
-
-
-enum {
- BUTTON_SELECTED,
- BUTTON_PRESSED,
- NUM_SIGNALS
-};
-
-static unsigned int signals[NUM_SIGNALS] = { 0 };
-
-G_DEFINE_TYPE (ESidebar, e_sidebar, GTK_TYPE_CONTAINER)
-
-#define INTERNAL_MODE(sidebar) (sidebar->priv->mode == E_SIDEBAR_MODE_TOOLBAR ? sidebar->priv->toolbar_mode : sidebar->priv->mode)
-#define H_PADDING 6
-#define V_PADDING 6
-
-/* Utility functions. */
-
-static Button *
-button_new (GtkWidget *button_widget,
- GtkWidget *label,
- GtkWidget *icon,
- GtkWidget *hbox,
- int id)
-{
- Button *button = g_new (Button, 1);
- const gchar *icon_name;
-
- button->button_widget = button_widget;
- button->label = label;
- button->icon = icon;
- button->hbox = hbox;
- button->id = id;
-
- gtk_image_get_icon_name (GTK_IMAGE (icon), &icon_name, NULL);
- button->default_icon_name = g_strdup (icon_name);
-
- g_object_ref (button_widget);
- g_object_ref (label);
- g_object_ref (icon);
- g_object_ref (hbox);
-
- return button;
-}
-
-static void
-button_free (Button *button)
-{
- g_object_unref (button->button_widget);
- g_object_unref (button->label);
- g_object_unref (button->icon);
- g_object_unref (button->hbox);
- g_free (button->default_icon_name);
- g_free (button);
-}
-
-static void
-update_buttons (ESidebar *sidebar, int new_selected_id)
-{
- GSList *p;
-
- sidebar->priv->in_toggle = TRUE;
-
- for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
- Button *button = p->data;
-
- if (button->id == new_selected_id)
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->button_widget), TRUE);
- else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->button_widget), FALSE);
- }
-
- sidebar->priv->in_toggle = FALSE;
-}
-
-
-/* Callbacks. */
-
-static void
-button_toggled_callback (GtkToggleButton *toggle_button,
- ESidebar *sidebar)
-{
- int id = 0;
- gboolean is_active = FALSE;
- GSList *p;
-
- if (sidebar->priv->in_toggle)
- return;
-
- sidebar->priv->in_toggle = TRUE;
-
- if (gtk_toggle_button_get_active (toggle_button))
- is_active = TRUE;
-
- for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
- Button *button = p->data;
-
- if (button->button_widget != GTK_WIDGET (toggle_button)) {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->button_widget), FALSE);
- } else {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->button_widget), TRUE);
- id = button->id;
- }
- }
-
- sidebar->priv->in_toggle = FALSE;
-
- if (is_active)
- g_signal_emit (sidebar, signals[BUTTON_SELECTED], 0, id);
-}
-
-static gboolean
-button_pressed_callback (GtkToggleButton *toggle_button,
- GdkEventButton *event,
- ESidebar *sidebar)
-{
- gboolean return_val = FALSE;
- GSList *p;
-
- for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
- Button *button = p->data;
-
- if (button->button_widget == GTK_WIDGET (toggle_button))
- g_signal_emit (sidebar, signals [BUTTON_PRESSED],
- 0, event, button->id, &return_val);
- }
-
- return return_val;
-}
-
-static gboolean
-button_query_tooltip (GtkWidget *widget,
- gint x,
- gint y,
- gboolean keyboard_mode,
- GtkTooltip *tooltip,
- ESidebar *sidebar)
-{
- /* Show the tooltip only if the label is hidden */
- if (INTERNAL_MODE (sidebar) == E_SIDEBAR_MODE_ICON) {
- char *tip;
-
- tip = g_object_get_data (G_OBJECT (widget),
- "ESidebar:button-tooltip");
- if (tip) {
- gtk_tooltip_set_text (tooltip, tip);
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-
-/* Layout. */
-
-static int
-layout_buttons (ESidebar *sidebar)
-{
- GtkAllocation *allocation = & GTK_WIDGET (sidebar)->allocation;
- ESidebarMode mode;
- gboolean icons_only;
- int num_btns = g_slist_length (sidebar->priv->buttons), btns_per_row;
- GSList **rows, *p;
- Button *button;
- int row_number;
- int max_btn_width = 0, max_btn_height = 0;
- int row_last;
- int x, y;
- int i;
-
- y = allocation->y + allocation->height - V_PADDING - 1;
-
- if (num_btns == 0)
- return y;
-
- mode = INTERNAL_MODE (sidebar);
- icons_only = (mode == E_SIDEBAR_MODE_ICON);
-
- /* Figure out the max width and height */
- for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
- GtkRequisition requisition;
-
- button = p->data;
- gtk_widget_size_request (GTK_WIDGET (button->button_widget), &requisition);
-
- max_btn_height = MAX (max_btn_height, requisition.height);
- max_btn_width = MAX (max_btn_width, requisition.width);
- }
-
- /* Figure out how many rows and columns we'll use. */
- btns_per_row = allocation->width / (max_btn_width + H_PADDING);
- if (!icons_only) {
- /* If using text buttons, we want to try to have a
- * completely filled-in grid, but if we can't, we want
- * the odd row to have just a single button.
- */
- while (num_btns % btns_per_row > 1)
- btns_per_row--;
- }
-
- /* Assign buttons to rows */
- rows = g_new0 (GSList *, num_btns / btns_per_row + 1);
-
- if (!icons_only && num_btns % btns_per_row != 0) {
- button = sidebar->priv->buttons->data;
- rows [0] = g_slist_append (rows [0], button->button_widget);
-
- p = sidebar->priv->buttons->next;
- row_number = p ? 1 : 0;
- } else {
- p = sidebar->priv->buttons;
- row_number = 0;
- }
-
- for (; p != NULL; p = p->next) {
- button = p->data;
-
- if (g_slist_length (rows [row_number]) == btns_per_row)
- row_number ++;
-
- rows [row_number] = g_slist_append (rows [row_number], button->button_widget);
- }
-
- row_last = row_number;
-
- /* Layout the buttons. */
- for (i = row_last; i >= 0; i --) {
- int len, extra_width;
-
- y -= max_btn_height;
- x = H_PADDING + allocation->x;
- len = g_slist_length (rows[i]);
- if (mode == E_SIDEBAR_MODE_TEXT || mode == E_SIDEBAR_MODE_BOTH)
- extra_width = (allocation->width - (len * max_btn_width ) - (len * H_PADDING)) / len;
- else
- extra_width = 0;
- for (p = rows [i]; p != NULL; p = p->next) {
- GtkAllocation child_allocation;
-
- child_allocation.x = x;
- child_allocation.y = y;
- child_allocation.width = max_btn_width + extra_width;
- child_allocation.height = max_btn_height;
-
- gtk_widget_size_allocate (GTK_WIDGET (p->data), &child_allocation);
-
- x += child_allocation.width + H_PADDING;
- }
-
- y -= V_PADDING;
- }
-
- for (i = 0; i <= row_last; i ++)
- g_slist_free (rows [i]);
- g_free (rows);
-
- return y;
-}
-
-static void
-do_layout (ESidebar *sidebar)
-{
- GtkAllocation *allocation = & GTK_WIDGET (sidebar)->allocation;
- GtkAllocation child_allocation;
- int y;
-
- if (sidebar->priv->show)
- y = layout_buttons (sidebar);
- else
- y = allocation->y + allocation->height;
-
- /* Place the selection widget. */
- child_allocation.x = allocation->x;
- child_allocation.y = allocation->y;
- child_allocation.width = allocation->width;
- child_allocation.height = y - allocation->y;
-
- gtk_widget_size_allocate (sidebar->priv->selection_widget, & child_allocation);
-}
-
-
-/* GtkContainer methods. */
-
-static void
-impl_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- void *callback_data)
-{
- ESidebar *sidebar = E_SIDEBAR (container);
- GSList *p;
-
- if (sidebar->priv->selection_widget != NULL)
- (* callback) (sidebar->priv->selection_widget, callback_data);
-
- for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
- GtkWidget *widget = ((Button *) p->data)->button_widget;
- (* callback) (widget, callback_data);
- }
-}
-
-static void
-impl_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- ESidebar *sidebar = E_SIDEBAR (container);
- GSList *p;
-
- if (widget == sidebar->priv->selection_widget) {
- e_sidebar_set_selection_widget (sidebar, NULL);
- return;
- }
-
- for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
- GtkWidget *button_widget = ((Button *) p->data)->button_widget;
-
- if (button_widget == widget) {
- gtk_widget_unparent (button_widget);
- sidebar->priv->buttons = g_slist_remove_link (sidebar->priv->buttons, p);
- gtk_widget_queue_resize (GTK_WIDGET (sidebar));
- break;
- }
- }
-}
-
-
-/* GtkWidget methods. */
-
-static void
-impl_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- ESidebar *sidebar = E_SIDEBAR (widget);
- GSList *p;
-
- if (sidebar->priv->selection_widget == NULL) {
- requisition->width = 2 * H_PADDING;
- requisition->height = 2 * V_PADDING;
- } else {
- gtk_widget_size_request (sidebar->priv->selection_widget, requisition);
- }
-
- if (!sidebar->priv->show)
- return;
-
- for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
- Button *button = p->data;
- GtkRequisition button_requisition;
-
- gtk_widget_size_request (button->button_widget, &button_requisition);
-
- requisition->width = MAX (requisition->width, button_requisition.width + 2 * H_PADDING);
- requisition->height += button_requisition.height + V_PADDING;
- }
-}
-
-static void
-impl_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- widget->allocation = *allocation;
-
- do_layout (E_SIDEBAR (widget));
-}
-
-
-/* GObject methods. */
-
-static void
-impl_dispose (GObject *object)
-{
- ESidebarPrivate *priv = E_SIDEBAR (object)->priv;
- GConfClient *gconf_client = gconf_client_get_default ();
-
- g_slist_foreach (priv->buttons, (GFunc) button_free, NULL);
- g_slist_free (priv->buttons);
- priv->buttons = NULL;
-
- if (priv->style_changed_id) {
- gconf_client_notify_remove (gconf_client, priv->style_changed_id);
- priv->style_changed_id = 0;
- }
-
- g_object_unref (gconf_client);
-
- (* G_OBJECT_CLASS (e_sidebar_parent_class)->dispose) (object);
-}
-
-static gboolean
-boolean_handled_accumulator (GSignalInvocationHint *ihint,
- GValue *return_accu,
- const GValue *handler_return,
- gpointer dummy)
-{
- gboolean handled;
-
- handled = g_value_get_boolean (handler_return);
- g_value_set_boolean (return_accu, handled);
-
- return !handled;
-}
-
-static void
-impl_finalize (GObject *object)
-{
- ESidebarPrivate *priv = E_SIDEBAR (object)->priv;
-
- g_free (priv);
-
- (* G_OBJECT_CLASS (e_sidebar_parent_class)->finalize) (object);
-}
-
-
-/* Initialization. */
-
-static void
-e_sidebar_class_init (ESidebarClass *klass)
-{
- GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- container_class->forall = impl_forall;
- container_class->remove = impl_remove;
-
- widget_class->size_request = impl_size_request;
- widget_class->size_allocate = impl_size_allocate;
-
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-
- signals[BUTTON_SELECTED]
- = g_signal_new ("button_selected",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (ESidebarClass, button_selected),
- NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1,
- G_TYPE_INT);
- signals[BUTTON_PRESSED]
- = g_signal_new ("button_pressed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESidebarClass, button_pressed),
- boolean_handled_accumulator, NULL,
- e_marshal_NONE__POINTER_INT,
- G_TYPE_BOOLEAN, 2,
- G_TYPE_POINTER, G_TYPE_INT);
-}
-
-static void
-e_sidebar_init (ESidebar *sidebar)
-{
- ESidebarPrivate *priv;
-
- GTK_WIDGET_SET_FLAGS (sidebar, GTK_NO_WINDOW);
-
- priv = g_new0 (ESidebarPrivate, 1);
- sidebar->priv = priv;
-
- priv->mode = E_SIDEBAR_MODE_TEXT;
-}
-
-GtkWidget *
-e_sidebar_new (void)
-{
- ESidebar *sidebar = g_object_new (e_sidebar_get_type (), NULL);
-
- return GTK_WIDGET (sidebar);
-}
-
-
-void
-e_sidebar_set_selection_widget (ESidebar *sidebar, GtkWidget *widget)
-{
- if (sidebar->priv->selection_widget != NULL)
- gtk_widget_unparent (sidebar->priv->selection_widget);
-
- sidebar->priv->selection_widget = widget;
-
- if (widget != NULL)
- gtk_widget_set_parent (widget, GTK_WIDGET (sidebar));
-
- gtk_widget_queue_resize (GTK_WIDGET (sidebar));
-}
-
-
-void
-e_sidebar_add_button (ESidebar *sidebar,
- const char *label,
- const char *tooltips,
- const char *icon_name,
- int id)
-{
- GtkWidget *button_widget;
- GtkWidget *hbox;
- GtkWidget *icon_widget;
- GtkWidget *label_widget;
-
- button_widget = gtk_toggle_button_new ();
- if (sidebar->priv->show)
- gtk_widget_show (button_widget);
- g_signal_connect (button_widget, "toggled", G_CALLBACK (button_toggled_callback), sidebar);
- g_signal_connect (button_widget, "button_press_event",
- G_CALLBACK (button_pressed_callback), sidebar);
-
- hbox = gtk_hbox_new (FALSE, 3);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
- gtk_widget_show (hbox);
-
- icon_widget = gtk_image_new_from_icon_name (
- icon_name, GTK_ICON_SIZE_BUTTON);
- gtk_widget_show (icon_widget);
-
- label_widget = gtk_label_new (label);
- gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5);
- gtk_widget_show (label_widget);
-
- g_object_set_data_full (G_OBJECT (button_widget),
- "ESidebar:button-tooltip",
- g_strdup (tooltips),
- g_free);
- gtk_widget_set_has_tooltip (button_widget, TRUE);
- g_signal_connect (button_widget, "query-tooltip",
- G_CALLBACK (button_query_tooltip), sidebar);
-
- switch (INTERNAL_MODE (sidebar)) {
- case E_SIDEBAR_MODE_TEXT:
- gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0);
- break;
- case E_SIDEBAR_MODE_ICON:
- gtk_box_pack_start (GTK_BOX (hbox), icon_widget, TRUE, TRUE, 0);
- break;
- case E_SIDEBAR_MODE_BOTH:
- default:
- gtk_box_pack_start (GTK_BOX (hbox), icon_widget, FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0);
- break;
- }
-
- gtk_container_add (GTK_CONTAINER (button_widget), hbox);
-
- sidebar->priv->buttons = g_slist_append (sidebar->priv->buttons, button_new (button_widget, label_widget, icon_widget, hbox, id));
- gtk_widget_set_parent (button_widget, GTK_WIDGET (sidebar));
-
- gtk_widget_queue_resize (GTK_WIDGET (sidebar));
-}
-
-/**
- * e_sidebar_change_button_icon
- * @sidebar: an #ESidebar
- * @icon_name: button icon name, or %NULL
- * @button_id: component's button ID, for which change the icon.
- *
- * This will change icon in icon_widget of the button of known component.
- * You cannot change icon as in a stack, only one default icon will be stored.
- **/
-void
-e_sidebar_change_button_icon (ESidebar *sidebar, const gchar *icon_name, int button_id)
-{
- GSList *p;
-
- g_return_if_fail (sidebar != NULL);
-
- for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
- Button *button = p->data;
-
- if (button->id == button_id) {
- if (!button->icon)
- break;
-
- if (icon_name == NULL)
- icon_name = button->default_icon_name;
-
- gtk_image_set_from_icon_name (
- GTK_IMAGE (button->icon),
- icon_name, GTK_ICON_SIZE_BUTTON);
-
- break;
- }
- }
-}
-
-void
-e_sidebar_select_button (ESidebar *sidebar, int id)
-{
- update_buttons (sidebar, id);
-
- g_signal_emit (sidebar, signals[BUTTON_SELECTED], 0, id);
-}
-
-ESidebarMode
-e_sidebar_get_mode (ESidebar *sidebar)
-{
- return sidebar->priv->mode;
-}
-
-
-static GConfEnumStringPair toolbar_styles[] = {
- { E_SIDEBAR_MODE_TEXT, "text" },
- { E_SIDEBAR_MODE_ICON, "icons" },
- { E_SIDEBAR_MODE_BOTH, "both" },
- { E_SIDEBAR_MODE_BOTH, "both-horiz" },
- { E_SIDEBAR_MODE_BOTH, "both_horiz" },
- { -1, NULL }
-};
-
-static void
-set_mode_internal (ESidebar *sidebar, ESidebarMode mode )
-{
- GSList *p;
-
- if (mode == INTERNAL_MODE (sidebar))
- return;
-
- for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
- Button *button = p->data;
-
- switch (mode) {
- case E_SIDEBAR_MODE_TEXT:
- gtk_container_remove (GTK_CONTAINER (button->hbox), button->icon);
- if (INTERNAL_MODE (sidebar) == E_SIDEBAR_MODE_ICON) {
- gtk_box_pack_start (GTK_BOX (button->hbox), button->label, TRUE, TRUE, 0);
- gtk_widget_show (button->label);
- }
- break;
- case E_SIDEBAR_MODE_ICON:
- gtk_container_remove(GTK_CONTAINER (button->hbox), button->label);
- if (INTERNAL_MODE (sidebar) == E_SIDEBAR_MODE_TEXT) {
- gtk_box_pack_start (GTK_BOX (button->hbox), button->icon, TRUE, TRUE, 0);
- gtk_widget_show (button->icon);
- } else
- gtk_container_child_set (GTK_CONTAINER (button->hbox), button->icon,
- "expand", TRUE,
- NULL);
- break;
- case E_SIDEBAR_MODE_BOTH:
- if (INTERNAL_MODE (sidebar) == E_SIDEBAR_MODE_TEXT) {
- gtk_container_remove (GTK_CONTAINER (button->hbox), button->label);
- gtk_box_pack_start (GTK_BOX (button->hbox), button->icon, FALSE, TRUE, 0);
- gtk_widget_show (button->icon);
- } else {
- gtk_container_child_set (GTK_CONTAINER (button->hbox), button->icon,
- "expand", FALSE,
- NULL);
- }
-
- gtk_box_pack_start (GTK_BOX (button->hbox), button->label, TRUE, TRUE, 0);
- gtk_widget_show (button->label);
- break;
- default:
- break;
- }
- }
-}
-
-static void
-style_changed_notify (GConfClient *gconf, guint id, GConfEntry *entry, void *data)
-{
- ESidebar *sidebar = data;
- char *val;
- int mode;
-
- val = gconf_client_get_string (gconf, "/desktop/gnome/interface/toolbar_style", NULL);
- if (val == NULL || !gconf_string_to_enum (toolbar_styles, val, &mode))
- mode = E_SIDEBAR_MODE_BOTH;
- g_free(val);
-
- set_mode_internal (E_SIDEBAR (sidebar), mode);
- sidebar->priv->toolbar_mode = mode;
-
- gtk_widget_queue_resize (GTK_WIDGET (sidebar));
-}
-
-void
-e_sidebar_set_mode (ESidebar *sidebar, ESidebarMode mode)
-{
- GConfClient *gconf_client = gconf_client_get_default ();
-
- if (sidebar->priv->mode == mode)
- return;
-
- if (sidebar->priv->mode == E_SIDEBAR_MODE_TOOLBAR) {
- if (sidebar->priv->style_changed_id) {
- gconf_client_notify_remove (gconf_client, sidebar->priv->style_changed_id);
- sidebar->priv->style_changed_id = 0;
- }
- }
-
- if (mode != E_SIDEBAR_MODE_TOOLBAR) {
- set_mode_internal (sidebar, mode);
-
- gtk_widget_queue_resize (GTK_WIDGET (sidebar));
- } else {
- /* This is a little bit tricky, toolbar mode is more
- * of a meta-mode where the actual mode is dictated by
- * the gnome toolbar setting, so that is why we have
- * the is_toolbar_mode bool - it tracks the toolbar
- * mode while the mode member is the actual look and
- * feel */
- sidebar->priv->style_changed_id = gconf_client_notify_add (gconf_client,
- "/desktop/gnome/interface/toolbar_style",
- style_changed_notify, sidebar, NULL, NULL);
- style_changed_notify (gconf_client, 0, NULL, sidebar);
- }
-
- g_object_unref (gconf_client);
-
- sidebar->priv->mode = mode;
-}
-
-void
-e_sidebar_set_show_buttons (ESidebar *sidebar, gboolean show)
-{
- GSList *p;
-
- if (sidebar->priv->show == show)
- return;
-
- for (p = sidebar->priv->buttons; p != NULL; p = p->next) {
- Button *button = p->data;
-
- if (show)
- gtk_widget_show (button->button_widget);
- else
- gtk_widget_hide (button->button_widget);
- }
-
- sidebar->priv->show = show;
-
- gtk_widget_queue_resize (GTK_WIDGET (sidebar));
-}
-
-gboolean
-e_sidebar_get_show_buttons (ESidebar *sidebar)
-{
- return sidebar->priv->show;
-}
diff --git a/shell/e-sidebar.h b/shell/e-sidebar.h
deleted file mode 100644
index a3d3b43fee..0000000000
--- a/shell/e-sidebar.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_SIDEBAR_H_
-#define _E_SIDEBAR_H_
-
-#include <gtk/gtk.h>
-
-#define E_TYPE_SIDEBAR (e_sidebar_get_type ())
-#define E_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SIDEBAR, ESidebar))
-#define E_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SIDEBAR, ESidebarClass))
-#define E_IS_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SIDEBAR))
-#define E_IS_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SIDEBAR))
-
-
-typedef struct _ESidebar ESidebar;
-typedef struct _ESidebarPrivate ESidebarPrivate;
-typedef struct _ESidebarClass ESidebarClass;
-
-typedef enum {
- E_SIDEBAR_MODE_TEXT,
- E_SIDEBAR_MODE_ICON,
- E_SIDEBAR_MODE_BOTH,
- E_SIDEBAR_MODE_TOOLBAR
-} ESidebarMode;
-
-struct _ESidebar {
- GtkContainer parent;
-
- ESidebarPrivate *priv;
-};
-
-struct _ESidebarClass {
- GtkContainerClass parent_class;
-
- /* signals */
- void (* button_selected) (ESidebar *sidebar, int id);
- void (* button_pressed) (ESidebar *sidebar, GdkEventButton *event, int id);
-};
-
-
-GType e_sidebar_get_type (void);
-GtkWidget *e_sidebar_new (void);
-
-void e_sidebar_set_selection_widget (ESidebar *sidebar,
- GtkWidget *widget);
-
-void e_sidebar_add_button (ESidebar *sidebar,
- const char *label,
- const char *tooltips,
- const char *icon_name,
- int id);
-
-void e_sidebar_select_button (ESidebar *sidebar,
- int id);
-
-void e_sidebar_change_button_icon (ESidebar *sidebar,
- const char *icon_name,
- int button_id);
-
-ESidebarMode e_sidebar_get_mode (ESidebar *sidebar);
-void e_sidebar_set_mode (ESidebar *sidebar, ESidebarMode mode);
-
-void e_sidebar_set_show_buttons (ESidebar *sidebar, gboolean show);
-gboolean e_sidebar_get_show_buttons (ESidebar *sidebar);
-
-
-#endif /* _E_SIDEBAR_H_ */
diff --git a/shell/e-user-creatable-items-handler.c b/shell/e-user-creatable-items-handler.c
deleted file mode 100644
index 30b0d1dfa2..0000000000
--- a/shell/e-user-creatable-items-handler.c
+++ /dev/null
@@ -1,914 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-user-creatable-items-handler.h"
-#include <e-util/e-icon-factory.h>
-#include "Evolution.h"
-
-#include "e-util/e-corba-utils.h"
-#include "misc/e-combo-button.h"
-
-#include <bonobo/bonobo-ui-util.h>
-#include <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-control.h>
-
-#include <gtk/gtk.h>
-#include <glib/gi18n-lib.h>
-
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-
-#include <gconf/gconf-client.h>
-
-struct _Component {
- char *id, *alias;
- GNOME_Evolution_Component component;
- GNOME_Evolution_CreatableItemTypeList *type_list;
-};
-typedef struct _Component Component;
-
-/* Representation of a single menu item. */
-struct _MenuItem {
- const char *label;
- char shortcut;
- char *verb;
- char *tooltip;
- char *component;
- GdkPixbuf *icon;
- GdkPixbuf *icon_toolbar;
-};
-typedef struct _MenuItem MenuItem;
-
-struct _EUserCreatableItemsHandlerPrivate {
- /* This component's alias */
- char *this_component;
-
- /* For creating items on the view */
- EUserCreatableItemsHandlerCreate create_local;
- void *create_data;
-
- /* The components that register user creatable items. */
- GSList *components; /* Component */
-
- /* The "New ..." menu items. */
- GSList *objects; /* MenuItem */
- GSList *folders; /* MenuItem */
-
- /* The default item (the mailer's "message" item). To be used when the
- component in the view we are in doesn't provide a default user
- creatable type. This pointer always points to one of the menu items
- in ->objects. */
- const MenuItem *fallback_menu_item;
- const MenuItem *default_menu_item;
-
- char *menu_xml;
- GtkWidget *new_button, *new_menu;
- BonoboControl *new_control;
- GtkAccelGroup *accel_group;
-};
-
-enum {
- PROP_THIS_COMPONENT = 1,
- LAST_PROP
-};
-
-G_DEFINE_TYPE (EUserCreatableItemsHandler, e_user_creatable_items_handler, G_TYPE_OBJECT)
-
-/* Component struct handling. */
-
-static Component *
-component_new (const char *id,
- const char *component_alias,
- GNOME_Evolution_Component component)
-{
- CORBA_Environment ev;
- Component *new;
-
- CORBA_exception_init (&ev);
-
- new = g_new (Component, 1);
- new->id = g_strdup (id);
- new->alias = g_strdup (component_alias);
-
- new->type_list = GNOME_Evolution_Component__get_userCreatableItems (component, &ev);
- if (BONOBO_EX (&ev))
- new->type_list = NULL;
-
- new->component = component;
- Bonobo_Unknown_ref (new->component, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- new->type_list = NULL;
-
- CORBA_exception_free (&ev);
-
- return new;
-}
-
-static void
-component_free (Component *component)
-{
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- Bonobo_Unknown_unref (component->component, &ev);
-
- g_free (component->id);
- g_free (component->alias);
-
- if (component->type_list != NULL)
- CORBA_free (component->type_list);
-
- CORBA_exception_free (&ev);
-
- g_free (component);
-}
-
-static const char *component_query =
- "repo_ids.has ('IDL:GNOME/Evolution/Component:" BASE_VERSION "')";
-
-static void
-get_components_from_bonobo (EUserCreatableItemsHandler *handler)
-{
- Bonobo_ServerInfoList *info_list;
- Bonobo_ActivationProperty *property;
- CORBA_Environment ev;
- char *iid, *alias;
- GNOME_Evolution_Component corba_component;
- Component *component;
- int i;
-
- CORBA_exception_init (&ev);
- info_list = bonobo_activation_query (component_query, NULL, &ev);
- if (BONOBO_EX (&ev)) {
- char *ex_text = bonobo_exception_get_text (&ev);
- g_warning ("Cannot query for components: %s\n", ex_text);
- g_free (ex_text);
- CORBA_exception_free (&ev);
- return;
- }
-
- for (i = 0; i < info_list->_length; i++) {
- iid = info_list->_buffer[i].iid;
- corba_component = bonobo_activation_activate_from_id (iid, Bonobo_ACTIVATION_FLAG_EXISTING_ONLY, NULL, &ev);
- if (BONOBO_EX (&ev)) {
- CORBA_exception_free (&ev);
- continue;
- }
-
- property = bonobo_server_info_prop_find (&info_list->_buffer[i],
- "evolution:component_alias");
- alias = property ? property->v._u.value_string : "unknown";
-
- component = component_new (iid, alias, corba_component);
- handler->priv->components = g_slist_prepend (handler->priv->components, component);
- }
-
- CORBA_free (info_list);
-}
-
-
-/* Helper functions. */
-
-static gboolean
-item_is_default (const MenuItem *item,
- const char *component)
-{
- if (component == NULL)
- return FALSE;
-
- if (strcmp (item->component, component) == 0)
- return TRUE;
- else
- return FALSE;
-}
-
-static char *
-create_verb (EUserCreatableItemsHandler *handler, int component_num, const char *comp, const char *type_id)
-{
- return g_strdup_printf ("EUserCreatableItemsHandler-%s:%d:%s", comp, component_num, type_id);
-}
-
-/* Setting up menu items for the "File -> New" submenu and the "New" toolbar
- button. */
-
-static void
-ensure_menu_items (EUserCreatableItemsHandler *handler)
-{
- EUserCreatableItemsHandlerPrivate *priv;
- GSList *objects, *folders;
- GSList *p;
- int component_num;
- const char *default_verb;
-
- priv = handler->priv;
- if (priv->objects != NULL)
- return;
-
- objects = folders = NULL;
- component_num = 0;
- default_verb = NULL;
- for (p = priv->components; p != NULL; p = p->next) {
- const Component *component;
- int i;
-
- component = (const Component *) p->data;
- if (component->type_list != NULL) {
- for (i = 0; i < component->type_list->_length; i ++) {
- const GNOME_Evolution_CreatableItemType *corba_item;
- MenuItem *item;
-
- corba_item = (const GNOME_Evolution_CreatableItemType *) component->type_list->_buffer + i;
-
- item = g_new (MenuItem, 1);
- item->label = corba_item->menuDescription;
- item->shortcut = corba_item->menuShortcut;
- item->verb = create_verb (handler, component_num, component->alias, corba_item->id);
- item->tooltip = corba_item->tooltip;
- item->component = g_strdup (component->alias);
-
- if (strcmp (item->component, "mail") == 0
- && strcmp (corba_item->id, "message") == 0)
- default_verb = item->verb;
-
- if (corba_item->iconName == NULL || *corba_item->iconName == '\0') {
- item->icon = NULL;
- item->icon_toolbar = NULL;
- } else {
- item->icon = e_icon_factory_get_icon (corba_item->iconName, E_ICON_SIZE_MENU);
- if (item_is_default (item, component->alias))
- item->icon_toolbar = e_icon_factory_get_icon (corba_item->iconName, E_ICON_SIZE_LARGE_TOOLBAR);
- else
- item->icon_toolbar = NULL;
- }
-
- if (corba_item->type == GNOME_Evolution_CREATABLE_OBJECT)
- objects = g_slist_prepend (objects, item);
- else
- folders = g_slist_prepend (folders, item);
- }
- }
-
- component_num ++;
- }
-
- priv->objects = g_slist_reverse (objects);
- priv->folders = g_slist_reverse (folders);
-
- priv->fallback_menu_item = NULL;
- if (default_verb != NULL) {
- for (p = priv->objects; p != NULL; p = p->next) {
- const MenuItem *item;
-
- item = (const MenuItem *) p->data;
- if (strcmp (item->verb, default_verb) == 0)
- priv->fallback_menu_item = item;
- }
- }
-}
-
-static void
-free_menu_items (GSList *menu_items)
-{
- GSList *p;
-
- if (menu_items == NULL)
- return;
-
- for (p = menu_items; p != NULL; p = p->next) {
- MenuItem *item;
-
- item = (MenuItem *) p->data;
- g_free (item->verb);
-
- if (item->icon != NULL)
- g_object_unref (item->icon);
-
- if (item->icon_toolbar != NULL)
- g_object_unref (item->icon_toolbar);
-
- g_free (item->component);
- g_free (item);
- }
-
- g_slist_free (menu_items);
-}
-
-static const MenuItem *
-get_default_action_for_view (EUserCreatableItemsHandler *handler)
-{
- EUserCreatableItemsHandlerPrivate *priv;
- const GSList *p;
-
- priv = handler->priv;
-
- for (p = priv->objects; p != NULL; p = p->next) {
- const MenuItem *item;
-
- item = (const MenuItem *) p->data;
- if (item_is_default (item, priv->this_component))
- return item;
- }
-
- return priv->fallback_menu_item;
-}
-
-
-/* Verb handling. */
-
-static void
-execute_verb (EUserCreatableItemsHandler *handler,
- const char *verb_name)
-{
- EUserCreatableItemsHandlerPrivate *priv;
- const Component *component;
- int component_number;
- const char *p;
- const char *id;
- GSList *component_list_item;
- int i;
-
- priv = handler->priv;
-
- p = strchr (verb_name, ':');
- g_return_if_fail (p != NULL);
- component_number = atoi (p + 1);
-
- p = strchr (p + 1, ':');
- g_return_if_fail (p != NULL);
- id = p + 1;
-
- component_list_item = g_slist_nth (priv->components, component_number);
- g_return_if_fail (component_list_item != NULL);
-
- component = (const Component *) component_list_item->data;
-
- if (component->type_list == NULL)
- return;
-
- /* TODO: why do we actually iterate this? Is it just to check we have it in the menu? The
- search isn't used otherwise */
- for (i = 0; i < component->type_list->_length; i ++) {
- if (strcmp (component->type_list->_buffer[i].id, id) == 0) {
- if (priv->create_local && priv->this_component && strcmp(priv->this_component, component->alias) == 0) {
- priv->create_local(handler, id, priv->create_data);
- } else {
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- GNOME_Evolution_Component_requestCreateItem (component->component, id, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_warning ("Error in requestCreateItem -- %s", BONOBO_EX_REPOID (&ev));
-
- CORBA_exception_free (&ev);
- }
- return;
- }
- }
-}
-
-static void
-verb_fn (BonoboUIComponent *ui_component,
- void *data,
- const char *verb_name)
-{
- EUserCreatableItemsHandler *handler=
- E_USER_CREATABLE_ITEMS_HANDLER (data);
-
- execute_verb (handler, verb_name);
-}
-
-static void
-add_verbs (EUserCreatableItemsHandler *handler,
- BonoboUIComponent *ui_component)
-{
- EUserCreatableItemsHandlerPrivate *priv;
- int component_num;
- GSList *p;
-
- priv = handler->priv;
-
- component_num = 0;
- for (p = priv->components; p != NULL; p = p->next) {
- const Component *component;
- int i;
-
- component = (const Component *) p->data;
-
- if (component->type_list != NULL) {
- for (i = 0; i < component->type_list->_length; i ++) {
- char *verb_name;
-
- verb_name = create_verb (handler,
- component_num,
- component->alias,
- component->type_list->_buffer[i].id);
-
- bonobo_ui_component_add_verb (ui_component, verb_name, verb_fn, handler);
-
- g_free (verb_name);
- }
- }
-
- component_num ++;
- }
-}
-
-
-/* Generic menu construction code */
-
-static int
-item_types_sort_func (const void *a,
- const void *b)
-{
- const MenuItem *item_a;
- const MenuItem *item_b;
- const char *p1, *p2;
-
- item_a = (const MenuItem *) a;
- item_b = (const MenuItem *) b;
-
- p1 = item_a->label;
- p2 = item_b->label;
-
- while (*p1 != '\0' && *p2 != '\0') {
- if (*p1 == '_') {
- p1 ++;
- continue;
- }
-
- if (*p2 == '_') {
- p2 ++;
- continue;
- }
-
- if (toupper ((int) *p1) < toupper ((int) *p2))
- return -1;
- else if (toupper ((int) *p1) > toupper ((int) *p2))
- return +1;
-
- p1 ++, p2 ++;
- }
-
- if (*p1 == '\0') {
- if (*p2 == '\0')
- return 0;
- else
- return -1;
- } else {
- return +1;
- }
-}
-
-typedef void (*EUserCreatableItemsHandlerMenuItemFunc) (EUserCreatableItemsHandler *, gpointer, MenuItem *, gboolean);
-typedef void (*EUserCreatableItemsHandlerSeparatorFunc) (EUserCreatableItemsHandler *, gpointer, int);
-
-static void
-construct_menu (EUserCreatableItemsHandler *handler, gpointer menu,
- EUserCreatableItemsHandlerMenuItemFunc menu_item_func,
- EUserCreatableItemsHandlerSeparatorFunc separator_func)
-{
- EUserCreatableItemsHandlerPrivate *priv;
- MenuItem *item;
- GSList *p, *items;
- gboolean first = TRUE;
-
- priv = handler->priv;
-
- /* First add the current component's creatable objects */
- for (p = priv->objects; p != NULL; p = p->next) {
- item = p->data;
- if (item_is_default (item, priv->this_component)) {
- menu_item_func (handler, menu, item, first);
- first = FALSE;
- }
- }
-
- /* Then its creatable folders */
- for (p = priv->folders; p != NULL; p = p->next) {
- item = p->data;
- if (item_is_default (item, priv->this_component))
- menu_item_func (handler, menu, item, FALSE);
- }
-
- /* Then a separator */
- separator_func (handler, menu, 1);
-
- /* Then the objects from other components. */
- items = NULL;
- for (p = priv->objects; p != NULL; p = p->next) {
- item = p->data;
- if (! item_is_default (item, priv->this_component))
- items = g_slist_prepend (items, item);
- }
-
- items = g_slist_sort (items, item_types_sort_func);
- for (p = items; p != NULL; p = p->next)
- menu_item_func (handler, menu, p->data, FALSE);
- g_slist_free (items);
-
- /* Another separator */
- separator_func (handler, menu, 2);
-
- /* And finally the folders from other components */
- items = NULL;
- for (p = priv->folders; p != NULL; p = p->next) {
- item = p->data;
- if (! item_is_default (item, priv->this_component))
- items = g_slist_prepend (items, item);
- }
-
- items = g_slist_sort (items, item_types_sort_func);
- for (p = items; p != NULL; p = p->next)
- menu_item_func (handler, menu, p->data, FALSE);
- g_slist_free (items);
-}
-
-/* The XML description for "File -> New". */
-
-static void
-xml_menu_item_func (EUserCreatableItemsHandler *handler, gpointer menu,
- MenuItem *item, gboolean first)
-{
- GString *xml = menu;
- char *encoded_label;
- char *encoded_tooltip;
-
- encoded_label = bonobo_ui_util_encode_str (item->label);
- g_string_append_printf (xml, "<menuitem name=\"New:%s\" verb=\"%s\" label=\"%s\"",
- item->verb, item->verb, encoded_label);
-
- if (first)
- g_string_append_printf (xml, " accel=\"*Control*N\"");
- else if (item->shortcut != '\0')
- g_string_append_printf (xml, " accel=\"*Control**Shift*%c\"", item->shortcut);
-
- if (item->icon != NULL) {
- char *icon_xml;
-
- icon_xml = bonobo_ui_util_pixbuf_to_xml (item->icon);
- g_string_append_printf (xml, " pixtype=\"pixbuf\" pixname=\"%s\"", icon_xml);
- g_free (icon_xml);
- }
-
- encoded_tooltip = bonobo_ui_util_encode_str (item->tooltip);
- g_string_append_printf (xml, " tip=\"%s\"", encoded_tooltip);
-
- g_string_append (xml, "/> ");
-
- g_free (encoded_label);
- g_free (encoded_tooltip);
-}
-
-static void
-xml_separator_func (EUserCreatableItemsHandler *handler, gpointer menu, int nth)
-{
- GString *xml = menu;
-
- g_string_append_printf (xml, "<separator f=\"\" name=\"EUserCreatableItemsHandlerSeparator%d\"/>", nth);
-}
-
-static void
-create_menu_xml (EUserCreatableItemsHandler *handler)
-{
- GString *xml;
-
- xml = g_string_new ("<placeholder name=\"NewMenu\">");
- construct_menu (handler, xml, xml_menu_item_func, xml_separator_func);
- g_string_append (xml, "</placeholder>");
-
- handler->priv->menu_xml = xml->str;
- g_string_free (xml, FALSE);
-}
-
-
-/* The GtkMenu for the toolbar button. */
-
-static void
-menuitem_activate (GtkMenuItem *item, gpointer data)
-{
- EUserCreatableItemsHandler *handler = data;
- const char *verb;
-
- verb = g_object_get_data (G_OBJECT (item), "EUserCreatableItemsHandler:verb");
- execute_verb (handler, verb);
-}
-
-static void
-default_activate (EComboButton *combo_button, gpointer data)
-{
- EUserCreatableItemsHandler *handler = data;
-
- execute_verb (handler, handler->priv->default_menu_item->verb);
-}
-
-static void
-gtk_menu_item_func (EUserCreatableItemsHandler *handler, gpointer menu,
- MenuItem *item, gboolean first)
-{
- GtkWidget *menuitem, *icon;
-
- menuitem = gtk_image_menu_item_new_with_mnemonic (item->label);
-
- if (item->icon) {
- icon = gtk_image_new_from_pixbuf (item->icon);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
- icon);
- }
-
- if (first) {
- gtk_widget_add_accelerator (menuitem, "activate",
- handler->priv->accel_group,
- 'n', GDK_CONTROL_MASK,
- GTK_ACCEL_VISIBLE);
- } else if (item->shortcut != '\0') {
- gtk_widget_add_accelerator (menuitem, "activate",
- handler->priv->accel_group,
- item->shortcut,
- GDK_CONTROL_MASK | GDK_SHIFT_MASK,
- GTK_ACCEL_VISIBLE);
- }
-
- g_object_set_data (G_OBJECT (menuitem), "EUserCreatableItemsHandler:verb", item->verb);
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (menuitem_activate), handler);
-
- gtk_menu_shell_append (menu, menuitem);
-}
-
-static void
-gtk_separator_func (EUserCreatableItemsHandler *handler, gpointer menu, int nth)
-{
- gtk_menu_shell_append (menu, gtk_separator_menu_item_new ());
-}
-
-static void
-set_combo_button_style (EComboButton *button, const gchar *style, GdkPixbuf *icon)
-{
- if(!g_ascii_strcasecmp (style,"both-horiz")){
- e_combo_button_pack_hbox (button);
- e_combo_button_set_label (button, _("New"));
- e_combo_button_set_icon (button, icon);
- }
- else if(!g_ascii_strcasecmp (style,"icons")){
- e_combo_button_pack_hbox (button);
- e_combo_button_set_icon (button, icon);
- e_combo_button_set_label (button, "");
- }
- else if(!g_ascii_strcasecmp(style,"text")){
- e_combo_button_pack_hbox (button);
- e_combo_button_set_label (button, _("New"));
- e_combo_button_set_icon (button, NULL);
- } else { /* Default to both */
- e_combo_button_pack_vbox (button);
- e_combo_button_set_icon (button, icon);
- e_combo_button_set_label (button, _("New"));
- }
-}
-
-static void
-new_button_change (GConfClient *gconf,
- unsigned int connection_id,
- GConfEntry *entry,
- EUserCreatableItemsHandler *handler)
-{
- EUserCreatableItemsHandlerPrivate *priv;
- char *val;
-
- priv = handler->priv;
- val = gconf_client_get_string (gconf, "/desktop/gnome/interface/toolbar_style", NULL);
-
- set_combo_button_style (E_COMBO_BUTTON (priv->new_button),
- val, priv->default_menu_item->icon_toolbar ? priv->default_menu_item->icon_toolbar : priv->default_menu_item->icon);
-
- g_free (val);
- gtk_widget_show (priv->new_button);
-}
-
-static void
-setup_toolbar_button (EUserCreatableItemsHandler *handler)
-{
- EUserCreatableItemsHandlerPrivate *priv;
- GConfClient *gconf = gconf_client_get_default ();
- char *val;
-
- priv = handler->priv;
- val = gconf_client_get_string (gconf, "/desktop/gnome/interface/toolbar_style", NULL);
-
- priv->new_button = e_combo_button_new ();
- priv->new_menu = gtk_menu_new ();
- priv->accel_group = gtk_accel_group_new ();
- construct_menu (handler, priv->new_menu,
- gtk_menu_item_func, gtk_separator_func);
- gtk_widget_show_all (priv->new_menu);
- e_combo_button_set_menu (E_COMBO_BUTTON (priv->new_button),
- GTK_MENU (priv->new_menu));
-
- g_signal_connect (priv->new_button, "activate_default",
- G_CALLBACK (default_activate), handler);
-
- priv->new_control = bonobo_control_new (priv->new_button);
-
- priv->default_menu_item = get_default_action_for_view (handler);
- if (!priv->default_menu_item) {
- gtk_widget_set_sensitive (priv->new_button, FALSE);
- g_object_unref (gconf);
- return;
- }
-
- gtk_widget_set_sensitive (priv->new_button, TRUE);
-
- set_combo_button_style (E_COMBO_BUTTON (priv->new_button),
- val, priv->default_menu_item->icon_toolbar ? priv->default_menu_item->icon_toolbar : priv->default_menu_item->icon);
-
- gconf_client_notify_add(gconf,"/desktop/gnome/interface/toolbar_style",
- (GConfClientNotifyFunc)new_button_change, handler, NULL, NULL);
-
- gtk_widget_set_tooltip_text (priv->new_button,
- priv->default_menu_item->tooltip);
- gtk_widget_show (priv->new_button);
-
- g_free (val);
- g_object_unref (gconf);
-}
-
-
-/* GObject methods. */
-
-static void
-impl_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
-{
- EUserCreatableItemsHandler *handler =
- E_USER_CREATABLE_ITEMS_HANDLER (object);
-
- switch (prop_id) {
- case PROP_THIS_COMPONENT:
- handler->priv->this_component = g_value_dup_string (value);
-
- get_components_from_bonobo (handler);
- ensure_menu_items (handler);
- break;
- default:
- break;
- }
-}
-
-static void
-impl_dispose (GObject *object)
-{
- EUserCreatableItemsHandler *handler;
- EUserCreatableItemsHandlerPrivate *priv;
- GSList *p;
-
- handler = E_USER_CREATABLE_ITEMS_HANDLER (object);
- priv = handler->priv;
-
- for (p = priv->components; p != NULL; p = p->next)
- component_free ((Component *) p->data);
-
- g_slist_free (priv->components);
- priv->components = NULL;
-
- if (priv->new_control) {
- bonobo_object_unref (priv->new_control);
- priv->new_control = NULL;
- }
-
- if (priv->accel_group) {
- g_object_unref (priv->accel_group);
- priv->accel_group = NULL;
- }
-
- (* G_OBJECT_CLASS (e_user_creatable_items_handler_parent_class)->dispose) (object);
-}
-
-static void
-impl_finalize (GObject *object)
-{
- EUserCreatableItemsHandler *handler;
- EUserCreatableItemsHandlerPrivate *priv;
-
- handler = E_USER_CREATABLE_ITEMS_HANDLER (object);
- priv = handler->priv;
-
- g_free (priv->this_component);
-
- free_menu_items (priv->objects);
- free_menu_items (priv->folders);
-
- g_free (priv->menu_xml);
-
- g_free (priv);
-
- (* G_OBJECT_CLASS (e_user_creatable_items_handler_parent_class)->finalize) (object);
-}
-
-
-static void
-e_user_creatable_items_handler_class_init (EUserCreatableItemsHandlerClass *klass)
-{
- GObjectClass *object_class;
-
- bindtextdomain (GETTEXT_PACKAGE, EVOLUTION_LOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
- object_class->set_property = impl_set_property;
-
- g_object_class_install_property (
- object_class, PROP_THIS_COMPONENT,
- g_param_spec_string ("this_component", "Component alias",
- "The component_alias of this component",
- NULL,
- G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
-}
-
-static void
-e_user_creatable_items_handler_init (EUserCreatableItemsHandler *handler)
-{
- EUserCreatableItemsHandlerPrivate *priv;
-
- priv = g_new0 (EUserCreatableItemsHandlerPrivate, 1);
-
- handler->priv = priv;
-}
-
-
-EUserCreatableItemsHandler *
-e_user_creatable_items_handler_new (const char *component_alias,
- EUserCreatableItemsHandlerCreate create_local, void *data)
-{
- EUserCreatableItemsHandler *handler;
-
- handler = g_object_new (e_user_creatable_items_handler_get_type (),
- "this_component", component_alias,
- NULL);
- handler->priv->create_local = create_local;
- handler->priv->create_data = data;
-
- return handler;
-}
-
-
-/**
- * e_user_creatable_items_handler_activate:
- * @handler: the #EUserCreatableItemsHandler
- * @ui_component: the #BonoboUIComponent to attach to
- *
- * Set up the menus and toolbar items for @ui_component.
- **/
-void
-e_user_creatable_items_handler_activate (EUserCreatableItemsHandler *handler,
- BonoboUIComponent *ui_component)
-{
- EUserCreatableItemsHandlerPrivate *priv;
-
- g_return_if_fail (E_IS_USER_CREATABLE_ITEMS_HANDLER (handler));
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
-
- priv = handler->priv;
-
- if (!priv->menu_xml) {
- create_menu_xml (handler);
- setup_toolbar_button (handler);
- add_verbs (handler, ui_component);
- }
-
- bonobo_ui_component_set (ui_component, "/menu/File/New",
- priv->menu_xml, NULL);
-
- bonobo_ui_component_object_set (ui_component,
- "/Toolbar/NewComboButton",
- BONOBO_OBJREF (priv->new_control),
- NULL);
-}
diff --git a/shell/e-user-creatable-items-handler.h b/shell/e-user-creatable-items-handler.h
deleted file mode 100644
index 5d51612539..0000000000
--- a/shell/e-user-creatable-items-handler.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _E_USER_CREATABLE_ITEMS_HANDLER_H_
-#define _E_USER_CREATABLE_ITEMS_HANDLER_H_
-
-#include <glib-object.h>
-#include <bonobo/bonobo-ui-component.h>
-#include <bonobo/bonobo-window.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#define E_TYPE_USER_CREATABLE_ITEMS_HANDLER (e_user_creatable_items_handler_get_type ())
-#define E_USER_CREATABLE_ITEMS_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_USER_CREATABLE_ITEMS_HANDLER, EUserCreatableItemsHandler))
-#define E_USER_CREATABLE_ITEMS_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_USER_CREATABLE_ITEMS_HANDLER, EUserCreatableItemsHandlerClass))
-#define E_IS_USER_CREATABLE_ITEMS_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_USER_CREATABLE_ITEMS_HANDLER))
-#define E_IS_USER_CREATABLE_ITEMS_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_USER_CREATABLE_ITEMS_HANDLER))
-
-
-typedef struct _EUserCreatableItemsHandler EUserCreatableItemsHandler;
-typedef struct _EUserCreatableItemsHandlerPrivate EUserCreatableItemsHandlerPrivate;
-typedef struct _EUserCreatableItemsHandlerClass EUserCreatableItemsHandlerClass;
-
-typedef void (*EUserCreatableItemsHandlerCreate)(EUserCreatableItemsHandler *handler, const char *item_type_name, void *data);
-
-struct _EUserCreatableItemsHandler {
- GObject parent;
-
- EUserCreatableItemsHandlerPrivate *priv;
-};
-
-struct _EUserCreatableItemsHandlerClass {
- GObjectClass parent_class;
-};
-
-
-GType e_user_creatable_items_handler_get_type (void);
-EUserCreatableItemsHandler *e_user_creatable_items_handler_new (const char *component_alias,
- EUserCreatableItemsHandlerCreate create_local, void *data);
-
-void e_user_creatable_items_handler_activate (EUserCreatableItemsHandler *handler,
- BonoboUIComponent *ui_component);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_USER_CREATABLE_ITEMS_HANDLER_H_ */
diff --git a/shell/es-event.c b/shell/es-event.c
index 8aeeb7b912..80d3896023 100644
--- a/shell/es-event.c
+++ b/shell/es-event.c
@@ -112,6 +112,14 @@ ESEvent *es_event_peek(void)
return es_event;
}
+ESEventTargetShell *
+es_event_target_new (ESEvent *eme)
+{
+ return e_event_target_new (
+ &eme->event, ES_EVENT_TARGET_SHELL,
+ sizeof (ESEventTargetShell));
+}
+
ESEventTargetState *
es_event_target_new_state(ESEvent *eme, int state)
{
@@ -130,16 +138,6 @@ es_event_target_new_state(ESEvent *eme, int state)
return t;
}
-ESEventTargetShell *
-es_event_target_new_shell(ESEvent *eme, EShell *shell)
-{
- ESEventTargetShell *t = e_event_target_new(&eme->event, ES_EVENT_TARGET_SHELL, sizeof(*t));
-
- t->shell = shell;
-
- return t;
-}
-
ESEventTargetUpgrade *
es_event_target_new_upgrade(ESEvent *eme, int major, int minor, int revision)
{
diff --git a/shell/es-event.h b/shell/es-event.h
index ca12eb22dd..df6d7e6398 100644
--- a/shell/es-event.h
+++ b/shell/es-event.h
@@ -28,12 +28,7 @@
#include "e-util/e-event.h"
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-struct _EShell; /* Avoid including "e-shell.h" */
+G_BEGIN_DECLS
typedef struct _ESEvent ESEvent;
typedef struct _ESEventClass ESEventClass;
@@ -59,8 +54,6 @@ typedef struct _ESEventTargetComponent ESEventTargetComponent;
struct _ESEventTargetShell {
EEventTarget target;
-
- struct _EShell *shell;
};
struct _ESEventTargetState {
@@ -100,8 +93,8 @@ GType es_event_get_type(void);
ESEvent *es_event_peek(void);
+ESEventTargetShell *es_event_target_new(ESEvent *eme);
ESEventTargetState *es_event_target_new_state(ESEvent *emp, int state);
-ESEventTargetShell *es_event_target_new_shell(ESEvent *eme, struct _EShell *shell);
ESEventTargetUpgrade *es_event_target_new_upgrade(ESEvent *emp, int major, int minor, int revision);
ESEventTargetComponent *es_event_target_new_component(ESEvent *eme, const char *id);
@@ -120,8 +113,6 @@ struct _ESEventHookClass {
GType es_event_hook_get_type(void);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
#endif /* __ES_EVENT_H__ */
diff --git a/shell/es-menu.c b/shell/es-menu.c
deleted file mode 100644
index ac2736b52a..0000000000
--- a/shell/es-menu.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Michael Zucchi <notzed@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <stdlib.h>
-
-#include <glib.h>
-
-#include "es-menu.h"
-
-static GObjectClass *esm_parent;
-
-static void
-esm_init(GObject *o)
-{
- /*ESMenu *esm = (ESMenu *)o; */
-}
-
-static void
-esm_finalise(GObject *o)
-{
- ((GObjectClass *)esm_parent)->finalize(o);
-}
-
-static void
-esm_target_free(EMenu *ep, EMenuTarget *t)
-{
- switch (t->type) {
- case ES_MENU_TARGET_SHELL: {
- ESMenuTargetShell *s = (ESMenuTargetShell *)t;
-
- s = s;
- break; }
- }
-
- ((EMenuClass *)esm_parent)->target_free(ep, t);
-}
-
-static void
-esm_class_init(GObjectClass *klass)
-{
- klass->finalize = esm_finalise;
- ((EMenuClass *)klass)->target_free = esm_target_free;
-}
-
-GType
-es_menu_get_type(void)
-{
- static GType type = 0;
-
- if (type == 0) {
- static const GTypeInfo info = {
- sizeof(ESMenuClass),
- NULL, NULL,
- (GClassInitFunc)esm_class_init,
- NULL, NULL,
- sizeof(ESMenu), 0,
- (GInstanceInitFunc)esm_init
- };
- esm_parent = g_type_class_ref(e_menu_get_type());
- type = g_type_register_static(e_menu_get_type(), "ESMenu", &info, 0);
- }
-
- return type;
-}
-
-ESMenu *es_menu_new(const char *menuid)
-{
- ESMenu *esm = g_object_new(es_menu_get_type(), NULL);
-
- e_menu_construct(&esm->menu, menuid);
-
- return esm;
-}
-
-/**
- * es_menu_target_new_shell:
- * @esm:
- * @flags:
- *
- * Create a new menu target for the shell.
- *
- * Return value:
- **/
-ESMenuTargetShell *
-es_menu_target_new_shell(ESMenu *esm, guint32 flags)
-{
- ESMenuTargetShell *t = e_menu_target_new(&esm->menu, ES_MENU_TARGET_SHELL, sizeof(*t));
- guint32 mask = ~0;
-
- mask &= ~ flags;
- t->target.mask = mask;
-
- return t;
-}
-
-/* ********************************************************************** */
-
-
-static void *esph_parent_class;
-#define esph ((ESMenuHook *)eph)
-
-static const EMenuHookTargetMask esph_shell_masks[] = {
- { "online", ES_MENU_SHELL_ONLINE },
- { "offline", ES_MENU_SHELL_OFFLINE },
- { NULL }
-};
-
-static const EMenuHookTargetMap esph_targets[] = {
- { "shell", ES_MENU_TARGET_SHELL, esph_shell_masks },
- { NULL }
-};
-
-static void
-esph_finalise(GObject *o)
-{
- /*EPluginHook *eph = (EPluginHook *)o;*/
-
- ((GObjectClass *)esph_parent_class)->finalize(o);
-}
-
-static void
-esph_class_init(EPluginHookClass *klass)
-{
- int i;
-
- /** @HookClass: Shell Main Menu
- * @Id: org.gnome.evolution.shell.bonobomenu:1.0
- * @Target: ESMenuTargetShell
- *
- * A hook for the main menus from the shell component.
- *
- * These menu's will be available from all components, but
- * will have no context for the current component.
- **/
-
- ((GObjectClass *)klass)->finalize = esph_finalise;
- ((EPluginHookClass *)klass)->id = "org.gnome.evolution.shell.bonobomenu:1.0";
-
- for (i=0;esph_targets[i].type;i++)
- e_menu_hook_class_add_target_map((EMenuHookClass *)klass, &esph_targets[i]);
-
- /* FIXME: leaks parent set class? */
- ((EMenuHookClass *)klass)->menu_class = g_type_class_ref(es_menu_get_type());
-}
-
-GType
-es_menu_hook_get_type(void)
-{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo info = {
- sizeof(ESMenuHookClass), NULL, NULL, (GClassInitFunc) esph_class_init, NULL, NULL,
- sizeof(ESMenuHook), 0, (GInstanceInitFunc) NULL,
- };
-
- esph_parent_class = g_type_class_ref(e_menu_hook_get_type());
- type = g_type_register_static(e_menu_hook_get_type(), "ESMenuHook", &info, 0);
- }
-
- return type;
-}
diff --git a/shell/es-menu.h b/shell/es-menu.h
deleted file mode 100644
index 7ea4df5576..0000000000
--- a/shell/es-menu.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Michel Zucchi <notzed@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef __ES_MENU_H__
-#define __ES_MENU_H__
-
-#include <glib-object.h>
-
-#include "e-util/e-menu.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-typedef struct _ESMenu ESMenu;
-typedef struct _ESMenuClass ESMenuClass;
-
-/* Current target description */
-/* Types of popup tagets */
-enum _es_menu_target_t {
- ES_MENU_TARGET_SHELL,
-};
-
-/* Flags that describe a TARGET_SHELL */
-enum {
- ES_MENU_SHELL_ONLINE = 1<<0,
- ES_MENU_SHELL_OFFLINE = 1<<1,
-};
-
-typedef struct _ESMenuTargetShell ESMenuTargetShell;
-
-struct _ESMenuTargetShell {
- EMenuTarget target;
-
- /* current component?? */
-};
-
-typedef struct _EMenuItem ESMenuItem;
-
-/* The object */
-struct _ESMenu {
- EMenu menu;
-
- struct _ESMenuPrivate *priv;
-};
-
-struct _ESMenuClass {
- EMenuClass menu_class;
-};
-
-GType es_menu_get_type(void);
-
-ESMenu *es_menu_new(const char *menuid);
-
-ESMenuTargetShell *es_menu_target_new_shell(ESMenu *emp, guint32 flags);
-
-/* ********************************************************************** */
-
-typedef struct _ESMenuHook ESMenuHook;
-typedef struct _ESMenuHookClass ESMenuHookClass;
-
-struct _ESMenuHook {
- EMenuHook hook;
-};
-
-struct _ESMenuHookClass {
- EMenuHookClass hook_class;
-};
-
-GType es_menu_hook_get_type(void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __ES_MENU_H__ */
diff --git a/shell/evolution-component.c b/shell/evolution-component.c
deleted file mode 100644
index 62cddb6a32..0000000000
--- a/shell/evolution-component.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Michael Zucchi <notzed@novell.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "evolution-component.h"
-
-#define PARENT_TYPE bonobo_object_get_type ()
-
-static BonoboObjectClass *parent_class = NULL;
-
-/* Evolution.Component */
-
-/* Initialization */
-
-static void
-evolution_component_class_init (EvolutionComponentClass *klass)
-{
- parent_class = g_type_class_peek_parent (klass);
-}
-
-static void
-evolution_component_init(EvolutionComponent *emf, EvolutionComponentClass *klass)
-{
-}
-
-BONOBO_TYPE_FUNC_FULL (EvolutionComponent, GNOME_Evolution_Component, PARENT_TYPE, evolution_component)
diff --git a/shell/evolution-config-control.c b/shell/evolution-config-control.c
deleted file mode 100644
index 35044c9dba..0000000000
--- a/shell/evolution-config-control.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "evolution-config-control.h"
-
-#include <e-util/e-util.h>
-
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-event-source.h>
-
-
-#define PARENT_TYPE BONOBO_OBJECT_TYPE
-static BonoboObjectClass *parent_class = NULL;
-
-struct _EvolutionConfigControlPrivate {
- BonoboControl *control;
- BonoboEventSource *event_source;
-};
-
-/* GObject methods. */
-
-static void
-impl_dispose (GObject *object)
-{
- EvolutionConfigControl *config_control;
- EvolutionConfigControlPrivate *priv;
-
- config_control = EVOLUTION_CONFIG_CONTROL (object);
- priv = config_control->priv;
-
- if (priv->control != NULL) {
- bonobo_object_unref (BONOBO_OBJECT (priv->control));
- priv->control = NULL;
- }
-
- if (priv->event_source != NULL) {
- bonobo_object_unref (BONOBO_OBJECT (priv->event_source));
- priv->event_source = NULL;
- }
-
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
-
-static void
-impl_finalize (GObject *object)
-{
- EvolutionConfigControl *config_control;
- EvolutionConfigControlPrivate *priv;
-
- config_control = EVOLUTION_CONFIG_CONTROL (object);
- priv = config_control->priv;
-
- g_free (priv);
-
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-
-/* Evolution::ConfigControl CORBA methods. */
-
-static Bonobo_Control
-impl__get_control (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- EvolutionConfigControl *config_control;
- EvolutionConfigControlPrivate *priv;
-
- config_control = EVOLUTION_CONFIG_CONTROL (bonobo_object_from_servant (servant));
- priv = config_control->priv;
-
- bonobo_object_ref (BONOBO_OBJECT (priv->control));
-
- return CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (priv->control)), ev);
-}
-
-static Bonobo_EventSource
-impl__get_eventSource (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- EvolutionConfigControl *config_control;
- EvolutionConfigControlPrivate *priv;
-
- config_control = EVOLUTION_CONFIG_CONTROL (bonobo_object_from_servant (servant));
- priv = config_control->priv;
-
- bonobo_object_ref (BONOBO_OBJECT (priv->event_source));
-
- return CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (priv->event_source)), ev);
-}
-
-
-static void
-evolution_config_control_class_init (EvolutionConfigControlClass *class)
-{
- POA_GNOME_Evolution_ConfigControl__epv *epv;
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (class);
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-
- epv = &class->epv;
- epv->_get_control = impl__get_control;
- epv->_get_eventSource = impl__get_eventSource;
-
- parent_class = g_type_class_ref (PARENT_TYPE);
-}
-
-static void
-evolution_config_control_init (EvolutionConfigControl *config_control)
-{
- EvolutionConfigControlPrivate *priv;
-
- priv = g_new (EvolutionConfigControlPrivate, 1);
- priv->control = NULL;
- priv->event_source = bonobo_event_source_new ();
-
- config_control->priv = priv;
-}
-
-
-void
-evolution_config_control_construct (EvolutionConfigControl *control,
- GtkWidget *widget)
-{
- EvolutionConfigControlPrivate *priv;
-
- g_return_if_fail (EVOLUTION_IS_CONFIG_CONTROL (control));
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- priv = control->priv;
-
- priv->control = bonobo_control_new (widget);
-}
-
-EvolutionConfigControl *
-evolution_config_control_new (GtkWidget *widget)
-{
- EvolutionConfigControl *new;
-
- g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-
- new = g_object_new (evolution_config_control_get_type (), NULL);
- evolution_config_control_construct (new, widget);
-
- return new;
-}
-
-BONOBO_TYPE_FUNC_FULL (EvolutionConfigControl,
- GNOME_Evolution_ConfigControl,
- PARENT_TYPE,
- evolution_config_control)
diff --git a/shell/evolution-config-control.h b/shell/evolution-config-control.h
deleted file mode 100644
index 10e320c4a8..0000000000
--- a/shell/evolution-config-control.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef EVOLUTION_CONFIG_CONTROL_H
-#define EVOLUTION_CONFIG_CONTROL_H
-
-#include "Evolution.h"
-
-#include <bonobo/bonobo-object.h>
-#include <gtk/gtk.h>
-
-#ifdef cplusplus
-extern "C" {
-#pragma }
-#endif /* cplusplus */
-
-#define EVOLUTION_TYPE_CONFIG_CONTROL (evolution_config_control_get_type ())
-#define EVOLUTION_CONFIG_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_TYPE_CONFIG_CONTROL, EvolutionConfigControl))
-#define EVOLUTION_CONFIG_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_CONFIG_CONTROL, EvolutionConfigControlClass))
-#define EVOLUTION_IS_CONFIG_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_TYPE_CONFIG_CONTROL))
-#define EVOLUTION_IS_CONFIG_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_CONFIG_CONTROL))
-
-typedef struct _EvolutionConfigControl EvolutionConfigControl;
-typedef struct _EvolutionConfigControlPrivate EvolutionConfigControlPrivate;
-typedef struct _EvolutionConfigControlClass EvolutionConfigControlClass;
-
-struct _EvolutionConfigControl {
- BonoboObject parent;
-
- EvolutionConfigControlPrivate *priv;
-};
-
-struct _EvolutionConfigControlClass {
- BonoboObjectClass parent_class;
-
- POA_GNOME_Evolution_ConfigControl__epv epv;
-};
-
-
-GType evolution_config_control_get_type (void);
-EvolutionConfigControl *evolution_config_control_new (GtkWidget *widget);
-void evolution_config_control_construct (EvolutionConfigControl *control,
- GtkWidget *widget);
-
-#endif /* EVOLUTION_CONFIG_CONTROL_H */
diff --git a/shell/evolution-listener.c b/shell/evolution-listener.c
deleted file mode 100644
index 516c04abb2..0000000000
--- a/shell/evolution-listener.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Michael Zucchi <notzed@novell.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "evolution-listener.h"
-
-#define PARENT_TYPE bonobo_object_get_type ()
-
-static BonoboObjectClass *parent_class = NULL;
-
-/* Evolution.Listener */
-static void
-impl_complete(PortableServer_Servant _servant, CORBA_Environment * ev)
-{
- EvolutionListener *el = (EvolutionListener *)bonobo_object_from_servant(_servant);
-
- if (el->complete)
- el->complete(el, el->data);
-}
-
-static void
-evolution_listener_class_init (EvolutionListenerClass *klass)
-{
- POA_GNOME_Evolution_Listener__epv *epv = &klass->epv;
-
- parent_class = g_type_class_peek_parent (klass);
-
- epv->complete = impl_complete;
-}
-
-static void
-evolution_listener_init(EvolutionListener *emf, EvolutionListenerClass *klass)
-{
-}
-
-BONOBO_TYPE_FUNC_FULL (EvolutionListener, GNOME_Evolution_Listener, PARENT_TYPE, evolution_listener)
-
-EvolutionListener *
-evolution_listener_new(EvolutionListenerFunc complete, void *data)
-{
- EvolutionListener *el;
-
- el = g_object_new(evolution_listener_get_type(), NULL);
- el->complete = complete;
- el->data = data;
-
- return el;
-}
diff --git a/shell/evolution-listener.h b/shell/evolution-listener.h
deleted file mode 100644
index c85ae53613..0000000000
--- a/shell/evolution-listener.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- *
- * Abstract class wrapper for EvolutionListener
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Michael Zucchi <notzed@novell.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _EVOLUTION_LISTENER_H_
-#define _EVOLUTION_LISTENER_H_
-
-#include <bonobo/bonobo-object.h>
-#include "shell/Evolution.h"
-
-typedef struct _EvolutionListener EvolutionListener;
-typedef struct _EvolutionListenerClass EvolutionListenerClass;
-
-typedef void (*EvolutionListenerFunc)(EvolutionListener *, void *);
-
-struct _EvolutionListener {
- BonoboObject parent;
-
- /* we dont need signals, so why bother wasting resources on it */
- EvolutionListenerFunc complete;
- void *data;
-};
-
-struct _EvolutionListenerClass {
- BonoboObjectClass parent_class;
-
- POA_GNOME_Evolution_Listener__epv epv;
-};
-
-GType evolution_listener_get_type(void);
-EvolutionListener *evolution_listener_new(EvolutionListenerFunc complete, void *data);
-
-#endif /* _EVOLUTION_LISTENER_H_ */
diff --git a/shell/evolution-shell-component-utils.c b/shell/evolution-shell-component-utils.c
deleted file mode 100644
index 9dc1c3323b..0000000000
--- a/shell/evolution-shell-component-utils.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "evolution-shell-component-utils.h"
-#include <e-util/e-icon-factory.h>
-#include "e-util/e-dialog-utils.h"
-
-#include <string.h>
-#include <glib/gi18n.h>
-#include <bonobo/bonobo-ui-util.h>
-#include <bonobo/bonobo-moniker-util.h>
-#include <bonobo/bonobo-exception.h>
-#include <bonobo-activation/bonobo-activation.h>
-
-static void free_pixmaps (void);
-static GSList *inited_arrays = NULL;
-
-void e_pixmaps_update (BonoboUIComponent *uic, EPixmap *pixcache)
-{
- static int done_init = 0;
- int i;
-
- if (!done_init) {
- g_atexit (free_pixmaps);
- done_init = 1;
- }
-
- if (g_slist_find (inited_arrays, pixcache) == NULL)
- inited_arrays = g_slist_prepend (inited_arrays, pixcache);
-
- for (i = 0; pixcache [i].path; i++) {
- if (!pixcache [i].pixbuf) {
- GdkPixbuf *pixbuf;
-
- pixbuf = e_icon_factory_get_icon (pixcache [i].name, pixcache [i].size);
- pixcache [i].pixbuf = bonobo_ui_util_pixbuf_to_xml (pixbuf);
- g_object_unref (pixbuf);
- bonobo_ui_component_set_prop (uic,
- pixcache [i].path, "pixname",
- pixcache [i].pixbuf, NULL);
- } else {
- bonobo_ui_component_set_prop (uic, pixcache [i].path,
- "pixname",
- pixcache [i].pixbuf,
- NULL);
- }
- }
-}
-
-static void
-free_pixmaps (void)
-{
- int i;
- GSList *li;
-
- for (li = inited_arrays; li != NULL; li = li->next) {
- EPixmap *pixcache = li->data;
- for (i = 0; pixcache [i].path; i++)
- g_free (pixcache [i].pixbuf);
- }
-
- g_slist_free (inited_arrays);
-}
-
-
-/**
- * e_get_activation_failure_msg:
- * @ev: An exception returned by an oaf_activate call.
- *
- * Get a descriptive error message from @ev.
- *
- * Return value: A newly allocated string with the printable error message.
- **/
-char *
-e_get_activation_failure_msg (CORBA_Environment *ev)
-{
- g_return_val_if_fail (ev != NULL, NULL);
-
- if (CORBA_exception_id (ev) == NULL)
- return NULL;
-
- if (strcmp (CORBA_exception_id (ev), ex_Bonobo_GeneralError) != 0) {
- return bonobo_exception_get_text (ev);
- } else {
- const Bonobo_GeneralError *oaf_general_error;
-
- oaf_general_error = CORBA_exception_value (ev);
- return g_strdup (oaf_general_error->description);
- }
-}
diff --git a/shell/evolution-shell-component-utils.h b/shell/evolution-shell-component-utils.h
deleted file mode 100644
index 0fe71de8f4..0000000000
--- a/shell/evolution-shell-component-utils.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef __EVOLUTION_SHELL_COMPONENT_UTILS_H__
-#define __EVOLUTION_SHELL_COMPONENT_UTILS_H__
-
-#include <bonobo/bonobo-ui-component.h>
-#include <gtk/gtk.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-typedef struct _EPixmap {
- const char *path;
- const char *name;
- gint size;
- char *pixbuf;
-} EPixmap;
-
-#define E_PIXMAP(path,name,size) { (path), (name), (size), NULL }
-#define E_PIXMAP_END { NULL, NULL, 0, NULL }
-
-/* Takes an array of pixmaps, terminated by E_PIXMAP_END, and loads into uic */
-void e_pixmaps_update (BonoboUIComponent *uic, EPixmap *pixcache);
-
-char *e_get_activation_failure_msg (CORBA_Environment *ev);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __EVOLUTION_SHELL_COMPONENT_UTILS_H__ */
diff --git a/shell/importer/GNOME_Evolution_Importer.idl b/shell/importer/GNOME_Evolution_Importer.idl
deleted file mode 100644
index e33ca150ae..0000000000
--- a/shell/importer/GNOME_Evolution_Importer.idl
+++ /dev/null
@@ -1,97 +0,0 @@
-/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Interfaces for the importer framework.
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Copyright (C) 2000 Ximian, Inc.
- */
-
-#include <Bonobo.idl>
-
-module GNOME {
-module Evolution {
- interface ImporterListener : Bonobo::Unknown {
- enum ImporterResult {
- OK,
- UNSUPPORTED_OPERATION,
- NOT_READY,
- BUSY,
- UNKNOWN_DATA,
- BAD_DATA,
- BAD_FILE
- };
-
- /**
- * notifyResult:
- * @result: The result of the import.
- * @more_items: Are there any more items to be processed?
- *
- * Notifies the listener of the result and whether there are
- * any more items to be imported.
- */
- oneway void notifyResult (in ImporterResult result,
- in boolean more_items);
- };
-
- interface Importer : Bonobo::Unknown {
-
- /**
- * processItem:
- * @listener: The ImporterListener that will be notified of the
- * progress.
- *
- * Processes the next item.
- *
- */
- oneway void processItem (in ImporterListener listener);
-
- /**
- * getError:
- *
- * Retrieve a detailed explaination of the error.
- *
- * Returns: A string.
- */
- string getError ();
-
- void createControl (out Bonobo::Control control);
-
- /**
- * supportFormat:
- * @filename: The filename of the file.
- *
- * Checks if the importer created by this factory can
- * import the file specified.
- *
- * Returns: A boolean, TRUE if it can import the file,
- * FALSE otherwise.
- */
- boolean supportFormat (in string filename);
-
- /**
- * loadFile:
- * @filename: The filename of the file.
- * @folderpath: The full pathname to the folder.
- * @foldertpe: The type of the folder to import to.
- *
- * Loads the file and prepares an Importer object that can
- * process files of this type.
- *
- * Returns: An Importer object.
- */
- boolean loadFile (in string filename);
- };
-
- interface IntelligentImporter : Bonobo::Unknown {
-
- readonly attribute string importername;
- readonly attribute string message;
-
- boolean canImport ();
-
- void importData ();
- };
-};
-};
diff --git a/shell/importer/Makefile.am b/shell/importer/Makefile.am
deleted file mode 100644
index 1aa5d5b484..0000000000
--- a/shell/importer/Makefile.am
+++ /dev/null
@@ -1,68 +0,0 @@
-INCLUDES = \
- -I$(top_srcdir) \
- -I$(top_srcdir)/shell \
- -I$(top_builddir)/shell \
- -DG_LOG_DOMAIN=\"Evolution-Importer\" \
- -DEVOLUTION_GLADEDIR="\"$(gladedir)\"" \
- $(SHELL_CFLAGS)
-
-privlib_LTLIBRARIES = libevolution-importer.la
-
-
-# IDL stuff
-
-IDLS = GNOME_Evolution_Importer.idl
-
-IDL_GENERATED_H = \
- GNOME_Evolution_Importer.h
-
-IDL_GENERATED_C = \
- GNOME_Evolution_Importer-common.c \
- GNOME_Evolution_Importer-skels.c \
- GNOME_Evolution_Importer-stubs.c
-
-IDL_GENERATED = $(IDL_GENERATED_H) $(IDL_GENERATED_C)
-
-$(IDL_GENERATED_H): $(IDLS)
- $(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES) $(srcdir)/GNOME_Evolution_Importer.idl
-
-$(IDL_GENERATED_C): $(IDL_GENERATED_H)
-
-idl_DATA = $(IDLS)
-
-
-# Component
-
-libevolution_importerincludedir = $(privincludedir)/importer
-libevolution_importer_la_SOURCES = \
- $(IDL_GENERATED) \
- evolution-intelligent-importer.c \
- evolution-importer-client.c \
- evolution-importer-listener.c \
- evolution-importer.c \
- intelligent.c \
- intelligent.h
-
-libevolution_importerinclude_HEADERS = \
- GNOME_Evolution_Importer.h \
- evolution-intelligent-importer.h \
- evolution-importer-client.h \
- evolution-importer-listener.h \
- evolution-importer.h
-
-libevolution_importer_la_LIBADD = \
- $(top_builddir)/e-util/libeutil.la \
- $(SHELL_LIBS)
-
-glade_DATA = import.glade
-
-EXTRA_DIST = $(glade_DATA) $(IDLS)
-
-BUILT_SOURCES= $(IDL_GENERATED)
-CLEANFILES = $(BUILT_SOURCES)
-
-dist-hook:
- cd $(distdir); rm -f $(BUILT_SOURCES)
-
-
--include $(top_srcdir)/git.mk
diff --git a/shell/importer/evolution-importer-client.c b/shell/importer/evolution-importer-client.c
deleted file mode 100644
index 5f32241b17..0000000000
--- a/shell/importer/evolution-importer-client.c
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Based on evolution-shell-component-client.c by Ettore Perazzoli
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "evolution-importer-client.h"
-
-#include <glib.h>
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-main.h>
-#include <bonobo/bonobo-widget.h>
-#include <bonobo/bonobo-exception.h>
-
-#include "GNOME_Evolution_Importer.h"
-
-G_DEFINE_TYPE (EvolutionImporterClient, evolution_importer_client, G_TYPE_OBJECT)
-
-
-static void
-finalise (GObject *object)
-{
- /* FIXME: should this unref the client->objref?? */
-
- (* G_OBJECT_CLASS (evolution_importer_client_parent_class)->finalize) (object);
-}
-
-static void
-evolution_importer_client_class_init (EvolutionImporterClientClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = finalise;
-}
-
-static void
-evolution_importer_client_init (EvolutionImporterClient *client)
-{
-}
-
-/**
- * evolution_importer_client_new:
- * @objref: The CORBA_Object to make a client for.
- *
- * Makes a client for @objref. @objref should be an Evolution_Importer.
- *
- * Returns: A newly created EvolutionImporterClient.
- */
-EvolutionImporterClient *
-evolution_importer_client_new (const CORBA_Object objref)
-{
- EvolutionImporterClient *client;
-
- g_return_val_if_fail (objref != CORBA_OBJECT_NIL, NULL);
-
- client = g_object_new (evolution_importer_client_get_type (), NULL);
- client->objref = objref;
-
- return client;
-}
-
-/**
- * evolution_importer_client_new_from_id:
- * @id: The oafiid of the component to make a client for.
- *
- * Makes a client for the object returned by activating @id.
- *
- * Returns: A newly created EvolutionImporterClient.
- */
-EvolutionImporterClient *
-evolution_importer_client_new_from_id (const char *id)
-{
- CORBA_Environment ev;
- CORBA_Object objref;
-
- g_return_val_if_fail (id != NULL, NULL);
-
- CORBA_exception_init (&ev);
- objref = bonobo_activation_activate_from_id ((char *) id, 0, NULL, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- CORBA_exception_free (&ev);
- g_warning ("Could not start %s.", id);
- return NULL;
- }
-
- CORBA_exception_free (&ev);
- if (objref == CORBA_OBJECT_NIL) {
- g_warning ("Could not activate component %s", id);
- return NULL;
- }
-
- return evolution_importer_client_new (objref);
-}
-
-/* API */
-GtkWidget *
-evolution_importer_client_create_control (EvolutionImporterClient *client)
-{
- GNOME_Evolution_Importer corba_importer;
- GtkWidget *widget = NULL;
- Bonobo_Control control;
- CORBA_Environment ev;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client), NULL);
-
- CORBA_exception_init (&ev);
- corba_importer = client->objref;
- GNOME_Evolution_Importer_createControl (corba_importer, &control, &ev);
-
- if (!BONOBO_EX (&ev)) {
- /* FIXME Pass in container? */
- widget = bonobo_widget_new_control_from_objref (control, NULL);
- gtk_widget_show (widget);
- }
-
- CORBA_exception_free (&ev);
-
- return widget;
-}
-
-/**
- * evolution_importer_client_support_format:
- * @client: The EvolutionImporterClient.
- * @filename: Name of the file to check.
- *
- * Checks whether @client is able to import @filename.
- *
- * Returns: TRUE if @client can import @filename, FALSE otherwise.
- */
-gboolean
-evolution_importer_client_support_format (EvolutionImporterClient *client,
- const char *filename)
-{
- GNOME_Evolution_Importer corba_importer;
- gboolean result;
- CORBA_Environment ev;
-
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client), FALSE);
- g_return_val_if_fail (filename != NULL, FALSE);
-
- CORBA_exception_init (&ev);
- corba_importer = client->objref;
- result = GNOME_Evolution_Importer_supportFormat (corba_importer,
- filename, &ev);
- CORBA_exception_free (&ev);
-
- return result;
-}
-
-/**
- * evolution_importer_client_load_file:
- * @client: The EvolutionImporterClient.
- * @filename: The file to load.
- * @physical_uri: The physical URI of the folder to import data into.
- * @folder_type: The type of the folder represented by @physical_uri.
- *
- * Loads and initialises the importer.
- *
- * Returns: TRUE on sucess, FALSE on failure.
- */
-gboolean
-evolution_importer_client_load_file (EvolutionImporterClient *client, const char *filename)
-{
- GNOME_Evolution_Importer corba_importer;
- gboolean result;
- CORBA_Environment ev;
-
- g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client), FALSE);
- g_return_val_if_fail (filename != NULL, FALSE);
-
- CORBA_exception_init (&ev);
- corba_importer = client->objref;
- result = GNOME_Evolution_Importer_loadFile (corba_importer, filename, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Oh there *WAS* an exception.\nIt was %s",
- CORBA_exception_id (&ev));
- CORBA_exception_free (&ev);
- return FALSE;
- }
- CORBA_exception_free (&ev);
-
- return result;
-}
-
-/**
- * evolution_importer_client_process_item:
- * @client: The EvolutionImporterClient.
- * @listener: The EvolutionImporterListener.
- *
- * Starts importing the next item in the file. @listener will be notified
- * when the item has finished.
- */
-void
-evolution_importer_client_process_item (EvolutionImporterClient *client,
- EvolutionImporterListener *listener)
-{
- GNOME_Evolution_Importer corba_importer;
- GNOME_Evolution_ImporterListener corba_listener;
- CORBA_Environment ev;
-
- g_return_if_fail (client != NULL);
- g_return_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client));
- g_return_if_fail (listener != NULL);
- g_return_if_fail (EVOLUTION_IS_IMPORTER_LISTENER (listener));
-
- CORBA_exception_init (&ev);
-
- corba_importer = client->objref;
- corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
- GNOME_Evolution_Importer_processItem (corba_importer,
- corba_listener, &ev);
- CORBA_exception_free (&ev);
-}
-
-/**
- * evolution_importer_client_get_error:
- * @client: The EvolutionImporterClient.
- *
- * Gets the error as a string.
- *
- * Returns: The error as a string. If there is no error NULL is returned.
- * Importers need not support this method and if so, NULL is also returned.
- */
-const char *
-evolution_importer_client_get_error (EvolutionImporterClient *client)
-{
- GNOME_Evolution_Importer corba_importer;
- CORBA_char *str;
- CORBA_Environment ev;
-
- g_return_val_if_fail (client != NULL, NULL);
- g_return_val_if_fail (EVOLUTION_IS_IMPORTER_CLIENT (client), NULL);
-
- corba_importer = client->objref;
-
- CORBA_exception_init (&ev);
- str = GNOME_Evolution_Importer_getError (corba_importer, &ev);
-
- return str;
-}
diff --git a/shell/importer/evolution-importer-client.h b/shell/importer/evolution-importer-client.h
deleted file mode 100644
index 35cde858d6..0000000000
--- a/shell/importer/evolution-importer-client.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef EVOLUTION_IMPORTER_CLIENT_H
-#define EVOLUTION_IMPORTER_CLIENT_H
-
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <importer/evolution-importer.h>
-#include <importer/evolution-importer-listener.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif
-
-#define EVOLUTION_TYPE_IMPORTER_CLIENT (evolution_importer_client_get_type ())
-#define EVOLUTION_IMPORTER_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_TYPE_IMPORTER_CLIENT, EvolutionImporterClient))
-#define EVOLUTION_IMPORTER_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_IMPORTER_CLIENT, EvolutionImporterClientClass))
-#define EVOLUTION_IS_IMPORTER_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_TYPE_IMPORTER_CLIENT))
-#define EVOLUTION_IS_IMPORTER_CLIENT_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE ((klass), EVOLUTION_TYPE_IMPORTER_CLIENT))
-
-
-typedef struct _EvolutionImporterClient EvolutionImporterClient;
-typedef struct _EvolutionImporterClientClass EvolutionImporterClientClass;
-
-struct _EvolutionImporterClient {
- GObject parent_type;
-
- GNOME_Evolution_Importer objref;
-};
-
-struct _EvolutionImporterClientClass {
- GObjectClass parent_class;
-};
-
-GType evolution_importer_client_get_type (void);
-
-EvolutionImporterClient *evolution_importer_client_new (const CORBA_Object objref);
-EvolutionImporterClient *evolution_importer_client_new_from_id (const char *id);
-
-GtkWidget *evolution_importer_client_create_control (EvolutionImporterClient *client);
-gboolean evolution_importer_client_support_format (EvolutionImporterClient *client,
- const char *filename);
-gboolean evolution_importer_client_load_file (EvolutionImporterClient *client,
- const char *filename);
-void evolution_importer_client_process_item (EvolutionImporterClient *client,
- EvolutionImporterListener *listener);
-const char *evolution_importer_client_get_error (EvolutionImporterClient *client);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/shell/importer/evolution-importer-listener.c b/shell/importer/evolution-importer-listener.c
deleted file mode 100644
index e8256971f1..0000000000
--- a/shell/importer/evolution-importer-listener.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "evolution-importer-listener.h"
-
-#include <bonobo/bonobo-object.h>
-#include <e-util/e-util.h>
-
-#include "GNOME_Evolution_Importer.h"
-#define PARENT_TYPE BONOBO_OBJECT_TYPE
-
-static BonoboObjectClass *parent_class = NULL;
-
-struct _EvolutionImporterListenerPrivate {
- EvolutionImporterListenerCallback callback;
-
- void *closure;
-};
-
-#if 0
-static POA_GNOME_Evolution_ImporterListener__vepv Listener_vepv;
-
-static POA_GNOME_Evolution_ImporterListener *
-create_servant (void)
-{
- POA_GNOME_Evolution_ImporterListener *servant;
- CORBA_Environment ev;
-
- servant = (POA_GNOME_Evolution_ImporterListener *) g_new0 (BonoboObjectServant, 1);
- servant->vepv = &Listener_vepv;
-
- CORBA_exception_init (&ev);
- POA_GNOME_Evolution_ImporterListener__init ((PortableServer_Servant) servant, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_free (servant);
- CORBA_exception_free (&ev);
- return NULL;
- }
-
- CORBA_exception_free (&ev);
-
- return servant;
-}
-#endif
-
-static EvolutionImporterResult
-corba_result_to_evolution (GNOME_Evolution_ImporterListener_ImporterResult corba_result)
-{
- switch (corba_result) {
- case GNOME_Evolution_ImporterListener_OK:
- return EVOLUTION_IMPORTER_OK;
- case GNOME_Evolution_ImporterListener_UNSUPPORTED_OPERATION:
- return EVOLUTION_IMPORTER_UNSUPPORTED_OPERATION;
- case GNOME_Evolution_ImporterListener_UNKNOWN_DATA:
- return EVOLUTION_IMPORTER_UNKNOWN_DATA;
- case GNOME_Evolution_ImporterListener_BAD_DATA:
- return EVOLUTION_IMPORTER_BAD_DATA;
- case GNOME_Evolution_ImporterListener_BAD_FILE:
- return EVOLUTION_IMPORTER_BAD_FILE;
- case GNOME_Evolution_ImporterListener_NOT_READY:
- return EVOLUTION_IMPORTER_NOT_READY;
- case GNOME_Evolution_ImporterListener_BUSY:
- return EVOLUTION_IMPORTER_BUSY;
- default:
- return EVOLUTION_IMPORTER_UNKNOWN_ERROR;
- }
-}
-
-static inline EvolutionImporterListener *
-evolution_importer_listener_from_servant (PortableServer_Servant servant)
-{
- return EVOLUTION_IMPORTER_LISTENER (bonobo_object_from_servant (servant));
-}
-
-static void
-impl_GNOME_Evolution_ImporterListener_notifyResult (PortableServer_Servant servant,
- GNOME_Evolution_ImporterListener_ImporterResult result,
- CORBA_boolean more_items,
- CORBA_Environment *ev)
-{
- EvolutionImporterListener *listener;
- EvolutionImporterListenerPrivate *priv;
- EvolutionImporterResult out_result;
-
- listener = evolution_importer_listener_from_servant (servant);
- priv = listener->priv;
-
- out_result = corba_result_to_evolution (result);
- if (priv->callback) {
- (priv->callback) (listener, out_result, more_items,
- priv->closure);
- }
-
- return;
-}
-
-
-/* GObject methods */
-static void
-finalise (GObject *object)
-{
- EvolutionImporterListener *listener;
- EvolutionImporterListenerPrivate *priv;
-
- listener = EVOLUTION_IMPORTER_LISTENER (object);
- priv = listener->priv;
-
- if (priv == NULL)
- return;
-
- g_free (priv);
- listener->priv = NULL;
-
- G_OBJECT_CLASS (parent_class)->finalize(object);
-}
-
-#if 0
-static void
-corba_class_init (void)
-{
- POA_GNOME_Evolution_ImporterListener__vepv *vepv;
- POA_GNOME_Evolution_ImporterListener__epv *epv;
- PortableServer_ServantBase__epv *base_epv;
-
- base_epv = g_new0 (PortableServer_ServantBase__epv, 1);
- base_epv->_private = NULL;
- base_epv->finalize = NULL;
- base_epv->default_POA = NULL;
-
- epv = g_new0 (POA_GNOME_Evolution_ImporterListener__epv, 1);
- epv->notifyResult = impl_GNOME_Evolution_ImporterListener_notifyResult;
-
- vepv = &Listener_vepv;
- vepv->_base_epv = base_epv;
- vepv->Bonobo_Unknown_epv = bonobo_object_get_epv ();
- vepv->GNOME_Evolution_ImporterListener_epv = epv;
-}
-#endif
-
-static void
-evolution_importer_listener_class_init (EvolutionImporterListenerClass *klass)
-{
- GObjectClass *object_class;
- POA_GNOME_Evolution_ImporterListener__epv *epv = &klass->epv;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = finalise;
-
- parent_class = g_type_class_ref(PARENT_TYPE);
- epv->notifyResult = impl_GNOME_Evolution_ImporterListener_notifyResult;
-}
-
-static void
-evolution_importer_listener_init (EvolutionImporterListener *listener)
-{
- EvolutionImporterListenerPrivate *priv;
-
- priv = g_new0 (EvolutionImporterListenerPrivate, 1);
- listener->priv = priv;
-}
-
-static void
-evolution_importer_listener_construct (EvolutionImporterListener *listener,
- EvolutionImporterListenerCallback callback,
- void *closure)
-{
- EvolutionImporterListenerPrivate *priv;
-
- g_return_if_fail (listener != NULL);
- g_return_if_fail (EVOLUTION_IS_IMPORTER_LISTENER (listener));
- g_return_if_fail (callback != NULL);
-
- priv = listener->priv;
- priv->callback = callback;
- priv->closure = closure;
-}
-
-/**
- * evolution_importer_listener_new
- * @callback: The #EvolutionImporterListenerCallback callback.
- * @closure: The data that will be passed to that callback.
- *
- * Creates a new #EvolutionImporterListener object which calls @callback when
- * something happens.
- * Returns: A newly allocated #EvolutionImporterListener.
- */
-EvolutionImporterListener *
-evolution_importer_listener_new (EvolutionImporterListenerCallback callback,
- void *closure)
-{
- EvolutionImporterListener *listener;
-
- listener = g_object_new (evolution_importer_listener_get_type (), NULL);
-
- evolution_importer_listener_construct (listener, callback, closure);
- return listener;
-}
-
-BONOBO_TYPE_FUNC_FULL (EvolutionImporterListener,
- GNOME_Evolution_ImporterListener,
- PARENT_TYPE, evolution_importer_listener);
diff --git a/shell/importer/evolution-importer-listener.h b/shell/importer/evolution-importer-listener.h
deleted file mode 100644
index 7e09ff2da8..0000000000
--- a/shell/importer/evolution-importer-listener.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef EVOLUTION_IMPORTER_LISTENER_H
-#define EVOLUTION_IMPORTER_LISTENER_H
-
-#include <glib.h>
-#include <bonobo/bonobo-object.h>
-#include <importer/GNOME_Evolution_Importer.h>
-#include "evolution-importer.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* cplusplus */
-
-#define EVOLUTION_TYPE_IMPORTER_LISTENER (evolution_importer_listener_get_type ())
-#define EVOLUTION_IMPORTER_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_TYPE_IMPORTER_LISTENER, EvolutionImporterListener))
-#define EVOLUTION_IMPORTER_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_IMPORTER_LISTENER, EvolutionImporterListenerClass))
-#define EVOLUTION_IS_IMPORTER_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_TYPE_IMPORTER_LISTENER))
-#define EVOLUTION_IS_IMPORTER_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_IMPORTER_LISTENER))
-
-typedef struct _EvolutionImporterListener EvolutionImporterListener;
-typedef struct _EvolutionImporterListenerPrivate EvolutionImporterListenerPrivate;
-typedef struct _EvolutionImporterListenerClass EvolutionImporterListenerClass;
-
-typedef void (* EvolutionImporterListenerCallback) (EvolutionImporterListener *listener,
- EvolutionImporterResult result,
- gboolean more_items,
- void *closure);
-struct _EvolutionImporterListener {
- BonoboObject parent;
-
- EvolutionImporterListenerPrivate *priv;
-};
-
-struct _EvolutionImporterListenerClass {
- BonoboObjectClass parent_class;
-
- POA_GNOME_Evolution_ImporterListener__epv epv;
-};
-
-GType evolution_importer_listener_get_type (void);
-
-EvolutionImporterListener *evolution_importer_listener_new (EvolutionImporterListenerCallback callback,
- void *closure);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/shell/importer/evolution-importer.c b/shell/importer/evolution-importer.c
deleted file mode 100644
index 9fb7e66f5e..0000000000
--- a/shell/importer/evolution-importer.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "evolution-importer.h"
-
-#include <bonobo/bonobo-object.h>
-#include <e-util/e-util.h>
-
-#include "GNOME_Evolution_Importer.h"
-
-#define PARENT_TYPE BONOBO_OBJECT_TYPE
-static BonoboObjectClass *parent_class = NULL;
-
-struct _EvolutionImporterPrivate {
- EvolutionImporterCreateControlFn create_control_fn;
- EvolutionImporterLoadFileFn load_file_fn;
- EvolutionImporterSupportFormatFn support_format_fn;
- EvolutionImporterProcessItemFn process_item_fn;
- EvolutionImporterGetErrorFn get_error_fn;
-
- void *closure;
-};
-
-
-static inline EvolutionImporter *
-evolution_importer_from_servant (PortableServer_Servant servant)
-{
- return EVOLUTION_IMPORTER (bonobo_object_from_servant (servant));
-}
-
-static void
-impl_GNOME_Evolution_Importer_createControl (PortableServer_Servant servant,
- Bonobo_Control *control,
- CORBA_Environment *ev)
-{
- EvolutionImporter *importer;
- EvolutionImporterPrivate *priv;
-
- importer = evolution_importer_from_servant (servant);
- priv = importer->priv;
-
- if (priv->create_control_fn != NULL)
- (priv->create_control_fn) (importer, control, priv->closure);
- else
- CORBA_exception_set_system (ev, ex_CORBA_NO_IMPLEMENT, CORBA_COMPLETED_NO);
-}
-
-static CORBA_boolean
-impl_GNOME_Evolution_Importer_supportFormat (PortableServer_Servant servant,
- const CORBA_char *filename,
- CORBA_Environment *ev)
-{
- EvolutionImporter *importer;
- EvolutionImporterPrivate *priv;
-
- importer = evolution_importer_from_servant (servant);
- priv = importer->priv;
-
- if (priv->support_format_fn != NULL)
- return (priv->support_format_fn) (importer, filename,
- priv->closure);
- else
- return FALSE;
-}
-
-static CORBA_boolean
-impl_GNOME_Evolution_Importer_loadFile (PortableServer_Servant servant,
- const CORBA_char *filename,
- CORBA_Environment *ev)
-{
- EvolutionImporter *importer;
- EvolutionImporterPrivate *priv;
-
- importer = evolution_importer_from_servant (servant);
- priv = importer->priv;
-
- if (priv->load_file_fn != NULL)
- return (priv->load_file_fn) (importer, filename, priv->closure);
- else
- return FALSE;
-}
-
-static void
-impl_GNOME_Evolution_Importer_processItem (PortableServer_Servant servant,
- GNOME_Evolution_ImporterListener listener,
- CORBA_Environment *ev)
-{
- EvolutionImporter *importer;
- EvolutionImporterPrivate *priv;
-
- importer = evolution_importer_from_servant (servant);
- priv = importer->priv;
-
- if (priv->process_item_fn != NULL)
- (priv->process_item_fn) (importer, listener, priv->closure, ev);
- else
- GNOME_Evolution_ImporterListener_notifyResult (listener,
- GNOME_Evolution_ImporterListener_UNSUPPORTED_OPERATION, FALSE, ev);
-}
-
-static CORBA_char *
-impl_GNOME_Evolution_Importer_getError (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- EvolutionImporter *importer;
- EvolutionImporterPrivate *priv;
- CORBA_char *out_str;
-
- importer = evolution_importer_from_servant (servant);
- priv = importer->priv;
-
- if (priv->get_error_fn != NULL) {
- out_str = (priv->get_error_fn) (importer, priv->closure);
- return CORBA_string_dup (out_str ? out_str : "");
- } else
- return CORBA_string_dup ("");
-}
-
-
-static void
-finalise (GObject *object)
-{
- EvolutionImporter *importer;
- EvolutionImporterPrivate *priv;
-
- importer = EVOLUTION_IMPORTER (object);
- priv = importer->priv;
-
- if (priv == NULL)
- return;
-
- g_free (priv);
- importer->priv = NULL;
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-evolution_importer_class_init (EvolutionImporterClass *klass)
-{
- GObjectClass *object_class;
- POA_GNOME_Evolution_Importer__epv *epv = &klass->epv;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = finalise;
-
- parent_class = g_type_class_ref(PARENT_TYPE);
- epv->createControl = impl_GNOME_Evolution_Importer_createControl;
- epv->supportFormat = impl_GNOME_Evolution_Importer_supportFormat;
- epv->loadFile = impl_GNOME_Evolution_Importer_loadFile;
- epv->processItem = impl_GNOME_Evolution_Importer_processItem;
- epv->getError = impl_GNOME_Evolution_Importer_getError;
-}
-
-static void
-evolution_importer_init (EvolutionImporter *importer)
-{
- EvolutionImporterPrivate *priv;
-
- priv = g_new0 (EvolutionImporterPrivate, 1);
-
- importer->priv = priv;
-}
-
-
-
-static void
-evolution_importer_construct (EvolutionImporter *importer,
- EvolutionImporterCreateControlFn create_control_fn,
- EvolutionImporterSupportFormatFn support_format_fn,
- EvolutionImporterLoadFileFn load_file_fn,
- EvolutionImporterProcessItemFn process_item_fn,
- EvolutionImporterGetErrorFn get_error_fn,
- void *closure)
-{
- EvolutionImporterPrivate *priv;
-
- g_return_if_fail (importer != NULL);
- g_return_if_fail (EVOLUTION_IS_IMPORTER (importer));
- g_return_if_fail (support_format_fn != NULL);
- g_return_if_fail (load_file_fn != NULL);
- g_return_if_fail (process_item_fn != NULL);
-
- priv = importer->priv;
- priv->create_control_fn = create_control_fn;
- priv->support_format_fn = support_format_fn;
- priv->load_file_fn = load_file_fn;
- priv->process_item_fn = process_item_fn;
- priv->get_error_fn = get_error_fn;
-
- priv->closure = closure;
-}
-
-/**
- * evolution_importer_new:
- * @support_format_fn: The function to be called by the supportFormat method.
- * @load_file_fn: The function to be called by the loadFile method.
- * @process_item_fn: The function to be called by the processItem method.
- * @get_error_fn: The function to be called by the getError method.
- * @closure: The data to be passed to all of the above functions.
- *
- * Creates a new EvolutionImporter object. Of the parameters only
- * @get_error_function and @closure may be #NULL.
- *
- * Returns: A newly created EvolutionImporter object.
- */
-EvolutionImporter *
-evolution_importer_new (EvolutionImporterCreateControlFn create_control_fn,
- EvolutionImporterSupportFormatFn support_format_fn,
- EvolutionImporterLoadFileFn load_file_fn,
- EvolutionImporterProcessItemFn process_item_fn,
- EvolutionImporterGetErrorFn get_error_fn,
- void *closure)
-{
- EvolutionImporter *importer;
-
- importer = g_object_new(evolution_importer_get_type (), NULL);
- evolution_importer_construct (importer, create_control_fn, support_format_fn, load_file_fn,
- process_item_fn, get_error_fn, closure);
- return importer;
-}
-
-BONOBO_TYPE_FUNC_FULL (EvolutionImporter,
- GNOME_Evolution_Importer,
- PARENT_TYPE,
- evolution_importer);
diff --git a/shell/importer/evolution-importer.h b/shell/importer/evolution-importer.h
deleted file mode 100644
index a684aecfb2..0000000000
--- a/shell/importer/evolution-importer.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef EVOLUTION_IMPORTER_H
-#define EVOLUTION_IMPORTER_H
-
-#include <glib.h>
-#include <bonobo/bonobo-object.h>
-#include <importer/GNOME_Evolution_Importer.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* cplusplus */
-
-#define EVOLUTION_TYPE_IMPORTER (evolution_importer_get_type ())
-#define EVOLUTION_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_TYPE_IMPORTER, EvolutionImporter))
-#define EVOLUTION_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_IMPORTER, EvolutionImporterClass))
-#define EVOLUTION_IS_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_TYPE_IMPORTER))
-#define EVOLUTION_IS_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_IMPORTER))
-
-typedef struct _EvolutionImporter EvolutionImporter;
-typedef struct _EvolutionImporterPrivate EvolutionImporterPrivate;
-typedef struct _EvolutionImporterClass EvolutionImporterClass;
-
-typedef void (* EvolutionImporterCreateControlFn) (EvolutionImporter *importer,
- Bonobo_Control *control,
- void *closure);
-
-typedef gboolean (* EvolutionImporterSupportFormatFn) (EvolutionImporter *importer,
- const char *filename,
- void *closure);
-typedef gboolean (* EvolutionImporterLoadFileFn) (EvolutionImporter *importer,
- const char *filename,
- void *closure);
-typedef void (* EvolutionImporterProcessItemFn) (EvolutionImporter *importer,
- CORBA_Object listener,
- void *closure,
- CORBA_Environment *ev);
-typedef char *(* EvolutionImporterGetErrorFn) (EvolutionImporter *importer,
- void *closure);
-
-typedef enum {
- EVOLUTION_IMPORTER_OK,
- EVOLUTION_IMPORTER_UNSUPPORTED_OPERATION,
- EVOLUTION_IMPORTER_INTERRUPTED,
- EVOLUTION_IMPORTER_BUSY,
- EVOLUTION_IMPORTER_NOT_READY,
- EVOLUTION_IMPORTER_UNKNOWN_DATA,
- EVOLUTION_IMPORTER_BAD_DATA,
- EVOLUTION_IMPORTER_BAD_FILE,
- EVOLUTION_IMPORTER_UNKNOWN_ERROR
-} EvolutionImporterResult;
-
-struct _EvolutionImporter {
- BonoboObject parent;
-
- EvolutionImporterPrivate *priv;
-};
-
-struct _EvolutionImporterClass {
- BonoboObjectClass parent_class;
-
- POA_GNOME_Evolution_Importer__epv epv;
-};
-
-GType evolution_importer_get_type (void);
-
-EvolutionImporter *evolution_importer_new (EvolutionImporterCreateControlFn create_control_fn,
- EvolutionImporterSupportFormatFn support_format_fn,
- EvolutionImporterLoadFileFn load_file_fn,
- EvolutionImporterProcessItemFn process_item_fn,
- EvolutionImporterGetErrorFn get_error_fn,
- void *closure);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/shell/importer/evolution-intelligent-importer.c b/shell/importer/evolution-intelligent-importer.c
deleted file mode 100644
index bce7d75fa8..0000000000
--- a/shell/importer/evolution-intelligent-importer.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "evolution-intelligent-importer.h"
-
-#include <bonobo/bonobo-object.h>
-
-#include "GNOME_Evolution_Importer.h"
-
-#define PARENT_TYPE BONOBO_OBJECT_TYPE
-static BonoboObjectClass *parent_class = NULL;
-
-struct _EvolutionIntelligentImporterPrivate {
- EvolutionIntelligentImporterCanImportFn can_import_fn;
- EvolutionIntelligentImporterImportDataFn import_data_fn;
-
- char *importername;
- char *message;
- void *closure;
-};
-
-
-static inline EvolutionIntelligentImporter *
-evolution_intelligent_importer_from_servant (PortableServer_Servant servant)
-{
- return EVOLUTION_INTELLIGENT_IMPORTER (bonobo_object_from_servant (servant));
-}
-
-static CORBA_char *
-impl_GNOME_Evolution_IntelligentImporter__get_importername (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- EvolutionIntelligentImporter *ii;
-
- ii = evolution_intelligent_importer_from_servant (servant);
-
- return CORBA_string_dup (ii->priv->importername ?
- ii->priv->importername : "");
-}
-
-static CORBA_char *
-impl_GNOME_Evolution_IntelligentImporter__get_message (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- EvolutionIntelligentImporter *ii;
-
- ii = evolution_intelligent_importer_from_servant (servant);
-
- return CORBA_string_dup (ii->priv->message ?
- ii->priv->message : "");
-}
-
-static CORBA_boolean
-impl_GNOME_Evolution_IntelligentImporter_canImport (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- EvolutionIntelligentImporter *ii;
- EvolutionIntelligentImporterPrivate *priv;
-
- ii = evolution_intelligent_importer_from_servant (servant);
- priv = ii->priv;
-
- if (priv->can_import_fn != NULL)
- return (priv->can_import_fn) (ii, priv->closure);
- else
- return FALSE;
-}
-
-static void
-impl_GNOME_Evolution_IntelligentImporter_importData (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- EvolutionIntelligentImporter *ii;
- EvolutionIntelligentImporterPrivate *priv;
-
- ii = evolution_intelligent_importer_from_servant (servant);
- priv = ii->priv;
-
- if (priv->import_data_fn)
- (priv->import_data_fn) (ii, priv->closure);
-}
-
-
-static void
-finalise (GObject *object)
-{
- EvolutionIntelligentImporter *ii;
-
- ii = EVOLUTION_INTELLIGENT_IMPORTER (object);
-
- if (ii->priv == NULL)
- return;
-
- g_free (ii->priv->importername);
- g_free (ii->priv);
- ii->priv = NULL;
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-evolution_intelligent_importer_class_init (EvolutionIntelligentImporterClass *klass)
-{
- GObjectClass *object_class;
- POA_GNOME_Evolution_IntelligentImporter__epv *epv = &klass->epv;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = finalise;
-
- parent_class = g_type_class_ref(PARENT_TYPE);
- epv->_get_importername = impl_GNOME_Evolution_IntelligentImporter__get_importername;
- epv->_get_message = impl_GNOME_Evolution_IntelligentImporter__get_message;
- epv->canImport = impl_GNOME_Evolution_IntelligentImporter_canImport;
- epv->importData = impl_GNOME_Evolution_IntelligentImporter_importData;
-}
-
-static void
-evolution_intelligent_importer_init (EvolutionIntelligentImporter *ii)
-{
- ii->priv = g_new0 (EvolutionIntelligentImporterPrivate, 1);
-}
-
-
-static void
-evolution_intelligent_importer_construct (EvolutionIntelligentImporter *ii,
- EvolutionIntelligentImporterCanImportFn can_import_fn,
- EvolutionIntelligentImporterImportDataFn import_data_fn,
- const char *importername,
- const char *message,
- void *closure)
-{
- g_return_if_fail (ii != NULL);
- ii->priv->importername = g_strdup (importername);
- ii->priv->message = g_strdup (message);
-
- ii->priv->can_import_fn = can_import_fn;
- ii->priv->import_data_fn = import_data_fn;
- ii->priv->closure = closure;
-}
-
-/**
- * evolution_intelligent_importer_new:
- * can_import_fn: The function that will be called to see if this importer can do
- * anything.
- * import_data_fn: The function that will be called when the importer should
- * import the data.
- * importername: The name of this importer.
- * message: The message that will be displayed when the importer can import.
- * closure: The data to be passed to @can_import_fn and @import_data_fn.
- *
- * Creates a new IntelligentImporter.
- *
- * Returns: A newly allocated EvolutionIntelligentImporter.
- */
-EvolutionIntelligentImporter *
-evolution_intelligent_importer_new (EvolutionIntelligentImporterCanImportFn can_import_fn,
- EvolutionIntelligentImporterImportDataFn import_data_fn,
- const char *importername,
- const char *message,
- void *closure)
-{
- EvolutionIntelligentImporter *ii;
-
- ii = g_object_new (evolution_intelligent_importer_get_type (), NULL);
- evolution_intelligent_importer_construct (ii, can_import_fn,
- import_data_fn, importername,
- message, closure);
- return ii;
-}
-
-BONOBO_TYPE_FUNC_FULL (EvolutionIntelligentImporter,
- GNOME_Evolution_IntelligentImporter,
- PARENT_TYPE,
- evolution_intelligent_importer);
diff --git a/shell/importer/evolution-intelligent-importer.h b/shell/importer/evolution-intelligent-importer.h
deleted file mode 100644
index 35ad7d0010..0000000000
--- a/shell/importer/evolution-intelligent-importer.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef EVOLUTION_INTELLIGENT_IMPORTER_H
-#define EVOLUTION_INTELLIGENT_IMPORTER_H
-
-#include <glib.h>
-#include <bonobo/bonobo-object.h>
-#include <importer/GNOME_Evolution_Importer.h>
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-#define EVOLUTION_TYPE_INTELLIGENT_IMPORTER (evolution_intelligent_importer_get_type ())
-#define EVOLUTION_INTELLIGENT_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_TYPE_INTELLIGENT_IMPORTER, EvolutionIntelligentImporter))
-#define EVOLUTION_INTELLIGENT_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_INTELLIGENT_IMPORTER, EvolutionIntelligentImporterClass))
-#define EVOLUTION_IS_INTELLIGENT_IMPORTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_TYPE_INTELLIGENT_IMPORTER))
-#define EVOLUTION_IS_INTELLIGENT_IMPORTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_INTELLIGENT_IMPORTER))
-
-typedef struct _EvolutionIntelligentImporter EvolutionIntelligentImporter;
-typedef struct _EvolutionIntelligentImporterPrivate EvolutionIntelligentImporterPrivate;
-typedef struct _EvolutionIntelligentImporterClass EvolutionIntelligentImporterClass;
-
-typedef gboolean (* EvolutionIntelligentImporterCanImportFn) (EvolutionIntelligentImporter *ii,
- void *closure);
-typedef void (* EvolutionIntelligentImporterImportDataFn) (EvolutionIntelligentImporter *ii,
- void *closure);
-
-struct _EvolutionIntelligentImporter {
- BonoboObject parent;
-
- EvolutionIntelligentImporterPrivate *priv;
-};
-
-struct _EvolutionIntelligentImporterClass {
- BonoboObjectClass parent_class;
-
- POA_GNOME_Evolution_IntelligentImporter__epv epv;
-};
-
-GType evolution_intelligent_importer_get_type (void);
-
-EvolutionIntelligentImporter *evolution_intelligent_importer_new (EvolutionIntelligentImporterCanImportFn can_import_fn,
- EvolutionIntelligentImporterImportDataFn import_data_fn,
- const char *importername,
- const char *message,
- void *closure);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/shell/importer/import.glade b/shell/importer/import.glade
deleted file mode 100644
index 389d2feee3..0000000000
--- a/shell/importer/import.glade
+++ /dev/null
@@ -1,124 +0,0 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
-
-<glade-interface>
-<requires lib="gnome"/>
-
-<widget class="GtkWindow" id="importwizard">
- <property name="title" translatable="yes">Evolution Import Assistant</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
- <property name="modal">False</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
-
- <child>
- <widget class="GnomeDruid" id="druid1">
- <property name="border_width">4</property>
- <property name="visible">True</property>
- <property name="show_help">False</property>
-
- <child>
- <widget class="GnomeDruidPageEdge" id="page0">
- <property name="visible">True</property>
- <property name="position">GNOME_EDGE_START</property>
- <property name="title" translatable="yes">Evolution Import Assistant</property>
- <property name="text" translatable="yes">Welcome to the Evolution Import Assistant.
-With this assistant you will be guided through the process of
-importing external files into Evolution.</property>
- </widget>
- </child>
-
- <child>
- <widget class="GnomeDruidPageStandard" id="page1">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Importer Type</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="druid-vbox2">
- <property name="border_width">16</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child>
- <placeholder/>
- </child>
- </widget>
- </child>
- </widget>
- </child>
-
- <child>
- <widget class="GnomeDruidPageStandard" id="page2-file">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Select a File</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="druid-vbox1">
- <property name="border_width">16</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child>
- <placeholder/>
- </child>
- </widget>
- </child>
- </widget>
- </child>
-
- <child>
- <widget class="GnomeDruidPageStandard" id="page3-file">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Import Location</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="druid-vbox3">
- <property name="border_width">16</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child>
- <placeholder/>
- </child>
- </widget>
- </child>
- </widget>
- </child>
-
- <child>
- <widget class="GnomeDruidPageStandard" id="page2-intelligent">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Select Information to Import</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="druid-vbox3">
- <property name="border_width">16</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child>
- <placeholder/>
- </child>
- </widget>
- </child>
- </widget>
- </child>
-
- <child>
- <widget class="GnomeDruidPageEdge" id="page4">
- <property name="visible">True</property>
- <property name="position">GNOME_EDGE_FINISH</property>
- <property name="title" translatable="yes">Import File</property>
- <property name="text" translatable="yes">Click &quot;Import&quot; to begin importing the file into Evolution. </property>
- </widget>
- </child>
- </widget>
- </child>
-</widget>
-
-</glade-interface>
diff --git a/shell/importer/intelligent.c b/shell/importer/intelligent.c
deleted file mode 100644
index 6503fc8ad6..0000000000
--- a/shell/importer/intelligent.c
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "intelligent.h"
-
-#include <gtk/gtk.h>
-
-#include <libgnome/gnome-config.h>
-#include <glib/gi18n.h>
-
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-widget.h>
-
-#include "intelligent.h"
-#include "GNOME_Evolution_Importer.h"
-
-/* Prototypes */
-
-void intelligent_importer_init (void);
-
-/* End prototypes */
-
-typedef struct {
- CORBA_Object object;
- Bonobo_Control control;
- GtkWidget *widget;
-
- char *name;
- char *blurb;
- char *iid;
-} IntelligentImporterData;
-
-typedef struct {
- GtkWidget *dialog;
- GtkWidget *placeholder;
- GtkWidget *clist;
- BonoboWidget *current;
-
- GList *importers;
-
- int running;
-} IntelligentImporterDialog;
-
-typedef struct {
- CORBA_Object importer;
- char *iid;
-} SelectedImporterData;
-
-static void
-free_importer_dialog (IntelligentImporterDialog *d)
-{
- GList *l;
-
- for (l = d->importers; l; l = l->next) {
- CORBA_Environment ev;
- IntelligentImporterData *data;
-
- data = l->data;
-
- CORBA_exception_init (&ev);
- if (data->object != CORBA_OBJECT_NIL)
- bonobo_object_release_unref (data->object, &ev);
-
- g_free (data->iid);
- g_free (data->name);
- g_free (data->blurb);
- g_free (data);
- }
-
- g_list_free (d->importers);
- gtk_widget_destroy (d->dialog);
- g_free (d);
-}
-
-static void
-start_importers (GList *selected)
-{
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
- for (; selected; selected = selected->next) {
- SelectedImporterData *selection = selected->data;
-
- GNOME_Evolution_IntelligentImporter_importData (selection->importer, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Error importing %s\n%s", selection->iid,
- CORBA_exception_id (&ev));
- }
- }
- CORBA_exception_free (&ev);
-}
-
-static GList *
-get_intelligent_importers (void)
-{
- Bonobo_ServerInfoList *info_list;
- GList *iids_ret = NULL;
- CORBA_Environment ev;
- int i;
-
- CORBA_exception_init (&ev);
- info_list = bonobo_activation_query ("repo_ids.has ('IDL:GNOME/Evolution/IntelligentImporter:" BASE_VERSION "')", NULL, &ev);
- CORBA_exception_free (&ev);
-
- for (i = 0; i < info_list->_length; i++) {
- const Bonobo_ServerInfo *info;
-
- info = info_list->_buffer + i;
- iids_ret = g_list_prepend (iids_ret, g_strdup (info->iid));
- }
-
- return iids_ret;
-}
-
-static void
-select_row_cb (GtkCList *clist,
- int row,
- int column,
- GdkEvent *ev,
- IntelligentImporterDialog *d)
-{
- gtk_notebook_set_current_page (GTK_NOTEBOOK (d->placeholder), row);
-}
-
-static void
-unselect_row_cb (GtkCList *clist,
- int row,
- int column,
- GdkEvent *ev,
- IntelligentImporterDialog *d)
-{
- gtk_notebook_set_current_page (GTK_NOTEBOOK (d->placeholder), d->running);
-}
-
-static IntelligentImporterDialog *
-create_gui (GList *importers)
-{
- GtkWidget *dialog, *clist, *sw, *label;
- GtkWidget *hbox, *vbox, *dummy;
- IntelligentImporterDialog *d;
- GList *l;
- int running = 0;
-
- d = g_new (IntelligentImporterDialog, 1);
- d->dialog = dialog = gtk_dialog_new();
- gtk_dialog_set_has_separator ((GtkDialog *) dialog, FALSE);
- gtk_container_set_border_width ((GtkContainer *) ((GtkDialog *)dialog)->vbox, 0);
- gtk_container_set_border_width ((GtkContainer *) ((GtkDialog *)dialog)->action_area, 12);
-
- gtk_window_set_title((GtkWindow *)dialog, _("Importers"));
- dummy = gtk_button_new_from_stock(GTK_STOCK_CONVERT);
- gtk_button_set_label((GtkButton *)dummy, _("Import"));
- gtk_dialog_add_action_widget((GtkDialog *)dialog, dummy, GTK_RESPONSE_ACCEPT);
-
- dummy = gtk_button_new_from_stock(GTK_STOCK_NO);
- gtk_button_set_label((GtkButton *)dummy, _("Do not import"));
- gtk_dialog_add_action_widget((GtkDialog *)dialog, dummy, GTK_RESPONSE_REJECT);
-
- dummy = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
- gtk_button_set_label((GtkButton *)dummy, _("Do not ask me again"));
- gtk_dialog_add_action_widget((GtkDialog *)dialog, dummy, GTK_RESPONSE_CANCEL);
- d->importers = NULL;
- d->current = NULL;
-
- d->clist = clist = gtk_clist_new (1);
- gtk_clist_set_selection_mode (GTK_CLIST (d->clist), GTK_SELECTION_MULTIPLE);
-
- label = gtk_label_new (_("Evolution can import data from the following files:"));
- gtk_misc_set_alignment(GTK_MISC(label), 0, .5);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label,
- TRUE, TRUE, 0);
-
- hbox = gtk_hbox_new (FALSE, 2);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
-
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox,
- TRUE, TRUE, 0);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(sw),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
- gtk_widget_set_size_request (sw, 300, 150);
- gtk_container_add (GTK_CONTAINER (sw), clist);
- gtk_box_pack_start (GTK_BOX (hbox), sw, TRUE, TRUE, 0);
-
- vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
- gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
-
- d->placeholder = gtk_notebook_new ();
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (d->placeholder), FALSE);
- gtk_box_pack_start (GTK_BOX (vbox), d->placeholder, TRUE, TRUE, 0);
-
- for (l = importers; l; l = l->next) {
- IntelligentImporterData *data;
- CORBA_Environment ev;
- gboolean dontaskagain, can_run;
- char *text[1], *prefix;
-
- /* Check if we want to show this one again */
- prefix = g_strdup_printf ("=%s/evolution/config/Shell=/intelligent-importers/", g_get_home_dir ());
- gnome_config_push_prefix (prefix);
- g_free (prefix);
-
- dontaskagain = gnome_config_get_bool (l->data);
- gnome_config_pop_prefix ();
-
- if (dontaskagain)
- continue;
-
- data = g_new0 (IntelligentImporterData, 1);
- data->iid = g_strdup (l->data);
-
- CORBA_exception_init (&ev);
- data->object = bonobo_activation_activate_from_id ((char *) data->iid, 0,
- NULL, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Could not start %s: %s", data->iid,
- CORBA_exception_id (&ev));
- CORBA_exception_free (&ev);
-
- /* Clean up the IntelligentImporterData */
- g_free (data->iid);
- g_free (data);
- continue;
- }
-
- CORBA_exception_free (&ev);
- if (data->object == CORBA_OBJECT_NIL) {
- g_warning ("Could not activate_component %s", data->iid);
- g_free (data->iid);
- g_free (data);
- continue;
- }
-
- CORBA_exception_init (&ev);
- can_run = GNOME_Evolution_IntelligentImporter_canImport (data->object,
- &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Could not get canImport(%s): %s",
- data->iid, CORBA_exception_id (&ev));
- bonobo_object_release_unref (data->object, &ev);
- CORBA_exception_free (&ev);
- g_free (data->iid);
- g_free (data);
- continue;
- }
- CORBA_exception_free (&ev);
-
- if (can_run == FALSE) {
- CORBA_exception_init (&ev);
- bonobo_object_release_unref (data->object, &ev);
- CORBA_exception_free (&ev);
- g_free (data->iid);
- g_free (data);
- continue;
- }
-
- running++;
-
- data->name = g_strdup (GNOME_Evolution_IntelligentImporter__get_importername (data->object, &ev));
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Could not get name(%s): %s",
- data->iid, CORBA_exception_id (&ev));
- bonobo_object_release_unref (data->object, &ev);
- CORBA_exception_free (&ev);
- g_free (data->iid);
- g_free (data);
- continue;
- }
-
- data->blurb = g_strdup (GNOME_Evolution_IntelligentImporter__get_message (data->object, &ev));
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Could not get message(%s): %s",
- data->iid, CORBA_exception_id (&ev));
- bonobo_object_release_unref (data->object, &ev);
- CORBA_exception_free (&ev);
- g_free (data->iid);
- g_free (data->name);
- g_free (data);
- continue;
- }
-
- data->control = Bonobo_Unknown_queryInterface (data->object,
- "IDL:Bonobo/Control:1.0", &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Could not QI for Bonobo/Control:1.0 %s:%s",
- data->iid, CORBA_exception_id (&ev));
- bonobo_object_release_unref (data->object, &ev);
- CORBA_exception_free (&ev);
- g_free (data->iid);
- g_free (data->name);
- g_free (data->blurb);
- continue;
- }
- if (data->control != CORBA_OBJECT_NIL) {
- data->widget = bonobo_widget_new_control_from_objref (data->control, CORBA_OBJECT_NIL);
- /* Ref this widget so even if we remove it from the
- containers it will always have an extra ref. */
- gtk_widget_show (data->widget);
- g_object_ref (data->widget);
- } else {
- data->widget = gtk_label_new ("");
- }
-
- CORBA_exception_free (&ev);
-
- d->importers = g_list_prepend (d->importers, data);
- gtk_notebook_prepend_page (GTK_NOTEBOOK (d->placeholder),
- data->widget, NULL);
- text[0] = data->name;
- gtk_clist_prepend (GTK_CLIST (clist), text);
- }
-
- d->running = running;
- dummy = gtk_drawing_area_new ();
- gtk_widget_show (dummy);
- gtk_notebook_append_page (GTK_NOTEBOOK (d->placeholder),
- dummy, NULL);
- /* Set the start to the blank page */
- gtk_notebook_set_current_page (GTK_NOTEBOOK (d->placeholder), running);
-
- g_signal_connect((clist), "select-row",
- G_CALLBACK (select_row_cb), d);
- g_signal_connect((clist), "unselect-row",
- G_CALLBACK (unselect_row_cb), d);
-
- gtk_widget_show_all (GTK_DIALOG (dialog)->vbox);
- return d;
-}
-
-void
-intelligent_importer_init (void)
-{
- GList *importers, *l, *selected = NULL;
- IntelligentImporterDialog *d;
- char *prefix;
- gboolean dontaskagain;
- int resp;
-
- prefix = g_strdup_printf ("=%s/evolution/config/Shell=/intelligent-importers/", g_get_home_dir());
- gnome_config_push_prefix (prefix);
- g_free (prefix);
-
- dontaskagain = gnome_config_get_bool ("Dontaskagain=False");
- gnome_config_pop_prefix ();
-
- if (dontaskagain) {
- return;
- }
-
- importers = get_intelligent_importers ();
- if (importers == NULL)
- return; /* No intelligent importers. Easy :) */
-
- d = create_gui (importers);
- if (d->running == 0) {
- free_importer_dialog (d);
- return; /* No runnable intelligent importers. */
- }
-
- resp = gtk_dialog_run((GtkDialog *)d->dialog);
- gtk_widget_destroy(d->dialog);
- switch (resp) {
- case GTK_RESPONSE_ACCEPT:
- /* Make a list of the importers */
-
- /* FIXME: Sort this list and don't do it a slow way */
- for (l = GTK_CLIST (d->clist)->selection; l; l = l->next) {
- IntelligentImporterData *data;
- SelectedImporterData *new_data;
- CORBA_Environment ev;
- char *iid;
-
- data = g_list_nth_data (d->importers, GPOINTER_TO_INT (l->data));
- iid = g_strdup (data->iid);
-
- new_data = g_new (SelectedImporterData, 1);
- new_data->iid = iid;
-
- /* Reference the remote object, and duplicate the
- local one. */
- CORBA_exception_init (&ev);
- new_data->importer = bonobo_object_dup_ref (data->object, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Error duplicating %s\n%s", iid,
- CORBA_exception_id (&ev));
- g_free (iid);
- CORBA_exception_free (&ev);
- g_free (new_data);
- continue;
- }
- CORBA_exception_free (&ev);
-
- selected = g_list_prepend (selected, new_data);
- }
-
- /* Now destroy all the importers, as we've kept references to
- the ones we need */
- free_importer_dialog (d);
-
- if (selected != NULL) {
- /* Restart the selected ones */
- start_importers (selected);
-
- /* Free the selected list */
- for (l = selected; l; l = l->next) {
- CORBA_Environment ev;
- SelectedImporterData *selection = l->data;
-
- CORBA_exception_init (&ev);
- bonobo_object_release_unref (selection->importer, &ev);
- CORBA_exception_free (&ev);
-
- g_free (selection->iid);
- g_free (selection);
- }
- g_list_free (selected);
- }
-
- break;
-
- case GTK_RESPONSE_CANCEL: /* Dont ask again */
- prefix = g_strdup_printf ("=%s/evolution/config/Shell=/intelligent-importers/", g_get_home_dir());
- gnome_config_push_prefix (prefix);
- g_free (prefix);
-
- gnome_config_set_bool ("Dontaskagain", TRUE);
- gnome_config_pop_prefix ();
-
- gnome_config_sync ();
- gnome_config_drop_all ();
- g_print ("Not asking again");
- free_importer_dialog (d);
- break;
-
- default:
- case GTK_RESPONSE_REJECT: /* No button */
- free_importer_dialog (d);
- break;
- }
-
- g_list_free (importers);
-}
diff --git a/shell/main.c b/shell/main.c
index 2abd30eec1..bf0a8c47c6 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -23,6 +23,7 @@
#include <config.h>
#include <gtk/gtk.h>
+#include <gdk/gdkx.h> /* for copied UniqueApp code */
#include <glib/gstdio.h>
#ifdef G_OS_WIN32
@@ -34,12 +35,10 @@
#include "e-util/e-bconf-map.h"
#include <e-util/e-icon-factory.h>
-#include "e-shell-constants.h"
#include "e-util/e-profile-event.h"
#include "e-util/e-util.h"
#include "e-shell.h"
-#include "es-menu.h"
#include "es-event.h"
#include "e-util/e-util-private.h"
@@ -55,12 +54,11 @@
#include <libgnomeui/gnome-ui-init.h>
#include <libgnomeui/gnome-client.h>
-#include <bonobo/bonobo-main.h>
-#include <bonobo/bonobo-moniker-util.h>
#include <bonobo/bonobo-exception.h>
#include <bonobo-activation/bonobo-activation.h>
+#include <libedataserver/e-categories.h>
#include <libedataserverui/e-passwords.h>
#include <glade/glade.h>
@@ -92,13 +90,11 @@
#define DEVELOPMENT 1
#endif
-static EShell *shell = NULL;
-
/* Command-line options. */
static gboolean start_online = FALSE;
static gboolean start_offline = FALSE;
static gboolean setup_only = FALSE;
-static gboolean killev = FALSE;
+static gboolean force_shutdown = FALSE;
#ifdef DEVELOPMENT
static gboolean force_migrate = FALSE;
#endif
@@ -106,24 +102,12 @@ static gboolean disable_eplugin = FALSE;
static gboolean disable_preview = FALSE;
static gboolean idle_cb (gchar **uris);
-static char *default_component_id = NULL;
-static char *evolution_debug_log = NULL;
+static gchar *requested_view = NULL;
+static gchar *evolution_debug_log = NULL;
static gchar **remaining_args;
-static void
-no_windows_left_cb (EShell *shell, gpointer data)
-{
- bonobo_object_unref (BONOBO_OBJECT (shell));
- bonobo_main_quit ();
-}
-
-static void
-shell_weak_notify (void *data,
- GObject *where_the_object_was)
-{
- bonobo_main_quit ();
-}
-
+/* Defined in <e-shell.h> */
+extern EShell *default_shell;
#ifdef KILL_PROCESS_CMD
@@ -184,6 +168,36 @@ kill_old_dataserver (void)
}
#endif
+static void
+categories_icon_theme_hack (void)
+{
+ GtkIconTheme *icon_theme;
+ const gchar *category_name;
+ const gchar *filename;
+ gchar *dirname;
+
+ /* XXX Allow the category icons to be referenced as named
+ * icons, since GtkAction does not support GdkPixbufs. */
+
+ /* Get the icon file for some default category. Doesn't matter
+ * which, so long as it has an icon. We're just interested in
+ * the directory components. */
+ category_name = _("Birthday");
+ filename = e_categories_get_icon_file_for (category_name);
+ g_return_if_fail (filename != NULL && *filename != '\0');
+
+ /* Extract the directory components. */
+ dirname = g_path_get_dirname (filename);
+
+ /* Add it to the icon theme's search path. This relies on
+ * GtkIconTheme's legacy feature of using image files found
+ * directly in the search path. */
+ icon_theme = gtk_icon_theme_get_default ();
+ gtk_icon_theme_append_search_path (icon_theme, dirname);
+
+ g_free (dirname);
+}
+
#ifdef DEVELOPMENT
@@ -286,123 +300,35 @@ destroy_config (GConfClient *client)
#endif /* DEVELOPMENT */
-static void
-open_uris (GNOME_Evolution_Shell corba_shell, gchar **uris)
-{
- CORBA_Environment ev;
- guint n_uris, ii;
-
- g_return_if_fail (uris != NULL);
- n_uris = g_strv_length (uris);
-
- CORBA_exception_init (&ev);
-
- for (ii = 0; ii < n_uris; ii++) {
- GNOME_Evolution_Shell_handleURI (corba_shell, uris[ii], &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Invalid URI: %s", uris[ii]);
- CORBA_exception_free (&ev);
- }
- }
-
- CORBA_exception_free (&ev);
-}
-
/* This is for doing stuff that requires the GTK+ loop to be running already. */
static gboolean
idle_cb (gchar **uris)
{
- GNOME_Evolution_Shell corba_shell;
- CORBA_Environment ev;
- EShellConstructResult result;
- EShellStartupLineMode startup_line_mode;
-
- g_return_val_if_fail (uris == NULL || g_strv_length (uris) > 0, FALSE);
+ EShell *shell;
#ifdef KILL_PROCESS_CMD
kill_old_dataserver ();
#endif
- CORBA_exception_init (&ev);
+ shell = e_shell_get_default ();
- if (! start_online && ! start_offline)
- startup_line_mode = E_SHELL_STARTUP_LINE_MODE_CONFIG;
- else if (start_online)
- startup_line_mode = E_SHELL_STARTUP_LINE_MODE_ONLINE;
+ /* These calls do the right thing when another Evolution
+ * process is running. */
+ if (uris != NULL && *uris != NULL)
+ e_shell_handle_uris (shell, uris);
else
- startup_line_mode = E_SHELL_STARTUP_LINE_MODE_OFFLINE;
-
- shell = e_shell_new (startup_line_mode, &result);
-
- switch (result) {
- case E_SHELL_CONSTRUCT_RESULT_OK:
- e_shell_set_crash_recovery (shell, e_file_lock_exists ());
- g_signal_connect (shell, "no_windows_left", G_CALLBACK (no_windows_left_cb), NULL);
- g_object_weak_ref (G_OBJECT (shell), shell_weak_notify, NULL);
- corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell));
- corba_shell = CORBA_Object_duplicate (corba_shell, &ev);
- break;
-
- case E_SHELL_CONSTRUCT_RESULT_CANNOTREGISTER:
- corba_shell = bonobo_activation_activate_from_id (E_SHELL_OAFIID, 0, NULL, &ev);
- if (ev._major != CORBA_NO_EXCEPTION || corba_shell == CORBA_OBJECT_NIL) {
- e_error_run(NULL, "shell:noshell", NULL);
- CORBA_exception_free (&ev);
- bonobo_main_quit ();
- return FALSE;
- }
- break;
+ e_shell_create_shell_window (shell, requested_view);
- default:
- e_error_run(NULL, "shell:noshell-reason",
- e_shell_construct_result_to_string(result), NULL);
- CORBA_exception_free (&ev);
- bonobo_main_quit ();
- return FALSE;
+ /* If another Evolution process is running, we're done. */
+ if (unique_app_is_running (UNIQUE_APP (shell)))
+ gtk_main_quit ();
- }
-
- if (shell != NULL) {
- if (uris != NULL)
- open_uris (corba_shell, uris);
- else {
- e_file_lock_create ();
- e_shell_create_window (shell, default_component_id, NULL);
- }
- } else {
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
- if (uris != NULL)
- open_uris (corba_shell, uris);
- else
- if (default_component_id == NULL)
- GNOME_Evolution_Shell_createNewWindow (corba_shell, "", &ev);
- else
- GNOME_Evolution_Shell_createNewWindow (corba_shell, default_component_id, &ev);
-
- CORBA_exception_free (&ev);
- }
-
- CORBA_Object_release (corba_shell, &ev);
-
- CORBA_exception_free (&ev);
-
- if (shell == NULL) {
- /*there is another instance but because we don't open any windows
- we must notify the startup was complete manually*/
- gdk_notify_startup_complete ();
- bonobo_main_quit ();
- }
-
- /* This must be done after Bonobo has created all the components. For
- * example the mail component makes the global variable `session` which
- * is being used by several EPlugins */
-
- if (!disable_eplugin) {
+ /* This must be done after EShell has loaded all the modules.
+ * For example the mail module makes the global variable `session`
+ * which is being used by several EPlugins */
+ else if (uris == NULL && !disable_eplugin)
e_plugin_load_plugins_with_missing_symbols ();
- }
return FALSE;
}
@@ -464,27 +390,15 @@ setup_segv_redirect (void)
#define setup_segv_redirect() (void)0
#endif
-static gint
-gnome_master_client_save_yourself_cb (GnomeClient *client, GnomeSaveStyle save_style, gint shutdown, GnomeInteractStyle interact_style, gint fast, gpointer user_data)
-{
- return !shell || e_shell_can_quit (shell);
-}
-
-static void
-gnome_master_client_die_cb (GnomeClient *client)
-{
- e_shell_do_quit (shell);
-}
-
-static const GOptionEntry options[] = {
- { "component", 'c', 0, G_OPTION_ARG_STRING, &default_component_id,
+static GOptionEntry entries[] = {
+ { "component", 'c', 0, G_OPTION_ARG_STRING, &requested_view,
N_("Start Evolution activating the specified component"), NULL },
{ "offline", '\0', 0, G_OPTION_ARG_NONE, &start_offline,
N_("Start in offline mode"), NULL },
{ "online", '\0', 0, G_OPTION_ARG_NONE, &start_online,
N_("Start in online mode"), NULL },
#ifdef KILL_PROCESS_CMD
- { "force-shutdown", '\0', 0, G_OPTION_ARG_NONE, &killev,
+ { "force-shutdown", '\0', 0, G_OPTION_ARG_NONE, &force_shutdown,
N_("Forcibly shut down all Evolution components"), NULL },
#endif
#ifdef DEVELOPMENT
@@ -547,19 +461,178 @@ set_paths (void)
g_free (exe_folder_utf8);
g_free (components_folder_utf8);
- /* Set BONOBO_ACTIVATION_PATH */
- if (g_getenv ("BONOBO_ACTIVATION_PATH" ) == NULL) {
- path = g_build_filename (top_folder_utf8,
- "lib/bonobo/servers",
- NULL);
- if (!g_setenv ("BONOBO_ACTIVATION_PATH", path, TRUE))
- g_warning ("Could not set BONOBO_ACTIVATION_PATH");
- g_free (path);
- }
g_free (top_folder_utf8);
}
#endif
+static void
+shell_window_destroyed_cb (EShell *shell)
+{
+ if (e_shell_get_watched_windows (shell) == NULL)
+ gtk_main_quit ();
+}
+
+static gint
+master_client_save_yourself_cb (GnomeClient *client,
+ GnomeSaveStyle save_style,
+ gint shutdown,
+ GnomeInteractStyle interact_style,
+ gint fast,
+ gpointer user_data)
+{
+ EShell *shell = user_data;
+
+ return !e_shell_is_busy (shell);
+}
+
+static void
+master_client_die_cb (GnomeClient *client,
+ gpointer user_data)
+{
+ EShell *shell = user_data;
+
+ e_shell_do_quit (shell);
+}
+
+/* taken from nautilus */
+static guint32
+slowly_and_stupidly_obtain_timestamp (GdkDisplay *display)
+{
+ Display *xdisplay;
+ Window xwindow;
+ XEvent event;
+ XSetWindowAttributes attrs;
+ Atom atom_name;
+ Atom atom_type;
+ char *name;
+
+ xdisplay = GDK_DISPLAY_XDISPLAY (display);
+
+ attrs.override_redirect = True;
+ attrs.event_mask = PropertyChangeMask | StructureNotifyMask;
+
+ xwindow = XCreateWindow (
+ xdisplay, RootWindow (xdisplay, 0),
+ -100, -100, 1, 1,
+ 0,
+ CopyFromParent,
+ CopyFromParent,
+ CopyFromParent,
+ CWOverrideRedirect | CWEventMask,
+ &attrs);
+
+ atom_name = XInternAtom (xdisplay, "WM_NAME", TRUE);
+ g_assert (atom_name != None);
+
+ atom_type = XInternAtom (xdisplay, "STRING", TRUE);
+ g_assert (atom_type != None);
+
+ name = "Fake Window";
+ XChangeProperty (
+ xdisplay, xwindow, atom_name, atom_type,
+ 8, PropModeReplace, (unsigned char *) name,
+ strlen (name));
+
+ XWindowEvent (
+ xdisplay, xwindow, PropertyChangeMask, &event);
+
+ XDestroyWindow (xdisplay, xwindow);
+
+ return event.xproperty.time;
+}
+
+static gchar *
+pick_startup_id (void)
+{
+ GdkDisplay *display;
+ const gchar *startup_id;
+ gchar *id;
+
+ /* XXX This copies logic from unique_app_new(), which we can't use
+ * because we're subclassing UniqueApp. I already sent ebassi
+ * a patch to fix this. */
+
+ display = gdk_display_get_default ();
+
+ /* Try and get the startup notification ID from GDK, the
+ * environment or, if everything else failed, fake one. */
+ startup_id = gdk_x11_display_get_startup_notification_id (display);
+
+ if (!startup_id || startup_id[0] == '\0')
+ startup_id = g_getenv ("DESKTOP_STARTUP_ID");
+
+ if (!startup_id || startup_id[0] == '\0') {
+ guint32 timestamp;
+
+ timestamp = slowly_and_stupidly_obtain_timestamp (display);
+ id = g_strdup_printf ("_TIME%lu", (gulong) timestamp);
+ } else
+ id = g_strdup (startup_id);
+
+ return id;
+}
+
+static void
+create_default_shell (void)
+{
+ EShell *shell;
+ GConfClient *conf_client;
+ GnomeClient *master_client;
+ gboolean online = TRUE;
+ gchar *startup_id;
+ GError *error = NULL;
+
+ conf_client = gconf_client_get_default ();
+ master_client = gnome_master_client ();
+
+ if (start_online)
+ online = TRUE;
+ else if (start_offline)
+ online = FALSE;
+ else {
+ const gchar *key;
+ gboolean value;
+
+ key = "/apps/evolution/shell/start_offline";
+ value = gconf_client_get_bool (conf_client, key, &error);
+ if (error == NULL)
+ online = !value;
+ else {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+ }
+
+ startup_id = pick_startup_id ();
+
+ shell = g_object_new (
+ E_TYPE_SHELL,
+ "name", "org.gnome.evolution",
+ "online", online,
+ "startup-id", startup_id,
+ NULL);
+
+ g_free (startup_id);
+
+ g_signal_connect (
+ shell, "window-destroyed",
+ G_CALLBACK (shell_window_destroyed_cb), NULL);
+
+ if (master_client != NULL) {
+ g_signal_connect (
+ master_client, "save_yourself",
+ G_CALLBACK (master_client_save_yourself_cb), shell);
+
+ g_signal_connect (
+ master_client, "die",
+ G_CALLBACK (master_client_die_cb), shell);
+ }
+
+ g_object_unref (conf_client);
+
+ default_shell = shell;
+}
+
int
main (int argc, char **argv)
{
@@ -571,10 +644,8 @@ main (int argc, char **argv)
#ifdef DEVELOPMENT
gboolean skip_warning_dialog;
#endif
- GnomeProgram *program;
- GnomeClient *master_client;
- GOptionContext *context;
- char *filename;
+ gchar *filename;
+ GError *error = NULL;
/* Make ElectricFence work. */
free (malloc (10));
@@ -583,21 +654,19 @@ main (int argc, char **argv)
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- context = g_option_context_new (_("- The Evolution PIM and Email Client"));
-
- g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
-
- g_option_context_set_translation_domain(context, GETTEXT_PACKAGE);
-
#ifdef G_OS_WIN32
set_paths ();
#endif
- program = gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv,
- GNOME_PROGRAM_STANDARD_PROPERTIES,
- GNOME_PARAM_GOPTION_CONTEXT, context,
- GNOME_PARAM_HUMAN_READABLE_NAME, _("Evolution"),
- NULL);
+ gtk_init_with_args (
+ &argc, &argv,
+ _("- The Evolution PIM and Email Client"),
+ entries, GETTEXT_PACKAGE, &error);
+ if (error != NULL) {
+ g_printerr ("%s\n", error->message);
+ g_error_free (error);
+ exit (1);
+ }
#ifdef G_OS_WIN32
if (strcmp (gettext (""), "") == 0) {
@@ -611,15 +680,14 @@ main (int argc, char **argv)
}
#endif
if (start_online && start_offline) {
- fprintf (stderr, _("%s: --online and --offline cannot be used together.\n Use %s --help for more information.\n"),
+ g_printerr (_("%s: --online and --offline cannot be used together.\n Use %s --help for more information.\n"),
argv[0], argv[0]);
exit (1);
}
- if (killev) {
- filename = g_build_filename (EVOLUTION_TOOLSDIR,
- "killev",
- NULL);
+ if (force_shutdown) {
+ filename = g_build_filename (
+ EVOLUTION_TOOLSDIR, "killev", NULL);
execl (filename, "killev", NULL);
/* Not reached */
exit (0);
@@ -628,11 +696,10 @@ main (int argc, char **argv)
client = gconf_client_get_default ();
#ifdef DEVELOPMENT
-
- if (force_migrate) {
+ if (force_migrate)
destroy_config (client);
- }
#endif
+
if (disable_preview) {
gconf_client_set_bool (client, "/apps/evolution/mail/display/show_preview", FALSE, NULL);
gconf_client_set_bool (client, "/apps/evolution/mail/display/safe_list", TRUE, NULL);
@@ -654,34 +721,29 @@ main (int argc, char **argv)
g_warning ("Could not set up debugging output file.");
}
- master_client = gnome_master_client ();
-
- g_signal_connect (G_OBJECT (master_client), "save_yourself", G_CALLBACK (gnome_master_client_save_yourself_cb), NULL);
- g_signal_connect (G_OBJECT (master_client), "die", G_CALLBACK (gnome_master_client_die_cb), NULL);
-
glade_init ();
e_cursors_init ();
e_icon_factory_init ();
- e_passwords_init();
+ e_passwords_init ();
gtk_window_set_default_icon_name ("evolution");
if (setup_only)
exit (0);
+ categories_icon_theme_hack ();
gnome_sound_init ("localhost");
gtk_accel_map_load (e_get_accels_filename ());
if (!disable_eplugin) {
- e_plugin_register_type(e_plugin_lib_get_type());
- e_plugin_hook_register_type(es_menu_hook_get_type());
- e_plugin_hook_register_type(es_event_hook_get_type());
+ e_plugin_register_type (e_plugin_lib_get_type ());
+ e_plugin_hook_register_type (es_event_hook_get_type ());
#ifdef ENABLE_PROFILING
- e_plugin_hook_register_type(e_profile_event_hook_get_type());
+ e_plugin_hook_register_type (e_profile_event_hook_get_type ());
#endif
- e_plugin_hook_register_type(e_plugin_type_hook_get_type());
- e_plugin_hook_register_type(e_import_hook_get_type());
- e_plugin_hook_register_type(E_TYPE_PLUGIN_UI_HOOK);
+ e_plugin_hook_register_type (e_plugin_type_hook_get_type ());
+ e_plugin_hook_register_type (e_import_hook_get_type ());
+ e_plugin_hook_register_type (E_TYPE_PLUGIN_UI_HOOK);
e_plugin_load_plugins ();
}
@@ -699,18 +761,26 @@ main (int argc, char **argv)
#else
g_idle_add ((GSourceFunc) idle_cb, remaining_args);
#endif
+
g_object_unref (client);
- bonobo_main ();
+ create_default_shell ();
+
+ gtk_main ();
+
+ /* Emit a warning if the shell is not finalized. */
+ g_object_unref (default_shell);
+ if (E_IS_SHELL (default_shell))
+ g_warning ("Shell not finalized on exit");
gtk_accel_map_save (e_get_accels_filename ());
e_icon_factory_shutdown ();
- g_object_unref (program);
gnome_sound_shutdown ();
e_cursors_shutdown ();
#ifdef G_OS_WIN32
link_shutdown ();
#endif
+
return 0;
}
diff --git a/shell/shell.error.xml b/shell/shell.error.xml
index 7ae57dec58..603d5ed955 100644
--- a/shell/shell.error.xml
+++ b/shell/shell.error.xml
@@ -16,9 +16,8 @@ You will need to make more space available in your home directory before you can
</error>
<error id="upgrade-failed" type="error">
- <_primary>Upgrade from previous version failed:
-{0}</_primary>
- <_secondary xml:space="preserve">{1}
+ <_primary>Upgrade from previous version failed:</_primary>
+ <_secondary xml:space="preserve">{0}
If you choose to continue, you may not have access to some of your old data.
</_secondary>
@@ -51,28 +50,6 @@ Once deleted, you cannot downgrade to the previous version of Evolution without
<button stock="gtk-delete" response="GTK_RESPONSE_OK"/>
</error>
- <error id="noshell" type="error">
- <_title>Cannot start Evolution</_title>
- <_primary>Evolution can not start.</_primary>
- <_secondary xml:space="preserve">Your system configuration does not match your Evolution configuration.
-
-Click help for details</_secondary>
- <help uri="http://go-evolution.org/FAQ#What_does_.22Your_system_configuration_does_not_match_your_Evolution_configuration.22_mean.3F"/>
- <button stock="gtk-quit" response="GTK_RESPONSE_CANCEL"/>
- </error>
-
- <error id="noshell-reason" type="error">
- <_title>Cannot start Evolution</_title>
- <_primary>Evolution can not start.</_primary>
- <_secondary xml:space="preserve">Your system configuration does not match your Evolution configuration:
-
-{0}
-
-Click help for details.</_secondary>
- <help uri="http://go-evolution.org/FAQ#What_does_.22Your_system_configuration_does_not_match_your_Evolution_configuration.22_mean.3F"/>
- <button stock="gtk-quit" response="GTK_RESPONSE_CANCEL"/>
- </error>
-
<error id="forget-passwords" type="question" default="GTK_RESPONSE_CANCEL">
<_primary>Are you sure you want to forget all remembered passwords?</_primary>
<_secondary xml:space="preserve">Forgetting your passwords will clear all remembered passwords. You will be reprompted next time they are needed.</_secondary>
diff --git a/shell/test/GNOME_Evolution_Test.server.in.in b/shell/test/GNOME_Evolution_Test.server.in.in
deleted file mode 100644
index ef0db8b1ac..0000000000
--- a/shell/test/GNOME_Evolution_Test.server.in.in
+++ /dev/null
@@ -1,39 +0,0 @@
-<oaf_info>
-
- <!-- (factory) -->
- <oaf_server iid="OAFIID:GNOME_Evolution_Test_Factory:@VERSION@"
- type="shlib"
- location="@COMPONENTDIR_IN_SERVER_FILE@/libevolution-test@SOEXT@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-
- <oaf_attribute name="name" type="string"
- _value="Evolution Test"/>
- </oaf_server>
-
- <!-- Component Interface -->
-
- <oaf_server iid="OAFIID:GNOME_Evolution_Test_Component:@VERSION@"
- type="factory"
- location="OAFIID:GNOME_Evolution_Test_Factory:@VERSION@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/Component:@VERSION@"/>
- </oaf_attribute>
-
- <oaf_attribute name="name" type="string" _value="Evolution Test component"/>
-
- <oaf_attribute name="evolution:component_alias" type="string" value="test"/>
-
- <oaf_attribute name="evolution:button_label" type="string" _value="Test"/>
- <oaf_attribute name="evolution:button_sort_order" type="string" value="-1"/>
- <oaf_attribute name="evolution:button_icon" type="string" value="stock_mail"/>
-
- <oaf_attribute name="evolution:component_icon" type="string" value="stock_mail"/>
- <oaf_attribute name="evolution:component_display_order" type="number" value="1"/>
-
- </oaf_server>
-
-</oaf_info>
diff --git a/shell/test/Makefile.am b/shell/test/Makefile.am
index 74bd509958..3656b5b782 100644
--- a/shell/test/Makefile.am
+++ b/shell/test/Makefile.am
@@ -1,15 +1,18 @@
-component_LTLIBRARIES = libevolution-test.la
+module_LTLIBRARIES = libevolution-test.la
INCLUDES = \
-I$(top_srcdir)/shell \
+ -I$(top_srcdir)/widgets \
+ -I$(top_srcdir)/widgets/menus \
-I$(top_srcdir)/widgets/misc \
-I$(top_builddir)/shell \
-DG_LOG_DOMAIN=\"evolution-test\" \
$(EVOLUTION_TEST_CFLAGS)
libevolution_test_la_SOURCES = \
- evolution-test-component.c \
- evolution-test-component.h
+ e-test-shell-module.c \
+ e-test-shell-view.c \
+ e-test-shell-view.h
libevolution_test_la_LIBADD = \
$(top_builddir)/shell/libeshell.la \
@@ -18,20 +21,4 @@ libevolution_test_la_LIBADD = \
libevolution_test_la_LDFLAGS = \
-avoid-version -module $(NO_UNDEFINED)
-testserver_in_files = GNOME_Evolution_Test.server.in.in
-testserver_DATA = $(testserver_in_files:.server.in.in=.server)
-testserverdir = $(serverdir)
-@EVO_SERVER_RULE@
-@INTLTOOL_SERVER_RULE@
-
-BUILT_SOURCES = $(testserver_DATA)
-CLEANFILES = $(BUILT_SOURCES)
-
-EXTRA_DIST = \
- $(testserver_in_files) \
- GNOME_Evolution_Test.server.in.in
-
-dist-hook:
- cd $(distdir); rm -f $(BUILD_SOURCES)
-
-include $(top_srcdir)/git.mk
diff --git a/shell/test/e-test-shell-module.c b/shell/test/e-test-shell-module.c
new file mode 100644
index 0000000000..0098866400
--- /dev/null
+++ b/shell/test/e-test-shell-module.c
@@ -0,0 +1,192 @@
+/*
+ * e-test-shell-module.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include <glib/gi18n.h>
+
+#include <e-shell.h>
+#include <e-shell-module.h>
+#include <e-shell-window.h>
+
+#include "e-test-shell-view.h"
+
+#define MODULE_NAME "test"
+#define MODULE_ALIASES "monkey"
+#define MODULE_SCHEMES ""
+#define MODULE_SORT_ORDER 100
+
+/* Module Entry Point */
+void e_shell_module_init (GTypeModule *type_module);
+
+static void
+action_test_item_new_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ g_debug ("%s", G_STRFUNC);
+}
+
+static void
+action_test_source_new_cb (GtkAction *action,
+ EShellWindow *shell_window)
+{
+ g_debug ("%s", G_STRFUNC);
+}
+
+static GtkActionEntry item_entries[] = {
+
+ { "test-item-new",
+ "document-new",
+ NC_("New", "_Test Item"),
+ NULL,
+ N_("Create a new test item"),
+ G_CALLBACK (action_test_item_new_cb) }
+};
+
+static GtkActionEntry source_entries[] = {
+
+ { "test-source-new",
+ "folder-new",
+ NC_("New", "Test _Source"),
+ NULL,
+ N_("Create a new test source"),
+ G_CALLBACK (action_test_source_new_cb) }
+};
+
+static void
+test_module_start (EShellModule *shell_module)
+{
+ g_debug ("%s", G_STRFUNC);
+}
+
+static gboolean
+test_module_is_busy (EShellModule *shell_module)
+{
+ g_debug ("%s", G_STRFUNC);
+
+ return FALSE;
+}
+
+static gboolean
+test_module_shutdown (EShellModule *shell_module)
+{
+ g_debug ("%s", G_STRFUNC);
+
+ return TRUE;
+}
+
+static gboolean
+test_module_migrate (EShellModule *shell_module,
+ gint major,
+ gint minor,
+ gint micro,
+ GError **error)
+{
+ g_debug ("%s (from %d.%d.%d)", G_STRFUNC, major, minor, micro);
+
+ return TRUE;
+}
+
+static gboolean
+test_module_handle_uri_cb (EShellModule *shell_module,
+ const gchar *uri)
+{
+ g_debug ("%s (uri=%s)", G_STRFUNC, uri);
+
+ return FALSE;
+}
+
+static void
+test_module_send_receive_cb (EShellModule *shell_module,
+ GtkWindow *parent_window)
+{
+ g_debug ("%s (window=%p)", G_STRFUNC, parent_window);
+}
+
+static void
+test_module_window_created_cb (EShellModule *shell_module,
+ GtkWindow *window)
+{
+ const gchar *module_name;
+
+ g_debug ("%s (%s)", G_STRFUNC, G_OBJECT_TYPE_NAME (window));
+
+ if (!E_IS_SHELL_WINDOW (window))
+ return;
+
+ module_name = G_TYPE_MODULE (shell_module)->name;
+
+ e_shell_window_register_new_item_actions (
+ E_SHELL_WINDOW (window), module_name,
+ item_entries, G_N_ELEMENTS (item_entries));
+
+ e_shell_window_register_new_source_actions (
+ E_SHELL_WINDOW (window), module_name,
+ source_entries, G_N_ELEMENTS (source_entries));
+}
+
+static void
+test_module_window_destroyed_cb (EShellModule *shell_module)
+{
+ g_debug ("%s", G_STRFUNC);
+}
+
+static EShellModuleInfo module_info = {
+
+ MODULE_NAME,
+ MODULE_ALIASES,
+ MODULE_SCHEMES,
+ MODULE_SORT_ORDER,
+
+ /* Methods */
+ test_module_start,
+ test_module_is_busy,
+ test_module_shutdown,
+ test_module_migrate
+};
+
+void
+e_shell_module_init (GTypeModule *type_module)
+{
+ EShell *shell;
+ EShellModule *shell_module;
+
+ shell_module = E_SHELL_MODULE (type_module);
+ shell = e_shell_module_get_shell (shell_module);
+
+ e_shell_module_set_info (
+ shell_module, &module_info,
+ e_test_shell_view_get_type (type_module));
+
+ g_signal_connect_swapped (
+ shell, "handle-uri",
+ G_CALLBACK (test_module_handle_uri_cb), shell_module);
+
+ g_signal_connect_swapped (
+ shell, "send-receive",
+ G_CALLBACK (test_module_send_receive_cb), shell_module);
+
+ g_signal_connect_swapped (
+ shell, "window-created",
+ G_CALLBACK (test_module_window_created_cb), shell_module);
+
+ g_signal_connect_swapped (
+ shell, "window-destroyed",
+ G_CALLBACK (test_module_window_destroyed_cb), shell_module);
+}
diff --git a/shell/test/e-test-shell-view.c b/shell/test/e-test-shell-view.c
new file mode 100644
index 0000000000..9bbffaf4cc
--- /dev/null
+++ b/shell/test/e-test-shell-view.c
@@ -0,0 +1,155 @@
+/*
+ * e-test-shell-view.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-test-shell-view.h"
+
+#include <e-shell-content.h>
+#include <e-shell-sidebar.h>
+
+#define E_TEST_SHELL_VIEW_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_TEST_SHELL_VIEW, ETestShellViewPrivate))
+
+struct _ETestShellViewPrivate {
+ EActivity *activity;
+};
+
+GType e_test_shell_view_type = 0;
+static gpointer parent_class;
+
+static void
+test_shell_view_toggled (EShellView *shell_view)
+{
+#if 0
+ gboolean is_active;
+ const gchar *active;
+
+ is_active = e_shell_view_is_active (shell_view);
+ active = is_active ? "active" : "inactive";
+ g_debug ("%s (now %s)", G_STRFUNC, active);
+#endif
+}
+
+static void
+test_shell_view_dispose (GObject *object)
+{
+ ETestShellViewPrivate *priv;
+
+ priv = E_TEST_SHELL_VIEW_GET_PRIVATE (object);
+
+ if (priv->activity != NULL) {
+ e_activity_complete (priv->activity);
+ g_object_unref (priv->activity);
+ priv->activity = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+test_shell_view_constructed (GObject *object)
+{
+ ETestShellViewPrivate *priv;
+ EShellContent *shell_content;
+ EShellSidebar *shell_sidebar;
+ EShellModule *shell_module;
+ EShellView *shell_view;
+ EActivity *activity;
+ GtkWidget *widget;
+
+ /* Chain up to parent's constructed() method. */
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+
+ priv = E_TEST_SHELL_VIEW_GET_PRIVATE (object);
+
+ shell_view = E_SHELL_VIEW (object);
+ shell_module = e_shell_view_get_shell_module (shell_view);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+ shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
+
+ widget = gtk_label_new ("Content Widget");
+ gtk_container_add (GTK_CONTAINER (shell_content), widget);
+ gtk_widget_show (widget);
+
+ widget = gtk_label_new ("Sidebar Widget");
+ gtk_container_add (GTK_CONTAINER (shell_sidebar), widget);
+ gtk_widget_show (widget);
+
+ activity = e_activity_new ("Test Activity");
+ e_activity_set_allow_cancel (activity, TRUE);
+ e_shell_module_add_activity (shell_module, activity);
+ priv->activity = activity;
+}
+
+static void
+test_shell_view_class_init (ETestShellViewClass *class,
+ GTypeModule *type_module)
+{
+ GObjectClass *object_class;
+ EShellViewClass *shell_view_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (ETestShellViewPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = test_shell_view_dispose;
+ object_class->constructed = test_shell_view_constructed;
+
+ shell_view_class = E_SHELL_VIEW_CLASS (class);
+ shell_view_class->label = "Test";
+ shell_view_class->icon_name = "face-monkey";
+ shell_view_class->type_module = type_module;
+ shell_view_class->toggled = test_shell_view_toggled;
+}
+
+static void
+test_shell_view_init (ETestShellView *test_shell_view)
+{
+ test_shell_view->priv =
+ E_TEST_SHELL_VIEW_GET_PRIVATE (test_shell_view);
+}
+
+GType
+e_test_shell_view_get_type (GTypeModule *type_module)
+{
+ if (e_test_shell_view_type == 0) {
+ const GTypeInfo type_info = {
+ sizeof (ETestShellViewClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) test_shell_view_class_init,
+ (GClassFinalizeFunc) NULL,
+ type_module,
+ sizeof (ETestShellView),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) test_shell_view_init,
+ NULL /* value_table */
+ };
+
+ e_test_shell_view_type =
+ g_type_module_register_type (
+ type_module, E_TYPE_SHELL_VIEW,
+ "ETestShellView", &type_info, 0);
+ }
+
+ return e_test_shell_view_type;
+}
diff --git a/shell/test/e-test-shell-view.h b/shell/test/e-test-shell-view.h
new file mode 100644
index 0000000000..df1098ae56
--- /dev/null
+++ b/shell/test/e-test-shell-view.h
@@ -0,0 +1,67 @@
+/*
+ * e-test-shell-view.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef E_TEST_SHELL_VIEW_H
+#define E_TEST_SHELL_VIEW_H
+
+#include <e-shell-view.h>
+
+/* Standard GObject macros */
+#define E_TYPE_TEST_SHELL_VIEW \
+ (e_test_shell_view_type)
+#define E_TEST_SHELL_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_TEST_SHELL_VIEW, ETestShellView))
+#define E_TEST_SHELL_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_TEST_SHELL_VIEW, ETestShellViewClass))
+#define E_IS_TEST_SHELL_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_TEST_SHELL_VIEW))
+#define E_IS_TEST_SHELL_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_TEST_SHELL_VIEW))
+#define E_TEST_SHELL_VIEW_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_TEST_SHELL_VIEW, ETestShellViewClass))
+
+G_BEGIN_DECLS
+
+extern GType e_test_shell_view_type;
+
+typedef struct _ETestShellView ETestShellView;
+typedef struct _ETestShellViewClass ETestShellViewClass;
+typedef struct _ETestShellViewPrivate ETestShellViewPrivate;
+
+struct _ETestShellView {
+ EShellView parent;
+ ETestShellViewPrivate *priv;
+};
+
+struct _ETestShellViewClass {
+ EShellViewClass parent_class;
+};
+
+GType e_test_shell_view_get_type (GTypeModule *type_module);
+
+G_END_DECLS
+
+#endif /* E_TEST_SHELL_VIEW_H */
diff --git a/shell/test/evolution-test-component.c b/shell/test/evolution-test-component.c
deleted file mode 100644
index 16aed882d0..0000000000
--- a/shell/test/evolution-test-component.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <errno.h>
-#include <string.h>
-#include <glib/gi18n.h>
-#include <bonobo/bonobo-shlib-factory.h>
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-exception.h>
-#include <gtk/gtk.h>
-#include "e-task-bar.h"
-#include "evolution-test-component.h"
-
-
-#define FACTORY_ID "OAFIID:GNOME_Evolution_Test_Factory:" BASE_VERSION
-#define TEST_COMPONENT_ID "OAFIID:GNOME_Evolution_Test_Component:" BASE_VERSION
-#define CREATE_TEST_ID "test"
-
-#define PARENT_TYPE bonobo_object_get_type ()
-
-static BonoboObjectClass *parent_class = NULL;
-
-struct _EvolutionTestComponentPrivate {
- BonoboControl *view_control;
- BonoboControl *sidebar_control;
- BonoboControl *status_control;
-};
-
-/* GObject methods */
-
-static void
-impl_dispose (GObject *object)
-{
- EvolutionTestComponentPrivate *priv;
-
- priv = EVOLUTION_TEST_COMPONENT (object)->priv;
-
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
-
-static void
-impl_finalize (GObject *object)
-{
- EvolutionTestComponentPrivate *priv = EVOLUTION_TEST_COMPONENT (object)->priv;
-
- g_free (priv);
-
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
-}
-
-/* Evolution::Component CORBA methods */
-
-static void
-impl_upgradeFromVersion (PortableServer_Servant servant,
- const CORBA_short major,
- const CORBA_short minor,
- const CORBA_short revision,
- CORBA_Environment *ev)
-{
- EvolutionTestComponent *component = EVOLUTION_TEST_COMPONENT (bonobo_object_from_servant (servant));
- EvolutionTestComponentPrivate *priv;
-
- priv = component->priv;
-
- g_message ("Upgrading from %d.%d.%d", major, minor, revision);
-}
-
-
-static GNOME_Evolution_CreatableItemTypeList *
-impl__get_userCreatableItems (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- GNOME_Evolution_CreatableItemTypeList *list = GNOME_Evolution_CreatableItemTypeList__alloc ();
-
- list->_length = 1;
- list->_maximum = list->_length;
- list->_buffer = GNOME_Evolution_CreatableItemTypeList_allocbuf (list->_length);
-
- CORBA_sequence_set_release (list, FALSE);
-
- list->_buffer[0].id = CREATE_TEST_ID;
- list->_buffer[0].description = _("New Test");
- list->_buffer[0].menuDescription = (char *) C_("New", "_Test");
- list->_buffer[0].tooltip = _("Create a new test item");
- list->_buffer[0].menuShortcut = 'i';
- list->_buffer[0].iconName = "";
-
- return list;
-}
-
-static void
-impl_requestCreateItem (PortableServer_Servant servant,
- const CORBA_char *item_type_name,
- CORBA_Environment *ev)
-{
- EvolutionTestComponent *evolution_test_component = EVOLUTION_TEST_COMPONENT (bonobo_object_from_servant (servant));
- EvolutionTestComponentPrivate *priv;
-
- priv = evolution_test_component->priv;
-
- if (strcmp (item_type_name, CREATE_TEST_ID) == 0) {
- g_message ("Creating test item");
- } else {
- bonobo_exception_set (ev, ex_GNOME_Evolution_Component_UnknownType);
- return;
- }
-}
-
-/* Initialization */
-
-static void
-evolution_test_component_class_init (EvolutionTestComponentClass *klass)
-{
- POA_GNOME_Evolution_Component__epv *epv = &klass->epv;
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
- epv->upgradeFromVersion = impl_upgradeFromVersion;
- epv->_get_userCreatableItems = impl__get_userCreatableItems;
- epv->requestCreateItem = impl_requestCreateItem;
-
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
-}
-
-static void
-evolution_test_component_init (EvolutionTestComponent *component, EvolutionTestComponentClass *klass)
-{
- EvolutionTestComponentPrivate *priv;
-
- priv = g_new0 (EvolutionTestComponentPrivate, 1);
-
- component->priv = priv;
-}
-
-BONOBO_TYPE_FUNC_FULL (EvolutionTestComponent, GNOME_Evolution_Component, PARENT_TYPE, evolution_test_component)
-
-static BonoboObject *
-factory (BonoboGenericFactory *factory,
- const char *component_id,
- void *closure)
-{
- if (strcmp (component_id, TEST_COMPONENT_ID) == 0) {
- BonoboObject *object = BONOBO_OBJECT (g_object_new (EVOLUTION_TEST_TYPE_COMPONENT, NULL));
- bonobo_object_ref (object);
- return object;
- }
-
- g_warning (FACTORY_ID ": Don't know what to do with %s", component_id);
-
- return NULL;
-}
-
-BONOBO_ACTIVATION_SHLIB_FACTORY (FACTORY_ID, "Evolution Calendar component factory", factory, NULL)
diff --git a/shell/test/evolution-test-component.h b/shell/test/evolution-test-component.h
deleted file mode 100644
index 18a86f1baf..0000000000
--- a/shell/test/evolution-test-component.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- *
- * Authors:
- * JP Rosevear <jpr@ximian.com>
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifndef _EVOLUTION_TEST_COMPONENT_H_
-#define _EVOLUTION_TEST_COMPONENT_H_
-
-#include <bonobo/bonobo-object.h>
-#include "Evolution.h"
-
-
-#define EVOLUTION_TEST_TYPE_COMPONENT (evolution_test_component_get_type ())
-#define EVOLUTION_TEST_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EVOLUTION_TEST_TYPE_COMPONENT, EvolutionTestComponent))
-#define EVOLUTION_TEST_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EVOLUTION_TEST_TYPE_COMPONENT, EvolutionTestComponentClass))
-#define EVOLUTION_TEST_IS_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EVOLUTION_TEST_TYPE_COMPONENT))
-#define EVOLUTION_TEST_IS_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EVOLUTION_TEST_TYPE_COMPONENT))
-
-
-typedef struct _EvolutionTestComponent EvolutionTestComponent;
-typedef struct _EvolutionTestComponentPrivate EvolutionTestComponentPrivate;
-typedef struct _EvolutionTestComponentClass EvolutionTestComponentClass;
-
-struct _EvolutionTestComponent {
- BonoboObject parent;
-
- EvolutionTestComponentPrivate *priv;
-};
-
-struct _EvolutionTestComponentClass {
- BonoboObjectClass parent_class;
-
- POA_GNOME_Evolution_Component__epv epv;
-};
-
-
-GType evolution_test_component_get_type (void);
-
-#endif /* _EVOLUTION_TEST_COMPONENT_H_ */