GnuCash  5.6-150-g038405b370+
gnc-gtk-utils.h
Go to the documentation of this file.
1 /********************************************************************\
2  * gnc-gtk-utils.h -- utility functions based on glib functions *
3  * Copyright (C) 2006 David Hampton <hampton@employees.org> *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License*
16  * along with this program; if not, contact: *
17  * *
18  * Free Software Foundation Voice: +1-617-542-5942 *
19  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
20  * Boston, MA 02110-1301, USA gnu@gnu.org *
21  * *
22 \********************************************************************/
23 
35 #ifndef GNC_GTK_UTILS_H
36 #define GNC_GTK_UTILS_H
37 
38 #include <gtk/gtk.h>
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
48 #define GNC_MENU_ATTRIBUTE_ACCELERATOR "accel"
49 #define GNC_MENU_ATTRIBUTE_TOOLTIP "tooltip"
50 #define GNC_MENU_ATTRIBUTE_TEMPORARY "temp"
51 
52 void gnc_cbwe_set_by_string(GtkComboBox *cbwe, const gchar *text);
53 void gnc_cbwe_add_completion (GtkComboBox *cbwe);
54 void gnc_cbwe_require_list_item (GtkComboBox *cbwe);
55 
56 gboolean gnc_is_dark_theme (GdkRGBA *fg_color);
57 void gnc_style_context_get_background_color (GtkStyleContext *context,
58  GtkStateFlags state,
59  GdkRGBA *color);
60 void gnc_style_context_get_border_color (GtkStyleContext *context,
61  GtkStateFlags state,
62  GdkRGBA *color);
63 
64 GtkWidget *gnc_get_dialog_widget_from_id (GtkDialog *dialog, const gchar *id);
65 
66 void gnc_disable_all_actions_in_group (GSimpleActionGroup *action_group);
67 
68 void gnc_add_accelerator_keys_for_menu (GtkWidget *menu, GMenuModel *model, GtkAccelGroup *accel_group);
69 
70 GtkWidget *gnc_find_menu_item_by_action_name (GtkWidget *menu, const gchar *action_name);
71 GtkWidget *gnc_find_menu_item_by_action_label (GtkWidget *menu, const gchar *action_label);
72 GList *gnc_menu_get_items (GtkWidget *menu);
73 
74 GtkWidget *gnc_find_toolbar_item (GtkWidget *toolbar, const gchar *action_name);
75 
76 void gnc_menu_item_setup_tooltip_to_statusbar_callback (GtkWidget *menu_item,
77  GtkWidget *statusbar);
78 
79 void gnc_tool_item_setup_tooltip_to_statusbar_callback (GtkWidget *tool_item,
80  GtkWidget *statusbar);
81 
83 {
84  const gchar *search_action_name;
85  const gchar *search_action_label;
86  const gchar *search_action_target;
87  const gchar *tooltip;
88  GMenuModel *model;
89  gint index;
90 };
91 
92 typedef struct _GncMenuModelSearch GncMenuModelSearch;
93 
94 gboolean gnc_menubar_model_find_item (GMenuModel *menu_model, GncMenuModelSearch *gsm);
95 GtkWidget *gnc_menubar_model_find_menu_item (GMenuModel *menu_model, GtkWidget *menu, const gchar *action_name);
96 
97 gboolean gnc_menubar_model_update_item (GMenuModel *menu_model, const gchar *action_name,
98  const gchar *target, const gchar *label,
99  const gchar *accel_name, const gchar *tooltip);
100 
101 void gnc_menubar_model_remove_items_with_attrib (GMenuModel *menu_model, const gchar *attrib);
102 
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #endif /* GNC_GTK_UTILS_H */
110 
void gnc_cbwe_set_by_string(GtkComboBox *cbwe, const gchar *text)
Find an entry in the GtkComboBox by its text value, and set the widget to that value.
Definition: gnc-gtk-utils.c:41
void gnc_menubar_model_remove_items_with_attrib(GMenuModel *menu_model, const gchar *attrib)
Remove GMenuModel entries based on having an attribute value equal to attrib, it does not matter what...
void gnc_tool_item_setup_tooltip_to_statusbar_callback(GtkWidget *tool_item, GtkWidget *statusbar)
Setup the callbacks for tool bar items so the tooltip can be displayed in the status bar...
gboolean gnc_menubar_model_find_item(GMenuModel *menu_model, GncMenuModelSearch *gsm)
Find a GtkMenu item from the action name.
gboolean gnc_is_dark_theme(GdkRGBA *fg_color)
Return whether the current gtk theme is a dark one.
void gnc_style_context_get_border_color(GtkStyleContext *context, GtkStateFlags state, GdkRGBA *color)
Wrapper to get the border color of a widget for a given state.
void gnc_style_context_get_background_color(GtkStyleContext *context, GtkStateFlags state, GdkRGBA *color)
Wrapper to get the background color of a widget for a given state.
GtkWidget * gnc_get_dialog_widget_from_id(GtkDialog *dialog, const gchar *id)
Find the Widget defined by &#39;id&#39; in the dialog.
GList * gnc_menu_get_items(GtkWidget *menu)
Return a list of GtkMenuItems.
GtkWidget * gnc_menubar_model_find_menu_item(GMenuModel *menu_model, GtkWidget *menu, const gchar *action_name)
Find a GtkMenu item from the action name.
GtkWidget * gnc_find_toolbar_item(GtkWidget *toolbar, const gchar *action_name)
Search the toolbar for the tool item based on the action name.
GtkWidget * gnc_find_menu_item_by_action_name(GtkWidget *menu, const gchar *action_name)
Search the menu for the menu item based on action name.
void gnc_add_accelerator_keys_for_menu(GtkWidget *menu, GMenuModel *model, GtkAccelGroup *accel_group)
Add accelerator keys for menu item widgets.
GtkWidget * gnc_find_menu_item_by_action_label(GtkWidget *menu, const gchar *action_label)
Search the menu for the menu item based on the action label.
void gnc_disable_all_actions_in_group(GSimpleActionGroup *action_group)
Disable all the actions in a simple action group.
gboolean gnc_menubar_model_update_item(GMenuModel *menu_model, const gchar *action_name, const gchar *target, const gchar *label, const gchar *accel_name, const gchar *tooltip)
Update the GMenuModel item based on the action name by copying existing item, removing it and inserti...
void gnc_menu_item_setup_tooltip_to_statusbar_callback(GtkWidget *menu_item, GtkWidget *statusbar)
Setup the callbacks for menu bar items so the tooltip can be displayed in the status bar...