mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Update Schedule Transaction Template dialog status bar
Copy the functions from gnc_main_window that updates the status bar with the action tooltips to gnc_window so that both GncMainWindow and GncEmbeddedWindow can use without duplicating code.
This commit is contained in:
parent
4fba473570
commit
cb69b806e7
@ -338,6 +338,10 @@ gnc_embedded_window_setup_window (GncEmbeddedWindow *window)
|
||||
g_signal_connect (G_OBJECT (window->ui_merge), "add_widget",
|
||||
G_CALLBACK (gnc_embedded_window_add_widget), window);
|
||||
|
||||
/* Use the "connect-proxy" signal for tooltip display in the status bar */
|
||||
g_signal_connect (G_OBJECT (window->ui_merge), "connect-proxy",
|
||||
G_CALLBACK (gnc_window_connect_proxy), priv->statusbar);
|
||||
|
||||
priv->action_group = NULL;
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
@ -3490,95 +3490,6 @@ gnc_main_window_init_menu_updaters (GncMainWindow *window)
|
||||
G_CALLBACK (gnc_main_window_edit_menu_hide_cb), window);
|
||||
}
|
||||
|
||||
/* CS: This callback functions will set the statusbar text to the
|
||||
* "tooltip" property of the currently selected GtkAction.
|
||||
*
|
||||
* This code is directly copied from gtk+/test/testmerge.c.
|
||||
* Thanks to (L)GPL! */
|
||||
typedef struct _ActionStatus ActionStatus;
|
||||
struct _ActionStatus
|
||||
{
|
||||
GtkAction *action;
|
||||
GtkWidget *statusbar;
|
||||
};
|
||||
|
||||
static void
|
||||
action_status_destroy (gpointer data)
|
||||
{
|
||||
ActionStatus *action_status = data;
|
||||
|
||||
g_object_unref (action_status->action);
|
||||
g_object_unref (action_status->statusbar);
|
||||
|
||||
g_free (action_status);
|
||||
}
|
||||
|
||||
static void
|
||||
set_tip (GtkWidget *widget)
|
||||
{
|
||||
ActionStatus *data;
|
||||
gchar *tooltip;
|
||||
|
||||
data = g_object_get_data (G_OBJECT (widget), "action-status");
|
||||
|
||||
if (data)
|
||||
{
|
||||
g_object_get (data->action, "tooltip", &tooltip, NULL);
|
||||
|
||||
gtk_statusbar_push (GTK_STATUSBAR (data->statusbar), 0,
|
||||
tooltip ? tooltip : " ");
|
||||
|
||||
g_free (tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unset_tip (GtkWidget *widget)
|
||||
{
|
||||
ActionStatus *data;
|
||||
|
||||
data = g_object_get_data (G_OBJECT (widget), "action-status");
|
||||
|
||||
if (data)
|
||||
gtk_statusbar_pop (GTK_STATUSBAR (data->statusbar), 0);
|
||||
}
|
||||
|
||||
static void
|
||||
connect_proxy (GtkUIManager *merge,
|
||||
GtkAction *action,
|
||||
GtkWidget *proxy,
|
||||
GtkWidget *statusbar)
|
||||
{
|
||||
if (GTK_IS_MENU_ITEM (proxy))
|
||||
{
|
||||
ActionStatus *data;
|
||||
|
||||
data = g_object_get_data (G_OBJECT (proxy), "action-status");
|
||||
if (data)
|
||||
{
|
||||
g_object_unref (data->action);
|
||||
g_object_unref (data->statusbar);
|
||||
|
||||
data->action = g_object_ref (action);
|
||||
data->statusbar = g_object_ref (statusbar);
|
||||
}
|
||||
else
|
||||
{
|
||||
data = g_new0 (ActionStatus, 1);
|
||||
|
||||
data->action = g_object_ref (action);
|
||||
data->statusbar = g_object_ref (statusbar);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (proxy), "action-status",
|
||||
data, action_status_destroy);
|
||||
|
||||
g_signal_connect (proxy, "select", G_CALLBACK (set_tip), NULL);
|
||||
g_signal_connect (proxy, "deselect", G_CALLBACK (unset_tip), NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* CS: end copied code from gtk+/test/testmerge.c */
|
||||
|
||||
static void
|
||||
gnc_main_window_window_menu (GncMainWindow *window)
|
||||
{
|
||||
@ -3700,10 +3611,10 @@ gnc_main_window_setup_window (GncMainWindow *window)
|
||||
|
||||
g_signal_connect (G_OBJECT (window->ui_merge), "add_widget",
|
||||
G_CALLBACK (gnc_main_window_add_widget), window);
|
||||
/* Use the "connect-proxy" signal for tooltip display in the
|
||||
status bar */
|
||||
|
||||
/* Use the "connect-proxy" signal for tooltip display in the status bar */
|
||||
g_signal_connect (G_OBJECT (window->ui_merge), "connect-proxy",
|
||||
G_CALLBACK (connect_proxy), priv->statusbar);
|
||||
G_CALLBACK (gnc_window_connect_proxy), priv->statusbar);
|
||||
|
||||
filename = gnc_filepath_locate_ui_file("gnc-main-window-ui.xml");
|
||||
|
||||
|
@ -210,3 +210,93 @@ gnc_window_show_progress (const char *message, double percentage)
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
}
|
||||
|
||||
|
||||
/* CS: This callback functions will set the statusbar text to the
|
||||
* "tooltip" property of the currently selected GtkAction.
|
||||
*
|
||||
* This code is directly copied from gtk+/test/testmerge.c.
|
||||
* Thanks to (L)GPL! */
|
||||
typedef struct _ActionStatus ActionStatus;
|
||||
struct _ActionStatus
|
||||
{
|
||||
GtkAction *action;
|
||||
GtkWidget *statusbar;
|
||||
};
|
||||
|
||||
static void
|
||||
action_status_destroy (gpointer data)
|
||||
{
|
||||
ActionStatus *action_status = data;
|
||||
|
||||
g_object_unref (action_status->action);
|
||||
g_object_unref (action_status->statusbar);
|
||||
|
||||
g_free (action_status);
|
||||
}
|
||||
|
||||
static void
|
||||
set_tip (GtkWidget *widget)
|
||||
{
|
||||
ActionStatus *data;
|
||||
gchar *tooltip;
|
||||
|
||||
data = g_object_get_data (G_OBJECT (widget), "action-status");
|
||||
|
||||
if (data)
|
||||
{
|
||||
g_object_get (data->action, "tooltip", &tooltip, NULL);
|
||||
|
||||
gtk_statusbar_push (GTK_STATUSBAR (data->statusbar), 0,
|
||||
tooltip ? tooltip : " ");
|
||||
|
||||
g_free (tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unset_tip (GtkWidget *widget)
|
||||
{
|
||||
ActionStatus *data;
|
||||
|
||||
data = g_object_get_data (G_OBJECT (widget), "action-status");
|
||||
|
||||
if (data)
|
||||
gtk_statusbar_pop (GTK_STATUSBAR (data->statusbar), 0);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_window_connect_proxy (GtkUIManager *merge,
|
||||
GtkAction *action,
|
||||
GtkWidget *proxy,
|
||||
GtkWidget *statusbar)
|
||||
{
|
||||
if (GTK_IS_MENU_ITEM (proxy))
|
||||
{
|
||||
ActionStatus *data;
|
||||
|
||||
data = g_object_get_data (G_OBJECT (proxy), "action-status");
|
||||
if (data)
|
||||
{
|
||||
g_object_unref (data->action);
|
||||
g_object_unref (data->statusbar);
|
||||
|
||||
data->action = g_object_ref (action);
|
||||
data->statusbar = g_object_ref (statusbar);
|
||||
}
|
||||
else
|
||||
{
|
||||
data = g_new0 (ActionStatus, 1);
|
||||
|
||||
data->action = g_object_ref (action);
|
||||
data->statusbar = g_object_ref (statusbar);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (proxy), "action-status",
|
||||
data, action_status_destroy);
|
||||
|
||||
g_signal_connect (proxy, "select", G_CALLBACK (set_tip), NULL);
|
||||
g_signal_connect (proxy, "deselect", G_CALLBACK (unset_tip), NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* CS: end copied code from gtk+/test/testmerge.c */
|
||||
|
@ -79,6 +79,22 @@ GncWindow *gnc_window_get_progressbar_window (void);
|
||||
GtkWidget *gnc_window_get_progressbar (GncWindow *window);
|
||||
void gnc_window_show_progress (const char *message, double percentage);
|
||||
|
||||
/** This callback functions will set the statusbar text to the
|
||||
* "tooltip" property of the currently selected GtkAction
|
||||
*
|
||||
* @param merge A pointer to the ui manager
|
||||
*
|
||||
* @param action A pointer to the action
|
||||
*
|
||||
* @param proxy A pointer to the proxy
|
||||
*
|
||||
* @param statusbar A pointer to the statusbar widget
|
||||
*/
|
||||
void gnc_window_connect_proxy (GtkUIManager *merge,
|
||||
GtkAction *action,
|
||||
GtkWidget *proxy,
|
||||
GtkWidget *statusbar);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GNC_WINDOW_H */
|
||||
|
Loading…
Reference in New Issue
Block a user