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

📄 abookmarkview.c

📁 linux手机下的电话本源码(是contact的上层)
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  addressbook - Address book *abookmarkview.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 "abookmarkview.h"#include "abookenv.h"#define _(x) gettext(x)static void abook_markview_class_init (ABookMarkViewClass *klass);static void abook_markview_init (ABookMarkView *window);GTypeabook_markview_get_type (void){  static GType markview_type = 0;  if (!markview_type)  {    static const GTypeInfo markview_info = {      sizeof (ABookMarkViewClass),      NULL,                     /* base_init */      NULL,                     /* base_finalize */      (GClassInitFunc) abook_markview_class_init,      NULL,                     /* class_finalize */      NULL,                     /* class_data */      sizeof (ABookMarkView),      0,                        /* n_preallocs */      (GInstanceInitFunc) abook_markview_init,    };    markview_type =      g_type_register_static (GTK_TYPE_FRAME, "ABookMarkView", &markview_info,                              0);  }  return markview_type;}static voidabook_markview_class_init (ABookMarkViewClass *klass){  return;}static voidabook_markview_toggled_cb (GtkCellRendererToggle *celltoggle,                           gchar *pathstr, GtkTreeView *tree){  GtkTreeModel *model = NULL;  GtkTreePath *path = NULL;  GtkTreeIter iter;  gboolean active;  model = gtk_tree_view_get_model (tree);  path = gtk_tree_path_new_from_string (pathstr);  if (!gtk_tree_model_get_iter (model, &iter, path))  {    g_print ("%s(): bad path %s\n", __FUNCTION__, pathstr);    return;  }  if (model)  {    gtk_tree_model_get (GTK_TREE_MODEL (model),                        &iter, COL_MV_CHECK, &active, -1);    active = !active;    gtk_tree_store_set (GTK_TREE_STORE (model),                        &iter, COL_MV_CHECK, active, -1);    /* we also need to modify the active state     *of relative parent of children     */    if (gtk_tree_path_get_depth (path) > 1)    {      /* means the current node is a child node */      GtkTreePath *parent_path = NULL;      GtkTreeIter parent_iter;      parent_path = gtk_tree_path_copy (path);      if (gtk_tree_path_up (parent_path) &&          gtk_tree_model_get_iter (model, &parent_iter, parent_path))      {        gint n_children = 0;        gint n_active = 0;        gint i;        n_children = gtk_tree_model_iter_n_children (model, &parent_iter);        for (i = 0; i < n_children; i++)        {          GtkTreeIter child_iter;          if (gtk_tree_model_iter_nth_child              (model, &child_iter, &parent_iter, i))          {            gboolean child_active;            gtk_tree_model_get (GTK_TREE_MODEL (model),                                &child_iter, COL_MV_CHECK, &child_active, -1);            if (child_active)            {              n_active++;            }          }        }        gtk_tree_store_set (GTK_TREE_STORE (model),                            &parent_iter,                            COL_MV_CHECK, (n_active >= n_children), -1);      }      gtk_tree_path_free (parent_path);      if (TRUE)      {        GtkTreeIter first_iter;        if (gtk_tree_model_get_iter_first (model, &first_iter))        {          gtk_tree_store_set (GTK_TREE_STORE (model),                              &first_iter, COL_MV_CHECK, FALSE, -1);        }      }    }    else    {      /* else it is a top-level node */      GtkTreePath *root = NULL;      root = gtk_tree_path_new_first ();      if (!gtk_tree_path_compare (path, root))      {//                              g_print("%s(): Select all\n", __FUNCTION__);        gint n_persons = 0;        gint i;        n_persons = gtk_tree_model_iter_n_children (model, NULL);//                              g_print("%s(): n_person = %d\n", __FUNCTION__, n_persons);        for (i = 1; i < n_persons; i++)        {          GtkTreeIter person_iter;          gint n_numbers = 0;          gint j;          if (gtk_tree_model_iter_nth_child (model, &person_iter, NULL, i))          {            gtk_tree_store_set (GTK_TREE_STORE (model),                                &person_iter, COL_MV_CHECK, active, -1);          }          n_numbers = gtk_tree_model_iter_n_children (model, &person_iter);          for (j = 0; j < n_numbers; j++)          {            GtkTreeIter num_iter;            if (gtk_tree_model_iter_nth_child                (model, &num_iter, &person_iter, j))            {              gtk_tree_store_set (GTK_TREE_STORE (model),                                  &num_iter, COL_MV_CHECK, active, -1);            }          }        }      }      else      {        gint n_children = 0;        gint i;//                              g_print("%s(): Select one\n", __FUNCTION__);        if (TRUE)        {          GtkTreeIter first_iter;          if (gtk_tree_model_get_iter_first (model, &first_iter))          {            gtk_tree_store_set (GTK_TREE_STORE (model),                                &first_iter, COL_MV_CHECK, FALSE, -1);          }        }        n_children = gtk_tree_model_iter_n_children (model, &iter);        for (i = 0; i < n_children; i++)        {          GtkTreeIter child_iter;          if (gtk_tree_model_iter_nth_child (model, &child_iter, &iter, i))          {            gtk_tree_store_set (GTK_TREE_STORE (model),                                &child_iter, COL_MV_CHECK, active, -1);          }        }      }    }  }  gtk_tree_path_free (path);  return;}static gbooleanabook_markview_treeview_key_press_event_cb (GtkWidget *widget,                                            GdkEventKey *event,                                            ABookMarkView *view){  GtkTreeView *treeview = GTK_TREE_VIEW (view->treeview);//      g_print("%s(): entering\n", __FUNCTION__);  if (event->keyval == GDK_Right)  {    GtkTreePath *path = NULL;    GtkTreeViewColumn *col = NULL;    gtk_tree_view_get_cursor (treeview, &path, &col);    if (path && gtk_tree_path_get_depth (path) == 1)    {      //GtkTreeModel *model = NULL;      gtk_tree_view_expand_row (treeview, path, FALSE);#if 0      model = gtk_tree_view_get_model (treeview);      if (model)      {        GtkTreeIter parent_iter;        if (gtk_tree_model_get_iter (model, &parent_iter, path))        {          GtkTreeIter iter;          if (gtk_tree_model_iter_children (model, &iter, &parent_iter))          {            GtkTreePath *focus_path = NULL;            focus_path = gtk_tree_model_get_path (model, &iter);            gtk_tree_view_set_cursor (treeview, focus_path, col, FALSE);            gtk_tree_path_free (focus_path);          }        }      }#endif    }    return TRUE;  }  else if (event->keyval == GDK_Left)  {    GtkTreePath *path = NULL;    GtkTreeViewColumn *col = NULL;    gtk_tree_view_get_cursor (treeview, &path, &col);    if (path)    {      if (gtk_tree_path_get_depth (path) > 1)      {        gtk_tree_path_up (path);        if (path)        {          gtk_tree_view_set_cursor (treeview, path, col, FALSE);        }      }      else      {        gtk_tree_view_collapse_row (treeview, path);      }    }    return TRUE;  }  else if (event->keyval == GDK_Up)  {    GtkTreePath *path = NULL;    GtkTreePath *first = NULL;    GtkTreeViewColumn *col = NULL;    gboolean result = FALSE;    gtk_tree_view_get_cursor (treeview, &path, &col);    first = gtk_tree_path_new_first ();    result = !gtk_tree_path_compare (path, first);    gtk_tree_path_free (first);    if (path && result)    {      GtkTreeModel *model = NULL;      model = gtk_tree_view_get_model (treeview);      if (model)      {        GtkTreeIter iter;        if (gtk_tree_model_iter_nth_child            (model, &iter, NULL,             gtk_tree_model_iter_n_children (model, NULL) - 1))        {          GtkTreePath *last = NULL;          last = gtk_tree_model_get_path (model, &iter);          if (gtk_tree_view_row_expanded (treeview, last))          {            GtkTreeIter child_iter;            if (gtk_tree_model_iter_nth_child                (model, &child_iter, &iter,                 gtk_tree_model_iter_n_children (model, &iter) - 1))            {              gtk_tree_path_free (last);

⌨️ 快捷键说明

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