📄 abookmemberview.c
字号:
/* addressbook - Address book *abookmemberview.c - * *Authors: YE Nan <nan.ye@orange-ftgroup.com> * ZHAO Liangjing <liangjing.zhao@orange-ftgroup.com> * *This software and associated documentation files (the "Software") *are copyright (C) 2005 LiPS Linux Phone Standards Forum [FranceTelecom] *All Rights Reserved. * *A copyright license is hereby granted for redistribution and use of *the Software in source and binary forms, with or without modification, *provided that the following conditions are met: *- Redistributions of source code must retain the above copyright notice, *this copyright license and the following disclaimer. *- Redistributions in binary form must reproduce the above copyright *notice, this copyright license and the following disclaimer in the *documentation and/or other materials provided with the distribution. *- Neither the name of LiPS nor the names of its Members may be used *to endorse or promote products derived from the Software without *specific prior written permission. * *A patent license for any Necessary Claims owned by Members of LiPS Forum *to make, have made, use, import, offer to sell, lease and sell or otherwise *distribute any implementation compliant with the any specification adopted *by the LiPS Forumcan be obtained from the respective Members on reasonable *and non-discriminatory terms and conditions and under reciprocity, as *regulated in more detail in the Internal Policy of the LiPS Forum. * *THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER, ITS MEMBERS AND CONTRIBUTORS *"AS IS", AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, *THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE *AND NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER, *ITS MEMBERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, *WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *POSSIBILITY OF SUCH DAMAGE. */#include <libintl.h>#include <gtk/gtk.h>#include <gdk/gdkkeysyms.h>#include "gtkautoscrolledwindow.h"#include "abooklistview.h"#include "abookmemberview.h"#include "abookenv.h"#include "abookpicture.h"#define _(x) gettext(x)static void abook_member_view_class_init (ABookMemberViewClass *klass);static void abook_member_view_init (ABookMemberView *view);static void abook_member_view_destroy (GtkObject *object);static GtkViewport *parent_class = NULL;GTypeabook_member_view_get_type (void){ static GType view_type = 0; if (!view_type) { static const GTypeInfo view_info = { sizeof (ABookMemberViewClass), NULL, /* base_init */ NULL, /* base_finalize */ (GClassInitFunc) abook_member_view_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (ABookMemberView), 0, /* n_preallocs */ (GInstanceInitFunc) abook_member_view_init, NULL, }; view_type = g_type_register_static (GTK_TYPE_VIEWPORT, "ABookMemberView", &view_info, 0); } return view_type;}static voidabook_member_view_class_init (ABookMemberViewClass *klass){ GtkObjectClass *object_class; object_class = (GtkObjectClass *) klass; parent_class = g_type_class_peek_parent (klass); object_class->destroy = abook_member_view_destroy; return;}static voidabook_member_view_destroy (GtkObject *object){ ABookMemberView *view = ABOOK_MEMBER_VIEW (object); if (view->uuid) { g_free (view->uuid); view->uuid = NULL; } (*GTK_OBJECT_CLASS (parent_class)->destroy) (object); return;}static voidabook_member_view_hide_cb (GtkWidget *widget, gpointer user_data){ ABookMemberView *view = ABOOK_MEMBER_VIEW (widget); GtkListStore *liststore = NULL; g_print ("%s(): entering\n", __FUNCTION__); liststore = abook_listview_get_model (ABOOK_LISTVIEW (view->member_listview)); gtk_list_store_clear (liststore); gtk_label_set_text (GTK_LABEL (view->name), ""); return;}static voidabook_member_view_init (ABookMemberView *view){ GtkWidget *vbox = NULL; GdkColor white_bg = { 0x00, 0xFFFF, 0xFFFF, 0xFFFF }; gtk_widget_modify_bg (GTK_WIDGET (view), GTK_STATE_NORMAL, &white_bg); view->name = gtk_label_new (NULL); gtk_widget_set_size_request (view->name, 150, 40); gtk_misc_set_alignment (GTK_MISC (view->name), 0.5, 1.0); view->image = gtk_image_new (); gtk_widget_set_size_request (view->image, SIZE_LARGE_W, SIZE_LARGE_H); vbox = gtk_vbox_new (FALSE, 0); if (TRUE) { GtkWidget *hbox = NULL; GtkWidget *lvbox = NULL; GtkWidget *lspace = NULL; lspace = gtk_label_new (NULL); lvbox = gtk_vbox_new (0, FALSE); gtk_box_pack_start (GTK_BOX (lvbox), lspace, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (lvbox), view->name, FALSE, FALSE, 0); hbox = gtk_hbox_new (0, FALSE); gtk_widget_set_size_request (hbox, -1, 80); gtk_box_pack_start (GTK_BOX (hbox), lvbox, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), view->image, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); } view->member_listview = abook_listview_new (); gtk_box_pack_start (GTK_BOX (vbox), view->member_listview, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (view), vbox); g_signal_connect (G_OBJECT (view), "hide", G_CALLBACK (abook_member_view_hide_cb), NULL); return;}GtkWidget *abook_member_view_new (void){ return gtk_widget_new (ABOOK_TYPE_MEMBER_VIEW, NULL);}G_CONST_RETURN gchar *abook_member_view_get_name (const ABookMemberView *view){ return gtk_label_get_text (GTK_LABEL (view->name));}voidabook_member_view_set_name (ABookMemberView *view, const gchar *name){ if (name == NULL) { return; } gtk_label_set_text (GTK_LABEL (view->name), name); return;}voidabook_member_view_set_picture (ABookMemberView *view, const gchar *pic){ GdkPixbuf *pixbuf = NULL; gchar *picpath = NULL; picpath = g_build_filename (abook_env_get_picpath (), pic, NULL); abook_pictures_load (picpath, PIC_LARGE); pixbuf = abook_pictures_find (picpath, PIC_LARGE); gtk_image_set_from_pixbuf (GTK_IMAGE (view->image), pixbuf); g_free (picpath); return;}ABookListView *abook_member_view_get_listview (ABookMemberView *view){ return ABOOK_LISTVIEW (view->member_listview);}voidabook_member_view_set_uid (ABookMemberView *view, const gchar *uidstr){ if (view->uuid) { g_free (view->uuid); view->uuid = NULL; } if (uidstr) { view->uuid = g_strdup (uidstr); } return;}G_CONST_RETURN gchar *abook_member_view_get_uid (ABookMemberView *view){ return view->uuid;}/* vi:ts=2:nowrap:ai:expandtab*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -