[grisbi-devel] [PATCH 05/12] Rewriting the toolbar of scheduler list
Rémi Cardona
remi at gentoo.org
Tue Mar 5 07:26:09 CET 2013
Globalement ok.
1) pourquoi ne pas profiter de la réécriture pour passer à GtkUIManager
voire même à GtkBuilder?
2) quelques commentaires plus bas.
Rémi
Le lundi 04 mars 2013 à 21:19 +0100, pbiava a écrit :
> ---
> src/fenetre_principale.c | 2 +-
> src/gsb_scheduler_list.c | 168 +++++++++++++++++++++++------------------------
> src/gsb_scheduler_list.h | 3 +-
> 3 files changed, 83 insertions(+), 90 deletions(-)
>
> diff --git a/src/fenetre_principale.c b/src/fenetre_principale.c
> index 3f55768..a92731f 100644
> --- a/src/fenetre_principale.c
> +++ b/src/fenetre_principale.c
> @@ -571,7 +571,7 @@ void gsb_gui_update_all_toolbars ( void )
> }
>
> gsb_gui_update_transaction_toolbar ( );
> - gsb_gui_update_scheduler_toolbar ( );
> + gsb_gui_update_scheduler_toolbar ( toolbar_style );
> payees_update_toolbar_list ( );
> categories_update_toolbar_list ( );
> budgetary_lines_update_toolbar_list ( );
> diff --git a/src/gsb_scheduler_list.c b/src/gsb_scheduler_list.c
> index cf06a32..feb44fc 100644
> --- a/src/gsb_scheduler_list.c
> +++ b/src/gsb_scheduler_list.c
> @@ -100,6 +100,7 @@ static gboolean gsb_scheduler_list_set_color_of_mother ( gint mother_scheduled_n
> static void gsb_scheduler_list_set_model ( GtkTreeModel *model );
> static void gsb_scheduler_list_set_sorted_model ( GtkTreeModelSort *tree_model_sort );
> static void gsb_scheduler_list_set_tree_view ( GtkWidget *tree_view );
> +static gboolean gsb_scheduler_list_show_notes ( GtkWidget *item );
> static gboolean gsb_scheduler_list_size_allocate ( GtkWidget *tree_view,
> GtkAllocation *allocation,
> gpointer null );
> @@ -198,6 +199,7 @@ GtkWidget *gsb_scheduler_list_create_list ( void )
> {
> GtkWidget *vbox, *scrolled_window;
> GtkWidget *tree_view;
> + GtkWidget *frame;
> GtkTreeModel *tree_model;
>
> devel_debug (NULL);
> @@ -205,12 +207,14 @@ GtkWidget *gsb_scheduler_list_create_list ( void )
> /* first, a vbox */
> vbox = gtk_box_new ( GTK_ORIENTATION_VERTICAL, 5 );
> gtk_container_set_border_width ( GTK_CONTAINER ( vbox ), 0 );
> - gtk_widget_show ( vbox );
>
> - /* create the toolbar */
> - scheduler_toolbar = gtk_handle_box_new ();
> - gtk_widget_show ( scheduler_toolbar );
> - gtk_box_pack_start ( GTK_BOX ( vbox ), scheduler_toolbar, FALSE, FALSE, 0 );
> + /* frame pour la barre d'outils */
> + frame = gtk_frame_new ( NULL );
> + gtk_box_pack_start ( GTK_BOX ( vbox ), frame, FALSE, FALSE, 0 );
Pourquoi créer une frame ici? Est-elle vraiment nécessaire? Ne peut-on
pas directement mettre la GtkToolbar dans la VBox?
> + /* création de la barre d'outils */
> + scheduler_toolbar = creation_barre_outils_echeancier ();
> + gtk_container_add ( GTK_CONTAINER ( frame ), scheduler_toolbar );
>
> /* create the scrolled window */
> scrolled_window = gtk_scrolled_window_new ( NULL, NULL);
> @@ -238,13 +242,15 @@ GtkWidget *gsb_scheduler_list_create_list ( void )
> gsb_scheduler_list_create_list_columns (tree_view);
>
> /* begin by hiding the notes */
> - gsb_scheduler_list_show_notes ();
> + gsb_scheduler_list_show_notes ( scheduler_display_hide_notes );
>
> g_signal_connect ( G_OBJECT ( gtk_tree_view_get_selection ( GTK_TREE_VIEW ( tree_view ) ) ),
> "changed",
> G_CALLBACK ( gsb_scheduler_list_selection_changed ),
> NULL );
>
> + gtk_widget_show_all ( vbox );
> +
> return vbox;
> }
>
[...]
>
> -
> /**
> *
> *
> *
> */
> -void gsb_gui_update_scheduler_toolbar ( void )
> +void gsb_gui_update_scheduler_toolbar ( gint toolbar_style )
> {
> - GList * list = NULL;
> -
> - list = gtk_container_get_children ( GTK_CONTAINER ( scheduler_toolbar ) );
> -
> - if ( list )
> - {
> - gtk_container_remove ( GTK_CONTAINER ( scheduler_toolbar ),
> - GTK_WIDGET ( list -> data ) );
> - g_list_free ( list );
> - }
> - gtk_container_add ( GTK_CONTAINER ( scheduler_toolbar ), creation_barre_outils_echeancier () );
> + gtk_toolbar_set_style ( GTK_TOOLBAR ( scheduler_toolbar ), toolbar_style );
> }
Vu ce qu'il reste de la fonction et son rôle, je propose de la renommer
en gsb_gui_scheduler_toolbar_set_style(). Ce n'est pas plus court, mais
ça dit bien ce que fait la fonction, contrairement au nom actuel.
> @@ -787,27 +784,24 @@ gint gsb_scheduler_list_default_sort_function ( GtkTreeModel *model,
> *
> * \return FALSE
> */
> -gboolean gsb_scheduler_list_show_notes ( void )
> +gboolean gsb_scheduler_list_show_notes ( GtkWidget *item )
> {
> if ( scheduler_display_hide_notes )
> {
> if ( conf.display_toolbar != GSB_BUTTON_ICON )
> {
> - GtkWidget *label;
> -
> - label = g_object_get_data ( G_OBJECT ( scheduler_display_hide_notes ), "label" );
> if ( etat.affichage_commentaire_echeancier )
> - gtk_label_set_text_with_mnemonic ( GTK_LABEL ( label ), _("Frequency/Mode") );
> + gtk_tool_button_set_label ( GTK_TOOL_BUTTON ( item ), _("Frequency/Mode") );
> else
> - gtk_label_set_text_with_mnemonic ( GTK_LABEL ( label ), _("Notes") );
> + gtk_tool_button_set_label ( GTK_TOOL_BUTTON ( item ), _("Notes") );
> }
>
> if ( etat.affichage_commentaire_echeancier )
> - gtk_widget_set_tooltip_text ( GTK_WIDGET ( scheduler_display_hide_notes ),
> + gtk_widget_set_tooltip_text ( GTK_WIDGET ( item ),
> _("Display the frequency and mode of scheduled transactions") );
> else
> - gtk_widget_set_tooltip_text ( GTK_WIDGET ( scheduler_display_hide_notes ),
> - _("Display the notes of scheduled transactions") );
> + gtk_widget_set_tooltip_text ( GTK_WIDGET ( item ),
> + _("Display the notes of scheduled transactions") );
> }
>
> gtk_tree_view_column_set_visible ( GTK_TREE_VIEW_COLUMN ( scheduler_list_column[COL_NB_FREQUENCY] ),
> @@ -2386,7 +2380,7 @@ void popup_scheduled_context_menu ( void )
> g_signal_connect_swapped ( G_OBJECT ( menu_item ),
> "activate",
> G_CALLBACK ( gsb_scheduler_list_show_notes ),
> - NULL );
> + scheduler_display_hide_notes );
> gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ), menu_item );
>
> /* Separator */
> diff --git a/src/gsb_scheduler_list.h b/src/gsb_scheduler_list.h
> index 493ae36..155ea93 100644
> --- a/src/gsb_scheduler_list.h
> +++ b/src/gsb_scheduler_list.h
> @@ -58,7 +58,7 @@ enum periodicity_units {
>
>
> /* START_DECLARATION */
> -void gsb_gui_update_scheduler_toolbar ( void );
> +void gsb_gui_update_scheduler_toolbar ( gint toolbar_style );
> gboolean gsb_scheduler_list_append_new_scheduled ( gint scheduled_number,
> GDate *end_date );
> gboolean gsb_scheduler_list_change_scheduler_view ( enum scheduler_periodicity periodicity,
> @@ -84,7 +84,6 @@ gboolean gsb_scheduler_list_remove_transaction_from_list ( gint scheduled_number
> gboolean gsb_scheduler_list_select ( gint scheduled_number );
> gboolean gsb_scheduler_list_set_background_color ( GtkWidget *tree_view );
> gboolean gsb_scheduler_list_set_largeur_col ( void );
> -gboolean gsb_scheduler_list_show_notes ( void );
> gboolean gsb_scheduler_list_update_transaction_in_list ( gint scheduled_number );
> /* END_DECLARATION */
>
More information about the devel
mailing list