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

📄 gem_internaltreeview.c.svn-base

📁 一款Linux手机上应用的文件管理器 系统要求就安装Gtk+2.0
💻 SVN-BASE
字号:
/*	contact - LiPS Address Book Application * *	Authors: YE Nan <nan.ye@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 <stdio.h>#include <gdk/gdkkeysyms.h>#include <glib.h>#include <gtk/gtk.h>#include "gem_internaltreeview.h"static void gem_internal_tree_view_class_init		(GemInternalTreeViewClass	*klass);static void gem_internal_tree_view_init					(GemInternalTreeView			*cntview);static void	gem_internal_tree_view_destroy			(GtkObject							*object);static gboolean gem_internal_tree_view_key_press_cb(GtkWidget *widget,GdkEventKey *event);static GemInternalTreeViewClass * parent_class = NULL;GTypegem_internal_tree_view_get_type (void){	static GType gem_internal_tree_view_type = 0;  if (!gem_internal_tree_view_type)	{		static const GTypeInfo gem_internal_tree_view_info =		{			sizeof (GemInternalTreeViewClass),			NULL,		/* base_init */			NULL,		/* base_finalize */			(GClassInitFunc) gem_internal_tree_view_class_init,			NULL,		/* class_finalize */			NULL,		/* class_data */			sizeof (GemInternalTreeView),			0,			/* n_preallocs */			(GInstanceInitFunc) gem_internal_tree_view_init,			NULL,		};		gem_internal_tree_view_type = g_type_register_static(GTK_TYPE_TREE_VIEW,																												"GemInternalTreeView",																												&gem_internal_tree_view_info,																												0);	}	return gem_internal_tree_view_type;}static voidgem_internal_tree_view_class_init		(GemInternalTreeViewClass	*klass){	GtkWidgetClass *widget_class = NULL;		widget_class = (GtkWidgetClass*)klass;  parent_class = g_type_class_peek_parent(klass);	widget_class->key_press_event = gem_internal_tree_view_key_press_cb;	return;}static gbooleangem_internal_tree_view_key_press_cb(GtkWidget *widget,                                    GdkEventKey *event){ 	GemInternalTreeView	*view = GEM_INTERNAL_TREE_VIEW(widget);	if(event->keyval == GDK_Return)  {  	g_print("%s() : keypress GDK_Return \n",__FUNCTION__);  }	  if (event->keyval == GDK_Up)  {    GtkTreePath *path = NULL;    GtkTreePath *first = NULL;    GtkTreeViewColumn *col = NULL;    gboolean result = FALSE;    gtk_tree_view_get_cursor (view, &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 (view);      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 (view, 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);              last = gtk_tree_model_get_path (model, &child_iter);            }          }          gtk_tree_view_set_cursor (view, last, NULL, FALSE);          gtk_tree_path_free (last);        }      }    }    gtk_tree_path_free (path);		if (result == FALSE)  	{			return GTK_WIDGET_CLASS(parent_class)->key_press_event(widget,		  																											 event);  	}  	    return TRUE;  }  else if (event->keyval == GDK_Down)  {    GtkTreePath *path = NULL;    GtkTreeViewColumn *col = NULL;    GtkTreeModel *model = NULL;    gboolean result = FALSE;    gtk_tree_view_get_cursor (view, &path, &col);    model = gtk_tree_view_get_model (view);    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 (view, 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);            last = gtk_tree_model_get_path (model, &child_iter);          }        }        result = !gtk_tree_path_compare (path, last);        if (result)        {          GtkTreePath *first = NULL;          first = gtk_tree_path_new_first ();          gtk_tree_view_set_cursor (view, first, NULL, FALSE);          gtk_tree_path_free (first);        }        gtk_tree_path_free (last);      }    }    gtk_tree_path_free (path);		if (result == FALSE)  	{			return GTK_WIDGET_CLASS(parent_class)->key_press_event(widget,		  																											 event);  	}  	    return TRUE;  }  else if (event->keyval == GDK_Right)  {  	GtkTreeView * tree = NULL;  	GtkTreeModel * model = NULL;  	  	tree = (GtkTreeView *)view;  	model = gtk_tree_view_get_model(tree);  	    GtkTreePath *path = NULL;    GtkTreeViewColumn *col = NULL;    gtk_tree_view_get_cursor (GTK_TREE_VIEW(tree), &path, &col);    if (path && gtk_tree_path_get_depth (path) == 1)    {      GtkTreeModel *model = NULL;      gtk_tree_view_expand_row (tree, path, FALSE);#if 0      model = gtk_tree_view_get_model (GTK_TREE_VIEW(tree));      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 (tree, focus_path, col, FALSE);            gtk_tree_path_free (focus_path);          }        }      }#endif    }    return TRUE;  }  else if (event->keyval == GDK_Left)  {	 	GtkTreeView * tree = NULL;  	GtkTreeModel * model = NULL;  	  	tree = (GtkTreeView *)view;  	model = gtk_tree_view_get_model(tree);  	    GtkTreePath *path = NULL;    GtkTreeViewColumn *col = NULL;    gtk_tree_view_get_cursor (tree, &path, &col);    if (path)    {      if (gtk_tree_path_get_depth (path) > 1)      {        gtk_tree_path_up (path);        if (path)        {          gtk_tree_view_set_cursor (tree, path, col, FALSE);        }      }      else      {        gtk_tree_view_collapse_row (tree, path);      }    }    return TRUE;  }	return GTK_WIDGET_CLASS(parent_class)->key_press_event(widget,																												 event);}static voidgem_internal_tree_view_init (GemInternalTreeView			*cntview){	return;}GtkWidget *gem_internal_tree_view_new (void){	return gtk_widget_new(GEM_TYPE_INTERNAL_TREE_VIEW,												NULL);}/*vi:ts=2:nowrap:ai:expandtab */

⌨️ 快捷键说明

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