[grisbi-devel] [PATCH 5/8] new functions for toolbars
pbiava
pierre.biava at nerim.net
Sun Feb 17 08:20:38 CET 2013
new functions for use "gtk_toolbar widget" instead of "gtk_handle_box" became obsolete with gtk3
---
src/utils.c | 30 ++++++++++++++++++++++++++++++
src/utils.h | 2 ++
src/utils_buttons.c | 33 +++++++++++++++++++++++++++++++--
src/utils_buttons.h | 2 ++
4 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/src/utils.c b/src/utils.c
index e5eba6c..f4b2a42 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1018,6 +1018,36 @@ gboolean utils_ui_left_panel_tree_view_select_page ( GtkWidget *tree_view,
/**
+ * retourne un menu_item avec une image comme icône
+ *
+ * \param image_name
+ * \param label_name
+ *
+ * \return
+ * */
+GtkWidget *utils_menu_new_item_from_image_label ( const gchar *image_name,
+ const gchar *label_name )
+{
+ GtkWidget *menu_item = NULL;
+ gchar *filename;
+
+ filename = g_build_filename ( gsb_dirs_get_pixmaps_dir (), image_name, NULL );
+ if ( filename )
+ {
+ GtkWidget *image;
+
+ image = gtk_image_new_from_file ( filename );
+ g_free ( filename );
+
+ menu_item = gtk_image_menu_item_new_with_label ( label_name );
+ gtk_image_menu_item_set_image ( GTK_IMAGE_MENU_ITEM ( menu_item ), image );
+ }
+
+ return menu_item;
+}
+
+
+/**
*
*
* \param
diff --git a/src/utils.h b/src/utils.h
index f4304a6..af7fbe1 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -43,6 +43,8 @@ GtkWidget *utils_get_image_with_etat ( GtkMessageType msg,
void utils_gtk_combo_box_set_text_renderer ( GtkComboBox *combo,
gint num_col );
GtkListStore *utils_list_store_create_from_string_array ( gchar **array );
+GtkWidget *utils_menu_new_item_from_image_label ( const gchar *image_name,
+ const gchar *label_name );
gboolean utils_set_image_with_etat ( GtkWidget *widget,
gint etat );
void utils_set_tree_view_selection_and_text_color ( GtkWidget *tree_view );
diff --git a/src/utils_buttons.c b/src/utils_buttons.c
index 4a47173..c509681 100644
--- a/src/utils_buttons.c
+++ b/src/utils_buttons.c
@@ -400,15 +400,17 @@ void utils_radiobutton_set_active_index ( GtkWidget *radiobutton,
*
* \return a GtkToolItem or NULL
* */
-GtkToolItem *utils_buttons_new_from_image_label ( const gchar *image_name, const gchar *label_name )
+GtkToolItem *utils_buttons_new_from_image_label ( const gchar *image_name,
+ const gchar *label_name )
{
GtkToolItem *button = NULL;
- GtkWidget *image;
gchar *filename;
filename = g_build_filename ( gsb_dirs_get_pixmaps_dir (), image_name, NULL );
if ( filename )
{
+ GtkWidget *image;
+
image = gtk_image_new_from_file ( filename );
g_free ( filename );
button = gtk_tool_button_new ( image, label_name );
@@ -419,6 +421,33 @@ GtkToolItem *utils_buttons_new_from_image_label ( const gchar *image_name, const
/**
+ * Création d'un GtkMenuToolButton à partir d'une image et d'un label
+ *
+ * \param image_name filename
+ * \param label_name label for button
+ *
+ * \return a GtkToolItem or NULL
+ * */
+GtkToolItem *utils_buttons_menu_new_from_image_label ( const gchar *image_name,
+ const gchar *label_name )
+{
+ GtkToolItem *button = NULL;
+ GtkWidget *image;
+ gchar *filename;
+
+ filename = g_build_filename ( gsb_dirs_get_pixmaps_dir (), image_name, NULL );
+ if ( filename )
+ {
+ image = gtk_image_new_from_file ( filename );
+ g_free ( filename );
+ button = gtk_menu_tool_button_new ( image, label_name );
+ }
+
+ return button;
+}
+
+
+/**
*
*
* \param
diff --git a/src/utils_buttons.h b/src/utils_buttons.h
index 827a424..4c91700 100644
--- a/src/utils_buttons.h
+++ b/src/utils_buttons.h
@@ -21,6 +21,8 @@ gboolean gsb_button_sensitive_by_checkbutton ( GtkWidget *check_button,
GtkWidget * new_image_label ( GsbButtonStyle style, const gchar * image_name, const gchar * name );
GtkWidget * new_stock_image_label ( GsbButtonStyle style, const gchar * stock_id, const gchar * name );
void set_popup_position (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data);
+GtkToolItem *utils_buttons_menu_new_from_image_label ( const gchar *image_name,
+ const gchar *label_name );
GtkToolItem *utils_buttons_new_from_image_label ( const gchar *image_name, const gchar *label_name );
gint utils_radiobutton_get_active_index ( GtkWidget *radiobutton );
void utils_radiobutton_set_active_index ( GtkWidget *radiobutton,
--
1.8.1.3
More information about the devel
mailing list