1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
/* ************************************************************************** */
/* */
/* Copyright (C) 2005-2008 Benjamin Drieu (bdrieu@april.org) */
/* http://www.grisbi.org */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* */
/* ************************************************************************** */
/**
* \file gsb_status.c
* Various routines that implement the status bar.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "include.h"
/*START_INCLUDE*/
#include "gsb_status.h"
#include "main.h"
#include "utils.h"
/*END_INCLUDE*/
/*START_STATIC*/
/*END_STATIC*/
/*START_EXTERN*/
extern GtkWidget *window;
/*END_EXTERN*/
/** Status bar displayed in the bottom of Grisbi window. */
static GtkWidget *main_statusbar = NULL;
/** Context ID from the GtkStatusBar. */
static guint context_id;
/** Message ID from the GtkStatusBar. */
static guint message_id = -1;
/** Optional progress bar in main status bar. */
/*
static GtkWidget * progress_bar = NULL;
*/
/** Timer ID of the timeout responsible for updating the
* GtkProgressBar. */
/*
static gint timer_id;
*/
/** Window under cursor at the time the cursor animation changed. */
static GdkWindow * tracked_window;
/**
* Create and return a new GtkStatusBar to hold various status
* information.
*
* \return A newly allocated GtkStatusBar.
*/
GtkWidget * gsb_new_statusbar ()
{
main_statusbar = gtk_statusbar_new ();
context_id = gtk_statusbar_get_context_id ( GTK_STATUSBAR (main_statusbar), "Grisbi" );
message_id = -1;
gtk_widget_show_all ( main_statusbar );
return main_statusbar;
}
/**
* Display a message in the status bar.
*
* \param message Message to display.
*/
void gsb_status_message ( gchar * message )
{
if ( ! main_statusbar || ! GTK_IS_STATUSBAR ( main_statusbar ) )
return;
gsb_status_clear ();
message_id = gtk_statusbar_push ( GTK_STATUSBAR (main_statusbar), context_id, message );
/** Call gtk_main_iteration() to ensure status message is
* displayed. This is done because we need to display it
* immediately without waiting to return to gtk_main(). */
while ( gtk_events_pending () ) gtk_main_iteration ( );
}
/**
* Clear any message in the status bar.
*/
void gsb_status_clear ( )
{
if ( ! main_statusbar || ! GTK_IS_STATUSBAR ( main_statusbar ) )
return;
if ( message_id >= 0 )
{
gtk_statusbar_remove ( GTK_STATUSBAR (main_statusbar), context_id, message_id );
message_id = -1;
}
/** Call gtk_main_iteration() to ensure status message is
* displayed. This is done because we need to display it
* immediately without waiting to return to gtk_main(). */
while ( gtk_events_pending () ) gtk_main_iteration ( );
}
/**
* Change current cursor to a animated watch (if animation supported
* by environment).
*
* \param force_update Call a gtk iteration to ensure cursor
* is updated. May cause trouble if
* called from some signal handlers.
*/
void gsb_status_wait ( gboolean force_update )
{
GdkWindow * current_window;
gdk_window_set_cursor ( window -> window,
gdk_cursor_new_for_display ( gdk_display_get_default ( ),
GDK_WATCH ) );
current_window = gdk_display_get_window_at_pointer ( gdk_display_get_default ( ),
NULL, NULL );
if ( current_window && GDK_IS_WINDOW ( current_window ) &&
current_window != window -> window )
{
GdkWindow * parent = gdk_window_get_toplevel ( current_window );
if ( parent && parent != current_window )
{
current_window = parent;
}
gdk_window_set_cursor ( current_window,
gdk_cursor_new_for_display ( gdk_display_get_default ( ),
GDK_WATCH ) );
tracked_window = current_window;
}
if ( force_update )
{
update_ecran ();
}
}
/**
* Change current cursor to default cursor.
*
* \param force_update Call a gtk iteration to ensure cursor
* is updated. May cause trouble if
* called from some signal handlers.
*/
void gsb_status_stop_wait ( gboolean force_update )
{
if ( ! window )
return;
gdk_window_set_cursor ( window -> window, NULL );
if ( tracked_window && gdk_window_is_visible ( tracked_window ) )
{
gdk_window_set_cursor ( tracked_window, NULL );
tracked_window = NULL;
}
if ( force_update )
{
update_ecran ();
}
}
/* Local Variables: */
/* c-basic-offset: 4 */
/* End: */
|