📄 uicompskwindow.c
字号:
/* 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 <glib.h>#include <gpe/gpeskwindow.h>#include <uicompskwindow.h>typedef struct _UICompSKWindowPriv UICompSKWindowPriv;struct _UICompSKWindowPriv{ GtkWidget *view; GtkUIManager *uimgr;};#define UI_COMP_SKWINDOW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ UI_COMP_TYPE_SKWINDOW, \ UICompSKWindowPriv));static void ui_comp_skwindow_class_init (UICompSKWindowClass *klass);static void ui_comp_skwindow_init (UICompSKWindow *skwindow);static void ui_comp_skwindow_destroy (GtkObject *object);static GpeSKWindowClass * parent_class = NULL;GTypeui_comp_skwindow_get_type (void){ static GType skwindow_type = 0; if (!skwindow_type) { static const GTypeInfo skwindow_info = { sizeof (UICompSKWindowClass), NULL, /* base_init */ NULL, /* base_finalize */ (GClassInitFunc) ui_comp_skwindow_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (UICompSKWindow), 0, /* n_preallocs */ (GInstanceInitFunc) ui_comp_skwindow_init, NULL, }; skwindow_type = g_type_register_static(GPE_TYPE_SKWINDOW, "UICompSKWindow", &skwindow_info, 0); } return skwindow_type;}static voidui_comp_skwindow_class_init (UICompSKWindowClass * klass){ GtkObjectClass *object_class; object_class = (GtkObjectClass*)klass; parent_class = g_type_class_peek_parent(klass); g_type_class_add_private(klass, sizeof(UICompSKWindowPriv)); object_class->destroy = ui_comp_skwindow_destroy; return;}static voidui_comp_skwindow_destroy (GtkObject *object){ UICompSKWindow * skwindow = UI_COMP_SKWINDOW(object); (*GTK_OBJECT_CLASS(parent_class)->destroy)(object); return;}static voidui_comp_skwindow_init (UICompSKWindow * skwindow){ UICompSKWindowPriv *priv = UI_COMP_SKWINDOW_GET_PRIVATE(skwindow); priv->view = NULL; priv->uimgr = NULL; return;}static voidui_comp_skwindow_set_view (UICompSKWindow *skwindow, GtkWidget *view){ UICompSKWindowPriv *priv = UI_COMP_SKWINDOW_GET_PRIVATE(skwindow); g_return_if_fail(view); gtk_container_add(GTK_CONTAINER(skwindow), view); priv->view = view; return;}static voidui_comp_skwindow_parse_sk_conf (UICompSKWindow *skwindow, const gchar *left_sk_label, const gchar *right_sk_label, const gchar *sk_uidesc, GtkActionEntry *sk_actions, guint n_sk_actions){ UICompSKWindowPriv *priv = UI_COMP_SKWINDOW_GET_PRIVATE(skwindow); GtkActionGroup *action_group = NULL; GtkWidget *menu_left = NULL; GtkWidget *menu_right = NULL; GError *error = NULL; priv->uimgr = gtk_ui_manager_new(); action_group = gtk_action_group_new ("Actions"); gtk_action_group_add_actions(action_group, sk_actions, n_sk_actions, NULL);/* g_print("%s(): n_sk_actions = %d\n", __FUNCTION__, n_sk_actions);*/ gtk_ui_manager_insert_action_group(priv->uimgr, action_group, 0); if (!gtk_ui_manager_add_ui_from_string(priv->uimgr, sk_uidesc, -1, &error)) { g_print("%s(): failed to parse menu desc: %s\n", __FUNCTION__, error->message); g_error_free(error); return; } menu_left = gtk_ui_manager_get_widget(priv->uimgr, "/PopupLeft"); gpe_skwindow_set_softkey_menu(GPE_SKWINDOW(skwindow), UI_COMP_SK_LEFT, menu_left); gpe_skwindow_set_softkey_label(GPE_SKWINDOW(skwindow), UI_COMP_SK_LEFT, left_sk_label); menu_right = gtk_ui_manager_get_widget(priv->uimgr, "/PopupRight"); gpe_skwindow_set_softkey_menu(GPE_SKWINDOW(skwindow), UI_COMP_SK_RIGHT, menu_right); gpe_skwindow_set_softkey_label(GPE_SKWINDOW(skwindow), UI_COMP_SK_RIGHT, right_sk_label); return;}GtkWidget *ui_comp_skwindow_new (GtkWidget *view, const gchar *left_sk_label, const gchar *right_sk_label, const gchar *sk_uidesc, GtkActionEntry *sk_actions, guint n_sk_actions){ GtkWidget *window = NULL; window = gtk_widget_new(UI_COMP_TYPE_SKWINDOW, NULL); g_return_val_if_fail(window, NULL); ui_comp_skwindow_set_view(UI_COMP_SKWINDOW(window), view); ui_comp_skwindow_parse_sk_conf(UI_COMP_SKWINDOW(window), left_sk_label, right_sk_label, sk_uidesc, sk_actions, n_sk_actions); return window;}GtkWidget *ui_comp_skwindow_get_view (UICompSKWindow *skwindow){ UICompSKWindowPriv *priv = UI_COMP_SKWINDOW_GET_PRIVATE(skwindow); return priv->view;}GtkUIManager *ui_comp_skwindow_get_ui_manager (UICompSKWindow *skwindow){ UICompSKWindowPriv *priv = UI_COMP_SKWINDOW_GET_PRIVATE(skwindow); return priv->uimgr;}/*vi:ts=2:nowrap:ai:expandtab */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -