[evolution-patches] Patch to make Name Selector dialog intuitive (libedataserverui)
- From: Vivek Jain <jvivek novell com>
- To: evo-patches <evolution-patches lists ximian com>
- Subject: [evolution-patches] Patch to make Name Selector dialog intuitive (libedataserverui)
- Date: Fri, 22 Jul 2005 12:22:44 +0530
hi,
This patch "tries" to make Name Selector dialog more intuitive. It
provides the option for removing a selected entry as well. Though I
myself have a feeling its little bit too ugly to have six buttons there
(when invoked from composer) but guess some users would prefer it that
way. Please gimme some ideas if you agree with me there.
And of course in code, if something is not taken care of.
Thanks,
Vivek Jain
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserverui/ChangeLog,v
retrieving revision 1.55
diff -u -p -r1.55 ChangeLog
--- ChangeLog 19 Jul 2005 10:19:41 -0000 1.55
+++ ChangeLog 22 Jul 2005 06:46:02 -0000
@@ -1,3 +1,16 @@
+2005-07-22 Vivek Jain <jvivek novell com>
+
+ * e-name-selector-dialog.c: "Section" structure has two new members
+ label and remove button
+ (add_section): set these new members properly
+ add a callback on the changed signal of htktreeview in section
+ Have new structure SelData to give us the selection data in callback
+ (destination_key_press) : moved actual code to new local function
+ (remove_selection).
+ (selection_changed):
+ (remove_button clicked): new functions to get the entry back from the
+ destination store and making sure UI is consistent
+
2005-07-07 S.Antony Vincent Pandian <santony gmail com>
* e-destination-store.c (e_destination_store_list_destinations):
Index: e-name-selector-dialog.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserverui/e-name-selector-dialog.c,v
retrieving revision 1.17
diff -u -p -r1.17 e-name-selector-dialog.c
--- e-name-selector-dialog.c 11 Jul 2005 08:25:32 -0000 1.17
+++ e-name-selector-dialog.c 22 Jul 2005 06:46:05 -0000
@@ -43,11 +43,19 @@ typedef struct {
gchar *name;
GtkBox *section_box;
+ GtkLabel *label;
GtkButton *transfer_button;
+ GtkButton *remove_button;
GtkTreeView *destination_view;
}
Section;
+typedef struct {
+ GtkTreeView *view;
+ GtkButton *button;
+ ENameSelectorDialog *dlg_ptr;
+} SelData;
+
static ESource *find_first_source (ESourceList *source_list);
static void search_changed (ENameSelectorDialog *name_selector_dialog);
static void source_selected (ENameSelectorDialog *name_selector_dialog, ESource *source);
@@ -58,6 +66,7 @@ static void contact_activated
static void destination_activated (ENameSelectorDialog *name_selector_dialog, GtkTreePath *path,
GtkTreeViewColumn *column, GtkTreeView *tree_view);
static gboolean destination_key_press (ENameSelectorDialog *name_selector_dialog, GdkEventKey *event, GtkTreeView *tree_view);
+static void remove_button_clicked (GtkButton *button, SelData *data);
static void remove_books (ENameSelectorDialog *name_selector_dialog);
static void contact_column_formatter (GtkTreeViewColumn *column, GtkCellRenderer *cell,
GtkTreeModel *model, GtkTreeIter *iter,
@@ -402,6 +411,17 @@ find_section_by_name (ENameSelectorDialo
return -1;
}
+static void
+selection_changed (GtkTreeSelection *selection, SelData *data)
+{
+ GtkTreeSelection *contact_selection;
+ gboolean have_selection;
+
+ contact_selection = gtk_tree_view_get_selection (data->view);
+ have_selection = gtk_tree_selection_get_selected (contact_selection, NULL, NULL);
+ gtk_widget_set_sensitive (GTK_WIDGET (data->button), have_selection);
+}
+
static gint
add_section (ENameSelectorDialog *name_selector_dialog,
const gchar *name, const gchar *pretty_name, EDestinationStore *destination_store)
@@ -411,6 +431,9 @@ add_section (ENameSelectorDialog *name_s
GtkCellRenderer *cell_renderer;
GtkWidget *widget;
gchar *text;
+ GtkBox *vbox, *hbox;
+ SelData *data;
+ GtkTreeSelection *selection;
g_assert (name != NULL);
g_assert (pretty_name != NULL);
@@ -420,20 +443,22 @@ add_section (ENameSelectorDialog *name_s
section.name = g_strdup (name);
section.section_box = GTK_BOX (gtk_hbox_new (FALSE, 12));
- section.transfer_button = GTK_BUTTON (gtk_button_new_with_mnemonic (pretty_name));
+ section.label = GTK_LABEL (gtk_label_new (pretty_name));
+ section.transfer_button = GTK_BUTTON (gtk_button_new_with_mnemonic ("_Add->"));
+ section.remove_button = GTK_BUTTON (gtk_button_new_with_mnemonic ("<-_Remove"));
section.destination_view = GTK_TREE_VIEW (gtk_tree_view_new ());
- if (pango_parse_markup (pretty_name, -1, '_', NULL,
- &text, NULL, NULL)) {
- atk_object_set_name (gtk_widget_get_accessible (
- GTK_WIDGET (section.destination_view)), text);
- g_free (text);
- }
-
/* Set up transfer button */
g_signal_connect_swapped (section.transfer_button, "clicked",
G_CALLBACK (transfer_button_clicked), name_selector_dialog);
-
+
+ /*data for the remove callback*/
+ data = g_malloc0(sizeof(SelData));
+ data->view = section.destination_view;
+ data->dlg_ptr = name_selector_dialog;
+ g_signal_connect(section.remove_button, "clicked",
+ G_CALLBACK (remove_button_clicked), data);
+
/* Set up view */
column = gtk_tree_view_column_new ();
cell_renderer = GTK_CELL_RENDERER (gtk_cell_renderer_text_new ());
@@ -446,17 +471,42 @@ add_section (ENameSelectorDialog *name_s
gtk_tree_view_set_model (section.destination_view, GTK_TREE_MODEL (destination_store));
/* Pack button (in an alignment) */
+ vbox = (GtkBox *)gtk_vbox_new (FALSE, 0);
widget = gtk_alignment_new (0.5, 0.0, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (section.transfer_button));
- gtk_box_pack_start (section.section_box, widget, FALSE, TRUE, 0);
+ gtk_box_pack_start (vbox, widget, FALSE, TRUE, 6);
gtk_size_group_add_widget (name_selector_dialog->button_size_group, GTK_WIDGET (section.transfer_button));
+
+ widget = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+ gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (section.remove_button));
+ gtk_box_pack_start (vbox, widget, FALSE, TRUE, 0);
+ gtk_size_group_add_widget (name_selector_dialog->button_size_group, GTK_WIDGET (section.remove_button));
+ gtk_widget_set_sensitive (GTK_WIDGET (section.remove_button), FALSE);
+ hbox = (GtkBox *)gtk_hbox_new (FALSE, 0);
+ gtk_box_pack_start (hbox, GTK_WIDGET (vbox), FALSE, FALSE, 12);
+ vbox = (GtkBox *)gtk_vbox_new (FALSE, 0);
+
+ widget = gtk_alignment_new (0.5, 0.0, 0.0, 0.0);
+ gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (section.label));
+ gtk_box_pack_start (vbox, widget, FALSE, TRUE, 0);
/* Pack view (in a scrolled window) */
widget = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (section.destination_view));
- gtk_box_pack_start (section.section_box, widget, TRUE, TRUE, 0);
+ gtk_box_pack_start (hbox, widget, TRUE, TRUE, 0);
+ gtk_box_pack_start (vbox, GTK_WIDGET (hbox), TRUE, TRUE, 0);
+ gtk_box_pack_start (section.section_box, GTK_WIDGET (vbox), TRUE, TRUE, 0);
+
+ /*data for 'changed' callback*/
+ data = g_malloc0(sizeof(SelData));
+ data->view = section.destination_view;
+ data->button = section.remove_button;
+ selection = gtk_tree_view_get_selection(section.destination_view);
+ g_signal_connect(selection, "changed",
+ G_CALLBACK (selection_changed), data);
+
g_signal_connect_swapped (section.destination_view, "row-activated",
G_CALLBACK (destination_activated), name_selector_dialog);
g_signal_connect_swapped (section.destination_view, "key-press-event",
@@ -671,8 +721,7 @@ destination_activated (ENameSelectorDial
}
static gboolean
-destination_key_press (ENameSelectorDialog *name_selector_dialog,
- GdkEventKey *event, GtkTreeView *tree_view)
+remove_selection (ENameSelectorDialog *name_selector_dialog, GtkTreeView *tree_view)
{
gint section_index;
EDestinationStore *destination_store;
@@ -680,10 +729,6 @@ destination_key_press (ENameSelectorDial
Section *section;
GtkTreeIter iter;
- /* we only care about DEL key */
- if (event->keyval != GDK_Delete)
- return FALSE;
-
section_index = find_section_by_tree_view (name_selector_dialog, tree_view);
if (section_index < 0) {
g_warning ("ENameSelectorDialog got key press from unknown view!");
@@ -706,6 +751,29 @@ destination_key_press (ENameSelectorDial
e_destination_store_remove_destination (destination_store, destination);
return TRUE;
+}
+
+static void
+remove_button_clicked (GtkButton *button, SelData *data)
+{
+ GtkTreeView *view;
+ ENameSelectorDialog *name_selector_dialog;
+
+ view = data->view;
+ name_selector_dialog = data->dlg_ptr;
+ remove_selection (name_selector_dialog, view);
+}
+
+static gboolean
+destination_key_press (ENameSelectorDialog *name_selector_dialog,
+ GdkEventKey *event, GtkTreeView *tree_view)
+{
+
+ /* we only care about DEL key */
+ if (event->keyval != GDK_Delete)
+ return FALSE;
+ return remove_selection (name_selector_dialog, tree_view);
+
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]