⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gtkappnotification.c

📁 linux手机下的电话本源码(是contact的上层)
💻 C
字号:
/*  addressbook - Address book *gtkappnotification.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 "gtkappnotification.h"#define _(x) gettext(x)#define	INNER_SPACE		10static void gtk_app_notification_class_init (GtkAppNotificationClass *klass);static void gtk_app_notification_init (GtkAppNotification *window);static void gtk_app_notification_destroy (GtkObject *object);static GtkWindowClass *parent_class = NULL;GTypegtk_app_notification_get_type (void){  static GType app_notification_type = 0;  if (!app_notification_type)  {    static const GTypeInfo app_notification_info = {      sizeof (GtkAppNotificationClass),      NULL,                     /* base_init */      NULL,                     /* base_finalize */      (GClassInitFunc) gtk_app_notification_class_init,      NULL,                     /* class_finalize */      NULL,                     /* class_data */      sizeof (GtkAppNotification),      0,                        /* n_preallocs */      (GInstanceInitFunc) gtk_app_notification_init,    };    app_notification_type =      g_type_register_static (GTK_TYPE_WINDOW, "GtkAppNotification",                              &app_notification_info, 0);  }  return app_notification_type;}static voidgtk_app_notification_class_init (GtkAppNotificationClass *klass){  GtkObjectClass *object_class;  object_class = (GtkObjectClass *) klass;  parent_class = g_type_class_peek_parent (klass);  object_class->destroy = gtk_app_notification_destroy;  return;}static voidgtk_app_notification_destroy (GtkObject *object){  GtkAppNotification *window = GTK_APP_NOTIFICATION (object);  g_source_remove (window->timeout);  (*GTK_OBJECT_CLASS (parent_class)->destroy) (object);  return;}static gbooleangtk_app_notification_expose (GtkWidget *widget, GdkEventExpose *event,                             gpointer user_data){  gint x, y;  gint w, h;  GdkGC *gc = NULL;  GdkColor color;  gint i;  x = widget->allocation.x;  y = widget->allocation.x;  w = widget->allocation.width;  h = widget->allocation.height;  gc = gdk_gc_new (widget->window);  if (gc == NULL)  {    g_print ("%s(): gc failure.\n", __FUNCTION__);    return FALSE;  }  gdk_color_parse ("DarkOrange", &color);  gdk_gc_set_rgb_fg_color (gc, &color);  for (i = 0; i < INNER_SPACE / 4; i++)  {    gdk_draw_rectangle (widget->window,                        gc,                        FALSE,                        x + i + 1, y + i + 1,                        w - (i + 1) *2 - 1, h - (i + 1) *2 - 1);  }  gdk_gc_unref (gc);  return FALSE;}static voidgtk_app_notification_show (GtkWidget *widget, gpointer user_data){  GtkAppNotification *window = GTK_APP_NOTIFICATION (widget);  if (window->hide_text)  {    gtk_widget_hide (window->text_nc);  }  if (window->hide_graphic)  {    gtk_widget_hide (window->graphic_nc);  }  if (window->hide_progress)  {    gtk_widget_hide (window->progress_nc);  }  return;}static gbooleangtk_app_notification_progress_bar_timeout (GtkAppNotification *window){  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (window->progress_nc),                                 window->fraction);  return TRUE;}static voidgtk_app_notification_init (GtkAppNotification *window){  GtkWidget *vbox = NULL;  GtkWidget *hbox = NULL;  window->text_nc = gtk_label_new (NULL);  window->graphic_nc = gtk_image_new ();  window->progress_nc = gtk_progress_bar_new ();  hbox = gtk_hbox_new (FALSE, 0);  gtk_box_pack_start (GTK_BOX (hbox), window->text_nc, TRUE, TRUE, 0);  gtk_box_pack_start (GTK_BOX (hbox), window->graphic_nc, FALSE, FALSE, 0);  vbox = gtk_vbox_new (FALSE, 10);  gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);  gtk_box_pack_start (GTK_BOX (vbox), window->progress_nc, TRUE, TRUE, 0);//      gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);  gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);  if (TRUE)  {    GdkColor color;    gdk_color_parse ("white", &color);    gtk_widget_modify_bg (GTK_WIDGET (window), GTK_STATE_NORMAL, &color);  }  gtk_container_add (GTK_CONTAINER (window), vbox);  g_signal_connect (G_OBJECT (vbox),                    "expose-event",                    G_CALLBACK (gtk_app_notification_expose), NULL);  g_signal_connect (G_OBJECT (window),                    "show", G_CALLBACK (gtk_app_notification_show), NULL);  window->fraction = 0.0;  window->timeout = g_timeout_add (100,                                   (GSourceFunc)                                   gtk_app_notification_progress_bar_timeout,                                   (gpointer) window);  window->hide_text = FALSE;  window->hide_graphic = FALSE;  window->hide_progress = FALSE;  return;}GtkWidget *gtk_app_notification_new (void){  return g_object_new (GTK_TYPE_APP_NOTIFICATION, "type", GTK_WINDOW_POPUP,//                                                                               "type-hint", GDK_WINDOW_TYPE_HINT_SPLASHSCREEN,                       "accept-focus", TRUE, NULL);}voidgtk_app_notification_set_image_from_file (GtkAppNotification *window,                                          const gchar *fname){  GtkRequisition req;  gtk_image_set_from_file (GTK_IMAGE (window->graphic_nc), fname);  gtk_widget_size_request (window->graphic_nc, &req);  g_print ("%s(): [%03d, %03d]\n", __FUNCTION__, req.width, req.height);  return;}voidgtk_app_notification_set_text (GtkAppNotification *window, const gchar *text){  gtk_label_set_text (GTK_LABEL (window->text_nc), text);  return;}voidgtk_app_notification_set_progross_fraction (GtkAppNotification *window,                                            gdouble fraction){  g_print ("%s(): entering, fraction = %f\n", __FUNCTION__, fraction);  if (window->fraction != fraction)  {    window->fraction = fraction;  }  return;}voidgtk_app_notification_hide_text (GtkAppNotification *window){  window->hide_text = TRUE;  return;}voidgtk_app_notification_hide_graphic (GtkAppNotification *window){  window->hide_graphic = TRUE;  return;}voidgtk_app_notification_hide_progressbar (GtkAppNotification *window){  window->hide_progress = TRUE;  return;}/* vi:ts=2:nowrap:ai:expandtab*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -