|
Packit |
15f964 |
/*
|
|
Packit |
15f964 |
* e-shell-view.c
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* This program is free software; you can redistribute it and/or modify it
|
|
Packit |
15f964 |
* under the terms of the GNU Lesser General Public License as published by
|
|
Packit |
15f964 |
* the Free Software Foundation.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* This program is distributed in the hope that it will be useful, but
|
|
Packit |
15f964 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
Packit |
15f964 |
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
Packit |
15f964 |
* for more details.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* You should have received a copy of the GNU Lesser General Public License
|
|
Packit |
15f964 |
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
*/
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* SECTION: e-shell-view
|
|
Packit |
15f964 |
* @short_description: views within the main window
|
|
Packit |
15f964 |
* @include: shell/e-shell-view.h
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#include "evolution-config.h"
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#include "e-shell-view.h"
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#include <string.h>
|
|
Packit |
15f964 |
#include <glib/gi18n.h>
|
|
Packit |
15f964 |
#include <libebackend/libebackend.h>
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#include "e-shell-searchbar.h"
|
|
Packit |
15f964 |
#include "e-shell-window-actions.h"
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#define E_SHELL_VIEW_GET_PRIVATE(obj) \
|
|
Packit |
15f964 |
(G_TYPE_INSTANCE_GET_PRIVATE \
|
|
Packit |
15f964 |
((obj), E_TYPE_SHELL_VIEW, EShellViewPrivate))
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#define SIMPLE_SEARCHBAR_WIDTH 300
|
|
Packit |
15f964 |
#define STATE_SAVE_TIMEOUT_SECONDS 3
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
struct _EShellViewPrivate {
|
|
Packit |
15f964 |
GThread *main_thread; /* not referenced */
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
gpointer shell_window; /* weak pointer */
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
GKeyFile *state_key_file;
|
|
Packit |
15f964 |
gpointer state_save_activity; /* weak pointer */
|
|
Packit |
15f964 |
guint state_save_timeout_id;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
GalViewInstance *view_instance;
|
|
Packit |
15f964 |
gulong view_instance_changed_handler_id;
|
|
Packit |
15f964 |
gulong view_instance_loaded_handler_id;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
gchar *title;
|
|
Packit |
15f964 |
gchar *view_id;
|
|
Packit |
15f964 |
gint page_num;
|
|
Packit |
15f964 |
guint merge_id;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
GtkAction *action;
|
|
Packit |
15f964 |
GtkSizeGroup *size_group;
|
|
Packit |
15f964 |
GtkWidget *shell_content;
|
|
Packit |
15f964 |
GtkWidget *shell_sidebar;
|
|
Packit |
15f964 |
GtkWidget *shell_taskbar;
|
|
Packit |
15f964 |
GtkWidget *searchbar;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
EFilterRule *search_rule;
|
|
Packit |
15f964 |
guint execute_search_blocked;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
GtkWidget *preferences_window;
|
|
Packit |
15f964 |
gulong preferences_hide_handler_id;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
guint update_actions_idle_id;
|
|
Packit |
15f964 |
};
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
enum {
|
|
Packit |
15f964 |
PROP_0,
|
|
Packit |
15f964 |
PROP_ACTION,
|
|
Packit |
15f964 |
PROP_PAGE_NUM,
|
|
Packit |
15f964 |
PROP_SEARCHBAR,
|
|
Packit |
15f964 |
PROP_SEARCH_RULE,
|
|
Packit |
15f964 |
PROP_SHELL_BACKEND,
|
|
Packit |
15f964 |
PROP_SHELL_CONTENT,
|
|
Packit |
15f964 |
PROP_SHELL_SIDEBAR,
|
|
Packit |
15f964 |
PROP_SHELL_TASKBAR,
|
|
Packit |
15f964 |
PROP_SHELL_WINDOW,
|
|
Packit |
15f964 |
PROP_STATE_KEY_FILE,
|
|
Packit |
15f964 |
PROP_TITLE,
|
|
Packit |
15f964 |
PROP_VIEW_ID,
|
|
Packit |
15f964 |
PROP_VIEW_INSTANCE
|
|
Packit |
15f964 |
};
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
enum {
|
|
Packit |
15f964 |
TOGGLED,
|
|
Packit |
15f964 |
CLEAR_SEARCH,
|
|
Packit |
15f964 |
CUSTOM_SEARCH,
|
|
Packit |
15f964 |
EXECUTE_SEARCH,
|
|
Packit |
15f964 |
UPDATE_ACTIONS,
|
|
Packit |
15f964 |
LAST_SIGNAL
|
|
Packit |
15f964 |
};
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gpointer parent_class;
|
|
Packit |
15f964 |
static gulong signals[LAST_SIGNAL];
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_init_search_context (EShellViewClass *class)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellBackend *shell_backend;
|
|
Packit |
15f964 |
ERuleContext *search_context;
|
|
Packit |
15f964 |
const gchar *config_dir;
|
|
Packit |
15f964 |
gchar *system_filename;
|
|
Packit |
15f964 |
gchar *user_filename;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_backend = class->shell_backend;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Sanity check the class fields we need. */
|
|
Packit |
15f964 |
g_return_if_fail (class->search_rules != NULL);
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_BACKEND (shell_backend));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* The basename for built-in searches is specified in the
|
|
Packit |
15f964 |
* shell view class. All built-in search rules live in the
|
|
Packit |
15f964 |
* same directory. */
|
|
Packit |
15f964 |
system_filename = g_build_filename (
|
|
Packit |
15f964 |
EVOLUTION_RULEDIR, class->search_rules, NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* The filename for custom saved searches is always of
|
|
Packit |
15f964 |
* the form "$(shell_backend_config_dir)/searches.xml". */
|
|
Packit |
15f964 |
config_dir = e_shell_backend_get_config_dir (shell_backend);
|
|
Packit |
15f964 |
user_filename = g_build_filename (config_dir, "searches.xml", NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Create the search context instance. Subclasses may override
|
|
Packit |
15f964 |
* the GType so check that it's really an ERuleContext instance. */
|
|
Packit |
15f964 |
search_context = g_object_new (class->search_context_type, NULL);
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_RULE_CONTEXT (search_context));
|
|
Packit |
15f964 |
class->search_context = search_context;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
e_rule_context_add_part_set (
|
|
Packit |
15f964 |
search_context, "partset", E_TYPE_FILTER_PART,
|
|
Packit |
15f964 |
e_rule_context_add_part, e_rule_context_next_part);
|
|
Packit |
15f964 |
e_rule_context_add_rule_set (
|
|
Packit |
15f964 |
search_context, "ruleset", E_TYPE_FILTER_RULE,
|
|
Packit |
15f964 |
e_rule_context_add_rule, e_rule_context_next_rule);
|
|
Packit |
15f964 |
e_rule_context_load (search_context, system_filename, user_filename);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_free (system_filename);
|
|
Packit |
15f964 |
g_free (user_filename);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_init_view_collection (EShellViewClass *class)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellBackend *shell_backend;
|
|
Packit |
15f964 |
EShellBackendClass *backend_class;
|
|
Packit |
15f964 |
const gchar *base_directory;
|
|
Packit |
15f964 |
const gchar *name;
|
|
Packit |
15f964 |
gchar *system_directory;
|
|
Packit |
15f964 |
gchar *user_directory;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_backend = class->shell_backend;
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_BACKEND (shell_backend));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
backend_class = E_SHELL_BACKEND_GET_CLASS (shell_backend);
|
|
Packit |
15f964 |
g_return_if_fail (backend_class != NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
name = backend_class->name;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
base_directory = EVOLUTION_GALVIEWSDIR;
|
|
Packit |
15f964 |
system_directory = g_build_filename (base_directory, name, NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
base_directory = e_shell_backend_get_config_dir (shell_backend);
|
|
Packit |
15f964 |
user_directory = g_build_filename (base_directory, "views", NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* The view collection is never destroyed. */
|
|
Packit |
15f964 |
class->view_collection = gal_view_collection_new (
|
|
Packit |
15f964 |
system_directory, user_directory);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_free (system_directory);
|
|
Packit |
15f964 |
g_free (user_directory);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_update_view_id (EShellView *shell_view,
|
|
Packit |
15f964 |
GalViewInstance *view_instance)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
gchar *view_id;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
view_id = gal_view_instance_get_current_view_id (view_instance);
|
|
Packit |
15f964 |
e_shell_view_set_view_id (shell_view, view_id);
|
|
Packit |
15f964 |
g_free (view_id);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_load_state (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellBackend *shell_backend;
|
|
Packit |
15f964 |
GKeyFile *key_file;
|
|
Packit |
15f964 |
const gchar *config_dir;
|
|
Packit |
15f964 |
gchar *filename;
|
|
Packit |
15f964 |
GError *error = NULL;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_backend = e_shell_view_get_shell_backend (shell_view);
|
|
Packit |
15f964 |
config_dir = e_shell_backend_get_config_dir (shell_backend);
|
|
Packit |
15f964 |
filename = g_build_filename (config_dir, "state.ini", NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* XXX Should do this asynchronously. */
|
|
Packit |
15f964 |
key_file = shell_view->priv->state_key_file;
|
|
Packit |
15f964 |
g_key_file_load_from_file (key_file, filename, 0, &error);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (error == NULL)
|
|
Packit |
15f964 |
goto exit;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
|
|
Packit |
15f964 |
g_warning ("%s", error->message);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_error_free (error);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
exit:
|
|
Packit |
15f964 |
g_free (filename);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
typedef struct {
|
|
Packit |
15f964 |
EShellView *shell_view;
|
|
Packit |
15f964 |
gchar *contents;
|
|
Packit |
15f964 |
} SaveStateData;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_save_state_done_cb (GFile *file,
|
|
Packit |
15f964 |
GAsyncResult *result,
|
|
Packit |
15f964 |
SaveStateData *data)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GError *error = NULL;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
e_file_replace_contents_finish (file, result, NULL, &error);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (error != NULL) {
|
|
Packit |
15f964 |
g_warning ("%s", error->message);
|
|
Packit |
15f964 |
g_error_free (error);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_object_unref (data->shell_view);
|
|
Packit |
15f964 |
g_free (data->contents);
|
|
Packit |
15f964 |
g_slice_free (SaveStateData, data);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static EActivity *
|
|
Packit |
15f964 |
shell_view_save_state (EShellView *shell_view,
|
|
Packit |
15f964 |
gboolean immediately)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellBackend *shell_backend;
|
|
Packit |
15f964 |
SaveStateData *data;
|
|
Packit |
15f964 |
EActivity *activity;
|
|
Packit |
15f964 |
GKeyFile *key_file;
|
|
Packit |
15f964 |
GFile *file;
|
|
Packit |
15f964 |
const gchar *config_dir;
|
|
Packit |
15f964 |
gchar *contents;
|
|
Packit |
15f964 |
gchar *path;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_backend = e_shell_view_get_shell_backend (shell_view);
|
|
Packit |
15f964 |
config_dir = e_shell_backend_get_config_dir (shell_backend);
|
|
Packit |
15f964 |
key_file = shell_view->priv->state_key_file;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
contents = g_key_file_to_data (key_file, NULL, NULL);
|
|
Packit |
15f964 |
g_return_val_if_fail (contents != NULL, NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
path = g_build_filename (config_dir, "state.ini", NULL);
|
|
Packit |
15f964 |
if (immediately) {
|
|
Packit |
15f964 |
g_file_set_contents (path, contents, -1, NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_free (path);
|
|
Packit |
15f964 |
g_free (contents);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
file = g_file_new_for_path (path);
|
|
Packit |
15f964 |
g_free (path);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* GIO does not copy the contents string, so we need to keep
|
|
Packit |
15f964 |
* it in memory until saving is complete. We reference the
|
|
Packit |
15f964 |
* shell view to keep it from being finalized while saving. */
|
|
Packit |
15f964 |
data = g_slice_new (SaveStateData);
|
|
Packit |
15f964 |
data->shell_view = g_object_ref (shell_view);
|
|
Packit |
15f964 |
data->contents = contents;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* The returned activity is a borrowed reference. */
|
|
Packit |
15f964 |
activity = e_file_replace_contents_async (
|
|
Packit |
15f964 |
file, contents, strlen (contents), NULL,
|
|
Packit |
15f964 |
FALSE, G_FILE_CREATE_PRIVATE, (GAsyncReadyCallback)
|
|
Packit |
15f964 |
shell_view_save_state_done_cb, data);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
e_activity_set_text (
|
|
Packit |
15f964 |
activity, (_("Saving user interface state")));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
e_shell_backend_add_activity (shell_backend, activity);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_object_unref (file);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return activity;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gboolean
|
|
Packit |
15f964 |
shell_view_state_timeout_cb (gpointer user_data)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellView *shell_view;
|
|
Packit |
15f964 |
EActivity *activity;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view = E_SHELL_VIEW (user_data);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* If a save is still in progress, check back later. */
|
|
Packit |
15f964 |
if (shell_view->priv->state_save_activity != NULL)
|
|
Packit |
15f964 |
return TRUE;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
activity = shell_view_save_state (shell_view, FALSE);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Set up a weak pointer that gets set to NULL when the
|
|
Packit |
15f964 |
* activity finishes. This will tell us if we're still
|
|
Packit |
15f964 |
* busy saving state data to disk on the next timeout. */
|
|
Packit |
15f964 |
shell_view->priv->state_save_activity = activity;
|
|
Packit |
15f964 |
g_object_add_weak_pointer (
|
|
Packit |
15f964 |
G_OBJECT (shell_view->priv->state_save_activity),
|
|
Packit |
15f964 |
&shell_view->priv->state_save_activity);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view->priv->state_save_timeout_id = 0;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return FALSE;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_emit_toggled (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_signal_emit (shell_view, signals[TOGGLED], 0);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_set_action (EShellView *shell_view,
|
|
Packit |
15f964 |
GtkAction *action)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
gchar *label;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (shell_view->priv->action == NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view->priv->action = g_object_ref (action);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_object_get (action, "label", &label, NULL);
|
|
Packit |
15f964 |
e_shell_view_set_title (shell_view, label);
|
|
Packit |
15f964 |
g_free (label);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_signal_connect_swapped (
|
|
Packit |
15f964 |
action, "toggled",
|
|
Packit |
15f964 |
G_CALLBACK (shell_view_emit_toggled), shell_view);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_set_shell_window (EShellView *shell_view,
|
|
Packit |
15f964 |
EShellWindow *shell_window)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
|
|
Packit |
15f964 |
g_return_if_fail (shell_view->priv->shell_window == NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view->priv->shell_window = shell_window;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_object_add_weak_pointer (
|
|
Packit |
15f964 |
G_OBJECT (shell_window),
|
|
Packit |
15f964 |
&shell_view->priv->shell_window);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_set_property (GObject *object,
|
|
Packit |
15f964 |
guint property_id,
|
|
Packit |
15f964 |
const GValue *value,
|
|
Packit |
15f964 |
GParamSpec *pspec)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
switch (property_id) {
|
|
Packit |
15f964 |
case PROP_ACTION:
|
|
Packit |
15f964 |
shell_view_set_action (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object),
|
|
Packit |
15f964 |
g_value_get_object (value));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_PAGE_NUM:
|
|
Packit |
15f964 |
e_shell_view_set_page_num (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object),
|
|
Packit |
15f964 |
g_value_get_int (value));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_SEARCH_RULE:
|
|
Packit |
15f964 |
e_shell_view_set_search_rule (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object),
|
|
Packit |
15f964 |
g_value_get_object (value));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_SHELL_WINDOW:
|
|
Packit |
15f964 |
shell_view_set_shell_window (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object),
|
|
Packit |
15f964 |
g_value_get_object (value));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_TITLE:
|
|
Packit |
15f964 |
e_shell_view_set_title (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object),
|
|
Packit |
15f964 |
g_value_get_string (value));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_VIEW_ID:
|
|
Packit |
15f964 |
e_shell_view_set_view_id (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object),
|
|
Packit |
15f964 |
g_value_get_string (value));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_VIEW_INSTANCE:
|
|
Packit |
15f964 |
e_shell_view_set_view_instance (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object),
|
|
Packit |
15f964 |
g_value_get_object (value));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_get_property (GObject *object,
|
|
Packit |
15f964 |
guint property_id,
|
|
Packit |
15f964 |
GValue *value,
|
|
Packit |
15f964 |
GParamSpec *pspec)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
switch (property_id) {
|
|
Packit |
15f964 |
case PROP_ACTION:
|
|
Packit |
15f964 |
g_value_set_object (
|
|
Packit |
15f964 |
value, e_shell_view_get_action (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object)));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_PAGE_NUM:
|
|
Packit |
15f964 |
g_value_set_int (
|
|
Packit |
15f964 |
value, e_shell_view_get_page_num (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object)));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_SEARCHBAR:
|
|
Packit |
15f964 |
g_value_set_object (
|
|
Packit |
15f964 |
value, e_shell_view_get_searchbar (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object)));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_SEARCH_RULE:
|
|
Packit |
15f964 |
g_value_set_object (
|
|
Packit |
15f964 |
value, e_shell_view_get_search_rule (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object)));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_SHELL_BACKEND:
|
|
Packit |
15f964 |
g_value_set_object (
|
|
Packit |
15f964 |
value, e_shell_view_get_shell_backend (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object)));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_SHELL_CONTENT:
|
|
Packit |
15f964 |
g_value_set_object (
|
|
Packit |
15f964 |
value, e_shell_view_get_shell_content (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object)));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_SHELL_SIDEBAR:
|
|
Packit |
15f964 |
g_value_set_object (
|
|
Packit |
15f964 |
value, e_shell_view_get_shell_sidebar (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object)));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_SHELL_TASKBAR:
|
|
Packit |
15f964 |
g_value_set_object (
|
|
Packit |
15f964 |
value, e_shell_view_get_shell_taskbar (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object)));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_SHELL_WINDOW:
|
|
Packit |
15f964 |
g_value_set_object (
|
|
Packit |
15f964 |
value, e_shell_view_get_shell_window (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object)));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_STATE_KEY_FILE:
|
|
Packit |
15f964 |
g_value_set_pointer (
|
|
Packit |
15f964 |
value, e_shell_view_get_state_key_file (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object)));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_TITLE:
|
|
Packit |
15f964 |
g_value_set_string (
|
|
Packit |
15f964 |
value, e_shell_view_get_title (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object)));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_VIEW_ID:
|
|
Packit |
15f964 |
g_value_set_string (
|
|
Packit |
15f964 |
value, e_shell_view_get_view_id (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object)));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_VIEW_INSTANCE:
|
|
Packit |
15f964 |
g_value_set_object (
|
|
Packit |
15f964 |
value, e_shell_view_get_view_instance (
|
|
Packit |
15f964 |
E_SHELL_VIEW (object)));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_dispose (GObject *object)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellViewPrivate *priv;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
priv = E_SHELL_VIEW_GET_PRIVATE (object);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Expedite any pending state saves. */
|
|
Packit |
15f964 |
if (priv->state_save_timeout_id > 0) {
|
|
Packit |
15f964 |
g_source_remove (priv->state_save_timeout_id);
|
|
Packit |
15f964 |
priv->state_save_timeout_id = 0;
|
|
Packit |
15f964 |
if (priv->state_save_activity == NULL)
|
|
Packit |
15f964 |
shell_view_save_state (E_SHELL_VIEW (object), TRUE);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (priv->update_actions_idle_id > 0) {
|
|
Packit |
15f964 |
g_source_remove (priv->update_actions_idle_id);
|
|
Packit |
15f964 |
priv->update_actions_idle_id = 0;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (priv->state_save_activity != NULL) {
|
|
Packit |
15f964 |
g_object_remove_weak_pointer (
|
|
Packit |
15f964 |
G_OBJECT (priv->state_save_activity),
|
|
Packit |
15f964 |
&priv->state_save_activity);
|
|
Packit |
15f964 |
priv->state_save_activity = NULL;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (priv->view_instance_changed_handler_id > 0) {
|
|
Packit |
15f964 |
g_signal_handler_disconnect (
|
|
Packit |
15f964 |
priv->view_instance,
|
|
Packit |
15f964 |
priv->view_instance_changed_handler_id);
|
|
Packit |
15f964 |
priv->view_instance_changed_handler_id = 0;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (priv->view_instance_loaded_handler_id > 0) {
|
|
Packit |
15f964 |
g_signal_handler_disconnect (
|
|
Packit |
15f964 |
priv->view_instance,
|
|
Packit |
15f964 |
priv->view_instance_loaded_handler_id);
|
|
Packit |
15f964 |
priv->view_instance_loaded_handler_id = 0;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (priv->preferences_window != NULL) {
|
|
Packit |
15f964 |
g_signal_handler_disconnect (
|
|
Packit |
15f964 |
priv->preferences_window,
|
|
Packit |
15f964 |
priv->preferences_hide_handler_id);
|
|
Packit |
15f964 |
priv->preferences_hide_handler_id = 0;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (priv->shell_window != NULL) {
|
|
Packit |
15f964 |
g_object_remove_weak_pointer (
|
|
Packit |
15f964 |
G_OBJECT (priv->shell_window), &priv->shell_window);
|
|
Packit |
15f964 |
priv->shell_window = NULL;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_clear_object (&priv->view_instance);
|
|
Packit |
15f964 |
g_clear_object (&priv->shell_content);
|
|
Packit |
15f964 |
g_clear_object (&priv->shell_sidebar);
|
|
Packit |
15f964 |
g_clear_object (&priv->shell_taskbar);
|
|
Packit |
15f964 |
g_clear_object (&priv->searchbar);
|
|
Packit |
15f964 |
g_clear_object (&priv->search_rule);
|
|
Packit |
15f964 |
g_clear_object (&priv->preferences_window);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Chain up to parent's dispose() method. */
|
|
Packit |
15f964 |
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_finalize (GObject *object)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellViewPrivate *priv;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
priv = E_SHELL_VIEW_GET_PRIVATE (object);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_key_file_free (priv->state_key_file);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_free (priv->title);
|
|
Packit |
15f964 |
g_free (priv->view_id);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Chain up to parent's finalize() method. */
|
|
Packit |
15f964 |
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_constructed (GObject *object)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShell *shell;
|
|
Packit |
15f964 |
EShellView *shell_view;
|
|
Packit |
15f964 |
EShellBackend *shell_backend;
|
|
Packit |
15f964 |
EShellViewClass *shell_view_class;
|
|
Packit |
15f964 |
GtkWidget *widget;
|
|
Packit |
15f964 |
gulong handler_id;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view = E_SHELL_VIEW (object);
|
|
Packit |
15f964 |
shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
|
|
Packit |
15f964 |
g_return_if_fail (shell_view_class != NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_backend = e_shell_view_get_shell_backend (shell_view);
|
|
Packit |
15f964 |
shell = e_shell_backend_get_shell (shell_backend);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view_load_state (shell_view);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Invoke factory methods. */
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Create the taskbar widget first so the content and
|
|
Packit |
15f964 |
* sidebar widgets can access it during construction. */
|
|
Packit |
15f964 |
widget = shell_view_class->new_shell_taskbar (shell_view);
|
|
Packit |
15f964 |
shell_view->priv->shell_taskbar = g_object_ref_sink (widget);
|
|
Packit |
15f964 |
gtk_widget_show (widget);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
widget = shell_view_class->new_shell_content (shell_view);
|
|
Packit |
15f964 |
shell_view->priv->shell_content = g_object_ref_sink (widget);
|
|
Packit |
15f964 |
gtk_widget_show (widget);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
widget = shell_view_class->new_shell_sidebar (shell_view);
|
|
Packit |
15f964 |
shell_view->priv->shell_sidebar = g_object_ref_sink (widget);
|
|
Packit |
15f964 |
gtk_widget_show (widget);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (shell_view_class->construct_searchbar != NULL) {
|
|
Packit |
15f964 |
widget = shell_view_class->construct_searchbar (shell_view);
|
|
Packit |
15f964 |
shell_view->priv->searchbar = g_object_ref_sink (widget);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Size group should be safe to unreference now. */
|
|
Packit |
15f964 |
g_object_unref (shell_view->priv->size_group);
|
|
Packit |
15f964 |
shell_view->priv->size_group = NULL;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Update actions whenever the Preferences window is closed. */
|
|
Packit |
15f964 |
widget = e_shell_get_preferences_window (shell);
|
|
Packit |
15f964 |
shell_view->priv->preferences_window = g_object_ref (widget);
|
|
Packit |
15f964 |
handler_id = g_signal_connect_swapped (
|
|
Packit |
15f964 |
shell_view->priv->preferences_window, "hide",
|
|
Packit |
15f964 |
G_CALLBACK (e_shell_view_update_actions_in_idle), shell_view);
|
|
Packit |
15f964 |
shell_view->priv->preferences_hide_handler_id = handler_id;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
e_extensible_load_extensions (E_EXTENSIBLE (object));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Chain up to parent's constructed() method. */
|
|
Packit |
15f964 |
G_OBJECT_CLASS (parent_class)->constructed (object);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static GtkWidget *
|
|
Packit |
15f964 |
shell_view_construct_searchbar (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellContent *shell_content;
|
|
Packit |
15f964 |
EShellViewClass *shell_view_class;
|
|
Packit |
15f964 |
GtkWidget *widget;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_content = e_shell_view_get_shell_content (shell_view);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
|
|
Packit |
15f964 |
g_return_val_if_fail (shell_view_class != NULL, NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
widget = shell_view_class->new_shell_searchbar (shell_view);
|
|
Packit |
15f964 |
e_shell_content_set_searchbar (shell_content, widget);
|
|
Packit |
15f964 |
gtk_widget_show (widget);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return widget;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gchar *
|
|
Packit |
15f964 |
shell_view_get_search_name (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellSearchbar *searchbar;
|
|
Packit |
15f964 |
EFilterRule *rule;
|
|
Packit |
15f964 |
const gchar *search_text;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
rule = e_shell_view_get_search_rule (shell_view);
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_FILTER_RULE (rule), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
searchbar = E_SHELL_SEARCHBAR (shell_view->priv->searchbar);
|
|
Packit |
15f964 |
search_text = e_shell_searchbar_get_search_text (searchbar);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (search_text == NULL || *search_text == '\0')
|
|
Packit |
15f964 |
search_text = "''";
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return g_strdup_printf ("%s %s", rule->name, search_text);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_toggled (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellViewPrivate *priv = shell_view->priv;
|
|
Packit |
15f964 |
EShellViewClass *shell_view_class;
|
|
Packit |
15f964 |
EShellWindow *shell_window;
|
|
Packit |
15f964 |
GtkUIManager *ui_manager;
|
|
Packit |
15f964 |
const gchar *basename, *id;
|
|
Packit |
15f964 |
gboolean view_is_active;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
|
|
Packit |
15f964 |
g_return_if_fail (shell_view_class != NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_window = e_shell_view_get_shell_window (shell_view);
|
|
Packit |
15f964 |
ui_manager = e_shell_window_get_ui_manager (shell_window);
|
|
Packit |
15f964 |
view_is_active = e_shell_view_is_active (shell_view);
|
|
Packit |
15f964 |
basename = shell_view_class->ui_definition;
|
|
Packit |
15f964 |
id = shell_view_class->ui_manager_id;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (view_is_active && priv->merge_id == 0) {
|
|
Packit |
15f964 |
priv->merge_id = e_load_ui_manager_definition (
|
|
Packit |
15f964 |
ui_manager, basename);
|
|
Packit |
15f964 |
e_plugin_ui_enable_manager (ui_manager, id);
|
|
Packit |
15f964 |
} else if (!view_is_active && priv->merge_id != 0) {
|
|
Packit |
15f964 |
e_plugin_ui_disable_manager (ui_manager, id);
|
|
Packit |
15f964 |
gtk_ui_manager_remove_ui (ui_manager, priv->merge_id);
|
|
Packit |
15f964 |
gtk_ui_manager_ensure_update (ui_manager);
|
|
Packit |
15f964 |
priv->merge_id = 0;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
gtk_ui_manager_ensure_update (ui_manager);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_clear_search (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
e_shell_view_set_search_rule (shell_view, NULL);
|
|
Packit |
15f964 |
e_shell_view_execute_search (shell_view);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_custom_search (EShellView *shell_view,
|
|
Packit |
15f964 |
EFilterRule *custom_rule)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
e_shell_view_set_search_rule (shell_view, custom_rule);
|
|
Packit |
15f964 |
e_shell_view_execute_search (shell_view);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_view_update_actions (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellWindow *shell_window;
|
|
Packit |
15f964 |
EFocusTracker *focus_tracker;
|
|
Packit |
15f964 |
GtkAction *action;
|
|
Packit |
15f964 |
GtkActionGroup *action_group;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (e_shell_view_is_active (shell_view));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_window = e_shell_view_get_shell_window (shell_view);
|
|
Packit |
15f964 |
focus_tracker = e_shell_window_get_focus_tracker (shell_window);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
e_focus_tracker_update_actions (focus_tracker);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
action_group = E_SHELL_WINDOW_ACTION_GROUP_CUSTOM_RULES (shell_window);
|
|
Packit |
15f964 |
gtk_action_group_set_sensitive (action_group, TRUE);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
action = E_SHELL_WINDOW_ACTION_SEARCH_ADVANCED (shell_window);
|
|
Packit |
15f964 |
gtk_action_set_sensitive (action, TRUE);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
e_shell_view_class_init (EShellViewClass *class)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GObjectClass *object_class;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
parent_class = g_type_class_peek_parent (class);
|
|
Packit |
15f964 |
g_type_class_add_private (class, sizeof (EShellViewPrivate));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
object_class = G_OBJECT_CLASS (class);
|
|
Packit |
15f964 |
object_class->set_property = shell_view_set_property;
|
|
Packit |
15f964 |
object_class->get_property = shell_view_get_property;
|
|
Packit |
15f964 |
object_class->dispose = shell_view_dispose;
|
|
Packit |
15f964 |
object_class->finalize = shell_view_finalize;
|
|
Packit |
15f964 |
object_class->constructed = shell_view_constructed;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
class->search_context_type = E_TYPE_RULE_CONTEXT;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Default Factories */
|
|
Packit |
15f964 |
class->new_shell_content = e_shell_content_new;
|
|
Packit |
15f964 |
class->new_shell_sidebar = e_shell_sidebar_new;
|
|
Packit |
15f964 |
class->new_shell_taskbar = e_shell_taskbar_new;
|
|
Packit |
15f964 |
class->new_shell_searchbar = e_shell_searchbar_new;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
class->construct_searchbar = shell_view_construct_searchbar;
|
|
Packit |
15f964 |
class->get_search_name = shell_view_get_search_name;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
class->toggled = shell_view_toggled;
|
|
Packit |
15f964 |
class->clear_search = shell_view_clear_search;
|
|
Packit |
15f964 |
class->custom_search = shell_view_custom_search;
|
|
Packit |
15f964 |
class->update_actions = shell_view_update_actions;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView:action:
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The #GtkRadioAction registered with #EShellSwitcher.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
g_object_class_install_property (
|
|
Packit |
15f964 |
object_class,
|
|
Packit |
15f964 |
PROP_ACTION,
|
|
Packit |
15f964 |
g_param_spec_object (
|
|
Packit |
15f964 |
"action",
|
|
Packit |
15f964 |
"Switcher Action",
|
|
Packit |
15f964 |
"The switcher action for this shell view",
|
|
Packit |
15f964 |
GTK_TYPE_RADIO_ACTION,
|
|
Packit |
15f964 |
G_PARAM_READWRITE |
|
|
Packit |
15f964 |
G_PARAM_CONSTRUCT_ONLY |
|
|
Packit |
15f964 |
G_PARAM_STATIC_STRINGS));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView:page-num
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The #GtkNotebook page number of the shell view.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
g_object_class_install_property (
|
|
Packit |
15f964 |
object_class,
|
|
Packit |
15f964 |
PROP_PAGE_NUM,
|
|
Packit |
15f964 |
g_param_spec_int (
|
|
Packit |
15f964 |
"page-num",
|
|
Packit |
15f964 |
"Page Number",
|
|
Packit |
15f964 |
"The notebook page number of the shell view",
|
|
Packit |
15f964 |
-1,
|
|
Packit |
15f964 |
G_MAXINT,
|
|
Packit |
15f964 |
-1,
|
|
Packit |
15f964 |
G_PARAM_READWRITE |
|
|
Packit |
15f964 |
G_PARAM_STATIC_STRINGS));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView:search-rule
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Criteria for the current search results.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
g_object_class_install_property (
|
|
Packit |
15f964 |
object_class,
|
|
Packit |
15f964 |
PROP_SEARCH_RULE,
|
|
Packit |
15f964 |
g_param_spec_object (
|
|
Packit |
15f964 |
"search-rule",
|
|
Packit |
15f964 |
"Search Rule",
|
|
Packit |
15f964 |
"Criteria for the current search results",
|
|
Packit |
15f964 |
E_TYPE_FILTER_RULE,
|
|
Packit |
15f964 |
G_PARAM_READWRITE |
|
|
Packit |
15f964 |
G_PARAM_STATIC_STRINGS));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView:shell-backend
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The #EShellBackend for this shell view.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
g_object_class_install_property (
|
|
Packit |
15f964 |
object_class,
|
|
Packit |
15f964 |
PROP_SHELL_BACKEND,
|
|
Packit |
15f964 |
g_param_spec_object (
|
|
Packit |
15f964 |
"shell-backend",
|
|
Packit |
15f964 |
"Shell Backend",
|
|
Packit |
15f964 |
"The EShellBackend for this shell view",
|
|
Packit |
15f964 |
E_TYPE_SHELL_BACKEND,
|
|
Packit |
15f964 |
G_PARAM_READABLE |
|
|
Packit |
15f964 |
G_PARAM_STATIC_STRINGS));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView:shell-content
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The content widget appears in an #EShellWindow's
|
|
Packit |
15f964 |
* right pane.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
g_object_class_install_property (
|
|
Packit |
15f964 |
object_class,
|
|
Packit |
15f964 |
PROP_SHELL_CONTENT,
|
|
Packit |
15f964 |
g_param_spec_object (
|
|
Packit |
15f964 |
"shell-content",
|
|
Packit |
15f964 |
"Shell Content Widget",
|
|
Packit |
15f964 |
"The content widget appears in "
|
|
Packit |
15f964 |
"a shell window's right pane",
|
|
Packit |
15f964 |
E_TYPE_SHELL_CONTENT,
|
|
Packit |
15f964 |
G_PARAM_READABLE |
|
|
Packit |
15f964 |
G_PARAM_STATIC_STRINGS));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView:shell-sidebar
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The sidebar widget appears in an #EShellWindow's
|
|
Packit |
15f964 |
* left pane.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
g_object_class_install_property (
|
|
Packit |
15f964 |
object_class,
|
|
Packit |
15f964 |
PROP_SHELL_SIDEBAR,
|
|
Packit |
15f964 |
g_param_spec_object (
|
|
Packit |
15f964 |
"shell-sidebar",
|
|
Packit |
15f964 |
"Shell Sidebar Widget",
|
|
Packit |
15f964 |
"The sidebar widget appears in "
|
|
Packit |
15f964 |
"a shell window's left pane",
|
|
Packit |
15f964 |
E_TYPE_SHELL_SIDEBAR,
|
|
Packit |
15f964 |
G_PARAM_READABLE |
|
|
Packit |
15f964 |
G_PARAM_STATIC_STRINGS));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView:shell-taskbar
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The taskbar widget appears at the bottom of an #EShellWindow.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
g_object_class_install_property (
|
|
Packit |
15f964 |
object_class,
|
|
Packit |
15f964 |
PROP_SHELL_TASKBAR,
|
|
Packit |
15f964 |
g_param_spec_object (
|
|
Packit |
15f964 |
"shell-taskbar",
|
|
Packit |
15f964 |
"Shell Taskbar Widget",
|
|
Packit |
15f964 |
"The taskbar widget appears at "
|
|
Packit |
15f964 |
"the bottom of a shell window",
|
|
Packit |
15f964 |
E_TYPE_SHELL_TASKBAR,
|
|
Packit |
15f964 |
G_PARAM_READABLE |
|
|
Packit |
15f964 |
G_PARAM_STATIC_STRINGS));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView:shell-window
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The #EShellWindow to which the shell view belongs.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
g_object_class_install_property (
|
|
Packit |
15f964 |
object_class,
|
|
Packit |
15f964 |
PROP_SHELL_WINDOW,
|
|
Packit |
15f964 |
g_param_spec_object (
|
|
Packit |
15f964 |
"shell-window",
|
|
Packit |
15f964 |
"Shell Window",
|
|
Packit |
15f964 |
"The window to which the shell view belongs",
|
|
Packit |
15f964 |
E_TYPE_SHELL_WINDOW,
|
|
Packit |
15f964 |
G_PARAM_READWRITE |
|
|
Packit |
15f964 |
G_PARAM_CONSTRUCT_ONLY |
|
|
Packit |
15f964 |
G_PARAM_STATIC_STRINGS));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView:state-key-file
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The #GKeyFile holding widget state data.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
g_object_class_install_property (
|
|
Packit |
15f964 |
object_class,
|
|
Packit |
15f964 |
PROP_STATE_KEY_FILE,
|
|
Packit |
15f964 |
g_param_spec_pointer (
|
|
Packit |
15f964 |
"state-key-file",
|
|
Packit |
15f964 |
"State Key File",
|
|
Packit |
15f964 |
"The key file holding widget state data",
|
|
Packit |
15f964 |
G_PARAM_READABLE |
|
|
Packit |
15f964 |
G_PARAM_STATIC_STRINGS));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView:title
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The title of the shell view. Also serves as the #EShellWindow
|
|
Packit |
15f964 |
* title when the shell view is active.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
g_object_class_install_property (
|
|
Packit |
15f964 |
object_class,
|
|
Packit |
15f964 |
PROP_TITLE,
|
|
Packit |
15f964 |
g_param_spec_string (
|
|
Packit |
15f964 |
"title",
|
|
Packit |
15f964 |
"Title",
|
|
Packit |
15f964 |
"The title of the shell view",
|
|
Packit |
15f964 |
NULL,
|
|
Packit |
15f964 |
G_PARAM_READWRITE |
|
|
Packit |
15f964 |
G_PARAM_STATIC_STRINGS));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView:view-id
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The current #GalView ID.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
g_object_class_install_property (
|
|
Packit |
15f964 |
object_class,
|
|
Packit |
15f964 |
PROP_VIEW_ID,
|
|
Packit |
15f964 |
g_param_spec_string (
|
|
Packit |
15f964 |
"view-id",
|
|
Packit |
15f964 |
"Current View ID",
|
|
Packit |
15f964 |
"The current GAL view ID",
|
|
Packit |
15f964 |
NULL,
|
|
Packit |
15f964 |
G_PARAM_READWRITE |
|
|
Packit |
15f964 |
G_PARAM_STATIC_STRINGS));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView:view-instance:
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The current #GalViewInstance.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
g_object_class_install_property (
|
|
Packit |
15f964 |
object_class,
|
|
Packit |
15f964 |
PROP_VIEW_INSTANCE,
|
|
Packit |
15f964 |
g_param_spec_object (
|
|
Packit |
15f964 |
"view-instance",
|
|
Packit |
15f964 |
"View Instance",
|
|
Packit |
15f964 |
"The current view instance",
|
|
Packit |
15f964 |
GAL_TYPE_VIEW_INSTANCE,
|
|
Packit |
15f964 |
G_PARAM_READWRITE));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView::toggled
|
|
Packit |
15f964 |
* @shell_view: the #EShellView which emitted the signal
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Emitted when @shell_view is activated or deactivated.
|
|
Packit |
15f964 |
* Use e_shell_view_is_active() to find out which event has
|
|
Packit |
15f964 |
* occurred. The shell view being deactivated is always
|
|
Packit |
15f964 |
* notified before the shell view being activated.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* By default, #EShellView adds the UI definition file
|
|
Packit |
15f964 |
* given in the <structfield>ui_definition</structfield>
|
|
Packit |
15f964 |
* field of #EShellViewClass on activation, and removes the
|
|
Packit |
15f964 |
* UI definition on deactivation.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
signals[TOGGLED] = g_signal_new (
|
|
Packit |
15f964 |
"toggled",
|
|
Packit |
15f964 |
G_OBJECT_CLASS_TYPE (object_class),
|
|
Packit |
15f964 |
G_SIGNAL_RUN_FIRST,
|
|
Packit |
15f964 |
G_STRUCT_OFFSET (EShellViewClass, toggled),
|
|
Packit |
15f964 |
NULL, NULL,
|
|
Packit |
15f964 |
g_cclosure_marshal_VOID__VOID,
|
|
Packit |
15f964 |
G_TYPE_NONE, 0);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView::clear-search
|
|
Packit |
15f964 |
* @shell_view: the #EShellView which emitted the signal
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Clears the current search. See e_shell_view_clear_search() for
|
|
Packit |
15f964 |
* details.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
signals[CLEAR_SEARCH] = g_signal_new (
|
|
Packit |
15f964 |
"clear-search",
|
|
Packit |
15f964 |
G_OBJECT_CLASS_TYPE (object_class),
|
|
Packit |
15f964 |
G_SIGNAL_RUN_LAST,
|
|
Packit |
15f964 |
G_STRUCT_OFFSET (EShellViewClass, clear_search),
|
|
Packit |
15f964 |
NULL, NULL,
|
|
Packit |
15f964 |
g_cclosure_marshal_VOID__VOID,
|
|
Packit |
15f964 |
G_TYPE_NONE, 0);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView::custom-search
|
|
Packit |
15f964 |
* @shell_view: the #EShellView which emitted the signal
|
|
Packit |
15f964 |
* @custom_rule: criteria for the custom search
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Emitted when an advanced or saved search is about to be executed.
|
|
Packit |
15f964 |
* See e_shell_view_custom_search() for details.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
signals[CUSTOM_SEARCH] = g_signal_new (
|
|
Packit |
15f964 |
"custom-search",
|
|
Packit |
15f964 |
G_OBJECT_CLASS_TYPE (object_class),
|
|
Packit |
15f964 |
G_SIGNAL_RUN_LAST,
|
|
Packit |
15f964 |
G_STRUCT_OFFSET (EShellViewClass, custom_search),
|
|
Packit |
15f964 |
NULL, NULL,
|
|
Packit |
15f964 |
g_cclosure_marshal_VOID__OBJECT,
|
|
Packit |
15f964 |
G_TYPE_NONE, 1,
|
|
Packit |
15f964 |
E_TYPE_FILTER_RULE);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView::execute-search
|
|
Packit |
15f964 |
* @shell_view: the #EShellView which emitted the signal
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* #EShellView subclasses should override the
|
|
Packit |
15f964 |
* <structfield>execute_search</structfield> method in
|
|
Packit |
15f964 |
* #EShellViewClass to execute the current search conditions.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
signals[EXECUTE_SEARCH] = g_signal_new (
|
|
Packit |
15f964 |
"execute-search",
|
|
Packit |
15f964 |
G_OBJECT_CLASS_TYPE (object_class),
|
|
Packit |
15f964 |
G_SIGNAL_RUN_FIRST,
|
|
Packit |
15f964 |
G_STRUCT_OFFSET (EShellViewClass, execute_search),
|
|
Packit |
15f964 |
NULL, NULL,
|
|
Packit |
15f964 |
g_cclosure_marshal_VOID__VOID,
|
|
Packit |
15f964 |
G_TYPE_NONE, 0);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellView::update-actions
|
|
Packit |
15f964 |
* @shell_view: the #EShellView which emitted the signal
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* #EShellView subclasses should override the
|
|
Packit |
15f964 |
* <structfield>update_actions</structfield> method in
|
|
Packit |
15f964 |
* #EShellViewClass to update sensitivities, labels, or any
|
|
Packit |
15f964 |
* other aspect of the #GtkActions they have registered.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Plugins can also connect to this signal to be notified
|
|
Packit |
15f964 |
* when to update their own #GtkActions.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
signals[UPDATE_ACTIONS] = g_signal_new (
|
|
Packit |
15f964 |
"update-actions",
|
|
Packit |
15f964 |
G_OBJECT_CLASS_TYPE (object_class),
|
|
Packit |
15f964 |
G_SIGNAL_RUN_FIRST,
|
|
Packit |
15f964 |
G_STRUCT_OFFSET (EShellViewClass, update_actions),
|
|
Packit |
15f964 |
NULL, NULL,
|
|
Packit |
15f964 |
g_cclosure_marshal_VOID__VOID,
|
|
Packit |
15f964 |
G_TYPE_NONE, 0);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
e_shell_view_init (EShellView *shell_view,
|
|
Packit |
15f964 |
EShellViewClass *class)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GtkSizeGroup *size_group;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* XXX Our use of GInstanceInitFunc's 'class' parameter
|
|
Packit |
15f964 |
* prevents us from using G_DEFINE_ABSTRACT_TYPE. */
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (class->search_context == NULL)
|
|
Packit |
15f964 |
shell_view_init_search_context (class);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (class->view_collection == NULL)
|
|
Packit |
15f964 |
shell_view_init_view_collection (class);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view->priv = E_SHELL_VIEW_GET_PRIVATE (shell_view);
|
|
Packit |
15f964 |
shell_view->priv->main_thread = g_thread_self ();
|
|
Packit |
15f964 |
shell_view->priv->state_key_file = g_key_file_new ();
|
|
Packit |
15f964 |
shell_view->priv->size_group = size_group;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
GType
|
|
Packit |
15f964 |
e_shell_view_get_type (void)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
static GType type = 0;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (G_UNLIKELY (type == 0)) {
|
|
Packit |
15f964 |
const GTypeInfo type_info = {
|
|
Packit |
15f964 |
sizeof (EShellViewClass),
|
|
Packit |
15f964 |
(GBaseInitFunc) NULL,
|
|
Packit |
15f964 |
(GBaseFinalizeFunc) NULL,
|
|
Packit |
15f964 |
(GClassInitFunc) e_shell_view_class_init,
|
|
Packit |
15f964 |
(GClassFinalizeFunc) NULL,
|
|
Packit |
15f964 |
NULL, /* class_data */
|
|
Packit |
15f964 |
sizeof (EShellView),
|
|
Packit |
15f964 |
0, /* n_preallocs */
|
|
Packit |
15f964 |
(GInstanceInitFunc) e_shell_view_init,
|
|
Packit |
15f964 |
NULL /* value_table */
|
|
Packit |
15f964 |
};
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
const GInterfaceInfo extensible_info = {
|
|
Packit |
15f964 |
(GInterfaceInitFunc) NULL,
|
|
Packit |
15f964 |
(GInterfaceFinalizeFunc) NULL,
|
|
Packit |
15f964 |
NULL /* interface_data */
|
|
Packit |
15f964 |
};
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
type = g_type_register_static (
|
|
Packit |
15f964 |
G_TYPE_OBJECT, "EShellView",
|
|
Packit |
15f964 |
&type_info, G_TYPE_FLAG_ABSTRACT);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_type_add_interface_static (
|
|
Packit |
15f964 |
type, E_TYPE_EXTENSIBLE, &extensible_info);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return type;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_name:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the view name for @shell_view, which is also the name of
|
|
Packit |
15f964 |
* the corresponding #EShellBackend (see the <structfield>name</structfield>
|
|
Packit |
15f964 |
* field in #EShellBackendInfo).
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the view name for @shell_view
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
const gchar *
|
|
Packit |
15f964 |
e_shell_view_get_name (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GtkAction *action;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
action = e_shell_view_get_action (shell_view);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Switcher actions have a secret "view-name" data value.
|
|
Packit |
15f964 |
* This gets set in e_shell_window_create_switcher_actions(). */
|
|
Packit |
15f964 |
return g_object_get_data (G_OBJECT (action), "view-name");
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_action:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the switcher action for @shell_view.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* An #EShellWindow creates a #GtkRadioAction for each registered subclass
|
|
Packit |
15f964 |
* of #EShellView. This action gets passed to the #EShellSwitcher, which
|
|
Packit |
15f964 |
* displays a button that proxies the action. The icon at the top of the
|
|
Packit |
15f964 |
* sidebar also proxies the action. When @shell_view is active, the
|
|
Packit |
15f964 |
* action's icon becomes the #EShellWindow icon.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the switcher action for @shell_view
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
GtkAction *
|
|
Packit |
15f964 |
e_shell_view_get_action (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return shell_view->priv->action;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_title:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the title for @shell_view. When @shell_view is active, the
|
|
Packit |
15f964 |
* shell view's title becomes the #EShellWindow title.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the title for @shell_view
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
const gchar *
|
|
Packit |
15f964 |
e_shell_view_get_title (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return shell_view->priv->title;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_set_title:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
* @title: a title for @shell_view
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Sets the title for @shell_view. When @shell_view is active, the
|
|
Packit |
15f964 |
* shell view's title becomes the #EShellWindow title.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_set_title (EShellView *shell_view,
|
|
Packit |
15f964 |
const gchar *title)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (!title) {
|
|
Packit |
15f964 |
EShellViewClass *klass = E_SHELL_VIEW_GET_CLASS (shell_view);
|
|
Packit |
15f964 |
g_return_if_fail (klass != NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
title = klass->label;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (g_strcmp0 (shell_view->priv->title, title) == 0)
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_free (shell_view->priv->title);
|
|
Packit |
15f964 |
shell_view->priv->title = g_strdup (title);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_object_notify (G_OBJECT (shell_view), "title");
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_view_id:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the ID of the currently selected #GalView.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* #EShellView subclasses are responsible for keeping this property in
|
|
Packit |
15f964 |
* sync with their #GalViewInstance. #EShellView itself just provides
|
|
Packit |
15f964 |
* a place to store the view ID, and emits a #GObject::notify signal
|
|
Packit |
15f964 |
* when the property changes.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the ID of the current #GalView
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
const gchar *
|
|
Packit |
15f964 |
e_shell_view_get_view_id (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return shell_view->priv->view_id;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_set_view_id:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
* @view_id: a #GalView ID
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Selects the #GalView whose ID is equal to @view_id.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* #EShellView subclasses are responsible for keeping this property in
|
|
Packit |
15f964 |
* sync with their #GalViewInstance. #EShellView itself just provides
|
|
Packit |
15f964 |
* a place to store the view ID, and emits a #GObject::notify signal
|
|
Packit |
15f964 |
* when the property changes.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_set_view_id (EShellView *shell_view,
|
|
Packit |
15f964 |
const gchar *view_id)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (g_strcmp0 (shell_view->priv->view_id, view_id) == 0)
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_free (shell_view->priv->view_id);
|
|
Packit |
15f964 |
shell_view->priv->view_id = g_strdup (view_id);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_object_notify (G_OBJECT (shell_view), "view-id");
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_new_view_instance:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
* @instance_id: a name for the #GalViewInstance
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Convenience function creates a new #GalViewInstance from the
|
|
Packit |
15f964 |
* #GalViewCollection in @shell_view's #EShellViewClass.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: a new #GalViewInstance
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
GalViewInstance *
|
|
Packit |
15f964 |
e_shell_view_new_view_instance (EShellView *shell_view,
|
|
Packit |
15f964 |
const gchar *instance_id)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellViewClass *class;
|
|
Packit |
15f964 |
GalViewCollection *view_collection;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
class = E_SHELL_VIEW_GET_CLASS (shell_view);
|
|
Packit |
15f964 |
g_return_val_if_fail (class != NULL, NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
view_collection = class->view_collection;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return gal_view_instance_new (view_collection, instance_id);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_view_instance:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the current #GalViewInstance for @shell_view.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* #EShellView subclasses are responsible for creating and configuring a
|
|
Packit |
15f964 |
* #GalViewInstance and handing it off so the @shell_view can monitor it
|
|
Packit |
15f964 |
* and perform common actions on it.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: a #GalViewInstance, or %NULL
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
GalViewInstance *
|
|
Packit |
15f964 |
e_shell_view_get_view_instance (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return shell_view->priv->view_instance;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_set_view_instance:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
* @view_instance: a #GalViewInstance, or %NULL
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Sets the current #GalViewInstance for @shell_view.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* #EShellView subclasses are responsible for creating and configuring a
|
|
Packit |
15f964 |
* #GalViewInstance and handing it off so the @shell_view can monitor it
|
|
Packit |
15f964 |
* and perform common actions on it.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_set_view_instance (EShellView *shell_view,
|
|
Packit |
15f964 |
GalViewInstance *view_instance)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (view_instance != NULL) {
|
|
Packit |
15f964 |
g_return_if_fail (GAL_IS_VIEW_INSTANCE (view_instance));
|
|
Packit |
15f964 |
g_object_ref (view_instance);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (shell_view->priv->view_instance_changed_handler_id > 0) {
|
|
Packit |
15f964 |
g_signal_handler_disconnect (
|
|
Packit |
15f964 |
shell_view->priv->view_instance,
|
|
Packit |
15f964 |
shell_view->priv->view_instance_changed_handler_id);
|
|
Packit |
15f964 |
shell_view->priv->view_instance_changed_handler_id = 0;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (shell_view->priv->view_instance_loaded_handler_id > 0) {
|
|
Packit |
15f964 |
g_signal_handler_disconnect (
|
|
Packit |
15f964 |
shell_view->priv->view_instance,
|
|
Packit |
15f964 |
shell_view->priv->view_instance_loaded_handler_id);
|
|
Packit |
15f964 |
shell_view->priv->view_instance_loaded_handler_id = 0;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_clear_object (&shell_view->priv->view_instance);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view->priv->view_instance = view_instance;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (view_instance != NULL) {
|
|
Packit |
15f964 |
gulong handler_id;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
handler_id = g_signal_connect_swapped (
|
|
Packit |
15f964 |
view_instance, "changed",
|
|
Packit |
15f964 |
G_CALLBACK (shell_view_update_view_id), shell_view);
|
|
Packit |
15f964 |
shell_view->priv->view_instance_changed_handler_id = handler_id;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
handler_id = g_signal_connect_swapped (
|
|
Packit |
15f964 |
view_instance, "loaded",
|
|
Packit |
15f964 |
G_CALLBACK (shell_view_update_view_id), shell_view);
|
|
Packit |
15f964 |
shell_view->priv->view_instance_loaded_handler_id = handler_id;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_object_notify (G_OBJECT (shell_view), "view-instance");
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_shell_window:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the #EShellWindow to which @shell_view belongs.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the #EShellWindow to which @shell_view belongs
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
EShellWindow *
|
|
Packit |
15f964 |
e_shell_view_get_shell_window (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return E_SHELL_WINDOW (shell_view->priv->shell_window);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_is_active:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns %TRUE if @shell_view is active. That is, if it's currently
|
|
Packit |
15f964 |
* visible in its #EShellWindow. An #EShellWindow can only display one
|
|
Packit |
15f964 |
* shell view at a time.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Technically this just checks the #GtkToggleAction:active property of
|
|
Packit |
15f964 |
* the shell view's switcher action. See e_shell_view_get_action().
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: %TRUE if @shell_view is active
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
gboolean
|
|
Packit |
15f964 |
e_shell_view_is_active (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GtkAction *action;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
action = e_shell_view_get_action (shell_view);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_page_num:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* This function is only interesting to #EShellWindow. It returns the
|
|
Packit |
15f964 |
* #GtkNotebook page number for @shell_view. The rest of the application
|
|
Packit |
15f964 |
* should have no need for this.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the notebook page number for @shell_view
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
gint
|
|
Packit |
15f964 |
e_shell_view_get_page_num (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), -1);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return shell_view->priv->page_num;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_set_page_num:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
* @page_num: a notebook page number
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* This function is only interesting to #EShellWindow. It sets the
|
|
Packit |
15f964 |
* #GtkNotebook page number for @shell_view. The rest of the application
|
|
Packit |
15f964 |
* must never call this because it could mess up shell view switching.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_set_page_num (EShellView *shell_view,
|
|
Packit |
15f964 |
gint page_num)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (shell_view->priv->page_num == page_num)
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view->priv->page_num = page_num;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_object_notify (G_OBJECT (shell_view), "page-num");
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_search_name:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns a newly-allocated string containing a suitable name for the
|
|
Packit |
15f964 |
* current search criteria. This is used as the suggested name in the
|
|
Packit |
15f964 |
* Save Search dialog. Free the returned string with g_free().
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: a name for the current search criteria
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
gchar *
|
|
Packit |
15f964 |
e_shell_view_get_search_name (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellViewClass *class;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
class = E_SHELL_VIEW_GET_CLASS (shell_view);
|
|
Packit |
15f964 |
g_return_val_if_fail (class != NULL, NULL);
|
|
Packit |
15f964 |
g_return_val_if_fail (class->get_search_name != NULL, NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return class->get_search_name (shell_view);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_search_rule:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the search criteria used to generate the current search results.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the current search criteria
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
EFilterRule *
|
|
Packit |
15f964 |
e_shell_view_get_search_rule (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return shell_view->priv->search_rule;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_searchbar:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the searchbar widget for @shell_view.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the searchbar widget for @shell_view
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
GtkWidget *
|
|
Packit |
15f964 |
e_shell_view_get_searchbar (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return shell_view->priv->searchbar;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_set_search_rule:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
* @search_rule: an #EFilterRule
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Sets the search criteria used to generate the current search results.
|
|
Packit |
15f964 |
* Note that this will not trigger a search. e_shell_view_execute_search()
|
|
Packit |
15f964 |
* must be called explicitly.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_set_search_rule (EShellView *shell_view,
|
|
Packit |
15f964 |
EFilterRule *search_rule)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (shell_view->priv->search_rule == search_rule)
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (search_rule != NULL) {
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_FILTER_RULE (search_rule));
|
|
Packit |
15f964 |
g_object_ref (search_rule);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (shell_view->priv->search_rule != NULL)
|
|
Packit |
15f964 |
g_object_unref (shell_view->priv->search_rule);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view->priv->search_rule = search_rule;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_object_notify (G_OBJECT (shell_view), "search-rule");
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_search_query:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Converts the #EShellView:search-rule property to a newly-allocated
|
|
Packit |
15f964 |
* S-expression string. If the #EShellView:search-rule property is %NULL
|
|
Packit |
15f964 |
* the function returns %NULL.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: an S-expression string, or %NULL
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
gchar *
|
|
Packit |
15f964 |
e_shell_view_get_search_query (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EFilterRule *rule;
|
|
Packit |
15f964 |
GString *string;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
rule = e_shell_view_get_search_rule (shell_view);
|
|
Packit |
15f964 |
if (rule == NULL)
|
|
Packit |
15f964 |
return NULL;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
string = g_string_sized_new (1024);
|
|
Packit |
15f964 |
e_filter_rule_build_code (rule, string);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return g_string_free (string, FALSE);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_size_group:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns a #GtkSizeGroup that #EShellContent and #EShellSidebar use
|
|
Packit |
15f964 |
* to keep the search bar and sidebar banner vertically aligned. The
|
|
Packit |
15f964 |
* rest of the application should have no need for this.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Note, this is only available during #EShellView construction.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: a #GtkSizeGroup for internal use
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
GtkSizeGroup *
|
|
Packit |
15f964 |
e_shell_view_get_size_group (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return shell_view->priv->size_group;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_shell_backend:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the corresponding #EShellBackend for @shell_view.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the corresponding #EShellBackend for @shell_view
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
EShellBackend *
|
|
Packit |
15f964 |
e_shell_view_get_shell_backend (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellViewClass *class;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
class = E_SHELL_VIEW_GET_CLASS (shell_view);
|
|
Packit |
15f964 |
g_return_val_if_fail (class != NULL, NULL);
|
|
Packit |
15f964 |
g_return_val_if_fail (class->shell_backend != NULL, NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return class->shell_backend;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_shell_content:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the #EShellContent instance for @shell_view.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* By default, #EShellView creates a plain #EShellContent during
|
|
Packit |
15f964 |
* initialization. But #EShellView subclasses can override the
|
|
Packit |
15f964 |
* <structfield>new_shell_content</structfield> factory method
|
|
Packit |
15f964 |
* in #EShellViewClass to create a custom #EShellContent.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the #EShellContent instance for @shell_view
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
EShellContent *
|
|
Packit |
15f964 |
e_shell_view_get_shell_content (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return E_SHELL_CONTENT (shell_view->priv->shell_content);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_shell_sidebar:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the #EShellSidebar instance for @shell_view.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* By default, #EShellView creates a plain #EShellSidebar during
|
|
Packit |
15f964 |
* initialization. But #EShellView subclasses can override the
|
|
Packit |
15f964 |
* <structfield>new_shell_sidebar</structfield> factory method
|
|
Packit |
15f964 |
* in #EShellViewClass to create a custom #EShellSidebar.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the #EShellSidebar instance for @shell_view
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
EShellSidebar *
|
|
Packit |
15f964 |
e_shell_view_get_shell_sidebar (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return E_SHELL_SIDEBAR (shell_view->priv->shell_sidebar);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_shell_taskbar:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the #EShellTaskbar instance for @shell_view.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* By default, #EShellView creates a plain #EShellTaskbar during
|
|
Packit |
15f964 |
* initialization. But #EShellView subclasses can override the
|
|
Packit |
15f964 |
* <structfield>new_shell_taskbar</structfield> factory method
|
|
Packit |
15f964 |
* in #EShellViewClass to create a custom #EShellTaskbar.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the #EShellTaskbar instance for @shell_view
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
EShellTaskbar *
|
|
Packit |
15f964 |
e_shell_view_get_shell_taskbar (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return E_SHELL_TASKBAR (shell_view->priv->shell_taskbar);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_get_state_key_file:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the #GKeyFile holding widget state data for @shell_view.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the #GKeyFile for @shell_view
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
GKeyFile *
|
|
Packit |
15f964 |
e_shell_view_get_state_key_file (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return shell_view->priv->state_key_file;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_set_state_dirty:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Marks the widget state data as modified (or "dirty") and schedules it
|
|
Packit |
15f964 |
* to be saved to disk after a short delay. The delay caps the frequency
|
|
Packit |
15f964 |
* of saving to disk.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_set_state_dirty (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
guint source_id;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* If a timeout is already scheduled, do nothing. */
|
|
Packit |
15f964 |
if (shell_view->priv->state_save_timeout_id > 0)
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
source_id = e_named_timeout_add_seconds (
|
|
Packit |
15f964 |
STATE_SAVE_TIMEOUT_SECONDS,
|
|
Packit |
15f964 |
shell_view_state_timeout_cb, shell_view);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view->priv->state_save_timeout_id = source_id;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_clear_search:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Emits the #EShellView::clear-search signal.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The default method sets the #EShellView:search-rule property to
|
|
Packit |
15f964 |
* %NULL and then emits the #EShellView::execute-search signal.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_clear_search (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_signal_emit (shell_view, signals[CLEAR_SEARCH], 0);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_custom_search:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
* @custom_rule: an #EFilterRule
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Emits the #EShellView::custom-search signal to indicate an advanced
|
|
Packit |
15f964 |
* or saved search is about to be executed.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The default method sets the #EShellView:search-rule property to
|
|
Packit |
15f964 |
* @custom_rule and then emits the #EShellView::execute-search signal.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_custom_search (EShellView *shell_view,
|
|
Packit |
15f964 |
EFilterRule *custom_rule)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_FILTER_RULE (custom_rule));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_signal_emit (shell_view, signals[CUSTOM_SEARCH], 0, custom_rule);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_execute_search:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Emits the #EShellView::execute-search signal.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* #EShellView subclasses should implement the
|
|
Packit |
15f964 |
* <structfield>execute_search</structfield> method in #EShellViewClass
|
|
Packit |
15f964 |
* to execute a search based on the current search conditions.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_execute_search (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (!e_shell_view_is_execute_search_blocked (shell_view))
|
|
Packit |
15f964 |
g_signal_emit (shell_view, signals[EXECUTE_SEARCH], 0);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_block_execute_search:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Blocks e_shell_view_execute_search() in a way it does nothing.
|
|
Packit |
15f964 |
* Pair function for this is e_shell_view_unblock_execute_search().
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_block_execute_search (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
g_return_if_fail (shell_view->priv->execute_search_blocked + 1 != 0);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view->priv->execute_search_blocked++;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_unblock_execute_search:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Unblocks previously blocked e_shell_view_execute_search() with
|
|
Packit |
15f964 |
* function e_shell_view_block_execute_search().
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_unblock_execute_search (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
g_return_if_fail (shell_view->priv->execute_search_blocked > 0);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view->priv->execute_search_blocked--;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_is_execute_search_blocked:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns whether e_shell_view_execute_search() is blocked as a result
|
|
Packit |
15f964 |
* of previous e_shell_view_block_execute_search() calls.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: %TRUE if e_shell_view_execute_search() is blocked
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
gboolean
|
|
Packit |
15f964 |
e_shell_view_is_execute_search_blocked (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return shell_view->priv->execute_search_blocked > 0;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_update_actions:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Emits the #EShellView::update-actions signal.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* #EShellView subclasses should implement the
|
|
Packit |
15f964 |
* <structfield>update_actions</structfield> method in #EShellViewClass
|
|
Packit |
15f964 |
* to update the various #GtkActions based on the current
|
|
Packit |
15f964 |
* #EShellSidebar and #EShellContent selections. The
|
|
Packit |
15f964 |
* #EShellView::update-actions signal is typically emitted just before
|
|
Packit |
15f964 |
* showing a popup menu or just after the user selects an item in the
|
|
Packit |
15f964 |
* shell view.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_update_actions (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (e_shell_view_is_active (shell_view)) {
|
|
Packit |
15f964 |
if (shell_view->priv->update_actions_idle_id > 0) {
|
|
Packit |
15f964 |
g_source_remove (shell_view->priv->update_actions_idle_id);
|
|
Packit |
15f964 |
shell_view->priv->update_actions_idle_id = 0;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_signal_emit (shell_view, signals[UPDATE_ACTIONS], 0);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gboolean
|
|
Packit |
15f964 |
shell_view_call_update_actions_idle (gpointer user_data)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellView *shell_view = user_data;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_view->priv->update_actions_idle_id = 0;
|
|
Packit |
15f964 |
e_shell_view_update_actions (shell_view);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return FALSE;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_update_actions_in_idle:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Schedules e_shell_view_update_actions() call on idle.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Since: 3.10
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_update_actions_in_idle (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (!e_shell_view_is_active (shell_view))
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (shell_view->priv->update_actions_idle_id == 0)
|
|
Packit |
15f964 |
shell_view->priv->update_actions_idle_id = g_idle_add (
|
|
Packit |
15f964 |
shell_view_call_update_actions_idle, shell_view);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
e_shell_view_popup_menu_deactivate (GtkMenu *popup_menu,
|
|
Packit |
15f964 |
gpointer user_data)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (GTK_IS_MENU (popup_menu));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_signal_handlers_disconnect_by_func (popup_menu, e_shell_view_popup_menu_deactivate, user_data);
|
|
Packit |
15f964 |
gtk_menu_detach (popup_menu);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_show_popup_menu:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
* @widget_path: path in the UI definition
|
|
Packit |
15f964 |
* @button_event: a #GdkEvent, or %NULL
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Displays a context-sensitive (or "popup") menu that is described in
|
|
Packit |
15f964 |
* the UI definition loaded into @shell_view's user interface
|
|
Packit |
15f964 |
* manager. The menu will be shown at the current mouse cursor position.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The #EShellView::update-actions signal is emitted just prior to
|
|
Packit |
15f964 |
* showing the menu to give @shell_view and any plugins that extend
|
|
Packit |
15f964 |
* @shell_view a chance to update the menu's actions.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the popup menu being displayed
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
GtkWidget *
|
|
Packit |
15f964 |
e_shell_view_show_popup_menu (EShellView *shell_view,
|
|
Packit |
15f964 |
const gchar *widget_path,
|
|
Packit |
15f964 |
GdkEvent *button_event)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellWindow *shell_window;
|
|
Packit |
15f964 |
GtkWidget *menu;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
e_shell_view_update_actions (shell_view);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_window = e_shell_view_get_shell_window (shell_view);
|
|
Packit |
15f964 |
menu = e_shell_window_get_managed_widget (shell_window, widget_path);
|
|
Packit |
15f964 |
g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (!gtk_menu_get_attach_widget (GTK_MENU (menu))) {
|
|
Packit |
15f964 |
gtk_menu_attach_to_widget (GTK_MENU (menu),
|
|
Packit |
15f964 |
GTK_WIDGET (shell_window),
|
|
Packit |
15f964 |
NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_signal_connect (menu, "deactivate", G_CALLBACK (e_shell_view_popup_menu_deactivate), NULL);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
gtk_menu_popup_at_pointer (GTK_MENU (menu), button_event);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return menu;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_write_source:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
* @source: an #ESource
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Submits the current contents of @source to the D-Bus service to be
|
|
Packit |
15f964 |
* written to disk and broadcast to other clients.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* This function does not block: @shell_view will dispatch the operation
|
|
Packit |
15f964 |
* asynchronously and handle any errors.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_write_source (EShellView *shell_view,
|
|
Packit |
15f964 |
ESource *source)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EActivity *activity;
|
|
Packit |
15f964 |
EAlertSink *alert_sink;
|
|
Packit |
15f964 |
EShellBackend *shell_backend;
|
|
Packit |
15f964 |
EShellContent *shell_content;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SOURCE (source));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_backend = e_shell_view_get_shell_backend (shell_view);
|
|
Packit |
15f964 |
shell_content = e_shell_view_get_shell_content (shell_view);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
alert_sink = E_ALERT_SINK (shell_content);
|
|
Packit |
15f964 |
activity = e_source_util_write (source, alert_sink);
|
|
Packit |
15f964 |
e_shell_backend_add_activity (shell_backend, activity);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_remove_source:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
* @source: the #ESource to be removed
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Requests the D-Bus service to delete the key files for @source and all of
|
|
Packit |
15f964 |
* its descendants and broadcast their removal to all clients.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* This function does not block: @shell_view will dispatch the operation
|
|
Packit |
15f964 |
* asynchronously and handle any errors.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_remove_source (EShellView *shell_view,
|
|
Packit |
15f964 |
ESource *source)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EActivity *activity;
|
|
Packit |
15f964 |
EAlertSink *alert_sink;
|
|
Packit |
15f964 |
EShellBackend *shell_backend;
|
|
Packit |
15f964 |
EShellContent *shell_content;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SOURCE (source));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_backend = e_shell_view_get_shell_backend (shell_view);
|
|
Packit |
15f964 |
shell_content = e_shell_view_get_shell_content (shell_view);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
alert_sink = E_ALERT_SINK (shell_content);
|
|
Packit |
15f964 |
activity = e_source_util_remove (source, alert_sink);
|
|
Packit |
15f964 |
e_shell_backend_add_activity (shell_backend, activity);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_remote_delete_source:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
* @source: an #ESource
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Deletes the resource represented by @source from a remote server.
|
|
Packit |
15f964 |
* The @source must be #ESource:remote-deletable. This will also delete
|
|
Packit |
15f964 |
* the key file for @source and broadcast its removal to all clients,
|
|
Packit |
15f964 |
* similar to e_shell_view_remove_source().
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* This function does not block; @shell_view will dispatch the operation
|
|
Packit |
15f964 |
* asynchronously and handle any errors.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_view_remote_delete_source (EShellView *shell_view,
|
|
Packit |
15f964 |
ESource *source)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EActivity *activity;
|
|
Packit |
15f964 |
EAlertSink *alert_sink;
|
|
Packit |
15f964 |
EShellBackend *shell_backend;
|
|
Packit |
15f964 |
EShellContent *shell_content;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SOURCE (source));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_backend = e_shell_view_get_shell_backend (shell_view);
|
|
Packit |
15f964 |
shell_content = e_shell_view_get_shell_content (shell_view);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
alert_sink = E_ALERT_SINK (shell_content);
|
|
Packit |
15f964 |
activity = e_source_util_remote_delete (source, alert_sink);
|
|
Packit |
15f964 |
e_shell_backend_add_activity (shell_backend, activity);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_view_submit_thread_job:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView instance
|
|
Packit |
15f964 |
* @description: user-friendly description of the job, to be shown in UI
|
|
Packit |
15f964 |
* @alert_ident: in case of an error, this alert identificator is used
|
|
Packit |
15f964 |
* for EAlert construction
|
|
Packit |
15f964 |
* @alert_arg_0: (allow-none): in case of an error, use this string as
|
|
Packit |
15f964 |
* the first argument to the EAlert construction; the second argument
|
|
Packit |
15f964 |
* is the actual error message; can be #NULL, in which case only
|
|
Packit |
15f964 |
* the error message is passed to the EAlert construction
|
|
Packit |
15f964 |
* @func: function to be run in a dedicated thread
|
|
Packit |
15f964 |
* @user_data: (allow-none): custom data passed into @func; can be #NULL
|
|
Packit |
15f964 |
* @free_user_data: (allow-none): function to be called on @user_data,
|
|
Packit |
15f964 |
* when the job is over; can be #NULL
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Runs the @func in a dedicated thread. Any error is propagated to UI.
|
|
Packit |
15f964 |
* The cancellable passed into the @func is a #CamelOperation, thus
|
|
Packit |
15f964 |
* the caller can overwrite progress and description message on it.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: (transfer full): Newly created #EActivity on success.
|
|
Packit |
15f964 |
* The caller is responsible to g_object_unref() it when done with it.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Note: The @free_user_data, if set, is called in the main thread.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Note: This function can be called only from the main thread.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
EActivity *
|
|
Packit |
15f964 |
e_shell_view_submit_thread_job (EShellView *shell_view,
|
|
Packit |
15f964 |
const gchar *description,
|
|
Packit |
15f964 |
const gchar *alert_ident,
|
|
Packit |
15f964 |
const gchar *alert_arg_0,
|
|
Packit |
15f964 |
EAlertSinkThreadJobFunc func,
|
|
Packit |
15f964 |
gpointer user_data,
|
|
Packit |
15f964 |
GDestroyNotify free_user_data)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellBackend *shell_backend;
|
|
Packit |
15f964 |
EShellContent *shell_content;
|
|
Packit |
15f964 |
EActivity *activity;
|
|
Packit |
15f964 |
EAlertSink *alert_sink;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
g_return_val_if_fail (description != NULL, NULL);
|
|
Packit |
15f964 |
g_return_val_if_fail (func != NULL, NULL);
|
|
Packit |
15f964 |
g_return_val_if_fail (g_thread_self () == shell_view->priv->main_thread, NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_backend = e_shell_view_get_shell_backend (shell_view);
|
|
Packit |
15f964 |
shell_content = e_shell_view_get_shell_content (shell_view);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
alert_sink = E_ALERT_SINK (shell_content);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
activity = e_alert_sink_submit_thread_job (
|
|
Packit |
15f964 |
alert_sink,
|
|
Packit |
15f964 |
description,
|
|
Packit |
15f964 |
alert_ident,
|
|
Packit |
15f964 |
alert_arg_0,
|
|
Packit |
15f964 |
func,
|
|
Packit |
15f964 |
user_data,
|
|
Packit |
15f964 |
free_user_data);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (activity)
|
|
Packit |
15f964 |
e_shell_backend_add_activity (shell_backend, activity);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return activity;
|
|
Packit |
15f964 |
}
|