*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
static void addressbook_close_clicked (GtkButton *button,
gpointer data);
-static gboolean addressbook_tree_selected (GtkCTree *ctree,
+static void addressbook_tree_selected (GtkCTree *ctree,
GtkCTreeNode *node,
gint column,
gpointer data);
GtkWidget *widget);
#endif
-static void addressbook_set_clist (AddressObject *obj);
+static void addressbook_set_clist (AddressObject *obj,
+ gboolean refresh);
static void addressbook_load_tree (void);
void addressbook_read_file (void);
return FALSE;
}
+/*!
+ *\brief Save Gtk object size to prefs dataset
+ */
+static void addressbook_size_allocate_cb(GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ g_return_if_fail(allocation != NULL);
+
+ prefs_common.addressbookwin_width = allocation->width;
+ prefs_common.addressbookwin_height = allocation->height;
+}
+
/*
* Create the address book widgets. The address book contains two CTree widgets: the
* address index tree on the left and the address list on the right.
gchar *text;
gint i;
+ static GdkGeometry geometry;
+
debug_print("Creating addressbook window...\n");
index_titles[COL_SOURCES] = _("Sources");
/* Address book window */
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), _("Address book"));
- gtk_widget_set_size_request(window, ADDRESSBOOK_WIDTH, ADDRESSBOOK_HEIGHT);
gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
gtk_widget_realize(window);
g_signal_connect(G_OBJECT(window), "delete_event",
G_CALLBACK(addressbook_close), NULL);
+ g_signal_connect(G_OBJECT(window), "size_allocate",
+ G_CALLBACK(addressbook_size_allocate_cb), NULL);
g_signal_connect(G_OBJECT(window), "key_press_event",
G_CALLBACK(key_pressed), NULL);
MANAGE_WINDOW_SIGNALS_CONNECT(window);
hbbox = gtk_hbutton_box_new();
gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END);
gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbbox), 2);
+ gtk_container_set_border_width(GTK_CONTAINER(hbbox), 4);
gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
#if GTK_CHECK_VERSION(2, 6, 0)
AddressTypeControlItem *atci = adapter->atci;
text = atci->displayName;
adapter->treeNode =
- gtk_ctree_insert_node( GTK_CTREE(ctree),
+ gtk_sctree_insert_node( GTK_CTREE(ctree),
NULL, NULL, &text, FOLDER_SPACING,
interfacexpm, interfacexpmmask,
interfacexpm, interfacexpmmask,
addrbook.listSelected = NULL;
address_completion_start(window);
+
+ if (!geometry.min_height) {
+ geometry.min_width = ADDRESSBOOK_WIDTH;
+ geometry.min_height = ADDRESSBOOK_HEIGHT;
+ }
+
+ gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
+ GDK_HINT_MIN_SIZE);
+ gtk_widget_set_size_request(window, prefs_common.addressbookwin_width,
+ prefs_common.addressbookwin_height);
+
gtk_widget_show_all(window);
}
* \param column Column number where selected occurred.
* \param data Pointer to user data.
*/
-static gboolean addressbook_tree_selected(GtkCTree *ctree, GtkCTreeNode *node,
+static void addressbook_tree_selected(GtkCTree *ctree, GtkCTreeNode *node,
gint column, gpointer data)
{
AddressObject *obj = NULL;
addressbook_status_show( "" );
if( addrbook.entry != NULL ) gtk_entry_set_text(GTK_ENTRY(addrbook.entry), "");
- if( addrbook.clist ) gtk_clist_clear( GTK_CLIST(addrbook.clist) );
if( node ) obj = gtk_ctree_node_get_row_data( ctree, node );
- if( obj == NULL ) return FALSE;
-
+ if( obj == NULL ) {
+ addressbook_set_clist(NULL, TRUE);
+ return;
+ }
addrbook.opened = node;
if( obj->type == ADDR_DATASOURCE ) {
static gboolean tVal = TRUE;
ads = ADAPTER_DSOURCE(obj);
- if( ads == NULL ) return FALSE;
+ if( ads == NULL ) return;
ds = ads->dataSource;
- if( ds == NULL ) return FALSE;
+ if( ds == NULL ) return;
if( addrindex_ds_get_modify_flag( ds ) ) {
addrindex_ds_read_data( ds );
}
/* Update address list */
- addressbook_set_clist( obj );
+ g_signal_handlers_block_by_func
+ (G_OBJECT(ctree),
+ G_CALLBACK(addressbook_tree_selected), NULL);
+ addressbook_set_clist( obj, FALSE );
+ g_signal_handlers_unblock_by_func
+ (G_OBJECT(ctree),
+ G_CALLBACK(addressbook_tree_selected), NULL);
/* Setup main menu selections */
addressbook_menubar_set_sensitive( FALSE );
addressbook_list_select_clear();
addressbook_list_menu_setup();
- return FALSE;
+ return;
}
/**
addressbook_menubar_set_sensitive( FALSE );
if( gtk_clist_get_selection_info( clist, event->x, event->y, &row, &column ) ) {
- gtk_clist_select_row( clist, row, column );
-
gtkut_clist_set_focus_row(clist, row);
obj = gtk_clist_get_row_data( clist, row );
}
if( ! iface->readOnly ) {
canEdit = TRUE;
canDelete = TRUE;
- menu_set_sensitive( addrbook.tree_factory, "/New Address", TRUE );
+ menu_set_sensitive( addrbook.list_factory, "/New Address", TRUE );
gtk_widget_set_sensitive( addrbook.reg_btn, TRUE );
}
}
GdkEventButton *event,
gpointer data)
{
- gtk_sctree_select( GTK_SCTREE(addrbook.ctree), addrbook.opened);
-
gtkut_ctree_set_focus_row(GTK_CTREE(addrbook.ctree), addrbook.opened);
return FALSE;
}
addrbook.treeSelected, ds, folder, ADDR_ITEM_FOLDER );
gtk_ctree_expand( ctree, addrbook.treeSelected );
if( addrbook.treeSelected == addrbook.opened )
- addressbook_set_clist(obj);
+ addressbook_set_clist(obj, TRUE);
}
}
nn = addressbook_node_add_group( addrbook.treeSelected, ds, group );
gtk_ctree_expand( ctree, addrbook.treeSelected );
if( addrbook.treeSelected == addrbook.opened )
- addressbook_set_clist(obj);
+ addressbook_set_clist(obj, TRUE);
}
}
gtk_ctree_get_node_info(ctree, node, text, &spacing,
&pix_cl, &mask_cl, &pix_op, &mask_op,
&is_leaf, &expanded);
- gtk_ctree_set_node_info(ctree, node, name, spacing,
+ gtk_sctree_set_node_info(ctree, node, name, spacing,
pix_cl, mask_cl, pix_op, mask_op,
is_leaf, expanded);
}
}
text[COL_ADDRESS] = email->address;
text[COL_REMARKS] = email->remarks;
- nodeEMail = gtk_ctree_insert_node(
+ nodeEMail = gtk_sctree_insert_node(
clist, NULL, NULL,
text, FOLDER_SPACING,
atci->iconXpm, atci->maskXpm,
else {
text[COL_NAME] = ADDRITEM_NAME(person);
}
- nodePerson = gtk_ctree_insert_node(
+ nodePerson = gtk_sctree_insert_node(
clist, NULL, NULL,
text, FOLDER_SPACING,
atci->iconXpm, atci->maskXpm,
else {
/* Subsequent email is a child node of person */
text[COL_NAME] = ADDRITEM_NAME(email);
- nodeEMail = gtk_ctree_insert_node(
+ nodeEMail = gtk_sctree_insert_node(
clist, nodePerson, NULL,
text, FOLDER_SPACING,
atciMail->iconXpm, atciMail->maskXpm,
text[COL_NAME] = ADDRITEM_NAME(person);
text[COL_ADDRESS] = NULL;
text[COL_REMARKS] = NULL;
- nodePerson = gtk_ctree_insert_node(
+ nodePerson = gtk_sctree_insert_node(
clist, NULL, NULL,
text, FOLDER_SPACING,
atci->iconXpm, atci->maskXpm,
text[COL_NAME] = ADDRITEM_NAME(group);
text[COL_ADDRESS] = NULL;
text[COL_REMARKS] = NULL;
- nodeGroup = gtk_ctree_insert_node(clist, NULL, NULL,
+ nodeGroup = gtk_sctree_insert_node(clist, NULL, NULL,
text, FOLDER_SPACING,
atci->iconXpm, atci->maskXpm,
atci->iconXpmOpen, atci->maskXpmOpen,
* Load address list widget with children of specified object.
* \param obj Parent object to be loaded.
*/
-static void addressbook_set_clist( AddressObject *obj ) {
+static void addressbook_set_clist( AddressObject *obj, gboolean refresh ) {
GtkCTree *ctreelist = GTK_CTREE(addrbook.clist);
GtkCList *clist = GTK_CLIST(addrbook.clist);
AddressDataSource *ds = NULL;
AdapterDSource *ads = NULL;
+ static AddressObject *last_obj = NULL;
+
+ if (obj == last_obj && !refresh)
+ return;
+ last_obj = obj;
if( obj == NULL ) {
gtk_clist_clear(clist);
return;
/* Add object to tree */
gchar **name;
name = &obj->name;
- added = gtk_ctree_insert_node( ctree, node, NULL, name, FOLDER_SPACING,
+ added = gtk_sctree_insert_node( ctree, node, NULL, name, FOLDER_SPACING,
atci->iconXpm, atci->maskXpm, atci->iconXpmOpen, atci->maskXpmOpen,
atci->treeLeaf, atci->treeExpand );
gtk_ctree_node_set_row_data_full( ctree, added, obj,
ADDRESS_OBJECT_NAME(adapter) = g_strdup( ADDRITEM_NAME(itemGroup) );
adapter->itemGroup = itemGroup;
- newNode = gtk_ctree_insert_node( ctree, node, NULL, name, FOLDER_SPACING,
+ newNode = gtk_sctree_insert_node( ctree, node, NULL, name, FOLDER_SPACING,
atci->iconXpm, atci->maskXpm, atci->iconXpm, atci->maskXpm,
atci->treeLeaf, atci->treeExpand );
gtk_ctree_node_set_row_data_full( ctree, newNode, adapter,
adapter->itemFolder = itemFolder;
name = ADDRITEM_NAME(itemFolder);
- newNode = gtk_ctree_insert_node( ctree, node, NULL, &name, FOLDER_SPACING,
+ newNode = gtk_sctree_insert_node( ctree, node, NULL, &name, FOLDER_SPACING,
atci->iconXpm, atci->maskXpm, atci->iconXpm, atci->maskXpm,
atci->treeLeaf, atci->treeExpand );
if( newNode ) {
ctree = GTK_CTREE(addrbook.ctree);
obj = gtk_ctree_node_get_row_data( ctree, addrbook.treeSelected );
if( obj == NULL ) return;
- addressbook_set_clist( obj );
+ addressbook_set_clist( obj, TRUE );
}
/**