summaryrefslogtreecommitdiff
path: root/thunar/thunar-view.c
blob: 17e556d553f4a3a24ea560a089876879aa46c1eb (plain)
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/* $Id$ */
/*-
 * Copyright (c) 2005 Benedikt Meurer <benny@xfce.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
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <thunar/thunar-view.h>



static void thunar_view_class_init  (gpointer klass);



GType
thunar_view_get_type (void)
{
  static GType type = G_TYPE_INVALID;

  if (G_UNLIKELY (type == G_TYPE_INVALID))
    {
      static const GTypeInfo info =
      {
        sizeof (ThunarViewIface),
        NULL,
        NULL,
        (GClassInitFunc) thunar_view_class_init,
        NULL,
        NULL,
        0,
        0,
        NULL,
      };

      type = g_type_register_static (G_TYPE_INTERFACE, I_("ThunarView"), &info, 0);
      g_type_interface_add_prerequisite (type, GTK_TYPE_WIDGET);
      g_type_interface_add_prerequisite (type, THUNAR_TYPE_NAVIGATOR);
    }

  return type;
}



static void
thunar_view_class_init (gpointer klass)
{
  /**
   * ThunarView:loading:
   *
   * Indicates whether the given #ThunarView is currently loading or
   * layouting its contents. Implementations should invoke
   * #g_object_notify() on this property whenever they start to load
   * the contents and then once they have finished loading.
   *
   * Other modules can use this property to display some kind of
   * user visible notification about the loading state, e.g. a
   * progress bar or an animated image.
   **/
  g_object_interface_install_property (klass,
                                       g_param_spec_boolean ("loading",
                                                             _("Loading"),
                                                             _("Whether the view is currently being loaded"),
                                                             FALSE,
                                                             EXO_PARAM_READABLE));

  /**
   * ThunarView:statusbar-text:
   *
   * The text to be displayed in the status bar, which is associated
   * with this #ThunarView instance. Implementations should invoke
   * #g_object_notify() on this property, whenever they have a new
   * text to be display in the status bar (e.g. the selection changed
   * or similar).
   **/
  g_object_interface_install_property (klass,
                                       g_param_spec_string ("statusbar-text",
                                                            _("Statusbar text"),
                                                            _("Text to be displayed in the statusbar associated with this view"),
                                                            NULL,
                                                            EXO_PARAM_READABLE));

  /**
   * ThunarView:show-hidden:
   *
   * Tells whether to display hidden and backup files in the
   * #ThunarView or whether to hide them.
   **/
  g_object_interface_install_property (klass,
                                       g_param_spec_boolean ("show-hidden",
                                                             _("Show hidden"),
                                                             _("Whether to display hidden files"),
                                                             FALSE,
                                                             EXO_PARAM_READWRITE));

  /**
   * ThunarView:ui-manager:
   *
   * The UI manager used by the surrounding #ThunarWindow. The
   * #ThunarView implementations may connect additional actions
   * to the UI manager.
   **/
  g_object_interface_install_property (klass,
                                       g_param_spec_object ("ui-manager",
                                                            _("UI manager"),
                                                            _("UI manager of the surrounding window"),
                                                            GTK_TYPE_UI_MANAGER,
                                                            EXO_PARAM_READWRITE));
}



/**
 * thunar_view_get_loading:
 * @view : a #ThunarView instance.
 *
 * Tells whether the given #ThunarView is currently loading or
 * layouting its contents.
 *
 * Return value: %TRUE if @view is currently being loaded, else %FALSE.
 **/
gboolean
thunar_view_get_loading (ThunarView *view)
{
  g_return_val_if_fail (THUNAR_IS_VIEW (view), FALSE);
  return (*THUNAR_VIEW_GET_IFACE (view)->get_loading) (view);
}



/**
 * thunar_view_get_statusbar_text:
 * @view : a #ThunarView instance.
 *
 * Queries the text that should be displayed in the status bar
 * associated with @view.
 *
 * Return value: the text to be displayed in the status bar
 *               asssociated with @view.
 **/
const gchar*
thunar_view_get_statusbar_text (ThunarView *view)
{
  g_return_val_if_fail (THUNAR_IS_VIEW (view), NULL);
  return (*THUNAR_VIEW_GET_IFACE (view)->get_statusbar_text) (view);
}



/**
 * thunar_view_get_show_hidden:
 * @view : a #ThunarView instance.
 *
 * Returns %TRUE if hidden and backup files are shown
 * in @view. Else %FALSE is returned.
 *
 * Return value: whether @view displays hidden files.
 **/
gboolean
thunar_view_get_show_hidden (ThunarView *view)
{
  g_return_val_if_fail (THUNAR_IS_VIEW (view), FALSE);
  return (*THUNAR_VIEW_GET_IFACE (view)->get_show_hidden) (view);
}



/**
 * thunar_view_set_show_hidden:
 * @view        : a #ThunarView instance.
 * @show_hidden : &TRUE to display hidden files, else %FALSE.
 *
 * If @show_hidden is %TRUE then @view will display hidden and
 * backup files, else those files will be hidden from the user
 * interface.
 **/
void
thunar_view_set_show_hidden (ThunarView *view,
                             gboolean    show_hidden)
{
  g_return_if_fail (THUNAR_IS_VIEW (view));
  (*THUNAR_VIEW_GET_IFACE (view)->set_show_hidden) (view, show_hidden);
}



/**
 * thunar_view_get_ui_manager:
 * @view : a #ThunarView instance.
 *
 * Returns the #GtkUIManager associated with @view or
 * %NULL if @view has no #GtkUIManager associated with
 * it.
 *
 * Return value: the #GtkUIManager associated with @view
 *               or %NULL.
 **/
GtkUIManager*
thunar_view_get_ui_manager (ThunarView *view)
{
  g_return_val_if_fail (THUNAR_IS_VIEW (view), NULL);
  return (*THUNAR_VIEW_GET_IFACE (view)->get_ui_manager) (view);
}



/**
 * thunar_view_set_ui_manager:
 * @view       : a #ThunarView instance.
 * @ui_manager : a #GtkUIManager or %NULL.
 *
 * Installs a new #GtkUIManager for @view or resets the ::ui-manager
 * property.
 *
 * Implementations of the #ThunarView interface must first disconnect
 * from any previously set #GtkUIManager and then connect to the
 * @ui_manager if not %NULL.
 **/
void
thunar_view_set_ui_manager (ThunarView   *view,
                            GtkUIManager *ui_manager)
{
  g_return_if_fail (THUNAR_IS_VIEW (view));
  g_return_if_fail (ui_manager == NULL || GTK_IS_UI_MANAGER (ui_manager));
  (*THUNAR_VIEW_GET_IFACE (view)->set_ui_manager) (view, ui_manager);
}