4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
22 * SECTION: e-shell-view
23 * @short_description: views within the main window
24 * @include: shell/e-shell-view.h
27 #include "evolution-config.h"
29 #include "e-shell-view.h"
32 #include <glib/gi18n.h>
33 #include <libebackend/libebackend.h>
35 #include "e-shell-searchbar.h"
36 #include "e-shell-window-actions.h"
38 #define E_SHELL_VIEW_GET_PRIVATE(obj) \
39 (G_TYPE_INSTANCE_GET_PRIVATE \
40 ((obj), E_TYPE_SHELL_VIEW, EShellViewPrivate))
42 #define SIMPLE_SEARCHBAR_WIDTH 300
43 #define STATE_SAVE_TIMEOUT_SECONDS 3
45 struct _EShellViewPrivate
{
46 GThread
*main_thread
; /* not referenced */
48 gpointer shell_window
; /* weak pointer */
50 GKeyFile
*state_key_file
;
51 gpointer state_save_activity
; /* weak pointer */
52 guint state_save_timeout_id
;
54 GalViewInstance
*view_instance
;
55 gulong view_instance_changed_handler_id
;
56 gulong view_instance_loaded_handler_id
;
64 GtkSizeGroup
*size_group
;
65 GtkWidget
*shell_content
;
66 GtkWidget
*shell_sidebar
;
67 GtkWidget
*shell_taskbar
;
70 EFilterRule
*search_rule
;
71 guint execute_search_blocked
;
73 GtkWidget
*preferences_window
;
74 gulong preferences_hide_handler_id
;
76 guint update_actions_idle_id
;
105 static gpointer parent_class
;
106 static gulong signals
[LAST_SIGNAL
];
109 shell_view_init_search_context (EShellViewClass
*class)
111 EShellBackend
*shell_backend
;
112 ERuleContext
*search_context
;
113 const gchar
*config_dir
;
114 gchar
*system_filename
;
115 gchar
*user_filename
;
117 shell_backend
= class->shell_backend
;
119 /* Sanity check the class fields we need. */
120 g_return_if_fail (class->search_rules
!= NULL
);
121 g_return_if_fail (E_IS_SHELL_BACKEND (shell_backend
));
123 /* The basename for built-in searches is specified in the
124 * shell view class. All built-in search rules live in the
126 system_filename
= g_build_filename (
127 EVOLUTION_RULEDIR
, class->search_rules
, NULL
);
129 /* The filename for custom saved searches is always of
130 * the form "$(shell_backend_config_dir)/searches.xml". */
131 config_dir
= e_shell_backend_get_config_dir (shell_backend
);
132 user_filename
= g_build_filename (config_dir
, "searches.xml", NULL
);
134 /* Create the search context instance. Subclasses may override
135 * the GType so check that it's really an ERuleContext instance. */
136 search_context
= g_object_new (class->search_context_type
, NULL
);
137 g_return_if_fail (E_IS_RULE_CONTEXT (search_context
));
138 class->search_context
= search_context
;
140 e_rule_context_add_part_set (
141 search_context
, "partset", E_TYPE_FILTER_PART
,
142 e_rule_context_add_part
, e_rule_context_next_part
);
143 e_rule_context_add_rule_set (
144 search_context
, "ruleset", E_TYPE_FILTER_RULE
,
145 e_rule_context_add_rule
, e_rule_context_next_rule
);
146 e_rule_context_load (search_context
, system_filename
, user_filename
);
148 g_free (system_filename
);
149 g_free (user_filename
);
153 shell_view_init_view_collection (EShellViewClass
*class)
155 EShellBackend
*shell_backend
;
156 EShellBackendClass
*backend_class
;
157 const gchar
*base_directory
;
159 gchar
*system_directory
;
160 gchar
*user_directory
;
162 shell_backend
= class->shell_backend
;
163 g_return_if_fail (E_IS_SHELL_BACKEND (shell_backend
));
165 backend_class
= E_SHELL_BACKEND_GET_CLASS (shell_backend
);
166 g_return_if_fail (backend_class
!= NULL
);
168 name
= backend_class
->name
;
170 base_directory
= EVOLUTION_GALVIEWSDIR
;
171 system_directory
= g_build_filename (base_directory
, name
, NULL
);
173 base_directory
= e_shell_backend_get_config_dir (shell_backend
);
174 user_directory
= g_build_filename (base_directory
, "views", NULL
);
176 /* The view collection is never destroyed. */
177 class->view_collection
= gal_view_collection_new (
178 system_directory
, user_directory
);
180 g_free (system_directory
);
181 g_free (user_directory
);
185 shell_view_update_view_id (EShellView
*shell_view
,
186 GalViewInstance
*view_instance
)
190 view_id
= gal_view_instance_get_current_view_id (view_instance
);
191 e_shell_view_set_view_id (shell_view
, view_id
);
196 shell_view_load_state (EShellView
*shell_view
)
198 EShellBackend
*shell_backend
;
200 const gchar
*config_dir
;
202 GError
*error
= NULL
;
204 shell_backend
= e_shell_view_get_shell_backend (shell_view
);
205 config_dir
= e_shell_backend_get_config_dir (shell_backend
);
206 filename
= g_build_filename (config_dir
, "state.ini", NULL
);
208 /* XXX Should do this asynchronously. */
209 key_file
= shell_view
->priv
->state_key_file
;
210 g_key_file_load_from_file (key_file
, filename
, 0, &error
);
215 if (!g_error_matches (error
, G_FILE_ERROR
, G_FILE_ERROR_NOENT
))
216 g_warning ("%s", error
->message
);
218 g_error_free (error
);
225 EShellView
*shell_view
;
230 shell_view_save_state_done_cb (GFile
*file
,
231 GAsyncResult
*result
,
234 GError
*error
= NULL
;
236 e_file_replace_contents_finish (file
, result
, NULL
, &error
);
239 g_warning ("%s", error
->message
);
240 g_error_free (error
);
243 g_object_unref (data
->shell_view
);
244 g_free (data
->contents
);
245 g_slice_free (SaveStateData
, data
);
249 shell_view_save_state (EShellView
*shell_view
,
250 gboolean immediately
)
252 EShellBackend
*shell_backend
;
257 const gchar
*config_dir
;
261 shell_backend
= e_shell_view_get_shell_backend (shell_view
);
262 config_dir
= e_shell_backend_get_config_dir (shell_backend
);
263 key_file
= shell_view
->priv
->state_key_file
;
265 contents
= g_key_file_to_data (key_file
, NULL
, NULL
);
266 g_return_val_if_fail (contents
!= NULL
, NULL
);
268 path
= g_build_filename (config_dir
, "state.ini", NULL
);
270 g_file_set_contents (path
, contents
, -1, NULL
);
278 file
= g_file_new_for_path (path
);
281 /* GIO does not copy the contents string, so we need to keep
282 * it in memory until saving is complete. We reference the
283 * shell view to keep it from being finalized while saving. */
284 data
= g_slice_new (SaveStateData
);
285 data
->shell_view
= g_object_ref (shell_view
);
286 data
->contents
= contents
;
288 /* The returned activity is a borrowed reference. */
289 activity
= e_file_replace_contents_async (
290 file
, contents
, strlen (contents
), NULL
,
291 FALSE
, G_FILE_CREATE_PRIVATE
, (GAsyncReadyCallback
)
292 shell_view_save_state_done_cb
, data
);
294 e_activity_set_text (
295 activity
, (_("Saving user interface state")));
297 e_shell_backend_add_activity (shell_backend
, activity
);
299 g_object_unref (file
);
305 shell_view_state_timeout_cb (gpointer user_data
)
307 EShellView
*shell_view
;
310 shell_view
= E_SHELL_VIEW (user_data
);
312 /* If a save is still in progress, check back later. */
313 if (shell_view
->priv
->state_save_activity
!= NULL
)
316 activity
= shell_view_save_state (shell_view
, FALSE
);
318 /* Set up a weak pointer that gets set to NULL when the
319 * activity finishes. This will tell us if we're still
320 * busy saving state data to disk on the next timeout. */
321 shell_view
->priv
->state_save_activity
= activity
;
322 g_object_add_weak_pointer (
323 G_OBJECT (shell_view
->priv
->state_save_activity
),
324 &shell_view
->priv
->state_save_activity
);
326 shell_view
->priv
->state_save_timeout_id
= 0;
332 shell_view_emit_toggled (EShellView
*shell_view
)
334 g_signal_emit (shell_view
, signals
[TOGGLED
], 0);
338 shell_view_set_action (EShellView
*shell_view
,
343 g_return_if_fail (shell_view
->priv
->action
== NULL
);
345 shell_view
->priv
->action
= g_object_ref (action
);
347 g_object_get (action
, "label", &label
, NULL
);
348 e_shell_view_set_title (shell_view
, label
);
351 g_signal_connect_swapped (
353 G_CALLBACK (shell_view_emit_toggled
), shell_view
);
357 shell_view_set_shell_window (EShellView
*shell_view
,
358 EShellWindow
*shell_window
)
360 g_return_if_fail (E_IS_SHELL_WINDOW (shell_window
));
361 g_return_if_fail (shell_view
->priv
->shell_window
== NULL
);
363 shell_view
->priv
->shell_window
= shell_window
;
365 g_object_add_weak_pointer (
366 G_OBJECT (shell_window
),
367 &shell_view
->priv
->shell_window
);
371 shell_view_set_property (GObject
*object
,
376 switch (property_id
) {
378 shell_view_set_action (
379 E_SHELL_VIEW (object
),
380 g_value_get_object (value
));
384 e_shell_view_set_page_num (
385 E_SHELL_VIEW (object
),
386 g_value_get_int (value
));
389 case PROP_SEARCH_RULE
:
390 e_shell_view_set_search_rule (
391 E_SHELL_VIEW (object
),
392 g_value_get_object (value
));
395 case PROP_SHELL_WINDOW
:
396 shell_view_set_shell_window (
397 E_SHELL_VIEW (object
),
398 g_value_get_object (value
));
402 e_shell_view_set_title (
403 E_SHELL_VIEW (object
),
404 g_value_get_string (value
));
408 e_shell_view_set_view_id (
409 E_SHELL_VIEW (object
),
410 g_value_get_string (value
));
413 case PROP_VIEW_INSTANCE
:
414 e_shell_view_set_view_instance (
415 E_SHELL_VIEW (object
),
416 g_value_get_object (value
));
420 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, property_id
, pspec
);
424 shell_view_get_property (GObject
*object
,
429 switch (property_id
) {
432 value
, e_shell_view_get_action (
433 E_SHELL_VIEW (object
)));
438 value
, e_shell_view_get_page_num (
439 E_SHELL_VIEW (object
)));
444 value
, e_shell_view_get_searchbar (
445 E_SHELL_VIEW (object
)));
448 case PROP_SEARCH_RULE
:
450 value
, e_shell_view_get_search_rule (
451 E_SHELL_VIEW (object
)));
454 case PROP_SHELL_BACKEND
:
456 value
, e_shell_view_get_shell_backend (
457 E_SHELL_VIEW (object
)));
460 case PROP_SHELL_CONTENT
:
462 value
, e_shell_view_get_shell_content (
463 E_SHELL_VIEW (object
)));
466 case PROP_SHELL_SIDEBAR
:
468 value
, e_shell_view_get_shell_sidebar (
469 E_SHELL_VIEW (object
)));
472 case PROP_SHELL_TASKBAR
:
474 value
, e_shell_view_get_shell_taskbar (
475 E_SHELL_VIEW (object
)));
478 case PROP_SHELL_WINDOW
:
480 value
, e_shell_view_get_shell_window (
481 E_SHELL_VIEW (object
)));
484 case PROP_STATE_KEY_FILE
:
485 g_value_set_pointer (
486 value
, e_shell_view_get_state_key_file (
487 E_SHELL_VIEW (object
)));
492 value
, e_shell_view_get_title (
493 E_SHELL_VIEW (object
)));
498 value
, e_shell_view_get_view_id (
499 E_SHELL_VIEW (object
)));
502 case PROP_VIEW_INSTANCE
:
504 value
, e_shell_view_get_view_instance (
505 E_SHELL_VIEW (object
)));
509 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, property_id
, pspec
);
513 shell_view_dispose (GObject
*object
)
515 EShellViewPrivate
*priv
;
517 priv
= E_SHELL_VIEW_GET_PRIVATE (object
);
519 /* Expedite any pending state saves. */
520 if (priv
->state_save_timeout_id
> 0) {
521 g_source_remove (priv
->state_save_timeout_id
);
522 priv
->state_save_timeout_id
= 0;
523 if (priv
->state_save_activity
== NULL
)
524 shell_view_save_state (E_SHELL_VIEW (object
), TRUE
);
527 if (priv
->update_actions_idle_id
> 0) {
528 g_source_remove (priv
->update_actions_idle_id
);
529 priv
->update_actions_idle_id
= 0;
532 if (priv
->state_save_activity
!= NULL
) {
533 g_object_remove_weak_pointer (
534 G_OBJECT (priv
->state_save_activity
),
535 &priv
->state_save_activity
);
536 priv
->state_save_activity
= NULL
;
539 if (priv
->view_instance_changed_handler_id
> 0) {
540 g_signal_handler_disconnect (
542 priv
->view_instance_changed_handler_id
);
543 priv
->view_instance_changed_handler_id
= 0;
546 if (priv
->view_instance_loaded_handler_id
> 0) {
547 g_signal_handler_disconnect (
549 priv
->view_instance_loaded_handler_id
);
550 priv
->view_instance_loaded_handler_id
= 0;
553 if (priv
->preferences_window
!= NULL
) {
554 g_signal_handler_disconnect (
555 priv
->preferences_window
,
556 priv
->preferences_hide_handler_id
);
557 priv
->preferences_hide_handler_id
= 0;
560 if (priv
->shell_window
!= NULL
) {
561 g_object_remove_weak_pointer (
562 G_OBJECT (priv
->shell_window
), &priv
->shell_window
);
563 priv
->shell_window
= NULL
;
566 g_clear_object (&priv
->view_instance
);
567 g_clear_object (&priv
->shell_content
);
568 g_clear_object (&priv
->shell_sidebar
);
569 g_clear_object (&priv
->shell_taskbar
);
570 g_clear_object (&priv
->searchbar
);
571 g_clear_object (&priv
->search_rule
);
572 g_clear_object (&priv
->preferences_window
);
574 /* Chain up to parent's dispose() method. */
575 G_OBJECT_CLASS (parent_class
)->dispose (object
);
579 shell_view_finalize (GObject
*object
)
581 EShellViewPrivate
*priv
;
583 priv
= E_SHELL_VIEW_GET_PRIVATE (object
);
585 g_key_file_free (priv
->state_key_file
);
587 g_free (priv
->title
);
588 g_free (priv
->view_id
);
590 /* Chain up to parent's finalize() method. */
591 G_OBJECT_CLASS (parent_class
)->finalize (object
);
595 shell_view_constructed (GObject
*object
)
598 EShellView
*shell_view
;
599 EShellBackend
*shell_backend
;
600 EShellViewClass
*shell_view_class
;
604 shell_view
= E_SHELL_VIEW (object
);
605 shell_view_class
= E_SHELL_VIEW_GET_CLASS (shell_view
);
606 g_return_if_fail (shell_view_class
!= NULL
);
608 shell_backend
= e_shell_view_get_shell_backend (shell_view
);
609 shell
= e_shell_backend_get_shell (shell_backend
);
611 shell_view_load_state (shell_view
);
613 /* Invoke factory methods. */
615 /* Create the taskbar widget first so the content and
616 * sidebar widgets can access it during construction. */
617 widget
= shell_view_class
->new_shell_taskbar (shell_view
);
618 shell_view
->priv
->shell_taskbar
= g_object_ref_sink (widget
);
619 gtk_widget_show (widget
);
621 widget
= shell_view_class
->new_shell_content (shell_view
);
622 shell_view
->priv
->shell_content
= g_object_ref_sink (widget
);
623 gtk_widget_show (widget
);
625 widget
= shell_view_class
->new_shell_sidebar (shell_view
);
626 shell_view
->priv
->shell_sidebar
= g_object_ref_sink (widget
);
627 gtk_widget_show (widget
);
629 if (shell_view_class
->construct_searchbar
!= NULL
) {
630 widget
= shell_view_class
->construct_searchbar (shell_view
);
631 shell_view
->priv
->searchbar
= g_object_ref_sink (widget
);
634 /* Size group should be safe to unreference now. */
635 g_object_unref (shell_view
->priv
->size_group
);
636 shell_view
->priv
->size_group
= NULL
;
638 /* Update actions whenever the Preferences window is closed. */
639 widget
= e_shell_get_preferences_window (shell
);
640 shell_view
->priv
->preferences_window
= g_object_ref (widget
);
641 handler_id
= g_signal_connect_swapped (
642 shell_view
->priv
->preferences_window
, "hide",
643 G_CALLBACK (e_shell_view_update_actions_in_idle
), shell_view
);
644 shell_view
->priv
->preferences_hide_handler_id
= handler_id
;
646 e_extensible_load_extensions (E_EXTENSIBLE (object
));
648 /* Chain up to parent's constructed() method. */
649 G_OBJECT_CLASS (parent_class
)->constructed (object
);
653 shell_view_construct_searchbar (EShellView
*shell_view
)
655 EShellContent
*shell_content
;
656 EShellViewClass
*shell_view_class
;
659 shell_content
= e_shell_view_get_shell_content (shell_view
);
661 shell_view_class
= E_SHELL_VIEW_GET_CLASS (shell_view
);
662 g_return_val_if_fail (shell_view_class
!= NULL
, NULL
);
664 widget
= shell_view_class
->new_shell_searchbar (shell_view
);
665 e_shell_content_set_searchbar (shell_content
, widget
);
666 gtk_widget_show (widget
);
672 shell_view_get_search_name (EShellView
*shell_view
)
674 EShellSearchbar
*searchbar
;
676 const gchar
*search_text
;
678 rule
= e_shell_view_get_search_rule (shell_view
);
679 g_return_val_if_fail (E_IS_FILTER_RULE (rule
), NULL
);
681 searchbar
= E_SHELL_SEARCHBAR (shell_view
->priv
->searchbar
);
682 search_text
= e_shell_searchbar_get_search_text (searchbar
);
684 if (search_text
== NULL
|| *search_text
== '\0')
687 return g_strdup_printf ("%s %s", rule
->name
, search_text
);
691 shell_view_toggled (EShellView
*shell_view
)
693 EShellViewPrivate
*priv
= shell_view
->priv
;
694 EShellViewClass
*shell_view_class
;
695 EShellWindow
*shell_window
;
696 GtkUIManager
*ui_manager
;
697 const gchar
*basename
, *id
;
698 gboolean view_is_active
;
700 shell_view_class
= E_SHELL_VIEW_GET_CLASS (shell_view
);
701 g_return_if_fail (shell_view_class
!= NULL
);
703 shell_window
= e_shell_view_get_shell_window (shell_view
);
704 ui_manager
= e_shell_window_get_ui_manager (shell_window
);
705 view_is_active
= e_shell_view_is_active (shell_view
);
706 basename
= shell_view_class
->ui_definition
;
707 id
= shell_view_class
->ui_manager_id
;
709 if (view_is_active
&& priv
->merge_id
== 0) {
710 priv
->merge_id
= e_load_ui_manager_definition (
711 ui_manager
, basename
);
712 e_plugin_ui_enable_manager (ui_manager
, id
);
713 } else if (!view_is_active
&& priv
->merge_id
!= 0) {
714 e_plugin_ui_disable_manager (ui_manager
, id
);
715 gtk_ui_manager_remove_ui (ui_manager
, priv
->merge_id
);
716 gtk_ui_manager_ensure_update (ui_manager
);
720 gtk_ui_manager_ensure_update (ui_manager
);
724 shell_view_clear_search (EShellView
*shell_view
)
726 e_shell_view_set_search_rule (shell_view
, NULL
);
727 e_shell_view_execute_search (shell_view
);
731 shell_view_custom_search (EShellView
*shell_view
,
732 EFilterRule
*custom_rule
)
734 e_shell_view_set_search_rule (shell_view
, custom_rule
);
735 e_shell_view_execute_search (shell_view
);
739 shell_view_update_actions (EShellView
*shell_view
)
741 EShellWindow
*shell_window
;
742 EFocusTracker
*focus_tracker
;
744 GtkActionGroup
*action_group
;
746 g_return_if_fail (e_shell_view_is_active (shell_view
));
748 shell_window
= e_shell_view_get_shell_window (shell_view
);
749 focus_tracker
= e_shell_window_get_focus_tracker (shell_window
);
751 e_focus_tracker_update_actions (focus_tracker
);
753 action_group
= E_SHELL_WINDOW_ACTION_GROUP_CUSTOM_RULES (shell_window
);
754 gtk_action_group_set_sensitive (action_group
, TRUE
);
756 action
= E_SHELL_WINDOW_ACTION_SEARCH_ADVANCED (shell_window
);
757 gtk_action_set_sensitive (action
, TRUE
);
761 e_shell_view_class_init (EShellViewClass
*class)
763 GObjectClass
*object_class
;
765 parent_class
= g_type_class_peek_parent (class);
766 g_type_class_add_private (class, sizeof (EShellViewPrivate
));
768 object_class
= G_OBJECT_CLASS (class);
769 object_class
->set_property
= shell_view_set_property
;
770 object_class
->get_property
= shell_view_get_property
;
771 object_class
->dispose
= shell_view_dispose
;
772 object_class
->finalize
= shell_view_finalize
;
773 object_class
->constructed
= shell_view_constructed
;
775 class->search_context_type
= E_TYPE_RULE_CONTEXT
;
777 /* Default Factories */
778 class->new_shell_content
= e_shell_content_new
;
779 class->new_shell_sidebar
= e_shell_sidebar_new
;
780 class->new_shell_taskbar
= e_shell_taskbar_new
;
781 class->new_shell_searchbar
= e_shell_searchbar_new
;
783 class->construct_searchbar
= shell_view_construct_searchbar
;
784 class->get_search_name
= shell_view_get_search_name
;
786 class->toggled
= shell_view_toggled
;
787 class->clear_search
= shell_view_clear_search
;
788 class->custom_search
= shell_view_custom_search
;
789 class->update_actions
= shell_view_update_actions
;
794 * The #GtkRadioAction registered with #EShellSwitcher.
796 g_object_class_install_property (
799 g_param_spec_object (
802 "The switcher action for this shell view",
803 GTK_TYPE_RADIO_ACTION
,
805 G_PARAM_CONSTRUCT_ONLY
|
806 G_PARAM_STATIC_STRINGS
));
809 * EShellView:page-num
811 * The #GtkNotebook page number of the shell view.
813 g_object_class_install_property (
819 "The notebook page number of the shell view",
824 G_PARAM_STATIC_STRINGS
));
827 * EShellView:search-rule
829 * Criteria for the current search results.
831 g_object_class_install_property (
834 g_param_spec_object (
837 "Criteria for the current search results",
840 G_PARAM_STATIC_STRINGS
));
843 * EShellView:shell-backend
845 * The #EShellBackend for this shell view.
847 g_object_class_install_property (
850 g_param_spec_object (
853 "The EShellBackend for this shell view",
854 E_TYPE_SHELL_BACKEND
,
856 G_PARAM_STATIC_STRINGS
));
859 * EShellView:shell-content
861 * The content widget appears in an #EShellWindow<!-- -->'s
864 g_object_class_install_property (
867 g_param_spec_object (
869 "Shell Content Widget",
870 "The content widget appears in "
871 "a shell window's right pane",
872 E_TYPE_SHELL_CONTENT
,
874 G_PARAM_STATIC_STRINGS
));
877 * EShellView:shell-sidebar
879 * The sidebar widget appears in an #EShellWindow<!-- -->'s
882 g_object_class_install_property (
885 g_param_spec_object (
887 "Shell Sidebar Widget",
888 "The sidebar widget appears in "
889 "a shell window's left pane",
890 E_TYPE_SHELL_SIDEBAR
,
892 G_PARAM_STATIC_STRINGS
));
895 * EShellView:shell-taskbar
897 * The taskbar widget appears at the bottom of an #EShellWindow.
899 g_object_class_install_property (
902 g_param_spec_object (
904 "Shell Taskbar Widget",
905 "The taskbar widget appears at "
906 "the bottom of a shell window",
907 E_TYPE_SHELL_TASKBAR
,
909 G_PARAM_STATIC_STRINGS
));
912 * EShellView:shell-window
914 * The #EShellWindow to which the shell view belongs.
916 g_object_class_install_property (
919 g_param_spec_object (
922 "The window to which the shell view belongs",
925 G_PARAM_CONSTRUCT_ONLY
|
926 G_PARAM_STATIC_STRINGS
));
929 * EShellView:state-key-file
931 * The #GKeyFile holding widget state data.
933 g_object_class_install_property (
936 g_param_spec_pointer (
939 "The key file holding widget state data",
941 G_PARAM_STATIC_STRINGS
));
946 * The title of the shell view. Also serves as the #EShellWindow
947 * title when the shell view is active.
949 g_object_class_install_property (
952 g_param_spec_string (
955 "The title of the shell view",
958 G_PARAM_STATIC_STRINGS
));
963 * The current #GalView ID.
965 g_object_class_install_property (
968 g_param_spec_string (
971 "The current GAL view ID",
974 G_PARAM_STATIC_STRINGS
));
977 * EShellView:view-instance:
979 * The current #GalViewInstance.
981 g_object_class_install_property (
984 g_param_spec_object (
987 "The current view instance",
988 GAL_TYPE_VIEW_INSTANCE
,
992 * EShellView::toggled
993 * @shell_view: the #EShellView which emitted the signal
995 * Emitted when @shell_view is activated or deactivated.
996 * Use e_shell_view_is_active() to find out which event has
997 * occurred. The shell view being deactivated is always
998 * notified before the shell view being activated.
1000 * By default, #EShellView adds the UI definition file
1001 * given in the <structfield>ui_definition</structfield>
1002 * field of #EShellViewClass on activation, and removes the
1003 * UI definition on deactivation.
1005 signals
[TOGGLED
] = g_signal_new (
1007 G_OBJECT_CLASS_TYPE (object_class
),
1009 G_STRUCT_OFFSET (EShellViewClass
, toggled
),
1011 g_cclosure_marshal_VOID__VOID
,
1015 * EShellView::clear-search
1016 * @shell_view: the #EShellView which emitted the signal
1018 * Clears the current search. See e_shell_view_clear_search() for
1021 signals
[CLEAR_SEARCH
] = g_signal_new (
1023 G_OBJECT_CLASS_TYPE (object_class
),
1025 G_STRUCT_OFFSET (EShellViewClass
, clear_search
),
1027 g_cclosure_marshal_VOID__VOID
,
1031 * EShellView::custom-search
1032 * @shell_view: the #EShellView which emitted the signal
1033 * @custom_rule: criteria for the custom search
1035 * Emitted when an advanced or saved search is about to be executed.
1036 * See e_shell_view_custom_search() for details.
1038 signals
[CUSTOM_SEARCH
] = g_signal_new (
1040 G_OBJECT_CLASS_TYPE (object_class
),
1042 G_STRUCT_OFFSET (EShellViewClass
, custom_search
),
1044 g_cclosure_marshal_VOID__OBJECT
,
1046 E_TYPE_FILTER_RULE
);
1049 * EShellView::execute-search
1050 * @shell_view: the #EShellView which emitted the signal
1052 * #EShellView subclasses should override the
1053 * <structfield>execute_search</structfield> method in
1054 * #EShellViewClass to execute the current search conditions.
1056 signals
[EXECUTE_SEARCH
] = g_signal_new (
1058 G_OBJECT_CLASS_TYPE (object_class
),
1060 G_STRUCT_OFFSET (EShellViewClass
, execute_search
),
1062 g_cclosure_marshal_VOID__VOID
,
1066 * EShellView::update-actions
1067 * @shell_view: the #EShellView which emitted the signal
1069 * #EShellView subclasses should override the
1070 * <structfield>update_actions</structfield> method in
1071 * #EShellViewClass to update sensitivities, labels, or any
1072 * other aspect of the #GtkAction<!-- -->s they have registered.
1074 * Plugins can also connect to this signal to be notified
1075 * when to update their own #GtkAction<!-- -->s.
1077 signals
[UPDATE_ACTIONS
] = g_signal_new (
1079 G_OBJECT_CLASS_TYPE (object_class
),
1081 G_STRUCT_OFFSET (EShellViewClass
, update_actions
),
1083 g_cclosure_marshal_VOID__VOID
,
1088 e_shell_view_init (EShellView
*shell_view
,
1089 EShellViewClass
*class)
1091 GtkSizeGroup
*size_group
;
1093 /* XXX Our use of GInstanceInitFunc's 'class' parameter
1094 * prevents us from using G_DEFINE_ABSTRACT_TYPE. */
1096 if (class->search_context
== NULL
)
1097 shell_view_init_search_context (class);
1099 if (class->view_collection
== NULL
)
1100 shell_view_init_view_collection (class);
1102 size_group
= gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL
);
1104 shell_view
->priv
= E_SHELL_VIEW_GET_PRIVATE (shell_view
);
1105 shell_view
->priv
->main_thread
= g_thread_self ();
1106 shell_view
->priv
->state_key_file
= g_key_file_new ();
1107 shell_view
->priv
->size_group
= size_group
;
1111 e_shell_view_get_type (void)
1113 static GType type
= 0;
1115 if (G_UNLIKELY (type
== 0)) {
1116 const GTypeInfo type_info
= {
1117 sizeof (EShellViewClass
),
1118 (GBaseInitFunc
) NULL
,
1119 (GBaseFinalizeFunc
) NULL
,
1120 (GClassInitFunc
) e_shell_view_class_init
,
1121 (GClassFinalizeFunc
) NULL
,
1122 NULL
, /* class_data */
1123 sizeof (EShellView
),
1124 0, /* n_preallocs */
1125 (GInstanceInitFunc
) e_shell_view_init
,
1126 NULL
/* value_table */
1129 const GInterfaceInfo extensible_info
= {
1130 (GInterfaceInitFunc
) NULL
,
1131 (GInterfaceFinalizeFunc
) NULL
,
1132 NULL
/* interface_data */
1135 type
= g_type_register_static (
1136 G_TYPE_OBJECT
, "EShellView",
1137 &type_info
, G_TYPE_FLAG_ABSTRACT
);
1139 g_type_add_interface_static (
1140 type
, E_TYPE_EXTENSIBLE
, &extensible_info
);
1147 * e_shell_view_get_name:
1148 * @shell_view: an #EShellView
1150 * Returns the view name for @shell_view, which is also the name of
1151 * the corresponding #EShellBackend (see the <structfield>name</structfield>
1152 * field in #EShellBackendInfo).
1154 * Returns: the view name for @shell_view
1157 e_shell_view_get_name (EShellView
*shell_view
)
1161 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1163 action
= e_shell_view_get_action (shell_view
);
1165 /* Switcher actions have a secret "view-name" data value.
1166 * This gets set in e_shell_window_create_switcher_actions(). */
1167 return g_object_get_data (G_OBJECT (action
), "view-name");
1171 * e_shell_view_get_action:
1172 * @shell_view: an #EShellView
1174 * Returns the switcher action for @shell_view.
1176 * An #EShellWindow creates a #GtkRadioAction for each registered subclass
1177 * of #EShellView. This action gets passed to the #EShellSwitcher, which
1178 * displays a button that proxies the action. The icon at the top of the
1179 * sidebar also proxies the action. When @shell_view is active, the
1180 * action's icon becomes the #EShellWindow icon.
1182 * Returns: the switcher action for @shell_view
1185 e_shell_view_get_action (EShellView
*shell_view
)
1187 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1189 return shell_view
->priv
->action
;
1193 * e_shell_view_get_title:
1194 * @shell_view: an #EShellView
1196 * Returns the title for @shell_view. When @shell_view is active, the
1197 * shell view's title becomes the #EShellWindow title.
1199 * Returns: the title for @shell_view
1202 e_shell_view_get_title (EShellView
*shell_view
)
1204 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1206 return shell_view
->priv
->title
;
1210 * e_shell_view_set_title:
1211 * @shell_view: an #EShellView
1212 * @title: a title for @shell_view
1214 * Sets the title for @shell_view. When @shell_view is active, the
1215 * shell view's title becomes the #EShellWindow title.
1218 e_shell_view_set_title (EShellView
*shell_view
,
1221 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
1224 EShellViewClass
*klass
= E_SHELL_VIEW_GET_CLASS (shell_view
);
1225 g_return_if_fail (klass
!= NULL
);
1227 title
= klass
->label
;
1230 if (g_strcmp0 (shell_view
->priv
->title
, title
) == 0)
1233 g_free (shell_view
->priv
->title
);
1234 shell_view
->priv
->title
= g_strdup (title
);
1236 g_object_notify (G_OBJECT (shell_view
), "title");
1240 * e_shell_view_get_view_id:
1241 * @shell_view: an #EShellView
1243 * Returns the ID of the currently selected #GalView.
1245 * #EShellView subclasses are responsible for keeping this property in
1246 * sync with their #GalViewInstance. #EShellView itself just provides
1247 * a place to store the view ID, and emits a #GObject::notify signal
1248 * when the property changes.
1250 * Returns: the ID of the current #GalView
1253 e_shell_view_get_view_id (EShellView
*shell_view
)
1255 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1257 return shell_view
->priv
->view_id
;
1261 * e_shell_view_set_view_id:
1262 * @shell_view: an #EShellView
1263 * @view_id: a #GalView ID
1265 * Selects the #GalView whose ID is equal to @view_id.
1267 * #EShellView subclasses are responsible for keeping this property in
1268 * sync with their #GalViewInstance. #EShellView itself just provides
1269 * a place to store the view ID, and emits a #GObject::notify signal
1270 * when the property changes.
1273 e_shell_view_set_view_id (EShellView
*shell_view
,
1274 const gchar
*view_id
)
1276 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
1278 if (g_strcmp0 (shell_view
->priv
->view_id
, view_id
) == 0)
1281 g_free (shell_view
->priv
->view_id
);
1282 shell_view
->priv
->view_id
= g_strdup (view_id
);
1284 g_object_notify (G_OBJECT (shell_view
), "view-id");
1288 * e_shell_view_new_view_instance:
1289 * @shell_view: an #EShellView
1290 * @instance_id: a name for the #GalViewInstance
1292 * Convenience function creates a new #GalViewInstance from the
1293 * #GalViewCollection in @shell_view's #EShellViewClass.
1295 * Returns: a new #GalViewInstance
1298 e_shell_view_new_view_instance (EShellView
*shell_view
,
1299 const gchar
*instance_id
)
1301 EShellViewClass
*class;
1302 GalViewCollection
*view_collection
;
1304 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1306 class = E_SHELL_VIEW_GET_CLASS (shell_view
);
1307 g_return_val_if_fail (class != NULL
, NULL
);
1309 view_collection
= class->view_collection
;
1311 return gal_view_instance_new (view_collection
, instance_id
);
1315 * e_shell_view_get_view_instance:
1316 * @shell_view: an #EShellView
1318 * Returns the current #GalViewInstance for @shell_view.
1320 * #EShellView subclasses are responsible for creating and configuring a
1321 * #GalViewInstance and handing it off so the @shell_view can monitor it
1322 * and perform common actions on it.
1324 * Returns: a #GalViewInstance, or %NULL
1327 e_shell_view_get_view_instance (EShellView
*shell_view
)
1329 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1331 return shell_view
->priv
->view_instance
;
1335 * e_shell_view_set_view_instance:
1336 * @shell_view: an #EShellView
1337 * @view_instance: a #GalViewInstance, or %NULL
1339 * Sets the current #GalViewInstance for @shell_view.
1341 * #EShellView subclasses are responsible for creating and configuring a
1342 * #GalViewInstance and handing it off so the @shell_view can monitor it
1343 * and perform common actions on it.
1346 e_shell_view_set_view_instance (EShellView
*shell_view
,
1347 GalViewInstance
*view_instance
)
1349 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
1351 if (view_instance
!= NULL
) {
1352 g_return_if_fail (GAL_IS_VIEW_INSTANCE (view_instance
));
1353 g_object_ref (view_instance
);
1356 if (shell_view
->priv
->view_instance_changed_handler_id
> 0) {
1357 g_signal_handler_disconnect (
1358 shell_view
->priv
->view_instance
,
1359 shell_view
->priv
->view_instance_changed_handler_id
);
1360 shell_view
->priv
->view_instance_changed_handler_id
= 0;
1363 if (shell_view
->priv
->view_instance_loaded_handler_id
> 0) {
1364 g_signal_handler_disconnect (
1365 shell_view
->priv
->view_instance
,
1366 shell_view
->priv
->view_instance_loaded_handler_id
);
1367 shell_view
->priv
->view_instance_loaded_handler_id
= 0;
1370 g_clear_object (&shell_view
->priv
->view_instance
);
1372 shell_view
->priv
->view_instance
= view_instance
;
1374 if (view_instance
!= NULL
) {
1377 handler_id
= g_signal_connect_swapped (
1378 view_instance
, "changed",
1379 G_CALLBACK (shell_view_update_view_id
), shell_view
);
1380 shell_view
->priv
->view_instance_changed_handler_id
= handler_id
;
1382 handler_id
= g_signal_connect_swapped (
1383 view_instance
, "loaded",
1384 G_CALLBACK (shell_view_update_view_id
), shell_view
);
1385 shell_view
->priv
->view_instance_loaded_handler_id
= handler_id
;
1388 g_object_notify (G_OBJECT (shell_view
), "view-instance");
1392 * e_shell_view_get_shell_window:
1393 * @shell_view: an #EShellView
1395 * Returns the #EShellWindow to which @shell_view belongs.
1397 * Returns: the #EShellWindow to which @shell_view belongs
1400 e_shell_view_get_shell_window (EShellView
*shell_view
)
1402 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1404 return E_SHELL_WINDOW (shell_view
->priv
->shell_window
);
1408 * e_shell_view_is_active:
1409 * @shell_view: an #EShellView
1411 * Returns %TRUE if @shell_view is active. That is, if it's currently
1412 * visible in its #EShellWindow. An #EShellWindow can only display one
1413 * shell view at a time.
1415 * Technically this just checks the #GtkToggleAction:active property of
1416 * the shell view's switcher action. See e_shell_view_get_action().
1418 * Returns: %TRUE if @shell_view is active
1421 e_shell_view_is_active (EShellView
*shell_view
)
1425 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), FALSE
);
1427 action
= e_shell_view_get_action (shell_view
);
1429 return gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action
));
1433 * e_shell_view_get_page_num:
1434 * @shell_view: an #EShellView
1436 * This function is only interesting to #EShellWindow. It returns the
1437 * #GtkNotebook page number for @shell_view. The rest of the application
1438 * should have no need for this.
1440 * Returns: the notebook page number for @shell_view
1443 e_shell_view_get_page_num (EShellView
*shell_view
)
1445 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), -1);
1447 return shell_view
->priv
->page_num
;
1451 * e_shell_view_set_page_num:
1452 * @shell_view: an #EShellView
1453 * @page_num: a notebook page number
1455 * This function is only interesting to #EShellWindow. It sets the
1456 * #GtkNotebook page number for @shell_view. The rest of the application
1457 * must never call this because it could mess up shell view switching.
1460 e_shell_view_set_page_num (EShellView
*shell_view
,
1463 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
1465 if (shell_view
->priv
->page_num
== page_num
)
1468 shell_view
->priv
->page_num
= page_num
;
1470 g_object_notify (G_OBJECT (shell_view
), "page-num");
1474 * e_shell_view_get_search_name:
1475 * @shell_view: an #EShellView
1477 * Returns a newly-allocated string containing a suitable name for the
1478 * current search criteria. This is used as the suggested name in the
1479 * Save Search dialog. Free the returned string with g_free().
1481 * Returns: a name for the current search criteria
1484 e_shell_view_get_search_name (EShellView
*shell_view
)
1486 EShellViewClass
*class;
1488 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1490 class = E_SHELL_VIEW_GET_CLASS (shell_view
);
1491 g_return_val_if_fail (class != NULL
, NULL
);
1492 g_return_val_if_fail (class->get_search_name
!= NULL
, NULL
);
1494 return class->get_search_name (shell_view
);
1498 * e_shell_view_get_search_rule:
1499 * @shell_view: an #EShellView
1501 * Returns the search criteria used to generate the current search results.
1503 * Returns: the current search criteria
1506 e_shell_view_get_search_rule (EShellView
*shell_view
)
1508 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1510 return shell_view
->priv
->search_rule
;
1514 * e_shell_view_get_searchbar:
1515 * @shell_view: an #EShellView
1517 * Returns the searchbar widget for @shell_view.
1519 * Returns: the searchbar widget for @shell_view
1522 e_shell_view_get_searchbar (EShellView
*shell_view
)
1524 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1526 return shell_view
->priv
->searchbar
;
1530 * e_shell_view_set_search_rule:
1531 * @shell_view: an #EShellView
1532 * @search_rule: an #EFilterRule
1534 * Sets the search criteria used to generate the current search results.
1535 * Note that this will not trigger a search. e_shell_view_execute_search()
1536 * must be called explicitly.
1539 e_shell_view_set_search_rule (EShellView
*shell_view
,
1540 EFilterRule
*search_rule
)
1542 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
1544 if (shell_view
->priv
->search_rule
== search_rule
)
1547 if (search_rule
!= NULL
) {
1548 g_return_if_fail (E_IS_FILTER_RULE (search_rule
));
1549 g_object_ref (search_rule
);
1552 if (shell_view
->priv
->search_rule
!= NULL
)
1553 g_object_unref (shell_view
->priv
->search_rule
);
1555 shell_view
->priv
->search_rule
= search_rule
;
1557 g_object_notify (G_OBJECT (shell_view
), "search-rule");
1561 * e_shell_view_get_search_query:
1562 * @shell_view: an #EShellView
1564 * Converts the #EShellView:search-rule property to a newly-allocated
1565 * S-expression string. If the #EShellView:search-rule property is %NULL
1566 * the function returns %NULL.
1568 * Returns: an S-expression string, or %NULL
1571 e_shell_view_get_search_query (EShellView
*shell_view
)
1576 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1578 rule
= e_shell_view_get_search_rule (shell_view
);
1582 string
= g_string_sized_new (1024);
1583 e_filter_rule_build_code (rule
, string
);
1585 return g_string_free (string
, FALSE
);
1589 * e_shell_view_get_size_group:
1590 * @shell_view: an #EShellView
1592 * Returns a #GtkSizeGroup that #EShellContent and #EShellSidebar use
1593 * to keep the search bar and sidebar banner vertically aligned. The
1594 * rest of the application should have no need for this.
1596 * Note, this is only available during #EShellView construction.
1598 * Returns: a #GtkSizeGroup for internal use
1601 e_shell_view_get_size_group (EShellView
*shell_view
)
1603 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1605 return shell_view
->priv
->size_group
;
1609 * e_shell_view_get_shell_backend:
1610 * @shell_view: an #EShellView
1612 * Returns the corresponding #EShellBackend for @shell_view.
1614 * Returns: the corresponding #EShellBackend for @shell_view
1617 e_shell_view_get_shell_backend (EShellView
*shell_view
)
1619 EShellViewClass
*class;
1621 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1623 class = E_SHELL_VIEW_GET_CLASS (shell_view
);
1624 g_return_val_if_fail (class != NULL
, NULL
);
1625 g_return_val_if_fail (class->shell_backend
!= NULL
, NULL
);
1627 return class->shell_backend
;
1631 * e_shell_view_get_shell_content:
1632 * @shell_view: an #EShellView
1634 * Returns the #EShellContent instance for @shell_view.
1636 * By default, #EShellView creates a plain #EShellContent during
1637 * initialization. But #EShellView subclasses can override the
1638 * <structfield>new_shell_content</structfield> factory method
1639 * in #EShellViewClass to create a custom #EShellContent.
1641 * Returns: the #EShellContent instance for @shell_view
1644 e_shell_view_get_shell_content (EShellView
*shell_view
)
1646 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1648 return E_SHELL_CONTENT (shell_view
->priv
->shell_content
);
1652 * e_shell_view_get_shell_sidebar:
1653 * @shell_view: an #EShellView
1655 * Returns the #EShellSidebar instance for @shell_view.
1657 * By default, #EShellView creates a plain #EShellSidebar during
1658 * initialization. But #EShellView subclasses can override the
1659 * <structfield>new_shell_sidebar</structfield> factory method
1660 * in #EShellViewClass to create a custom #EShellSidebar.
1662 * Returns: the #EShellSidebar instance for @shell_view
1665 e_shell_view_get_shell_sidebar (EShellView
*shell_view
)
1667 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1669 return E_SHELL_SIDEBAR (shell_view
->priv
->shell_sidebar
);
1673 * e_shell_view_get_shell_taskbar:
1674 * @shell_view: an #EShellView
1676 * Returns the #EShellTaskbar instance for @shell_view.
1678 * By default, #EShellView creates a plain #EShellTaskbar during
1679 * initialization. But #EShellView subclasses can override the
1680 * <structfield>new_shell_taskbar</structfield> factory method
1681 * in #EShellViewClass to create a custom #EShellTaskbar.
1683 * Returns: the #EShellTaskbar instance for @shell_view
1686 e_shell_view_get_shell_taskbar (EShellView
*shell_view
)
1688 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1690 return E_SHELL_TASKBAR (shell_view
->priv
->shell_taskbar
);
1694 * e_shell_view_get_state_key_file:
1695 * @shell_view: an #EShellView
1697 * Returns the #GKeyFile holding widget state data for @shell_view.
1699 * Returns: the #GKeyFile for @shell_view
1702 e_shell_view_get_state_key_file (EShellView
*shell_view
)
1704 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1706 return shell_view
->priv
->state_key_file
;
1710 * e_shell_view_set_state_dirty:
1711 * @shell_view: an #EShellView
1713 * Marks the widget state data as modified (or "dirty") and schedules it
1714 * to be saved to disk after a short delay. The delay caps the frequency
1715 * of saving to disk.
1718 e_shell_view_set_state_dirty (EShellView
*shell_view
)
1722 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
1724 /* If a timeout is already scheduled, do nothing. */
1725 if (shell_view
->priv
->state_save_timeout_id
> 0)
1728 source_id
= e_named_timeout_add_seconds (
1729 STATE_SAVE_TIMEOUT_SECONDS
,
1730 shell_view_state_timeout_cb
, shell_view
);
1732 shell_view
->priv
->state_save_timeout_id
= source_id
;
1736 * e_shell_view_clear_search:
1737 * @shell_view: an #EShellView
1739 * Emits the #EShellView::clear-search signal.
1741 * The default method sets the #EShellView:search-rule property to
1742 * %NULL and then emits the #EShellView::execute-search signal.
1745 e_shell_view_clear_search (EShellView
*shell_view
)
1747 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
1749 g_signal_emit (shell_view
, signals
[CLEAR_SEARCH
], 0);
1753 * e_shell_view_custom_search:
1754 * @shell_view: an #EShellView
1755 * @custom_rule: an #EFilterRule
1757 * Emits the #EShellView::custom-search signal to indicate an advanced
1758 * or saved search is about to be executed.
1760 * The default method sets the #EShellView:search-rule property to
1761 * @custom_rule and then emits the #EShellView::execute-search signal.
1764 e_shell_view_custom_search (EShellView
*shell_view
,
1765 EFilterRule
*custom_rule
)
1767 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
1768 g_return_if_fail (E_IS_FILTER_RULE (custom_rule
));
1770 g_signal_emit (shell_view
, signals
[CUSTOM_SEARCH
], 0, custom_rule
);
1774 * e_shell_view_execute_search:
1775 * @shell_view: an #EShellView
1777 * Emits the #EShellView::execute-search signal.
1779 * #EShellView subclasses should implement the
1780 * <structfield>execute_search</structfield> method in #EShellViewClass
1781 * to execute a search based on the current search conditions.
1784 e_shell_view_execute_search (EShellView
*shell_view
)
1786 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
1788 if (!e_shell_view_is_execute_search_blocked (shell_view
))
1789 g_signal_emit (shell_view
, signals
[EXECUTE_SEARCH
], 0);
1793 * e_shell_view_block_execute_search:
1794 * @shell_view: an #EShellView
1796 * Blocks e_shell_view_execute_search() in a way it does nothing.
1797 * Pair function for this is e_shell_view_unblock_execute_search().
1800 e_shell_view_block_execute_search (EShellView
*shell_view
)
1802 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
1803 g_return_if_fail (shell_view
->priv
->execute_search_blocked
+ 1 != 0);
1805 shell_view
->priv
->execute_search_blocked
++;
1809 * e_shell_view_unblock_execute_search:
1810 * @shell_view: an #EShellView
1812 * Unblocks previously blocked e_shell_view_execute_search() with
1813 * function e_shell_view_block_execute_search().
1816 e_shell_view_unblock_execute_search (EShellView
*shell_view
)
1818 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
1819 g_return_if_fail (shell_view
->priv
->execute_search_blocked
> 0);
1821 shell_view
->priv
->execute_search_blocked
--;
1825 * e_shell_view_is_execute_search_blocked:
1826 * @shell_view: an #EShellView
1828 * Returns whether e_shell_view_execute_search() is blocked as a result
1829 * of previous e_shell_view_block_execute_search() calls.
1831 * Returns: %TRUE if e_shell_view_execute_search() is blocked
1834 e_shell_view_is_execute_search_blocked (EShellView
*shell_view
)
1836 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), FALSE
);
1838 return shell_view
->priv
->execute_search_blocked
> 0;
1842 * e_shell_view_update_actions:
1843 * @shell_view: an #EShellView
1845 * Emits the #EShellView::update-actions signal.
1847 * #EShellView subclasses should implement the
1848 * <structfield>update_actions</structfield> method in #EShellViewClass
1849 * to update the various #GtkAction<!-- -->s based on the current
1850 * #EShellSidebar and #EShellContent selections. The
1851 * #EShellView::update-actions signal is typically emitted just before
1852 * showing a popup menu or just after the user selects an item in the
1856 e_shell_view_update_actions (EShellView
*shell_view
)
1858 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
1860 if (e_shell_view_is_active (shell_view
)) {
1861 if (shell_view
->priv
->update_actions_idle_id
> 0) {
1862 g_source_remove (shell_view
->priv
->update_actions_idle_id
);
1863 shell_view
->priv
->update_actions_idle_id
= 0;
1866 g_signal_emit (shell_view
, signals
[UPDATE_ACTIONS
], 0);
1871 shell_view_call_update_actions_idle (gpointer user_data
)
1873 EShellView
*shell_view
= user_data
;
1875 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), FALSE
);
1877 shell_view
->priv
->update_actions_idle_id
= 0;
1878 e_shell_view_update_actions (shell_view
);
1884 * e_shell_view_update_actions_in_idle:
1885 * @shell_view: an #EShellView
1887 * Schedules e_shell_view_update_actions() call on idle.
1892 e_shell_view_update_actions_in_idle (EShellView
*shell_view
)
1894 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
1896 if (!e_shell_view_is_active (shell_view
))
1899 if (shell_view
->priv
->update_actions_idle_id
== 0)
1900 shell_view
->priv
->update_actions_idle_id
= g_idle_add (
1901 shell_view_call_update_actions_idle
, shell_view
);
1905 e_shell_view_popup_menu_deactivate (GtkMenu
*popup_menu
,
1908 g_return_if_fail (GTK_IS_MENU (popup_menu
));
1910 g_signal_handlers_disconnect_by_func (popup_menu
, e_shell_view_popup_menu_deactivate
, user_data
);
1911 gtk_menu_detach (popup_menu
);
1915 * e_shell_view_show_popup_menu:
1916 * @shell_view: an #EShellView
1917 * @widget_path: path in the UI definition
1918 * @button_event: a #GdkEvent, or %NULL
1920 * Displays a context-sensitive (or "popup") menu that is described in
1921 * the UI definition loaded into @shell_view<!-- -->'s user interface
1922 * manager. The menu will be shown at the current mouse cursor position.
1924 * The #EShellView::update-actions signal is emitted just prior to
1925 * showing the menu to give @shell_view and any plugins that extend
1926 * @shell_view a chance to update the menu's actions.
1928 * Returns: the popup menu being displayed
1931 e_shell_view_show_popup_menu (EShellView
*shell_view
,
1932 const gchar
*widget_path
,
1933 GdkEvent
*button_event
)
1935 EShellWindow
*shell_window
;
1938 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
1940 e_shell_view_update_actions (shell_view
);
1942 shell_window
= e_shell_view_get_shell_window (shell_view
);
1943 menu
= e_shell_window_get_managed_widget (shell_window
, widget_path
);
1944 g_return_val_if_fail (GTK_IS_MENU (menu
), NULL
);
1946 if (!gtk_menu_get_attach_widget (GTK_MENU (menu
))) {
1947 gtk_menu_attach_to_widget (GTK_MENU (menu
),
1948 GTK_WIDGET (shell_window
),
1951 g_signal_connect (menu
, "deactivate", G_CALLBACK (e_shell_view_popup_menu_deactivate
), NULL
);
1954 gtk_menu_popup_at_pointer (GTK_MENU (menu
), button_event
);
1960 * e_shell_view_write_source:
1961 * @shell_view: an #EShellView
1962 * @source: an #ESource
1964 * Submits the current contents of @source to the D-Bus service to be
1965 * written to disk and broadcast to other clients.
1967 * This function does not block: @shell_view will dispatch the operation
1968 * asynchronously and handle any errors.
1971 e_shell_view_write_source (EShellView
*shell_view
,
1974 EActivity
*activity
;
1975 EAlertSink
*alert_sink
;
1976 EShellBackend
*shell_backend
;
1977 EShellContent
*shell_content
;
1979 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
1980 g_return_if_fail (E_IS_SOURCE (source
));
1982 shell_backend
= e_shell_view_get_shell_backend (shell_view
);
1983 shell_content
= e_shell_view_get_shell_content (shell_view
);
1985 alert_sink
= E_ALERT_SINK (shell_content
);
1986 activity
= e_source_util_write (source
, alert_sink
);
1987 e_shell_backend_add_activity (shell_backend
, activity
);
1991 * e_shell_view_remove_source:
1992 * @shell_view: an #EShellView
1993 * @source: the #ESource to be removed
1995 * Requests the D-Bus service to delete the key files for @source and all of
1996 * its descendants and broadcast their removal to all clients.
1998 * This function does not block: @shell_view will dispatch the operation
1999 * asynchronously and handle any errors.
2002 e_shell_view_remove_source (EShellView
*shell_view
,
2005 EActivity
*activity
;
2006 EAlertSink
*alert_sink
;
2007 EShellBackend
*shell_backend
;
2008 EShellContent
*shell_content
;
2010 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
2011 g_return_if_fail (E_IS_SOURCE (source
));
2013 shell_backend
= e_shell_view_get_shell_backend (shell_view
);
2014 shell_content
= e_shell_view_get_shell_content (shell_view
);
2016 alert_sink
= E_ALERT_SINK (shell_content
);
2017 activity
= e_source_util_remove (source
, alert_sink
);
2018 e_shell_backend_add_activity (shell_backend
, activity
);
2022 * e_shell_view_remote_delete_source:
2023 * @shell_view: an #EShellView
2024 * @source: an #ESource
2026 * Deletes the resource represented by @source from a remote server.
2027 * The @source must be #ESource:remote-deletable. This will also delete
2028 * the key file for @source and broadcast its removal to all clients,
2029 * similar to e_shell_view_remove_source().
2031 * This function does not block; @shell_view will dispatch the operation
2032 * asynchronously and handle any errors.
2035 e_shell_view_remote_delete_source (EShellView
*shell_view
,
2038 EActivity
*activity
;
2039 EAlertSink
*alert_sink
;
2040 EShellBackend
*shell_backend
;
2041 EShellContent
*shell_content
;
2043 g_return_if_fail (E_IS_SHELL_VIEW (shell_view
));
2044 g_return_if_fail (E_IS_SOURCE (source
));
2046 shell_backend
= e_shell_view_get_shell_backend (shell_view
);
2047 shell_content
= e_shell_view_get_shell_content (shell_view
);
2049 alert_sink
= E_ALERT_SINK (shell_content
);
2050 activity
= e_source_util_remote_delete (source
, alert_sink
);
2051 e_shell_backend_add_activity (shell_backend
, activity
);
2055 * e_shell_view_submit_thread_job:
2056 * @shell_view: an #EShellView instance
2057 * @description: user-friendly description of the job, to be shown in UI
2058 * @alert_ident: in case of an error, this alert identificator is used
2059 * for EAlert construction
2060 * @alert_arg_0: (allow-none): in case of an error, use this string as
2061 * the first argument to the EAlert construction; the second argument
2062 * is the actual error message; can be #NULL, in which case only
2063 * the error message is passed to the EAlert construction
2064 * @func: function to be run in a dedicated thread
2065 * @user_data: (allow-none): custom data passed into @func; can be #NULL
2066 * @free_user_data: (allow-none): function to be called on @user_data,
2067 * when the job is over; can be #NULL
2069 * Runs the @func in a dedicated thread. Any error is propagated to UI.
2070 * The cancellable passed into the @func is a #CamelOperation, thus
2071 * the caller can overwrite progress and description message on it.
2073 * Returns: (transfer full): Newly created #EActivity on success.
2074 * The caller is responsible to g_object_unref() it when done with it.
2076 * Note: The @free_user_data, if set, is called in the main thread.
2078 * Note: This function can be called only from the main thread.
2081 e_shell_view_submit_thread_job (EShellView
*shell_view
,
2082 const gchar
*description
,
2083 const gchar
*alert_ident
,
2084 const gchar
*alert_arg_0
,
2085 EAlertSinkThreadJobFunc func
,
2087 GDestroyNotify free_user_data
)
2089 EShellBackend
*shell_backend
;
2090 EShellContent
*shell_content
;
2091 EActivity
*activity
;
2092 EAlertSink
*alert_sink
;
2094 g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view
), NULL
);
2095 g_return_val_if_fail (description
!= NULL
, NULL
);
2096 g_return_val_if_fail (func
!= NULL
, NULL
);
2097 g_return_val_if_fail (g_thread_self () == shell_view
->priv
->main_thread
, NULL
);
2099 shell_backend
= e_shell_view_get_shell_backend (shell_view
);
2100 shell_content
= e_shell_view_get_shell_content (shell_view
);
2102 alert_sink
= E_ALERT_SINK (shell_content
);
2104 activity
= e_alert_sink_submit_thread_job (
2114 e_shell_backend_add_activity (shell_backend
, activity
);