📄 abookconfirmdialog.c
字号:
/* addressbook - Address book *abookconfirmdialog.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 <ctype.h>#include <gtk/gtk.h>#include <gdk/gdkkeysyms.h>#include "abookconfirmdialog.h"#include "abookpicture.h"#include "abookenv.h"#define _(x) gettext(x)static void abook_confirm_dialog_class_init (ABookConfirmDialogClass *klass);static void abook_confirm_dialog_init (ABookConfirmDialog *dialog);GTypeabook_confirm_dialog_get_type (void){ static GType confirm_dialog_type = 0; if (!confirm_dialog_type) { static const GTypeInfo confirm_dialog_info = { sizeof (ABookConfirmDialogClass), NULL, /* base_init */ NULL, /* base_finalize */ (GClassInitFunc) abook_confirm_dialog_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (ABookConfirmDialog), 0, /* n_preallocs */ (GInstanceInitFunc) abook_confirm_dialog_init, }; confirm_dialog_type = g_type_register_static (GTK_TYPE_DIALOG, "ABookConfirmDialog", &confirm_dialog_info, 0); } return confirm_dialog_type;}static voidabook_confirm_dialog_class_init (ABookConfirmDialogClass *klass){ return;}static voidabook_confirm_dialog_btn_clicked_cb (GtkButton *button, ABookConfirmDialog *dialog){ if (g_strcasecmp (gtk_button_get_label (button), "OK") == 0) { gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); } else if (g_strcasecmp (gtk_button_get_label (button), "Cancel") == 0) { gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL); } return;}static voidabook_confirm_dialog_init (ABookConfirmDialog *dialog){ GtkWidget *hbox = NULL; GtkWidget *vbox = NULL; GtkWidget *button = NULL; GtkWidget *frame = NULL; frame = gtk_frame_new (NULL); vbox = gtk_vbox_new (0, FALSE); dialog->image = gtk_image_new (); if (TRUE) { GdkPixbuf *pixbuf = NULL; gchar *picpath = NULL; picpath = g_build_filename (abook_env_get_picpath (), "alert.png", NULL); g_print ("%s(): path = %s\n", __FUNCTION__, picpath); abook_pictures_load (picpath, PIC_LARGE); pixbuf = abook_pictures_find (picpath, PIC_LARGE); if (pixbuf) { gtk_image_set_from_pixbuf (GTK_IMAGE (dialog->image), pixbuf); } } dialog->title = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (dialog->title), "<span color=\"Red\">Warning</span>"); vbox = gtk_vbox_new (0, FALSE); gtk_box_pack_start (GTK_BOX (vbox), dialog->image, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), dialog->title, FALSE, FALSE, 0); dialog->message = gtk_label_new (NULL); gtk_label_set_line_wrap (GTK_LABEL (dialog->message), TRUE); hbox = gtk_hbox_new (0, FALSE); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 10); gtk_box_pack_start (GTK_BOX (hbox), dialog->message, TRUE, TRUE, 10); vbox = gtk_vbox_new (0, FALSE); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 10); hbox = gtk_hbox_new (10, TRUE); button = gtk_button_new_with_label ("OK"); gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (abook_confirm_dialog_btn_clicked_cb), dialog); button = gtk_button_new_with_label ("Cancel"); gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (abook_confirm_dialog_btn_clicked_cb), dialog); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), frame); gtk_widget_set_size_request (GTK_DIALOG (dialog)->action_area, -1, 0);// gtk_dialog_add_buttons(GTK_DIALOG(dialog), "Ok", GTK_RESPONSE_OK, "Cancel", GTK_RESPONSE_CANCEL, NULL); gtk_window_set_decorated (GTK_WINDOW (dialog), FALSE); gtk_window_set_has_frame (GTK_WINDOW (dialog), FALSE); gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); return;}GtkWidget *abook_confirm_dialog_new (void){ return g_object_new (ABOOK_TYPE_CONFIRM_DIALOG, NULL);}voidabook_confirm_dialog_set_title (ABookConfirmDialog *dialog, const gchar *title){ gtk_label_set_markup (GTK_LABEL (dialog->title), title); return;}voidabook_confirm_dialog_set_message (ABookConfirmDialog *dialog, const gchar *message){ gtk_label_set_markup (GTK_LABEL (dialog->message), message); return;}/* vi:ts=2:nowrap:ai:expandtab*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -