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

📄 abooklistview.c

📁 linux手机下的电话本源码(是contact的上层)
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  addressbook - Address book *abooklistview.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 <string.h>#include <gtk/gtk.h>#include <gdk/gdkkeysyms.h>#include "abooklistview.h"#include "abookenv.h"#define _(x) gettext(x)static void abook_listview_class_init (ABookListViewClass *klass);static void abook_listview_init (ABookListView *window);GTypeabook_listview_get_type (void){  static GType listview_type = 0;  if (!listview_type)  {    static const GTypeInfo listview_info = {      sizeof (ABookListViewClass),      NULL,                     /* base_init */      NULL,                     /* base_finalize */      (GClassInitFunc) abook_listview_class_init,      NULL,                     /* class_finalize */      NULL,                     /* class_data */      sizeof (ABookListView),      0,                        /* n_preallocs */      (GInstanceInitFunc) abook_listview_init,    };    listview_type =      g_type_register_static (GTK_TYPE_FRAME, "ABookListView", &listview_info,                              0);  }  return listview_type;}static voidabook_listview_class_init (ABookListViewClass *klass){  return;}static voidabook_listview_row_activated (GtkTreeView *treeview, GtkTreePath *path,                              GtkTreeViewColumn *col, gpointer user_data){  ABookListView *view = (ABookListView *) user_data;  GtkTreeModel *model = NULL;  GtkTreeIter iter;  model = gtk_tree_view_get_model (treeview);  if (gtk_tree_model_get_iter (model, &iter, path))  {    gchar *uid = NULL;    ABookListViewStorageType type;    char strType[20] = "";    gtk_tree_model_get (model, &iter, COL_UID, &uid, COL_STORAGE, &type, -1);    g_print ("%s(): uid  = %s\n", __FUNCTION__, uid);    switch (type)    {      case STORAGE_LOCAL:        strcpy (strType, "local");        break;      case STORAGE_SIM:        strcpy (strType, "sim");        break;      case STORAGE_NET:        strcpy (strType, "net");        break;      default:        break;    }    g_print ("%s(): type = %s\n", __FUNCTION__, strType);    if (view->row_activated_cb)    {      view->row_activated_cb (view, uid, type);    }    g_free (uid);  }  return;}static gbooleanabook_listview_entry_key_press_event_cb (GtkWidget *widget,                                         GdkEventKey *event,                                         gpointer user_data){  ABookListView *view = (ABookListView *) user_data;  g_print ("%s(): entring\n", __FUNCTION__);  if (event->keyval == GDK_Return)  {    GtkTreeView *tree = NULL;    GtkTreeModel *model = NULL;    tree = (GtkTreeView *) view->treeview;    model = (GtkTreeModel *) view->liststore;    if (tree && model)    {      GtkTreePath *path = NULL;      GtkTreeIter iter;      gtk_tree_view_get_cursor (GTK_TREE_VIEW (tree), &path, NULL);      if (path && gtk_tree_model_get_iter (model, &iter, path))      {        gchar *uid = NULL;        ABookListViewStorageType type;        gtk_tree_model_get (model,                            &iter, COL_UID, &uid, COL_STORAGE, &type, -1);        g_print ("%s(): uid  = %s\n", __FUNCTION__, uid);        g_print ("%s(): type = %s\n",                 __FUNCTION__, (type == STORAGE_LOCAL) ? "local" : "sim");        if (view->row_activated_cb)        {          view->row_activated_cb (view, uid, type);        }        g_free (uid);      }    }    return TRUE;  }  else if (event->keyval == GDK_Right)  {    return FALSE;  }  else if (event->keyval == GDK_Left)  {    return FALSE;  }  return FALSE;}static voidabook_listview_entry_changed_cb (GtkEditable *editable, gpointer user_data){  ABookListView *view = (ABookListView *) user_data;  if (TRUE)  {    GtkTreeView *tree = NULL;    GtkTreeModel *model = NULL;    tree = (GtkTreeView *) view->treeview;    model = (GtkTreeModel *) view->liststore;    if (tree && model)    {      GtkTreeIter iter;      gchar *string = NULL;      string = g_utf8_strup (gtk_entry_get_text (GTK_ENTRY (editable)), -1);      g_strstrip (string);      if (gtk_tree_model_iter_n_children (model, NULL) > 0 &&          gtk_tree_model_get_iter_first (model, &iter))      {        do        {          gchar *name = NULL;          gchar *caseless = NULL;          gtk_tree_model_get (model, &iter, COL_NAME, &name, -1);/* 					g_print("%s(): entry = %s, name = %s\n",									__FUNCTION__,									string,									name);*/          caseless = g_utf8_strup (name, -1);          if (g_strstr_len (caseless, strlen (caseless), string) != NULL)          {            GtkTreePath *path = NULL;            path = gtk_tree_model_get_path (model, &iter);            if (path)            {              gtk_tree_view_set_cursor (tree, path, NULL, FALSE);            }            gtk_tree_path_free (path);            break;          }          g_free (caseless);          g_free (name);        } while (gtk_tree_model_iter_next (model, &iter));      }      g_free (string);    }  }  return;}static gbooleanabook_listview_treeview_key_press_event_cb (GtkWidget *widget,                                            GdkEventKey *event,                                            ABookListView *view){//      ABookListView *view = (ABookListView *)widget;//      g_print("%s():\n", __FUNCTION__);  if (event->keyval == GDK_Up)  {    GtkTreeView *tree = NULL;    GtkTreeModel *model = NULL;    tree = (GtkTreeView *) view->treeview;    model = (GtkTreeModel *) view->liststore;    if (tree && model)    {      GtkTreePath *path = NULL;      gtk_tree_view_get_cursor (GTK_TREE_VIEW (tree), &path, NULL);//                      g_print("%s(): Up curr = %s\n", __FUNCTION__, gtk_tree_path_to_string(path));      if (path)      {        GtkTreePath *p;        gint count;        count = gtk_tree_model_iter_n_children (model, NULL);        p = gtk_tree_path_copy (path);        gtk_tree_path_prev (path);//                              g_print("%s(): Up prev = %s\n", __FUNCTION__, gtk_tree_path_to_string(path));        if (!gtk_tree_path_compare (path, p))        {          path = gtk_tree_path_new_from_indices (count - 1, -1);        }        gtk_tree_path_free (p);        gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree), path, NULL, FALSE);        gtk_tree_path_free (path);      }      return TRUE;    }  }  else if (event->keyval == GDK_Down)  {    GtkTreeView *tree = NULL;    GtkTreeModel *model = NULL;    tree = (GtkTreeView *) view->treeview;    model = (GtkTreeModel *) view->liststore;    if (tree && model)    {      GtkTreePath *path = NULL;      gtk_tree_view_get_cursor (GTK_TREE_VIEW (tree), &path, NULL);//                      g_print("%s(): Down curr = %s\n", __FUNCTION__, gtk_tree_path_to_string(path));      if (path)      {        GtkTreePath *p;        gint count;        count = gtk_tree_model_iter_n_children (model, NULL);        p = gtk_tree_path_new_from_indices (count, -1);        gtk_tree_path_next (path);//                              g_print("%s(): Down next = %s\n", __FUNCTION__, gtk_tree_path_to_string(path));

⌨️ 快捷键说明

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