*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
#ifdef HAVE_CONFIG_H
#include <gtk/gtkentry.h>
#include <gtk/gtktable.h>
+#include "alertpanel.h"
#include "mgutils.h"
#include "addressbook.h"
#include "addressitem.h"
#include "addrbook.h"
#include "manage_window.h"
#include "gtkutils.h"
+#include "filesel.h"
#include "codeconv.h"
#include "editaddress.h"
-
+#include "editaddress_other_attributes_ldap.h"
#include "prefs_common.h"
-
-static struct _PersonEdit_dlg {
- GtkWidget *container;
- GtkWidget *notebook;
- GtkWidget *ok_btn;
- GtkWidget *cancel_btn;
- GtkWidget *statusbar; /* used when prefs_common.addressbook_use_editaddress_dialog is TRUE */
- GtkWidget *title; /* used when prefs_common.addressbook_use_editaddress_dialog is FALSE */
- gint status_cid;
-
- /* User data tab */
- GtkWidget *entry_name;
- GtkWidget *entry_first;
- GtkWidget *entry_last;
- GtkWidget *entry_nick;
-
- /* EMail data tab */
- GtkWidget *entry_email;
- GtkWidget *entry_alias;
- GtkWidget *entry_remarks;
- GtkWidget *clist_email;
- GtkWidget *email_up;
- GtkWidget *email_down;
- GtkWidget *email_del;
- GtkWidget *email_mod;
- GtkWidget *email_add;
-
- /* Attribute data tab */
- GtkWidget *entry_atname;
- GtkWidget *entry_atvalue;
- GtkWidget *clist_attrib;
- GtkWidget *attrib_add;
- GtkWidget *attrib_del;
- GtkWidget *attrib_mod;
-
- gint rowIndEMail;
- gint rowIndAttrib;
- gboolean editNew;
- gboolean read_only;
-} personeditdlg;
+#include "menu.h"
/* transient data */
+static struct _PersonEdit_dlg personeditdlg;
static AddressBookFile *current_abf = NULL;
static ItemPerson *current_person = NULL;
static ItemFolder *current_parent_folder = NULL;
#define EDITPERSON_WIDTH 520
#define EDITPERSON_HEIGHT 320
-#define EMAIL_N_COLS 3
-#define EMAIL_COL_WIDTH_EMAIL 180
-#define EMAIL_COL_WIDTH_ALIAS 80
+#ifndef MAEMO
+# define EMAIL_N_COLS 3
+# define EMAIL_COL_WIDTH_EMAIL 180
+# define EMAIL_COL_WIDTH_ALIAS 80
+#else
+# define EMAIL_N_COLS 1
+# define EMAIL_COL_WIDTH_EMAIL 130
+# define EMAIL_COL_WIDTH_ALIAS 130
+#endif
-#define ATTRIB_N_COLS 2
-#define ATTRIB_COL_WIDTH_NAME 120
-#define ATTRIB_COL_WIDTH_VALUE 180
+#ifndef MAEMO
+# define ATTRIB_N_COLS 2
+# define ATTRIB_COL_WIDTH_NAME 240
+# define ATTRIB_COL_WIDTH_VALUE 0
+#else
+# define ATTRIB_N_COLS 2
+# define ATTRIB_COL_WIDTH_NAME 120
+# define ATTRIB_COL_WIDTH_VALUE 120
+#endif
#define PAGE_BASIC 0
#define PAGE_EMAIL 1
}
static void edit_person_attrib_clear( gpointer data ) {
- gtk_entry_set_text( GTK_ENTRY(personeditdlg.entry_atname), "" );
- gtk_entry_set_text( GTK_ENTRY(personeditdlg.entry_atvalue), "" );
+ if (!personeditdlg.ldap) {
+ gtk_entry_set_text( GTK_ENTRY(personeditdlg.entry_atname), "" );
+ gtk_entry_set_text( GTK_ENTRY(personeditdlg.entry_atvalue), "" );
+ }
}
static void edit_person_switch_page( GtkNotebook *notebook, GtkNotebookPage *page,
ItemEMail *email = addritem_copyfull_item_email( emorig );
gint row;
text[ EMAIL_COL_EMAIL ] = email->address;
+#ifndef MAEMO
text[ EMAIL_COL_ALIAS ] = email->obj.name;
text[ EMAIL_COL_REMARKS ] = email->remarks;
-
+#endif
row = gtk_clist_append( clist, text );
gtk_clist_set_row_data( clist, row, email );
node = g_list_next( node );
if( ! errFlg ) {
gchar *text[ EMAIL_N_COLS ];
text[ EMAIL_COL_EMAIL ] = email->address;
+#ifndef MAEMO
text[ EMAIL_COL_ALIAS ] = email->obj.name;
text[ EMAIL_COL_REMARKS ] = email->remarks;
-
+#endif
row = gtk_clist_insert( clist, 1 + row, text );
gtk_clist_set_row_data( clist, row, email );
gtk_clist_select_row( clist, row, 0 );
UserAttribute *atorig = ( UserAttribute * ) node->data;
UserAttribute *attrib = addritem_copy_attribute( atorig );
gint row;
+ debug_print("name: %s value: %s\n", attrib->name, attrib->value);
text[ ATTRIB_COL_NAME ] = attrib->name;
text[ ATTRIB_COL_VALUE ] = attrib->value;
static void edit_person_attrib_list_selected( GtkCList *clist, gint row, gint column, GdkEvent *event, gpointer data ) {
UserAttribute *attrib = gtk_clist_get_row_data( clist, row );
- if( attrib && !personeditdlg.read_only) {
+ if( attrib && !personeditdlg.read_only && !personeditdlg.ldap ) {
gtk_entry_set_text( GTK_ENTRY(personeditdlg.entry_atname), attrib->name );
gtk_entry_set_text( GTK_ENTRY(personeditdlg.entry_atvalue), attrib->value );
gtk_widget_set_sensitive(personeditdlg.attrib_del, TRUE);
personeditdlg.rowIndAttrib = -1 + row;
}
- if (!personeditdlg.read_only)
+ if (!personeditdlg.read_only && !personeditdlg.ldap)
gtk_widget_set_sensitive(personeditdlg.attrib_del, gtk_clist_get_row_data(clist, 0) != NULL);
edit_person_status_show( NULL );
attrib = edit_person_attrib_edit( &errFlg, NULL );
if( ! errFlg ) {
- gchar *text[ EMAIL_N_COLS ];
+ gchar *text[ ATTRIB_N_COLS ];
text[ ATTRIB_COL_NAME ] = attrib->name;
text[ ATTRIB_COL_VALUE ] = attrib->value;
GtkWidget *cancel_btn;
vbox = gtk_vbox_new(FALSE, 4);
- /* gtk_container_set_border_width(GTK_CONTAINER(vbox), BORDER_WIDTH); */
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), BORDER_WIDTH);
gtk_widget_show(vbox);
gtk_container_add(GTK_CONTAINER(container), vbox);
gtk_widget_hide( personeditdlg.container );
}
+static void addressbook_edit_person_unset_picture (void *obj, guint action, void *data)
+{
+ GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 48, 48);
+ gdk_pixbuf_fill(pixbuf, 0xffffff00);
+ personeditdlg.picture_set = FALSE;
+ gtk_image_set_from_pixbuf(GTK_IMAGE(personeditdlg.image), pixbuf);
+ g_object_unref(pixbuf);
+}
+
+static GtkItemFactoryEntry editaddr_popup_entries[] =
+{
+ {N_("/_Unset picture"), NULL, addressbook_edit_person_unset_picture, 0, NULL},
+};
+
+static void addressbook_edit_person_set_picture(GtkWidget *widget,
+ GdkEventButton *event, gpointer data)
+{
+ GError *error = NULL;
+ gchar *filename;
+ int width, height, scalewidth, scaleheight;
+
+ if (event->button == 1) {
+ if ( (filename = filesel_select_file_open(_("Choose a picture"), NULL)) ) {
+ GdkPixbuf *pixbuf = NULL;
+ gdk_pixbuf_get_file_info(filename, &width, &height);
+
+ if ( width > 128 || height > 128 ) {
+ if (width > height) {
+ scaleheight = (height * 128) / width;
+ scalewidth = 128;
+ }
+ else {
+ scalewidth = (width * 128) / height;
+ scaleheight = 128;
+ }
+ pixbuf = gdk_pixbuf_new_from_file_at_scale(filename,
+ scalewidth, scaleheight, TRUE, &error);
+ } else {
+ pixbuf = gdk_pixbuf_new_from_file(filename, &error);
+ }
+ if (error) {
+ alertpanel_error(_("Failed to import image: \n%s"),
+ error->message);
+ g_error_free(error);
+ }
+ personeditdlg.picture_set = TRUE;
+ g_free(filename);
+ gtk_image_set_from_pixbuf(GTK_IMAGE(personeditdlg.image), pixbuf);
+ g_object_unref(pixbuf);
+ }
+ } else {
+ gtk_menu_popup(GTK_MENU(personeditdlg.editaddr_popupmenu),
+ NULL, NULL, NULL, NULL,
+ event->button, event->time);
+ }
+}
+
static void addressbook_edit_person_page_basic( gint pageNum, gchar *pageLbl ) {
GtkWidget *vbox;
+ GtkWidget *hbox;
GtkWidget *table;
GtkWidget *label;
+ GtkWidget *ebox_picture;
+ GtkWidget *frame_picture;
GtkWidget *entry_name;
GtkWidget *entry_fn;
GtkWidget *entry_ln;
GtkWidget *entry_nn;
const gchar *locale;
gint top = 0;
+ gint n_entries;
+ GdkPixbuf *pixbuf;
+ vbox = gtk_vbox_new( FALSE, 20 );
+ hbox = gtk_hbox_new( FALSE, 8 );
- vbox = gtk_vbox_new( FALSE, 8 );
- gtk_widget_show( vbox );
- gtk_container_add( GTK_CONTAINER( personeditdlg.notebook ), vbox );
+ gtk_widget_show( vbox );
+
+ /* User's picture */
+ ebox_picture = gtk_event_box_new();
+ frame_picture = gtk_frame_new("Photo");
+
+ /* Room for a photo */
+ pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 48, 48);
+ gdk_pixbuf_fill(pixbuf, 0xffffff00);
+ personeditdlg.picture_set = FALSE;
+ personeditdlg.image = gtk_image_new_from_pixbuf(pixbuf);
+ g_object_unref(pixbuf);
+
+ gtk_container_add(GTK_CONTAINER(ebox_picture), personeditdlg.image);
+ gtk_container_add(GTK_CONTAINER(frame_picture), ebox_picture);
+ gtk_container_add(GTK_CONTAINER( personeditdlg.notebook ), hbox );
gtk_container_set_border_width( GTK_CONTAINER (vbox), BORDER_WIDTH );
+ gtk_container_set_border_width( GTK_CONTAINER (hbox), BORDER_WIDTH );
label = gtk_label_new_with_mnemonic( pageLbl );
gtk_widget_show( label );
+
+ gtk_box_pack_start(GTK_BOX(hbox), frame_picture, TRUE, TRUE, 0);
+
gtk_notebook_set_tab_label(
GTK_NOTEBOOK( personeditdlg.notebook ),
gtk_notebook_get_nth_page( GTK_NOTEBOOK( personeditdlg.notebook ), pageNum ), label );
+
+ g_signal_connect(G_OBJECT(ebox_picture), "button_press_event",
+ G_CALLBACK(addressbook_edit_person_set_picture), NULL);
- table = gtk_table_new( 4, 3, FALSE);
- gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
- gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
- gtk_table_set_row_spacings(GTK_TABLE(table), 8);
- gtk_table_set_col_spacings(GTK_TABLE(table), 8);
+ n_entries = sizeof(editaddr_popup_entries) /
+ sizeof(editaddr_popup_entries[0]);
+ personeditdlg.editaddr_popupmenu = menu_create_items(editaddr_popup_entries, n_entries,
+ "<EditAddrPopupMenu>", &personeditdlg.editaddr_popupfactory,
+ NULL);
+
+ table = gtk_table_new( 3, 3, FALSE);
#define ATTACH_ROW(text, entry) \
{ \
top++; \
}
+#define ATTACH_HIDDEN_ROW(text, entry) \
+{ \
+ entry = gtk_entry_new(); \
+}
+
+#ifndef MAEMO
ATTACH_ROW(_("Display Name"), entry_name);
+#else
+ ATTACH_HIDDEN_ROW(_("Display Name"), entry_name);
+#endif
locale = conv_get_current_locale();
if (locale &&
(!g_ascii_strncasecmp(locale, "ja", 2) ||
ATTACH_ROW(_("First Name"), entry_fn);
ATTACH_ROW(_("Last Name"), entry_ln);
}
+#ifndef MAEMO
ATTACH_ROW(_("Nickname"), entry_nn);
+#else
+ ATTACH_HIDDEN_ROW(_("Nickname"), entry_nn);
+#endif
#undef ATTACH_ROW
+#undef ATTACH_HIDDEN_ROW
+ gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
+ gtk_box_pack_end(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+ gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
+ gtk_table_set_row_spacings(GTK_TABLE(table), 15);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 8);
gtk_widget_show_all(vbox);
-
personeditdlg.entry_name = entry_name;
personeditdlg.entry_first = entry_fn;
personeditdlg.entry_last = entry_ln;
gint i;
titles[ EMAIL_COL_EMAIL ] = _("Email Address");
+#ifndef MAEMO
titles[ EMAIL_COL_ALIAS ] = _("Alias");
titles[ EMAIL_COL_REMARKS ] = _("Remarks");
-
+#endif
vbox = gtk_vbox_new( FALSE, 8 );
gtk_widget_show( vbox );
gtk_container_add( GTK_CONTAINER( personeditdlg.notebook ), vbox );
gtk_container_set_border_width( GTK_CONTAINER(vboxl), 4 );
clist_swin = gtk_scrolled_window_new( NULL, NULL );
- gtk_container_add( GTK_CONTAINER(vboxl), clist_swin );
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(clist_swin),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
clist = gtk_clist_new_with_titles( EMAIL_N_COLS, titles );
+
gtk_container_add( GTK_CONTAINER(clist_swin), clist );
gtk_clist_set_selection_mode( GTK_CLIST(clist), GTK_SELECTION_BROWSE );
gtk_clist_set_column_width( GTK_CLIST(clist), EMAIL_COL_EMAIL, EMAIL_COL_WIDTH_EMAIL );
/* Data entry area */
table = gtk_table_new( 4, 2, FALSE);
+
+#ifndef MAEMO
+ gtk_container_add( GTK_CONTAINER(vboxl), clist_swin );
+ gtk_box_pack_start(GTK_BOX(vboxl), table, FALSE, FALSE, 0);
+#else
gtk_box_pack_start(GTK_BOX(vboxl), table, FALSE, FALSE, 0);
+ gtk_container_add( GTK_CONTAINER(vboxl), clist_swin );
+ gtk_clist_column_titles_hide(GTK_CLIST(clist));
+#endif
gtk_container_set_border_width( GTK_CONTAINER(table), 4 );
gtk_table_set_row_spacings(GTK_TABLE(table), 4);
gtk_table_set_col_spacings(GTK_TABLE(table), 4);
+ entry_email = gtk_entry_new();
+ entry_alias = gtk_entry_new();
+ entry_remarks = gtk_entry_new();
+
/* First row */
top = 0;
label = gtk_label_new(_("Email Address"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- entry_email = gtk_entry_new();
gtk_table_attach(GTK_TABLE(table), entry_email, 1, 2, top, (top + 1), GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
+#ifndef MAEMO
/* Next row */
++top;
label = gtk_label_new(_("Alias"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- entry_alias = gtk_entry_new();
gtk_table_attach(GTK_TABLE(table), entry_alias, 1, 2, top, (top + 1), GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
/* Next row */
gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- entry_remarks = gtk_entry_new();
gtk_table_attach(GTK_TABLE(table), entry_remarks, 1, 2, top, (top + 1), GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
+#endif
/* Button box */
vboxb = gtk_vbox_new( FALSE, 4 );
/* Buttons */
buttonUp = gtk_button_new_from_stock(GTK_STOCK_GO_UP);
+ buttonDown = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN);
+ buttonDel = gtk_button_new_from_stock(GTK_STOCK_DELETE);
+ buttonMod = gtk_button_new_from_stock(GTK_STOCK_SAVE);
+ buttonAdd = gtk_button_new_from_stock(GTK_STOCK_ADD);
+
+
+#ifndef MAEMO
gtk_container_add( GTK_CONTAINER(vbuttonbox), buttonUp );
- buttonDown = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN);
gtk_container_add( GTK_CONTAINER(vbuttonbox), buttonDown );
-
- buttonDel = gtk_button_new_from_stock(GTK_STOCK_DELETE);
+#endif
gtk_container_add( GTK_CONTAINER(vbuttonbox), buttonDel );
- buttonMod = gtk_button_new_from_stock(GTK_STOCK_SAVE);
gtk_container_add( GTK_CONTAINER(vbuttonbox), buttonMod );
- buttonAdd = gtk_button_new_from_stock(GTK_STOCK_ADD);
gtk_container_add( GTK_CONTAINER(vbuttonbox), buttonAdd );
gtk_widget_show_all(vbox);
{
gboolean non_empty = gtk_clist_get_row_data(GTK_CLIST(personeditdlg.clist_attrib), 0) != NULL;
- if (personeditdlg.read_only)
+ if (personeditdlg.read_only || personeditdlg.ldap)
return;
if (gtk_entry_get_text(GTK_ENTRY(personeditdlg.entry_atname)) == NULL
gtk_container_set_border_width( GTK_CONTAINER(vboxl), 4 );
clist_swin = gtk_scrolled_window_new( NULL, NULL );
- gtk_container_add( GTK_CONTAINER(vboxl), clist_swin );
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(clist_swin),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
clist = gtk_clist_new_with_titles( ATTRIB_N_COLS, titles );
gtk_container_add( GTK_CONTAINER(clist_swin), clist );
gtk_clist_set_selection_mode( GTK_CLIST(clist), GTK_SELECTION_BROWSE );
- gtk_clist_set_column_width( GTK_CLIST(clist), ATTRIB_COL_NAME, ATTRIB_COL_WIDTH_NAME );
- gtk_clist_set_column_width( GTK_CLIST(clist), ATTRIB_COL_VALUE, ATTRIB_COL_WIDTH_VALUE );
gtk_clist_set_compare_func( GTK_CLIST(clist), edit_person_attrib_compare_func );
gtk_clist_set_auto_sort( GTK_CLIST(clist), TRUE );
+ gtk_clist_set_column_width( GTK_CLIST(clist), ATTRIB_COL_NAME, ATTRIB_COL_WIDTH_NAME );
+ gtk_clist_set_column_width( GTK_CLIST(clist), ATTRIB_COL_VALUE, ATTRIB_COL_WIDTH_VALUE );
for( i = 0; i < ATTRIB_N_COLS; i++ )
GTK_WIDGET_UNSET_FLAGS(GTK_CLIST(clist)->column[i].button, GTK_CAN_FOCUS);
/* Data entry area */
+#ifndef MAEMO
table = gtk_table_new( 4, 2, FALSE);
+ gtk_container_add( GTK_CONTAINER(vboxl), clist_swin );
gtk_box_pack_start(GTK_BOX(vboxl), table, FALSE, FALSE, 0);
+#else
+ table = gtk_table_new( 2, 4, FALSE);
+ gtk_box_pack_start(GTK_BOX(vboxl), table, FALSE, FALSE, 0);
+ gtk_container_add( GTK_CONTAINER(vboxl), clist_swin );
+ gtk_clist_column_titles_hide(GTK_CLIST(clist));
+#endif
gtk_container_set_border_width( GTK_CONTAINER(table), 4 );
gtk_table_set_row_spacings(GTK_TABLE(table), 4);
gtk_table_set_col_spacings(GTK_TABLE(table), 4);
/* First row */
top = 0;
+#ifndef MAEMO
label = gtk_label_new(_("Name"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
entry_value = gtk_entry_new();
gtk_table_attach(GTK_TABLE(table), entry_value, 1, 2, top, (top + 1), GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
+#else
+ label = gtk_label_new(_("Name"));
+ gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
+ gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+
+ entry_name = gtk_entry_new();
+ gtk_table_attach(GTK_TABLE(table), entry_name, 1, 2, 0, 1, GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
+
+ /* Next row */
+ ++top;
+ label = gtk_label_new(_("Value"));
+ gtk_table_attach(GTK_TABLE(table), label, 2, 3, 0, 1, GTK_FILL, 0, 0, 0);
+ gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+ entry_value = gtk_entry_new();
+ gtk_table_attach(GTK_TABLE(table), entry_value, 3, 4, 0, 1, GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
+#endif
/* Button box */
vboxb = gtk_vbox_new( FALSE, 4 );
gtk_box_pack_start(GTK_BOX(hbox), vboxb, FALSE, FALSE, 2);
addressbook_edit_person_widgetset_create( parent, cancelled );
addressbook_edit_person_page_basic( PAGE_BASIC, _( "_User Data" ) );
addressbook_edit_person_page_email( PAGE_EMAIL, _( "_Email Addresses" ) );
- addressbook_edit_person_page_attrib( PAGE_ATTRIBUTES, _( "O_ther Attributes" ) );
+#ifdef USE_LDAP
+ if (personeditdlg.ldap)
+ addressbook_edit_person_page_attrib_ldap(&personeditdlg, PAGE_ATTRIBUTES, _("O_ther Attributes"));
+ else
+#endif
+ addressbook_edit_person_page_attrib( PAGE_ATTRIBUTES, _( "O_ther Attributes" ) );
gtk_widget_show_all( personeditdlg.container );
}
gtk_widget_set_sensitive(personeditdlg.entry_name, !personeditdlg.read_only);
gtk_widget_set_sensitive(personeditdlg.entry_first, !personeditdlg.read_only);
gtk_widget_set_sensitive(personeditdlg.entry_last, !personeditdlg.read_only);
- gtk_widget_set_sensitive(personeditdlg.entry_nick, !personeditdlg.read_only);
+ gtk_widget_set_sensitive(personeditdlg.entry_nick, !personeditdlg.read_only && !personeditdlg.ldap);
gtk_widget_set_sensitive(personeditdlg.entry_email, !personeditdlg.read_only);
- gtk_widget_set_sensitive(personeditdlg.entry_alias, !personeditdlg.read_only);
- gtk_widget_set_sensitive(personeditdlg.entry_remarks, !personeditdlg.read_only);
+ gtk_widget_set_sensitive(personeditdlg.entry_alias, !personeditdlg.read_only && !personeditdlg.ldap);
+ gtk_widget_set_sensitive(personeditdlg.entry_remarks, !personeditdlg.read_only && !personeditdlg.ldap);
gtk_widget_set_sensitive(personeditdlg.email_up, !personeditdlg.read_only);
gtk_widget_set_sensitive(personeditdlg.email_down, !personeditdlg.read_only);
gtk_widget_set_sensitive(personeditdlg.email_del, !personeditdlg.read_only);
{
GList *listEMail = NULL;
GList *listAttrib = NULL;
+ GError *error;
gchar *cn = NULL;
listEMail = edit_person_build_email_list();
return FALSE;
}
+#ifndef MAEMO
cn = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_name), 0, -1 );
+#else
+ {
+ gchar *first = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_first), 0, -1 );
+ gchar *last = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_last), 0, -1 );
+ cn = g_strdup_printf("%s%s%s", first, (first && last && *first && *last)?" ":"", last);
+ g_free(first);
+ g_free(last);
+ }
+#endif
if( current_person && current_abf ) {
/* Update email/attribute list for existing current_person */
addrbook_update_address_list( current_abf, current_person, listEMail );
listAttrib = NULL;
if( ! cancelled ) {
- /* Set current_person stuff */
+ /* Set current_person stuff */
+
gchar *name;
addritem_person_set_common_name( current_person, cn );
+ if (personeditdlg.picture_set) {
+ GdkPixbuf * pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(personeditdlg.image));
+ name = g_strconcat( get_rc_dir(), G_DIR_SEPARATOR_S, ADDRBOOK_DIR, G_DIR_SEPARATOR_S,
+ ADDRITEM_ID(current_person), ".png", NULL );
+ gdk_pixbuf_save(pixbuf, name, "png", &error, NULL);
+ if (error) {
+ alertpanel_error(_("Failed to save image: \n%s"),
+ error->message);
+ g_error_free(error);
+ }
+ addritem_person_set_picture( current_person, ADDRITEM_ID(current_person) ) ;
+ g_free( name );
+ } else {
+ name = g_strconcat( get_rc_dir(), G_DIR_SEPARATOR_S, ADDRBOOK_DIR, G_DIR_SEPARATOR_S,
+ ADDRITEM_ID(current_person), ".png", NULL );
+ g_unlink(name);
+ g_free(name);
+ }
name = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_first), 0, -1 );
addritem_person_set_first_name( current_person, name );
g_free( name );
* only required for new objects).
* person Person to edit, or NULL for a new person object.
* pgMail If TRUE, E-Mail page will be activated.
-* Return: Edited object, or NULL if cancelled.
-*/
+* Return: Edited object, or NULL if cancelled.*/
ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent_folder, ItemPerson *person,
gboolean pgMail, GtkWidget *parent_container,
void (*post_update_cb) (ItemPerson *person),
gboolean get_focus) {
static gboolean cancelled;
-
+ GError *error = NULL;
+ GdkPixbuf *pixbuf;
/* set transient data */
current_abf = abf;
current_person = person;
current_parent_folder = parent_folder;
edit_person_close_post_update_cb = post_update_cb;
+ personeditdlg.ldap = (abf && abf->type == ADBOOKTYPE_LDAP)? TRUE : FALSE;
- if( !personeditdlg.container )
- addressbook_edit_person_create(parent_container, &cancelled);
+ if( personeditdlg.container ) {
+ gtk_widget_destroy(personeditdlg.container);
+ personeditdlg.container = NULL;
+ }
+ addressbook_edit_person_create(parent_container, &cancelled);
/* typically, get focus when dialog mode is enabled, or when editing a new address */
if( get_focus ) {
gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_nick), "" );
personeditdlg.editNew = FALSE;
- if( person ) {
- if( ADDRITEM_NAME(person) )
+ if( current_person ) {
+ if( ADDRITEM_NAME(current_person) )
gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_name), ADDRITEM_NAME(person) );
- if( person->firstName )
- gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_first), person->firstName );
- if( person->lastName )
- gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_last), person->lastName );
- if( person->nickName )
- gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_nick), person->nickName );
- edit_person_load_email( person );
- edit_person_load_attrib( person );
+
+ if( current_person->picture ) {
+ gchar *filename = g_strconcat( get_rc_dir(), G_DIR_SEPARATOR_S, ADDRBOOK_DIR, G_DIR_SEPARATOR_S,
+ current_person->picture, ".png", NULL );
+ if (is_file_exist(filename)) {
+ pixbuf = gdk_pixbuf_new_from_file(filename, &error);
+ if (error) {
+ debug_print("Failed to import image: \n%s",
+ error->message);
+ g_error_free(error);
+ goto no_img;
+ }
+ personeditdlg.picture_set = TRUE;
+ } else {
+ goto no_img;
+ }
+ g_free(filename);
+ } else {
+no_img:
+ personeditdlg.picture_set = FALSE;
+ pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 48, 48);
+ gdk_pixbuf_fill(pixbuf, 0xffffff00);
+ }
+ gtk_image_set_from_pixbuf(GTK_IMAGE(personeditdlg.image), pixbuf);
+ g_object_unref(pixbuf);
+ pixbuf = NULL;
+
+ if( current_person->firstName )
+ gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_first), current_person->firstName );
+ if( current_person->lastName )
+ gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_last), current_person->lastName );
+ if( current_person->nickName )
+ gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_nick), current_person->nickName );
+ edit_person_load_email( current_person );
+ edit_person_load_attrib( current_person );
+ gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_atvalue), "");
}
else {
personeditdlg.editNew = TRUE;
gtk_clist_select_row( GTK_CLIST(personeditdlg.clist_email), 0, 0 );
gtk_clist_select_row( GTK_CLIST(personeditdlg.clist_attrib), 0, 0 );
edit_person_email_clear( NULL );
- if (person)
+ if (current_person)
edit_person_email_list_selected(GTK_CLIST(personeditdlg.clist_email), 0, 0, NULL, NULL);
edit_person_attrib_clear( NULL );
return NULL;
}
- return person;
+ return current_person;
}
/*