📄 abookviewcellimg.c
字号:
/* addressbook - Address book *abookviewcellimg.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 <stdio.h>#include <stdlib.h>#include <glib.h>#include <gtk/gtk.h>#include "abookviewcell.h"#include "abookviewcellimg.h"#include "abookpicture.h"#include "abookenv.h"static void abook_view_cell_image_class_init (ABookViewCellImageClass *klass);static void abook_view_cell_image_init (ABookViewCellImage *view);static void abook_view_cell_image_destroy (GtkObject *object);static void abook_view_cell_image_set_value (ABookViewCell *cell, const gchar *val);static G_CONST_RETURN gchar *abook_view_cell_image_get_value (ABookViewCell * cell);static ABookViewCellStdClass *parent_class = NULL;GTypeabook_view_cell_image_get_type (void){ static GType cell_type = 0; if (!cell_type) { static const GTypeInfo cell_info = { sizeof (ABookViewCellImageClass), NULL, /* base_init */ NULL, /* base_finalize */ (GClassInitFunc) abook_view_cell_image_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (ABookViewCellImage), 0, /* n_preallocs */ (GInstanceInitFunc) abook_view_cell_image_init, NULL, }; cell_type = g_type_register_static (ABOOK_TYPE_VIEW_CELL_STD, "ABookViewCellImage", &cell_info, 0); } return cell_type;}static voidabook_view_cell_image_class_init (ABookViewCellImageClass *klass){ GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); parent_class = g_type_class_peek_parent (klass); object_class->destroy = abook_view_cell_image_destroy; ABOOK_VIEW_CELL_CLASS (klass)->set_value = abook_view_cell_image_set_value; ABOOK_VIEW_CELL_CLASS (klass)->get_value = abook_view_cell_image_get_value; return;}static voidabook_view_cell_image_destroy (GtkObject *object){ (*GTK_OBJECT_CLASS (parent_class)->destroy) (object); return;}static gbooleanabook_view_cell_image_entry_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, gpointer user_data){ ABookViewCellStd *cell_std = ABOOK_VIEW_CELL_STD (user_data); ABookViewCellImage *cell_image = ABOOK_VIEW_CELL_IMAGE (user_data); if (cell_image->image) { GdkPixbuf *pixbuf = NULL; gchar *picpath = NULL; picpath = g_build_filename (abook_env_get_picpath (), gtk_entry_get_text (GTK_ENTRY (cell_std->entry)), NULL); abook_pictures_load (picpath, PIC_LARGE); pixbuf = abook_pictures_find (picpath, PIC_LARGE); if (pixbuf) { gtk_image_set_from_pixbuf (GTK_IMAGE (cell_image->image), pixbuf); } g_free (picpath); } return FALSE;}static voidabook_view_cell_image_init (ABookViewCellImage *cell){ cell->image = NULL; g_signal_connect (G_OBJECT (ABOOK_VIEW_CELL_STD (cell)->entry), "focus-out-event", G_CALLBACK (abook_view_cell_image_entry_focus_out_cb), (gpointer) cell); return;}GtkWidget *abook_view_cell_image_new (const gchar *label){ GtkWidget *widget = NULL; widget = gtk_widget_new (ABOOK_TYPE_VIEW_CELL_IMAGE, NULL); if (label) { ABookViewCellStd *cell = ABOOK_VIEW_CELL_STD (widget); gtk_label_set_markup (GTK_LABEL (cell->label), label); } return widget;}static voidabook_view_cell_image_set_value (ABookViewCell *cell, const gchar *val){ ABookViewCellStd *cell_std = ABOOK_VIEW_CELL_STD (cell); ABookViewCellImage *cell_image = ABOOK_VIEW_CELL_IMAGE (cell); g_print ("%s(): entering, [%s]\n", __FUNCTION__, val); gtk_entry_set_text (GTK_ENTRY (cell_std->entry), val); if (cell_image->image) { GdkPixbuf *pixbuf = NULL; gchar *picpath = NULL; picpath = g_build_filename (abook_env_get_picpath (), gtk_entry_get_text (GTK_ENTRY (cell_std->entry)), NULL); abook_pictures_load (picpath, PIC_LARGE); pixbuf = abook_pictures_find (picpath, PIC_LARGE); if (pixbuf) { gtk_image_set_from_pixbuf (GTK_IMAGE (cell_image->image), pixbuf); } g_free (picpath); } return;}static G_CONST_RETURN gchar *abook_view_cell_image_get_value (ABookViewCell *cell){ ABookViewCellStd *cell_std = ABOOK_VIEW_CELL_STD (cell); const gchar *value = NULL; value = gtk_entry_get_text (GTK_ENTRY (cell_std->entry)); return value;}GtkWidget *abook_view_cell_image_set_buddy (ABookViewCellImage *cell, GtkWidget *image){ GtkWidget *old_image = NULL; if (cell->image) { old_image = cell->image; } cell->image = image; return old_image;}GtkWidget *abook_view_cell_image_get_buddy (ABookViewCellImage *cell){ return cell->image;}/* vi:ts=2:nowrap:ai:expandtab*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -