aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/e-tasks.c21
-rw-r--r--calendar/gui/e-tasks.h3
-rw-r--r--calendar/gui/gnome-cal.h5
-rw-r--r--calendar/gui/tasks-control.c82
4 files changed, 75 insertions, 36 deletions
diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c
index 1686ac793a..609e2551c1 100644
--- a/calendar/gui/e-tasks.c
+++ b/calendar/gui/e-tasks.c
@@ -32,7 +32,6 @@
#include "widgets/menus/gal-view-menus.h"
#include "dialogs/task-editor.h"
#include "calendar-config.h"
-#include "e-calendar-table.h"
#include "calendar-config.h"
#include "component-factory.h"
@@ -635,6 +634,26 @@ e_tasks_setup_menus (ETasks *tasks,
gtk_object_sink (GTK_OBJECT (collection));
}
+/**
+ * e_tasks_get_calendar_table:
+ * @tasks: A tasks widget.
+ *
+ * Queries the #ECalendarTable contained in a tasks widget.
+ *
+ * Return value: The #ECalendarTable that the tasks widget uses to display its
+ * information.
+ **/
+ECalendarTable *
+e_tasks_get_calendar_table (ETasks *tasks)
+{
+ ETasksPrivate *priv;
+
+ g_return_val_if_fail (tasks != NULL, NULL);
+ g_return_val_if_fail (E_IS_TASKS (tasks), NULL);
+
+ priv = tasks->priv;
+ return E_CALENDAR_TABLE (priv->tasks_view);
+}
/* This updates all the preference settings for all the ETasks widgets in use.
*/
diff --git a/calendar/gui/e-tasks.h b/calendar/gui/e-tasks.h
index ed6fd8199f..63ec5df5e9 100644
--- a/calendar/gui/e-tasks.h
+++ b/calendar/gui/e-tasks.h
@@ -28,6 +28,7 @@
#include <gtk/gtktable.h>
#include <cal-client/cal-client.h>
+#include "e-calendar-table.h"
#define E_TYPE_TASKS (e_tasks_get_type ())
#define E_TASKS(obj) (GTK_CHECK_CAST ((obj), E_TYPE_TASKS, ETasks))
@@ -71,6 +72,8 @@ void e_tasks_delete_selected (ETasks *tasks);
void e_tasks_setup_menus (ETasks *tasks,
BonoboUIComponent *uic);
+ECalendarTable *e_tasks_get_calendar_table (ETasks *tasks);
+
/* This updates all the preference settings for all the ETasks widgets in use.
*/
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index b9b5cd42a3..dbda38c593 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -68,10 +68,7 @@ CalClient *gnome_calendar_get_cal_client (GnomeCalendar *gcal);
CalClient *gnome_calendar_get_task_pad_cal_client(GnomeCalendar *gcal);
gboolean gnome_calendar_open (GnomeCalendar *gcal, const char *str_uri);
-/*
-int gnome_calendar_create (GnomeCalendar *gcal,
- char *file);
-*/
+
void gnome_calendar_next (GnomeCalendar *gcal);
void gnome_calendar_previous (GnomeCalendar *gcal);
void gnome_calendar_goto (GnomeCalendar *gcal,
diff --git a/calendar/gui/tasks-control.c b/calendar/gui/tasks-control.c
index 281846977b..e460e5fe00 100644
--- a/calendar/gui/tasks-control.c
+++ b/calendar/gui/tasks-control.c
@@ -54,7 +54,8 @@ static void tasks_control_activate_cb (BonoboControl *control,
gpointer user_data);
static void tasks_control_activate (BonoboControl *control,
ETasks *tasks);
-static void tasks_control_deactivate (BonoboControl *control);
+static void tasks_control_deactivate (BonoboControl *control,
+ ETasks *tasks);
static void tasks_control_new_task_cmd (BonoboUIComponent *uic,
gpointer data,
@@ -64,28 +65,6 @@ static void tasks_control_delete_cmd (BonoboUIComponent *uic,
const char *path);
-/* Callback used when the selection in the table changes */
-static void
-selection_changed_cb (ETasks *tasks, int n_selected, gpointer data)
-{
- BonoboControl *control;
- BonoboUIComponent *uic;
- Bonobo_UIContainer ui_container;
-
- control = BONOBO_CONTROL (data);
-
- uic = bonobo_control_get_ui_component (control);
- g_assert (uic != NULL);
-
- ui_container = bonobo_ui_component_get_container (uic);
- if (ui_container == CORBA_OBJECT_NIL)
- return;
-
- bonobo_ui_component_set_prop (uic, "/commands/TasksDelete", "sensitive",
- n_selected == 0 ? "0" : "1",
- NULL);
-}
-
BonoboControl *
tasks_control_new (void)
{
@@ -110,9 +89,6 @@ tasks_control_new (void)
GTK_SIGNAL_FUNC (tasks_control_activate_cb),
tasks);
- gtk_signal_connect (GTK_OBJECT (tasks), "selection_changed",
- GTK_SIGNAL_FUNC (selection_changed_cb), control);
-
return control;
}
@@ -199,12 +175,42 @@ tasks_control_activate_cb (BonoboControl *control,
gboolean activate,
gpointer user_data)
{
+ ETasks *tasks;
+
+ tasks = E_TASKS (user_data);
+
if (activate)
- tasks_control_activate (control, user_data);
+ tasks_control_activate (control, tasks);
else
- tasks_control_deactivate (control);
+ tasks_control_deactivate (control, tasks);
+}
+
+/* Sensitizes the UI Component menu/toolbar commands based on the number of
+ * selected tasks.
+ */
+static void
+sensitize_commands (ETasks *tasks, BonoboControl *control, int n_selected)
+{
+ BonoboUIComponent *uic;
+
+ uic = bonobo_control_get_ui_component (control);
+ g_assert (uic != NULL);
+
+ bonobo_ui_component_set_prop (uic, "/commands/TasksDelete", "sensitive",
+ n_selected == 0 ? "0" : "1",
+ NULL);
}
+/* Callback used when the selection in the table changes */
+static void
+selection_changed_cb (ETasks *tasks, int n_selected, gpointer data)
+{
+ BonoboControl *control;
+
+ control = BONOBO_CONTROL (data);
+
+ sensitize_commands (tasks, control, n_selected);
+}
static BonoboUIVerb verbs [] = {
BONOBO_UI_VERB ("TasksNewTask", tasks_control_new_task_cmd),
@@ -220,11 +226,13 @@ static EPixmap pixmaps [] = {
};
static void
-tasks_control_activate (BonoboControl *control,
- ETasks *tasks)
+tasks_control_activate (BonoboControl *control, ETasks *tasks)
{
Bonobo_UIContainer remote_uih;
BonoboUIComponent *uic;
+ int n_selected;
+ ECalendarTable *cal_table;
+ ETable *etable;
uic = bonobo_control_get_ui_component (control);
g_assert (uic != NULL);
@@ -245,16 +253,28 @@ tasks_control_activate (BonoboControl *control,
e_pixmaps_update (uic, pixmaps);
+ gtk_signal_connect (GTK_OBJECT (tasks), "selection_changed",
+ GTK_SIGNAL_FUNC (selection_changed_cb), control);
+
+ cal_table = e_tasks_get_calendar_table (tasks);
+ etable = e_calendar_table_get_table (cal_table);
+ n_selected = e_table_selected_count (etable);
+
+ sensitize_commands (tasks, control, n_selected);
+
bonobo_ui_component_thaw (uic, NULL);
}
static void
-tasks_control_deactivate (BonoboControl *control)
+tasks_control_deactivate (BonoboControl *control, ETasks *tasks)
{
BonoboUIComponent *uic = bonobo_control_get_ui_component (control);
g_assert (uic != NULL);
+ /* Stop monitoring the "selection_changed" signal */
+ gtk_signal_disconnect_by_data (GTK_OBJECT (tasks), control);
+
bonobo_ui_component_rm (uic, "/", NULL);
bonobo_ui_component_unset_container (uic);
}