static void task_shell_content_view_created (ECalBaseShellContent *cal_base_shell_content) { ETaskShellContent *task_shell_content; EShellView *shell_view; GalViewInstance *view_instance; GSettings *settings; task_shell_content = E_TASK_SHELL_CONTENT (cal_base_shell_content); shell_view = e_shell_content_get_shell_view (E_SHELL_CONTENT (task_shell_content)); /* Bind GObject properties to settings keys. */ settings = e_util_ref_settings ("org.gnome.evolution.calendar"); g_settings_bind ( settings, "task-hpane-position", task_shell_content->priv->paned, "hposition", G_SETTINGS_BIND_DEFAULT); g_settings_bind ( settings, "task-vpane-position", task_shell_content->priv->paned, "vposition", G_SETTINGS_BIND_DEFAULT); g_object_unref (settings); /* Finally load the view instance */ view_instance = e_shell_view_get_view_instance (shell_view); gal_view_instance_load (view_instance); /* Show everything known by default */ e_cal_model_set_time_range (e_cal_base_shell_content_get_model (cal_base_shell_content), 0, 0); }
static void task_shell_content_focus_search_results (EShellContent *shell_content) { ETaskShellContent *task_shell_content; task_shell_content = E_TASK_SHELL_CONTENT (shell_content); gtk_widget_grab_focus (task_shell_content->priv->task_table); }
static void task_shell_content_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { switch (property_id) { case PROP_ORIENTATION: task_shell_content_set_orientation ( E_TASK_SHELL_CONTENT (object), g_value_get_enum (value)); return; case PROP_PREVIEW_VISIBLE: e_task_shell_content_set_preview_visible ( E_TASK_SHELL_CONTENT (object), g_value_get_boolean (value)); return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); }
static void task_shell_content_dispose (GObject *object) { ETaskShellContent *task_shell_content = E_TASK_SHELL_CONTENT (object); g_clear_object (&task_shell_content->priv->paned); g_clear_object (&task_shell_content->priv->task_table); g_clear_object (&task_shell_content->priv->preview_pane); g_free (task_shell_content->priv->current_uid); task_shell_content->priv->current_uid = NULL; /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_task_shell_content_parent_class)->dispose (object); }
static void task_shell_content_constructed (GObject *object) { ETaskShellContent *task_shell_content; EShellView *shell_view; EShellContent *shell_content; EShellTaskbar *shell_taskbar; ECalModel *model; GalViewInstance *view_instance; GtkTargetList *target_list; GtkTargetEntry *targets; GtkWidget *container; GtkWidget *widget; gint n_targets; task_shell_content = E_TASK_SHELL_CONTENT (object); /* Chain up to parent's constructed() method. */ G_OBJECT_CLASS (e_task_shell_content_parent_class)->constructed (object); model = e_cal_base_shell_content_get_model (E_CAL_BASE_SHELL_CONTENT (task_shell_content)); shell_content = E_SHELL_CONTENT (object); shell_view = e_shell_content_get_shell_view (shell_content); shell_taskbar = e_shell_view_get_shell_taskbar (shell_view); /* Build content widgets. */ container = GTK_WIDGET (object); widget = e_paned_new (GTK_ORIENTATION_VERTICAL); gtk_container_add (GTK_CONTAINER (container), widget); task_shell_content->priv->paned = g_object_ref (widget); gtk_widget_show (widget); e_binding_bind_property ( object, "orientation", widget, "orientation", G_BINDING_SYNC_CREATE); container = task_shell_content->priv->paned; widget = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, FALSE); gtk_widget_show (widget); container = widget; widget = e_task_table_new (shell_view, model); gtk_container_add (GTK_CONTAINER (container), widget); task_shell_content->priv->task_table = g_object_ref (widget); gtk_widget_show (widget); container = task_shell_content->priv->paned; widget = e_cal_component_preview_new (); gtk_widget_show (widget); g_signal_connect_swapped ( widget, "status-message", G_CALLBACK (e_shell_taskbar_set_message), shell_taskbar); widget = e_preview_pane_new (E_WEB_VIEW (widget)); gtk_paned_pack2 (GTK_PANED (container), widget, FALSE, FALSE); task_shell_content->priv->preview_pane = g_object_ref (widget); gtk_widget_show (widget); e_binding_bind_property ( object, "preview-visible", widget, "visible", G_BINDING_SYNC_CREATE); target_list = gtk_target_list_new (NULL, 0); e_target_list_add_calendar_targets (target_list, 0); targets = gtk_target_table_new_from_list (target_list, &n_targets); e_table_drag_source_set ( E_TABLE (task_shell_content->priv->task_table), GDK_BUTTON1_MASK, targets, n_targets, GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_ASK); gtk_target_table_free (targets, n_targets); gtk_target_list_unref (target_list); g_signal_connect_swapped ( task_shell_content->priv->task_table, "table-drag-data-get", G_CALLBACK (task_shell_content_table_drag_data_get_cb), object); g_signal_connect_swapped ( task_shell_content->priv->task_table, "table-drag-data-delete", G_CALLBACK (task_shell_content_table_drag_data_delete_cb), object); g_signal_connect_swapped ( task_shell_content->priv->task_table, "cursor-change", G_CALLBACK (task_shell_content_cursor_change_cb), object); g_signal_connect_swapped ( task_shell_content->priv->task_table, "selection-change", G_CALLBACK (task_shell_content_selection_change_cb), object); e_signal_connect_notify ( task_shell_content->priv->task_table, "notify::is-editing", G_CALLBACK (task_shell_content_is_editing_changed_cb), shell_view); g_signal_connect_swapped ( model, "model-row-changed", G_CALLBACK (task_shell_content_model_row_changed_cb), object); /* Prepare the view instance. */ view_instance = e_shell_view_new_view_instance (shell_view, NULL); g_signal_connect_swapped ( view_instance, "display-view", G_CALLBACK (task_shell_content_display_view_cb), object); e_shell_view_set_view_instance (shell_view, view_instance); g_object_unref (view_instance); }
static guint32 task_shell_content_check_state (EShellContent *shell_content) { ETaskShellContent *task_shell_content; ETaskTable *task_table; GSList *list, *iter; gboolean assignable = TRUE; gboolean editable = TRUE; gboolean has_url = FALSE; gint n_selected; gint n_complete = 0; gint n_incomplete = 0; guint32 state = 0; task_shell_content = E_TASK_SHELL_CONTENT (shell_content); task_table = e_task_shell_content_get_task_table (task_shell_content); n_selected = e_table_selected_count (E_TABLE (task_table)); list = e_task_table_get_selected (task_table); for (iter = list; iter != NULL; iter = iter->next) { ECalModelComponent *comp_data = iter->data; icalproperty *prop; const gchar *cap; gboolean read_only; if (!comp_data) continue; read_only = e_client_is_readonly (E_CLIENT (comp_data->client)); editable &= !read_only; cap = CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT; if (e_client_check_capability (E_CLIENT (comp_data->client), cap)) assignable = FALSE; cap = CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK; if (e_client_check_capability (E_CLIENT (comp_data->client), cap)) assignable = FALSE; prop = icalcomponent_get_first_property ( comp_data->icalcomp, ICAL_URL_PROPERTY); has_url |= (prop != NULL); prop = icalcomponent_get_first_property ( comp_data->icalcomp, ICAL_COMPLETED_PROPERTY); if (prop != NULL) n_complete++; else n_incomplete++; } g_slist_free (list); if (n_selected == 1) state |= E_CAL_BASE_SHELL_CONTENT_SELECTION_SINGLE; if (n_selected > 1) state |= E_CAL_BASE_SHELL_CONTENT_SELECTION_MULTIPLE; if (assignable) state |= E_CAL_BASE_SHELL_CONTENT_SELECTION_CAN_ASSIGN; if (editable) state |= E_CAL_BASE_SHELL_CONTENT_SELECTION_IS_EDITABLE; if (n_complete > 0) state |= E_CAL_BASE_SHELL_CONTENT_SELECTION_HAS_COMPLETE; if (n_incomplete > 0) state |= E_CAL_BASE_SHELL_CONTENT_SELECTION_HAS_INCOMPLETE; if (has_url) state |= E_CAL_BASE_SHELL_CONTENT_SELECTION_HAS_URL; return state; }
static void task_shell_view_execute_search (EShellView *shell_view) { ETaskShellContent *task_shell_content; EShellWindow *shell_window; EShellContent *shell_content; EShellSearchbar *searchbar; EActionComboBox *combo_box; GtkRadioAction *action; ECalComponentPreview *task_preview; EPreviewPane *preview_pane; ETaskTable *task_table; EWebView *web_view; ECalModel *model; ECalDataModel *data_model; icaltimezone *timezone; struct icaltimetype current_time; time_t start_range; time_t end_range; time_t now_time; gchar *start, *end; gchar *query; gchar *temp; gint value; shell_window = e_shell_view_get_shell_window (shell_view); shell_content = e_shell_view_get_shell_content (shell_view); task_shell_content = E_TASK_SHELL_CONTENT (shell_content); searchbar = e_task_shell_content_get_searchbar (task_shell_content); task_shell_content = E_TASK_SHELL_CONTENT (shell_content); task_table = e_task_shell_content_get_task_table (task_shell_content); model = e_task_table_get_model (task_table); data_model = e_cal_model_get_data_model (model); timezone = e_cal_model_get_timezone (model); current_time = icaltime_current_time_with_zone (timezone); now_time = time_day_begin (icaltime_as_timet (current_time)); action = GTK_RADIO_ACTION (ACTION (TASK_SEARCH_ANY_FIELD_CONTAINS)); value = gtk_radio_action_get_current_value (action); if (value == TASK_SEARCH_ADVANCED) { query = e_shell_view_get_search_query (shell_view); if (!query) query = g_strdup (""); } else { const gchar *format; const gchar *text; GString *string; text = e_shell_searchbar_get_search_text (searchbar); if (text == NULL || *text == '\0') { text = ""; value = TASK_SEARCH_SUMMARY_CONTAINS; } switch (value) { default: text = ""; /* fall through */ case TASK_SEARCH_SUMMARY_CONTAINS: format = "(contains? \"summary\" %s)"; break; case TASK_SEARCH_DESCRIPTION_CONTAINS: format = "(contains? \"description\" %s)"; break; case TASK_SEARCH_ANY_FIELD_CONTAINS: format = "(contains? \"any\" %s)"; break; } /* Build the query. */ string = g_string_new (""); e_sexp_encode_string (string, text); query = g_strdup_printf (format, string->str); g_string_free (string, TRUE); } /* Apply selected filter. */ combo_box = e_shell_searchbar_get_filter_combo_box (searchbar); value = e_action_combo_box_get_current_value (combo_box); switch (value) { case TASK_FILTER_ANY_CATEGORY: break; case TASK_FILTER_UNMATCHED: temp = g_strdup_printf ( "(and (has-categories? #f) %s)", query); g_free (query); query = temp; break; case TASK_FILTER_NEXT_7_DAYS_TASKS: start_range = now_time; end_range = time_day_end (time_add_day (start_range, 7)); start = isodate_from_time_t (start_range); end = isodate_from_time_t (end_range); temp = g_strdup_printf ( "(and %s (due-in-time-range? " "(make-time \"%s\") (make-time \"%s\")))", query, start, end); g_free (query); query = temp; break; case TASK_FILTER_ACTIVE_TASKS: start_range = now_time; end_range = time_day_end (time_add_day (start_range, 365)); start = isodate_from_time_t (start_range); end = isodate_from_time_t (end_range); temp = g_strdup_printf ( "(and %s (due-in-time-range? " "(make-time \"%s\") (make-time \"%s\")) " "(not (is-completed?)))", query, start, end); g_free (query); query = temp; break; case TASK_FILTER_OVERDUE_TASKS: start_range = 0; end_range = time_day_end (now_time); start = isodate_from_time_t (start_range); end = isodate_from_time_t (end_range); temp = g_strdup_printf ( "(and %s (due-in-time-range? " "(make-time \"%s\") (make-time \"%s\")) " "(not (is-completed?)))", query, start, end); g_free (query); query = temp; break; case TASK_FILTER_COMPLETED_TASKS: temp = g_strdup_printf ( "(and (is-completed?) %s)", query); g_free (query); query = temp; break; case TASK_FILTER_TASKS_WITH_ATTACHMENTS: temp = g_strdup_printf ( "(and (has-attachments?) %s)", query); g_free (query); query = temp; break; default: { GList *categories; const gchar *category_name; categories = e_util_dup_searchable_categories (); category_name = g_list_nth_data (categories, value); temp = g_strdup_printf ( "(and (has-categories? \"%s\") %s)", category_name, query); g_free (query); query = temp; g_list_free_full (categories, g_free); break; } } /* Honor the user's preference to hide completed tasks. */ temp = calendar_config_get_hide_completed_tasks_sexp (FALSE); if (temp != NULL) { gchar *temp2; temp2 = g_strdup_printf ("(and %s %s)", temp, query); g_free (query); g_free (temp); query = temp2; } /* Submit the query. */ e_cal_data_model_set_filter (data_model, query); g_free (query); preview_pane = e_task_shell_content_get_preview_pane (task_shell_content); web_view = e_preview_pane_get_web_view (preview_pane); task_preview = E_CAL_COMPONENT_PREVIEW (web_view); e_cal_component_preview_clear (task_preview); }
void e_task_shell_view_private_constructed (ETaskShellView *task_shell_view) { ETaskShellViewPrivate *priv = task_shell_view->priv; EShellBackend *shell_backend; EShellContent *shell_content; EShellSidebar *shell_sidebar; EShellWindow *shell_window; EShellView *shell_view; EShell *shell; gulong handler_id; shell_view = E_SHELL_VIEW (task_shell_view); shell_backend = e_shell_view_get_shell_backend (shell_view); shell_content = e_shell_view_get_shell_content (shell_view); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); shell = e_shell_window_get_shell (shell_window); e_shell_window_add_action_group (shell_window, "tasks"); e_shell_window_add_action_group (shell_window, "tasks-filter"); /* Cache these to avoid lots of awkward casting. */ priv->task_shell_backend = g_object_ref (shell_backend); priv->task_shell_content = g_object_ref (shell_content); priv->task_shell_sidebar = g_object_ref (shell_sidebar); priv->settings = g_settings_new ("org.gnome.evolution.calendar"); handler_id = g_signal_connect_object ( priv->task_shell_sidebar, "client-added", G_CALLBACK (task_shell_view_selector_client_added_cb), task_shell_view, G_CONNECT_SWAPPED); priv->client_added_handler_id = handler_id; handler_id = g_signal_connect_object ( priv->task_shell_sidebar, "client-removed", G_CALLBACK (task_shell_view_selector_client_removed_cb), task_shell_view, G_CONNECT_SWAPPED); priv->client_removed_handler_id = handler_id; /* Keep our own reference to this so we can * disconnect our signal handlers in dispose(). */ priv->client_cache = e_shell_get_client_cache (shell); g_object_ref (priv->client_cache); handler_id = g_signal_connect ( priv->client_cache, "backend-error", G_CALLBACK (task_shell_view_backend_error_cb), task_shell_view); priv->backend_error_handler_id = handler_id; /* Keep our own reference to this so we can * disconnect our signal handlers in dispose(). */ priv->task_table = e_task_shell_content_get_task_table ( E_TASK_SHELL_CONTENT (shell_content)); g_object_ref (priv->task_table); handler_id = g_signal_connect_swapped ( priv->task_table, "open-component", G_CALLBACK (e_task_shell_view_open_task), task_shell_view); priv->open_component_handler_id = handler_id; handler_id = g_signal_connect_swapped ( priv->task_table, "popup-event", G_CALLBACK (task_shell_view_table_popup_event_cb), task_shell_view); priv->popup_event_handler_id = handler_id; handler_id = g_signal_connect_swapped ( priv->task_table, "selection-change", G_CALLBACK (e_task_shell_view_update_sidebar), task_shell_view); priv->selection_change_1_handler_id = handler_id; handler_id = g_signal_connect_swapped ( priv->task_table, "selection-change", G_CALLBACK (e_shell_view_update_actions), task_shell_view); priv->selection_change_2_handler_id = handler_id; handler_id = g_signal_connect_swapped ( priv->task_table, "status-message", G_CALLBACK (e_task_shell_view_set_status_message), task_shell_view); priv->status_message_handler_id = handler_id; /* Keep our own reference to this so we can * disconnect our signal handlers in dispose(). */ priv->model = e_task_table_get_model (priv->task_table); g_object_ref (priv->model); handler_id = g_signal_connect_swapped ( priv->model, "model-changed", G_CALLBACK (e_task_shell_view_update_sidebar), task_shell_view); priv->model_changed_handler_id = handler_id; handler_id = g_signal_connect_swapped ( priv->model, "model-rows-deleted", G_CALLBACK (e_task_shell_view_update_sidebar), task_shell_view); priv->model_rows_deleted_handler_id = handler_id; handler_id = g_signal_connect_swapped ( priv->model, "model-rows-inserted", G_CALLBACK (e_task_shell_view_update_sidebar), task_shell_view); priv->model_rows_inserted_handler_id = handler_id; handler_id = g_signal_connect_swapped ( priv->model, "row-appended", G_CALLBACK (task_shell_view_model_row_appended_cb), task_shell_view); priv->rows_appended_handler_id = handler_id; /* Keep our own reference to this so we can * disconnect our signal handlers in dispose(). */ priv->selector = e_task_shell_sidebar_get_selector ( E_TASK_SHELL_SIDEBAR (shell_sidebar)); g_object_ref (priv->selector); handler_id = g_signal_connect_swapped ( priv->selector, "popup-event", G_CALLBACK (task_shell_view_selector_popup_event_cb), task_shell_view); priv->selector_popup_event_handler_id = handler_id; handler_id = g_signal_connect_swapped ( priv->selector, "primary-selection-changed", G_CALLBACK (e_shell_view_update_actions), task_shell_view); priv->primary_selection_changed_handler_id = handler_id; e_categories_add_change_hook ( (GHookFunc) e_task_shell_view_update_search_filter, task_shell_view); /* Listen for configuration changes. */ g_settings_bind ( priv->settings, "confirm-purge", shell_view, "confirm-purge", G_SETTINGS_BIND_DEFAULT); /* Keep the ECalModel in sync with the sidebar. */ g_object_bind_property ( shell_sidebar, "default-client", priv->model, "default-client", G_BINDING_SYNC_CREATE); /* Hide Completed Tasks (enable/units/value) */ handler_id = g_signal_connect ( priv->settings, "changed::hide-completed-tasks", G_CALLBACK (task_shell_view_hide_completed_tasks_changed_cb), task_shell_view); priv->settings_hide_completed_tasks_handler_id = handler_id; handler_id = g_signal_connect ( priv->settings, "changed::hide-completed-tasks-units", G_CALLBACK (task_shell_view_hide_completed_tasks_changed_cb), task_shell_view); priv->settings_hide_completed_tasks_units_handler_id = handler_id; handler_id = g_signal_connect ( priv->settings, "changed::hide-completed-tasks-value", G_CALLBACK (task_shell_view_hide_completed_tasks_changed_cb), task_shell_view); priv->settings_hide_completed_tasks_value_handler_id = handler_id; e_task_shell_view_actions_init (task_shell_view); e_task_shell_view_update_sidebar (task_shell_view); e_task_shell_view_update_search_filter (task_shell_view); /* Call this when everything is ready, like actions in * action groups and such. */ task_shell_view_update_timeout_cb (task_shell_view); priv->update_timeout = e_named_timeout_add_full ( G_PRIORITY_LOW, 60000, task_shell_view_update_timeout_cb, task_shell_view, NULL); }