~ubuntu-branches/ubuntu/maverick/nautilus-actions/maverick

« back to all changes in this revision

Viewing changes to src/nact/nact-main-statusbar.c

  • Committer: Bazaar Package Importer
  • Author(s): Christine Spang
  • Date: 2009-10-25 14:04:13 UTC
  • mfrom: (1.1.7 upstream) (3.1.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091025140413-okqdth1kvcx8ko3o
Tags: 2.29.1-1
* New upstream version.
  - implements full API as defined for use by Nautilus menu
    extensions : this let the user define items which will be
    available when there is no selection, and will apply to
    current folder, either in the 'File' menu or in the
    toolbar ;
  - the ability for the user to define a full hierarchy of
    actions with menus, submenus, and so on ;
  - drag and drop ;
  - full cut/copy/paste clipboard support.
  - Gnome bugs fixed:
    - #325528 reported by Frederic Ruaudel
              (bloated  contextual menu)
    - #325587 reported by Frederic Ruaudel
              (drag & drop support)
    - #326699 reported by Frederic Ruaudel
              (action items do not remain in user defined order)
    - #353353 reported by Frederic Ruaudel
              (check if command exist and if not warn user)
    - #588482 reported by Sean
            (ordering in actions list)
    - #326699 reported by Frederic Ruaudel
            (action items do not remain in user defined order)
    - #353353 reported by Frederic Ruaudel
              (check if command exist and if not warn user)
    - #588482 reported by Sean
              (ordering in actions list)
    - #590400 reported by Pierre Wieser
              (have some sort of warnings in the ui)
    - #599520 reported by António Lima
              (do not mark authors names and emails for translating)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Nautilus Actions
 
3
 * A Nautilus extension which offers configurable context menu actions.
 
4
 *
 
5
 * Copyright (C) 2005 The GNOME Foundation
 
6
 * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
 
7
 * Copyright (C) 2009 Pierre Wieser and others (see AUTHORS)
 
8
 *
 
9
 * This Program is free software; you can redistribute it and/or
 
10
 * modify it under the terms of the GNU General Public License as
 
11
 * published by the Free Software Foundation; either version 2 of
 
12
 * the License, or (at your option) any later version.
 
13
 *
 
14
 * This Program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public
 
20
 * License along with this Library; see the file COPYING.  If not,
 
21
 * write to the Free Software Foundation, Inc., 59 Temple Place,
 
22
 * Suite 330, Boston, MA 02111-1307, USA.
 
23
 *
 
24
 * Authors:
 
25
 *   Frederic Ruaudel <grumz@grumz.net>
 
26
 *   Rodrigo Moya <rodrigo@gnome-db.org>
 
27
 *   Pierre Wieser <pwieser@trychlos.org>
 
28
 *   ... and many others (see AUTHORS)
 
29
 */
 
30
 
 
31
#ifdef HAVE_CONFIG_H
 
32
#include <config.h>
 
33
#endif
 
34
 
 
35
#include "nact-main-statusbar.h"
 
36
 
 
37
typedef struct {
 
38
        guint         event_source_id;
 
39
        guint         context_id;
 
40
        GtkStatusbar *bar;
 
41
}
 
42
        StatusbarTimeoutDisplayStruct;
 
43
 
 
44
static GtkStatusbar *get_statusbar( const NactMainWindow *window );
 
45
static gboolean      display_timeout( StatusbarTimeoutDisplayStruct *stds );
 
46
static void          display_timeout_free( StatusbarTimeoutDisplayStruct *stds );
 
47
 
 
48
void
 
49
nact_main_statusbar_display_status( NactMainWindow *window, const gchar *context, const gchar *status )
 
50
{
 
51
        GtkStatusbar *bar;
 
52
 
 
53
        if( !status || !g_utf8_strlen( status, -1 )){
 
54
                return;
 
55
        }
 
56
 
 
57
        bar = get_statusbar( window );
 
58
 
 
59
        if( bar ){
 
60
                guint context_id = gtk_statusbar_get_context_id( bar, context );
 
61
                gtk_statusbar_push( bar, context_id, status );
 
62
        }
 
63
}
 
64
 
 
65
/*
 
66
 * push a message
 
67
 * automatically pop it after a timeout
 
68
 * the timeout is not suspended when another message is pushed onto the
 
69
 * previous one
 
70
 */
 
71
void
 
72
nact_main_statusbar_display_with_timeout( NactMainWindow *window, const gchar *context, const gchar *status )
 
73
{
 
74
        GtkStatusbar *bar;
 
75
        StatusbarTimeoutDisplayStruct *stds;
 
76
 
 
77
        if( !status || !g_utf8_strlen( status, -1 )){
 
78
                return;
 
79
        }
 
80
 
 
81
        bar = get_statusbar( window );
 
82
 
 
83
        if( bar ){
 
84
                guint context_id = gtk_statusbar_get_context_id( bar, context );
 
85
                gtk_statusbar_push( bar, context_id, status );
 
86
 
 
87
                stds = g_new0( StatusbarTimeoutDisplayStruct, 1 );
 
88
                stds->context_id = context_id;
 
89
                stds->bar = bar;
 
90
                stds->event_source_id = g_timeout_add_seconds_full(
 
91
                                G_PRIORITY_DEFAULT,
 
92
                                10,
 
93
                                ( GSourceFunc ) display_timeout,
 
94
                                stds,
 
95
                                ( GDestroyNotify ) display_timeout_free );
 
96
        }
 
97
}
 
98
 
 
99
void
 
100
nact_main_statusbar_hide_status( NactMainWindow *window, const gchar *context )
 
101
{
 
102
        GtkStatusbar *bar;
 
103
 
 
104
        bar = get_statusbar( window );
 
105
 
 
106
        if( bar ){
 
107
                guint context_id = gtk_statusbar_get_context_id( bar, context );
 
108
                gtk_statusbar_pop( bar, context_id );
 
109
        }
 
110
}
 
111
 
 
112
/*
 
113
 * Returns the status bar widget
 
114
 */
 
115
static GtkStatusbar *
 
116
get_statusbar( const NactMainWindow *window )
 
117
{
 
118
        GtkWidget *statusbar;
 
119
 
 
120
        statusbar = base_window_get_widget( BASE_WINDOW( window ), "StatusBar" );
 
121
 
 
122
        return( GTK_STATUSBAR( statusbar ));
 
123
}
 
124
 
 
125
static gboolean
 
126
display_timeout( StatusbarTimeoutDisplayStruct *stds )
 
127
{
 
128
        gboolean keep_source = FALSE;
 
129
 
 
130
        gtk_statusbar_pop( stds->bar, stds->context_id );
 
131
 
 
132
        return( keep_source );
 
133
}
 
134
 
 
135
static void
 
136
display_timeout_free( StatusbarTimeoutDisplayStruct *stds )
 
137
{
 
138
        g_debug( "nact_main_statusbar_display_timeout_free: stds=%p", ( void * ) stds );
 
139
 
 
140
        g_free( stds );
 
141
}