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

📄 gtkautoscrolledwindow.c

📁 linux手机下的电话本源码(是contact的上层)
💻 C
字号:
/*  addressbook - Address book *gtkautoscrolledwindow.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 <gtk/gtk.h>#include "gtkautoscrolledwindow.h"static GtkFrameClass *parent_class = NULL;static void gtk_auto_scrolled_window_class_init (GtkAutoScrolledWindowClass *                                                 klass);static void gtk_auto_scrolled_window_init (GtkAutoScrolledWindow *window);static void gtk_auto_scrolled_window_finalize (GObject *object);static void gtk_auto_scrolled_window_destroy (GtkObject *object);GTypegtk_auto_scrolled_window_get_type (void){  static GType auto_scrolled_window_type = 0;  if (!auto_scrolled_window_type)  {    static const GTypeInfo auto_scrolled_window_info = {      sizeof (GtkAutoScrolledWindowClass),      NULL,                     /* base_init */      NULL,                     /* base_finalize */      (GClassInitFunc) gtk_auto_scrolled_window_class_init,      NULL,                     /* class_finalize */      NULL,                     /* class_data */      sizeof (GtkAutoScrolledWindow),      0,                        /* n_preallocs */      (GInstanceInitFunc) gtk_auto_scrolled_window_init,    };    auto_scrolled_window_type = g_type_register_static (GTK_TYPE_FRAME,                                                        "GtkAutoScrolledWindow",                                                        &auto_scrolled_window_info,                                                        0);  }  return auto_scrolled_window_type;}static voidgtk_auto_scrolled_window_class_init (GtkAutoScrolledWindowClass *klass){  GObjectClass *object_class;  GtkObjectClass *gtk_object_class;  parent_class = g_type_class_peek_parent (klass);  gtk_object_class = (GtkObjectClass *) klass;  gtk_object_class->destroy = gtk_auto_scrolled_window_destroy;  object_class = (GObjectClass *) klass;  object_class->finalize = gtk_auto_scrolled_window_finalize;  return;}static voidgtk_auto_scrolled_window_destroy (GtkObject *object){  GTK_OBJECT_CLASS (parent_class)->destroy (object);  return;}static voidgtk_auto_scrolled_window_finalize (GObject *object){  G_OBJECT_CLASS (parent_class)->finalize (object);  return;}static voidgtk_auto_scrolled_window_get_focus_child (GtkContainer *container,                                          GtkWidget *widget,                                          gpointer user_data){  GtkAutoScrolledWindow *as_window = (GtkAutoScrolledWindow *) user_data;  GtkWidget *scrolled_window = as_window->scrolledwindow;  GtkAdjustment *hadjustment =    gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (scrolled_window));  GtkAdjustment *vadjustment =    gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_window));  if (widget)  {    GtkWidget *parent = NULL;    parent = gtk_widget_get_parent (widget);    if (parent)    {      gint x, y;      gtk_widget_translate_coordinates (widget, GTK_WIDGET (container), 0, 0,                                        &x, &y);      if (vadjustment)      {        gdouble lower;        gdouble upper;        gdouble prop;        g_object_get (vadjustment, "lower", &lower, "upper", &upper, NULL);        prop =          (upper - lower) / (gdouble) GTK_WIDGET (container)->allocation.height;        gtk_adjustment_clamp_page (vadjustment, y *prop,                                   (y + widget->allocation.height) *prop);      }      if (hadjustment)      {        gdouble lower;        gdouble upper;        gdouble prop;        g_object_get (vadjustment, "lower", &lower, "upper", &upper, NULL);        prop =          (upper - lower) / (gdouble) GTK_WIDGET (container)->allocation.width;        gtk_adjustment_clamp_page (hadjustment, y *prop,                                   (y + widget->allocation.width) *prop);      }    }  }  return;}static voidgtk_auto_scrolled_window_init (GtkAutoScrolledWindow *as_window){  as_window->scrolledwindow = gtk_scrolled_window_new (NULL, NULL);  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW                                  (as_window->scrolledwindow),                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);  gtk_container_add (GTK_CONTAINER (as_window), as_window->scrolledwindow);  gtk_widget_show (as_window->scrolledwindow);  as_window->viewport = NULL;  as_window->child = NULL;  return;}GtkWidget *gtk_auto_scrolled_window_new (void){  return gtk_widget_new (GTK_TYPE_AUTO_SCROLLED_WINDOW, NULL);}voidgtk_auto_scrolled_window_add_with_viewport (GtkAutoScrolledWindow *as_window,                                            GtkWidget *widget){  g_assert (GTK_IS_CONTAINER (widget));  if (as_window->viewport == NULL)  {    as_window->viewport = gtk_viewport_new (NULL, NULL);    gtk_container_add (GTK_CONTAINER (as_window->scrolledwindow),                       as_window->viewport);  }  gtk_container_add (GTK_CONTAINER (as_window->viewport), widget);//      gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(as_window->scrolledwindow), widget);  gtk_container_set_focus_hadjustment (GTK_CONTAINER (widget),                                       gtk_scrolled_window_get_hadjustment                                       (GTK_SCROLLED_WINDOW                                        (as_window->scrolledwindow)));  gtk_container_set_focus_vadjustment (GTK_CONTAINER (widget),                                       gtk_scrolled_window_get_vadjustment                                       (GTK_SCROLLED_WINDOW                                        (as_window->scrolledwindow)));#if 1  g_signal_connect (GTK_OBJECT (widget),                    "set-focus-child",                    GTK_SIGNAL_FUNC (gtk_auto_scrolled_window_get_focus_child),                    as_window);#endif//      as_window->child = gtk_widget_ref(widget);  return;}voidgtk_auto_scrolled_window_add (GtkAutoScrolledWindow *as_window,                              GtkWidget *widget){  g_assert (GTK_IS_CONTAINER (widget));  gtk_container_add (GTK_CONTAINER (as_window->scrolledwindow), widget);  gtk_container_set_focus_hadjustment (GTK_CONTAINER (widget),                                       gtk_scrolled_window_get_hadjustment                                       (GTK_SCROLLED_WINDOW                                        (as_window->scrolledwindow)));  gtk_container_set_focus_vadjustment (GTK_CONTAINER (widget),                                       gtk_scrolled_window_get_vadjustment                                       (GTK_SCROLLED_WINDOW                                        (as_window->scrolledwindow)));#if 1  g_signal_connect (GTK_OBJECT (widget),                    "set-focus-child",                    GTK_SIGNAL_FUNC (gtk_auto_scrolled_window_get_focus_child),                    as_window);#endif  if (as_window->viewport)  {    gtk_widget_destroy (as_window->viewport);  }//      as_window->child = gtk_widget_ref(widget);  return;}GtkWidget *gtk_auto_scrolled_window_get_viewport (GtkAutoScrolledWindow *as_window){  return as_window->viewport;}/* vi:ts=2:nowrap:ai:expandtab*/

⌨️ 快捷键说明

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