diff options
author | Chris Toshok <toshok@ximian.com> | 2001-05-18 07:30:57 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2001-05-18 07:30:57 +0800 |
commit | bb0671f820227cd6759c5b77e678c87ff24af99a (patch) | |
tree | 3a00d31e02aaf352a35807d19f4276959bbe4111 /addressbook/gui/widgets/e-addressbook-view.c | |
parent | e435c042d08e5b3a46889bd7fafd1ef0f28bc734 (diff) | |
download | gsoc2013-evolution-bb0671f820227cd6759c5b77e678c87ff24af99a.tar gsoc2013-evolution-bb0671f820227cd6759c5b77e678c87ff24af99a.tar.gz gsoc2013-evolution-bb0671f820227cd6759c5b77e678c87ff24af99a.tar.bz2 gsoc2013-evolution-bb0671f820227cd6759c5b77e678c87ff24af99a.tar.lz gsoc2013-evolution-bb0671f820227cd6759c5b77e678c87ff24af99a.tar.xz gsoc2013-evolution-bb0671f820227cd6759c5b77e678c87ff24af99a.tar.zst gsoc2013-evolution-bb0671f820227cd6759c5b77e678c87ff24af99a.zip |
add our selection_change signal. (e_minicard_view_widget_realize): connect
2001-05-17 Chris Toshok <toshok@ximian.com>
* gui/widgets/e-minicard-view-widget.c
(e_minicard_view_widget_class_init): add our selection_change
signal.
(e_minicard_view_widget_realize): connect to the ESelectionModel's
selection_changed signal.
(e_minicard_view_widget_selected_count): new function.
(selection_change): new function - emit our "selection_change"
signal.
* gui/widgets/e-minicard-view-widget.h (struct
_EMinicardViewWidgetClass): add selection_change signal. also,
add prototype for e_minicard_view_widget_selected_count. *
gui/widgets/e-addressbook-view.c
(e_addressbook_view_class_init): add our command_state_change
signal.
(e_addressbook_view_init): connect to the writable_status signal
on the EAddressbookModel.
(minicard_selection_change): new function - calls
command_state_change.
(create_minicard_view): connect to selection_change on the
minicard_view so we know when to update command state.
(table_selection_change): new function - calls
command_state_change.
(writable_status): new function - calls command_state_change.
(command_state_change): new function - emits our
"command_state_change" signal.
(create_table_view): connect to the selection_change signal so we
know to update the command state.
(change_view_type): update the command state every time we change
view types.
(e_addressbook_view_can_create): new function.
(e_addressbook_view_can_print): new function.
(e_addressbook_view_can_delete): new function.
(e_addressbook_view_can_stop): new function.
* gui/widgets/e-addressbook-view.h (struct
_EAddressbookViewClass): add command_state_change signal, and
prototypes of functions the component can use to test the state of
commands.
* gui/widgets/e-addressbook-model.c (addressbook_destroy): unlink
the writable_status signal on the EBook.
(writable_status): new function.
(e_addressbook_model_class_init): add our writable_status signal.
(e_addressbook_model_init): init writable_status_id.
(e_addressbook_model_set_arg): unlink the writable_status signal
on the old EBook, and connect it on the new one.
* gui/widgets/e-addressbook-model.h: add writable_status signal.
* gui/component/addressbook.c (update_command_state): new
function, set the sensitivity of the bonobo commands.
(control_activate): update our command state immediately upon
activating the control.
(addressbook_factory_new_control): register command_state_change
to update the commands.
svn path=/trunk/; revision=9874
Diffstat (limited to 'addressbook/gui/widgets/e-addressbook-view.c')
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index 352d1b4b62..2cc1acd7e4 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -62,6 +62,8 @@ static void e_addressbook_view_destroy (GtkObject *object); static void change_view_type (EAddressbookView *view, EAddressbookViewType view_type); static void status_message (GtkObject *object, const gchar *status, EAddressbookView *eav); +static void writable_status (GtkObject *object, gboolean writable, EAddressbookView *eav); +static void command_state_change (EAddressbookView *eav); static GtkTableClass *parent_class = NULL; @@ -75,6 +77,7 @@ enum { enum { STATUS_MESSAGE, + COMMAND_STATE_CHANGE, LAST_SIGNAL }; @@ -141,6 +144,14 @@ e_addressbook_view_class_init (EAddressbookViewClass *klass) gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); + e_addressbook_view_signals [COMMAND_STATE_CHANGE] = + gtk_signal_new ("command_state_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EAddressbookViewClass, command_state_change), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + gtk_object_class_add_signals (object_class, e_addressbook_view_signals, LAST_SIGNAL); } @@ -156,6 +167,11 @@ e_addressbook_view_init (EAddressbookView *eav) GTK_SIGNAL_FUNC (status_message), eav); + gtk_signal_connect (GTK_OBJECT(eav->model), + "writable_status", + GTK_SIGNAL_FUNC (writable_status), + eav); + eav->editable = FALSE; eav->book = NULL; eav->query = g_strdup("(contains \"x-evolution-any-field\" \"\")"); @@ -321,6 +337,12 @@ create_alphabet (EAddressbookView *view) } static void +minicard_selection_change (EMinicardViewWidget *widget, EAddressbookView *view) +{ + command_state_change (view); +} + +static void create_minicard_view (EAddressbookView *view) { GtkWidget *scrollframe; @@ -337,6 +359,10 @@ create_minicard_view (EAddressbookView *view) adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(e_addressbook_reflow_adapter_new (view->model)); minicard_view = e_minicard_view_widget_new(adapter); + gtk_signal_connect(GTK_OBJECT(minicard_view), "selection_change", + GTK_SIGNAL_FUNC(minicard_selection_change), view); + + view->object = GTK_OBJECT(minicard_view); view->widget = minicard_hbox; @@ -609,6 +635,12 @@ table_right_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EA } static void +table_selection_change(ETableScrolled *table, EAddressbookView *view) +{ + command_state_change (view); +} + +static void table_drag_data_get (ETable *table, int row, int col, @@ -648,6 +680,19 @@ status_message (GtkObject *object, const gchar *status, EAddressbookView *eav) status); } +static void +writable_status (GtkObject *object, gboolean writable, EAddressbookView *eav) +{ + command_state_change (eav); +} + +static void +command_state_change (EAddressbookView *eav) +{ + gtk_signal_emit (GTK_OBJECT (eav), + e_addressbook_view_signals [COMMAND_STATE_CHANGE]); +} + #ifdef JUST_FOR_TRANSLATORS static char *list [] = { N_("* Click here to add a contact *"), @@ -769,6 +814,8 @@ create_table_view (EAddressbookView *view) GTK_SIGNAL_FUNC(table_double_click), view); gtk_signal_connect(GTK_OBJECT(e_table_scrolled_get_table(E_TABLE_SCROLLED(table))), "right_click", GTK_SIGNAL_FUNC(table_right_click), view); + gtk_signal_connect(GTK_OBJECT(e_table_scrolled_get_table(E_TABLE_SCROLLED(table))), "selection_change", + GTK_SIGNAL_FUNC(table_selection_change), view); /* drag & drop signals */ e_table_drag_source_set (E_TABLE(E_TABLE_SCROLLED(table)->table), GDK_BUTTON1_MASK, @@ -816,6 +863,8 @@ change_view_type (EAddressbookView *view, EAddressbookViewType view_type) } view->view_type = view_type; + + command_state_change (view); } static void @@ -1009,3 +1058,45 @@ e_addressbook_view_stop(EAddressbookView *view) { e_addressbook_model_stop (view->model); } + +gboolean +e_addressbook_view_can_create (EAddressbookView *view) +{ + return e_addressbook_model_editable (view->model); +} + +gboolean +e_addressbook_view_can_print (EAddressbookView *view) +{ + switch (view->view_type) { + case E_ADDRESSBOOK_VIEW_TABLE: + return e_table_selected_count (E_TABLE_SCROLLED(view->widget)->table) != 0; + case E_ADDRESSBOOK_VIEW_MINICARD: + return e_minicard_view_widget_selected_count (E_MINICARD_VIEW_WIDGET (view->object)) != 0; + default: + return FALSE; + } +} + +gboolean +e_addressbook_view_can_delete (EAddressbookView *view) +{ + if (!e_addressbook_model_editable (view->model)) + return FALSE; + + switch (view->view_type) { + case E_ADDRESSBOOK_VIEW_TABLE: + return e_table_selected_count (E_TABLE_SCROLLED(view->widget)->table) != 0; + case E_ADDRESSBOOK_VIEW_MINICARD: + return e_minicard_view_widget_selected_count (E_MINICARD_VIEW_WIDGET (view->object)) != 0; + default: + return FALSE; + } +} + +gboolean +e_addressbook_view_can_stop (EAddressbookView *view) +{ + return FALSE; +} + |