aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/component/select-names/e-select-names.c
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-12-28 11:08:27 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-12-28 11:08:27 +0800
commit2786536d7f25b29b20a41b417896cff810368d85 (patch)
tree3ecdda5c24e1de152937a451a10bc09a5be891ba /addressbook/gui/component/select-names/e-select-names.c
parentb054d4b4e6f7eff593a2ac7c3b40f2d8bb92b82c (diff)
downloadgsoc2013-evolution-2786536d7f25b29b20a41b417896cff810368d85.tar
gsoc2013-evolution-2786536d7f25b29b20a41b417896cff810368d85.tar.gz
gsoc2013-evolution-2786536d7f25b29b20a41b417896cff810368d85.tar.bz2
gsoc2013-evolution-2786536d7f25b29b20a41b417896cff810368d85.tar.lz
gsoc2013-evolution-2786536d7f25b29b20a41b417896cff810368d85.tar.xz
gsoc2013-evolution-2786536d7f25b29b20a41b417896cff810368d85.tar.zst
gsoc2013-evolution-2786536d7f25b29b20a41b417896cff810368d85.zip
When we clean, don't clean the model's last element. This helps keep
2001-12-27 Jon Trowbridge <trow@ximian.com> * gui/component/select-names/e-select-names.c (real_add_address_cb): When we clean, don't clean the model's last element. This helps keep things working properly when we have signal-character separators. (section_right_click_cb): Changed to work properly with our EText-emitted popup signal. (e_select_names_add_section): Use ETexts for the recipient sections, rather than tables. This lets us make them directly editable. (Bug #1721) * gui/component/select-names/e-select-names-popup.c (popup_info_new): Pass in a ESelectNamesTextModel, not a ESelectNamesModel. (e_select_names_popup): Adjust for the new signature for e_select_names_model_text_pos. * gui/component/select-names/e-select-names-manager.c (focus_out_cb): Schedule a cleaning when we focus out. (focus_in_cb): Cancel pending cleaning when we get focus. This helps us avoid bad things happening during the fast focus out/ins that happen when the completion dropdown appears. (completion_handler): Adjust for new signatures of e_select_names_model_text_pos and e_select_names_model_name_pos. (e_select_names_manager_entry_new): Pass in our ESelectNamesTextModel when constructing the ESelectNamesCompletion. (e_select_names_manager_entry_free): Cancel any pending clean-ups. * gui/component/select-names/e-select-names-bonobo.c (entry_get_property_fn): Get the text off of the text model. Which is the only way that really makes sense when you think about it. * gui/component/select-names/e-select-names-completion.c: Added a copy of the associated ESelectNamesTextModel to ESelectNamesCompletionPrivate. This replaces the ESelectNamesModel. (e_select_names_completion_destroy): Unref ->text_model. (e_select_names_completion_handle_request): Pass in our text model's separator info when calling e_select_names_model_text_pos. (e_select_names_completion_new): Pass in the text model as an arg instead of the model, and ref it as needed. * gui/component/select-names/e-select-names-text-model.c (e_select_names_text_model_init): Set separator as either ", " or ",", depending on the value of the EVOLUTION_DISABLE_MAGIC_COMMA environment variable. (e_select_names_text_model_destroy): Free the separator. (changed_cb): Flush our cached text on changed. (e_select_names_text_model_set_source): Use our own changed_cb callback on changed, rather than just connecting up e_text_model_changed. (e_select_names_text_model_set_separator): Added. Lets the separator between recipients be specified. (e_select_names_text_model_get_text): Cache the text we get from calling e_select_names_model_get_textification. (e_select_names_text_model_insert_length): A bunch of small changes to properly support generic separators, rather than (implicit and explicitly) assuming ", ". (e_select_names_text_model_delete): More small tweaks to handle generic separators. (e_select_names_text_model_get_nth_obj): Use new signature when calling e_select_names_model_name_pos, and use our cached text. * gui/component/select-names/e-select-names-model.c (e_select_names_model_destroy): We don't cache the text or addr_text anymore, so no need to free them here. (e_select_names_model_changed): ...and no need to reset our text and addr_text caches here. (e_select_names_model_get_textification): Take a separator as an arg, rather than just using ", ". Also, no caching. (e_select_names_model_get_address_text): Take a separator as an arg, rather than just using ", ". And no caching here either. (e_select_names_model_clean): Add arg that give us control over whether or not the last entry should get cleaned. We need this when using a one-character separator, so that new destinations that get tacked onto the end don't get immediately cleaned away for being empty. (e_select_names_model_name_pos): Take the separator length as an argument, remove implicit assumption of length 2. (e_select_names_model_text_pos): Take the separator length as an argument, remove implicit assumption of length 2.CVS: ---------------------------------------------------------------------- svn path=/trunk/; revision=15221
Diffstat (limited to 'addressbook/gui/component/select-names/e-select-names.c')
-rw-r--r--addressbook/gui/component/select-names/e-select-names.c92
1 files changed, 52 insertions, 40 deletions
diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c
index 1ee8d345a4..095d928a41 100644
--- a/addressbook/gui/component/select-names/e-select-names.c
+++ b/addressbook/gui/component/select-names/e-select-names.c
@@ -42,7 +42,7 @@
#include "e-select-names.h"
#include <addressbook/backend/ebook/e-card-simple.h>
-#include "e-select-names-table-model.h"
+#include "e-select-names-text-model.h"
#include <gal/widgets/e-categories-master-list-combo.h>
#include <gal/widgets/e-unicode.h>
#include <gal/e-text/e-entry.h>
@@ -63,11 +63,12 @@ enum {
};
typedef struct {
- char *title;
- ETableModel *model;
- ESelectNamesModel *source;
- ESelectNames *names;
- GtkWidget *label;
+ char *title;
+ ETableModel *model;
+ ESelectNamesModel *source;
+ ESelectNamesTextModel *text_model;
+ ESelectNames *names;
+ GtkWidget *label;
} ESelectNamesChild;
GtkType
@@ -215,7 +216,7 @@ real_add_address_cb (int model_row, gpointer closure)
e_destination_set_card (dest, card, 0);
e_select_names_model_append (child->source, dest);
- e_select_names_model_clean (child->source);
+ e_select_names_model_clean (child->source, FALSE);
gtk_object_unref(GTK_OBJECT(card));
}
@@ -513,10 +514,11 @@ add_additional_select_names_uris (ESelectNames *e_select_names, CORBA_Environmen
Bonobo_ConfigDatabase config_db;
guint32 num_additional_uris;
int i;
+ gboolean flag;
config_db = addressbook_config_database (ev);
- num_additional_uris = bonobo_config_get_ulong_with_default (config_db, "/Addressbook/additional_select_names_folders/num", 0, ev);
+ num_additional_uris = bonobo_config_get_ulong_with_default (config_db, "/Addressbook/additional_select_names_folders/num", 0, &flag);
for (i = 0; i < num_additional_uris; i ++) {
ESelectNamesFolder *e_folder;
char *config_path;
@@ -775,18 +777,21 @@ button_clicked(GtkWidget *button, ESelectNamesChild *child)
real_add_address(child->names, child);
}
+#if 0
static void
remove_address(ETable *table, int row, int col, GdkEvent *event, ESelectNamesChild *child)
{
e_select_names_model_delete (child->source, row);
}
+#endif
struct _RightClickData {
- ETable *table;
ESelectNamesChild *child;
+ int index;
};
typedef struct _RightClickData RightClickData;
+#if 0
static GSList *selected_rows = NULL;
static void
@@ -805,47 +810,38 @@ selected_rows_foreach_cb (void *row, void *data)
remove_address (NULL, GPOINTER_TO_INT (row), 0, NULL, child);
}
+#endif
static void
remove_cb (GtkWidget *widget, void *data)
{
RightClickData *rcdata = (RightClickData *)data;
- e_select_names_model_freeze (rcdata->child->source);
-
- /* Build a list of selected rows */
- e_table_selected_row_foreach (rcdata->table,
- etable_selection_foreach_cb,
- rcdata->child);
-
- /* Now process the list we made, removing each selected row */
- g_slist_foreach (selected_rows,
- (GFunc)selected_rows_foreach_cb,
- rcdata->child);
-
- e_select_names_model_thaw (rcdata->child->source);
+ e_select_names_model_delete (rcdata->child->source, rcdata->index);
/* Free everything we've created */
g_free (rcdata);
- g_slist_free (selected_rows);
- selected_rows = NULL;
}
static void
-section_right_click_cb (ETable *table, gint row, gint col, GdkEvent *event, ESelectNamesChild *child)
+section_right_click_cb (EText *text, GdkEventButton *ev, gint pos, ESelectNamesChild *child)
{
EPopupMenu right_click_menu[] = {
{ N_("Remove"), NULL,
GTK_SIGNAL_FUNC (remove_cb), NULL, 0 },
{ NULL, NULL, NULL, 0 }
};
+ gint index;
+
+ e_select_names_model_text_pos (child->source, child->text_model->seplen, pos, &index, NULL, NULL);
- RightClickData *rcdata = g_new0 (RightClickData, 1);
- rcdata->table = table;
- rcdata->child = child;
+ if (index != -1) {
+ RightClickData *rcdata = g_new0 (RightClickData, 1);
+ rcdata->index = index;
+ rcdata->child = child;
- e_popup_menu_run (right_click_menu, event, 0, 0,
- rcdata);
+ e_popup_menu_run (right_click_menu, (GdkEvent *)ev, 0, 0, rcdata);
+ }
}
void
@@ -858,8 +854,8 @@ e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id, E
GtkTable *table;
char *label_text;
- ETableModel *model;
- GtkWidget *etable;
+ GtkWidget *sw;
+ GtkWidget *recipient_table;
if (g_hash_table_lookup(e_select_names->children, id)) {
return;
@@ -872,6 +868,12 @@ e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id, E
child->names = e_select_names;
child->title = e_utf8_from_locale_string(_(name));
+ child->text_model = (ESelectNamesTextModel *) e_select_names_text_model_new (source);
+ e_select_names_text_model_set_separator (child->text_model, "\n");
+
+ child->source = source;
+ gtk_object_ref(GTK_OBJECT(child->source));
+
e_select_names->child_count++;
alignment = gtk_alignment_new(0, 0, 1, 0);
@@ -909,27 +911,37 @@ e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id, E
GTK_FILL, GTK_FILL,
0, 0);
- model = e_select_names_table_model_new(source);
- etable = e_table_scrolled_new (model, NULL, SPEC2, NULL);
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ recipient_table = e_entry_new ();
+ gtk_object_set (GTK_OBJECT (recipient_table),
+ "model", child->text_model,
+ "allow_newlines", TRUE,
+ NULL);
+
+ gtk_signal_connect (GTK_OBJECT (recipient_table),
+ "popup",
+ GTK_SIGNAL_FUNC (section_right_click_cb),
+ child);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), recipient_table);
+
+#if 0
gtk_signal_connect(GTK_OBJECT(e_table_scrolled_get_table(E_TABLE_SCROLLED(etable))), "right_click",
GTK_SIGNAL_FUNC(section_right_click_cb), child);
gtk_signal_connect(GTK_OBJECT(e_table_scrolled_get_table(E_TABLE_SCROLLED(etable))), "double_click",
GTK_SIGNAL_FUNC(remove_address), child);
+#endif
- child->model = model;
- child->source = source;
- gtk_object_ref(GTK_OBJECT(child->model));
- gtk_object_ref(GTK_OBJECT(child->source));
gtk_signal_connect (GTK_OBJECT (child->source),
"changed",
GTK_SIGNAL_FUNC (sync_table_and_models),
e_select_names);
- gtk_widget_show(etable);
+ gtk_widget_show_all (sw);
- gtk_table_attach(table, etable,
+ gtk_table_attach(table, sw,
1, 2,
e_select_names->child_count,
e_select_names->child_count + 1,