Merge lp:~aauzi/midori/fix-1177553-3 into lp:midori

Proposed by André Auzi
Status: Superseded
Proposed branch: lp:~aauzi/midori/fix-1177553-3
Merge into: lp:midori
Diff against target: 1940 lines (+1825/-37)
5 files modified
katze/katze-cellrenderer2pixbufs.c (+359/-0)
katze/katze-cellrenderer2pixbufs.h (+59/-0)
katze/katze-cellrenderer2texts.c (+1136/-0)
katze/katze-cellrenderer2texts.h (+71/-0)
midori/midori-browser.c (+200/-37)
To merge this branch: bzr merge lp:~aauzi/midori/fix-1177553-3
Reviewer Review Type Date Requested Status
Cris Dywan Needs Fixing
Review via email: mp+172463@code.launchpad.net

This proposal has been superseded by a proposal from 2013-07-18.

Description of the change

This last step for Bookmark folder tree reflection addresses the bookmarks edit dialog combo box.

The combo box is reworked to display a tree view of the bookmark folders.

Folder icons are added and give, in the combo box, a display of folders that aims to have consistent aspect with bookmark bar, bookmark menu and bookmark panel.

The combo box population algorithm is reworked to handle the case of sub-folders referring to a previously populated parent folder.

After this process, remaining items of the retrieved folders list are orphaned folder entries.

NOTE: such orphaned folders are actually created when deleting non empty folders.

It looks like the statements "FOREIGN KEY(parentid) REFERENCES bookmarks(id) ON DELETE CASCADE" used in the bookmarks table structure does not work as expected. This should should be traced in another bug.

NOTE 1: I finally dropped the idea of displaying the folder's path in the combo box button.

First, the solution I had was only working with GTK2 and, second, I think it's more consistent this way.

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote :

I could live with the "duplicate" folder if need be. If it's feasible I'd consider renaming the "second" menu item to "Choose this folder", a style I've seen in a few places.
For the sizing, sokoke.c has a function, alternatively something screen width based. Hard to say which works best in this case honestly.

review: Needs Fixing
lp:~aauzi/midori/fix-1177553-3 updated
6245. By André Auzi

merge lp:midori

6246. By André Auzi

manage a way to render combobox opened folder differently

6247. By André Auzi

implement only combo box text cell renderer by derivation

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'katze/katze-cellrenderer2pixbufs.c'
--- katze/katze-cellrenderer2pixbufs.c 1970-01-01 00:00:00 +0000
+++ katze/katze-cellrenderer2pixbufs.c 2013-07-18 19:43:28 +0000
@@ -0,0 +1,359 @@
1/*
2 Copyright (C) 2008-2013 Christian Dywan <christian@twotoasts.de>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 See the file COPYING for the full license text.
10*/
11
12#include "katze-cellrenderer2pixbufs.h"
13
14#include "marshal.h"
15
16#include <gdk/gdk.h>
17
18#define P_(String) (String)
19#define I_(String) (String)
20#define GTK_PARAM_READABLE G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
21#define GTK_PARAM_WRITABLE G_PARAM_WRITABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
22#define GTK_PARAM_READWRITE G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
23
24
25static void
26katze_cell_renderer_2pixbufs_finalize (GObject* object);
27static void
28katze_cell_renderer_2pixbufs_get_property (GObject* object,
29 guint param_id,
30 GValue* value,
31 GParamSpec* pspec);
32static void
33katze_cell_renderer_2pixbufs_set_property (GObject* object,
34 guint param_id,
35 const GValue* value,
36 GParamSpec* pspec);
37static void
38katze_cell_renderer_2pixbufs_get_size (GtkCellRenderer* cell,
39 GtkWidget* widget,
40 GdkRectangle* cell_area,
41 gint* x_offset,
42 gint* y_offset,
43 gint* width,
44 gint* height);
45static void
46#if GTK_CHECK_VERSION(3,0,0)
47katze_cell_renderer_2pixbufs_render (GtkCellRenderer *cell,
48 cairo_t* cr,
49 GtkWidget *widget,
50 GdkRectangle *background_area,
51 GdkRectangle *cell_area,
52 GtkCellRendererState flags);
53#else
54katze_cell_renderer_2pixbufs_render (GtkCellRenderer *cell,
55 GdkDrawable *window,
56 GtkWidget *widget,
57 GdkRectangle *background_area,
58 GdkRectangle *cell_area,
59 GdkRectangle *expose_area,
60 GtkCellRendererState flags);
61#endif
62
63enum {
64 PROP_0,
65 PROP_PIXBUF_EXPANDER_OPEN,
66 PROP_PIXBUF_EXPANDER_CLOSED,
67 PROP_FOLLOW_STATE,
68};
69
70#define KATZE_CELL_RENDERER_2PIXBUFS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KATZE_TYPE_CELL_RENDERER_2PIXBUFS, KatzeCellRenderer2PixbufsPrivate))
71
72typedef struct _KatzeCellRenderer2PixbufsPrivate KatzeCellRenderer2PixbufsPrivate;
73struct _KatzeCellRenderer2PixbufsPrivate
74{
75 GtkCellRendererPixbuf* cellpixbuf;
76
77 guint markup_set : 1;
78 guint alternate_markup_set : 1;
79};
80
81G_DEFINE_TYPE (KatzeCellRenderer2Pixbufs, katze_cell_renderer_2pixbufs, GTK_TYPE_CELL_RENDERER)
82
83static void
84katze_cell_renderer_2pixbufs_notify (GObject *gobject,
85 GParamSpec *pspec,
86 KatzeCellRenderer2Pixbufs *cellpixbuf)
87{
88 if (!g_strcmp0(P_("text"), pspec->name)
89 || !g_strcmp0(P_("attributes"), pspec->name))
90 return;
91
92 g_object_notify (G_OBJECT (cellpixbuf), pspec->name);
93}
94
95static void
96katze_cell_renderer_2pixbufs_init (KatzeCellRenderer2Pixbufs *cellpixbuf)
97{
98 GValue true_value = {0};
99 KatzeCellRenderer2PixbufsPrivate *priv;
100
101 priv = KATZE_CELL_RENDERER_2PIXBUFS_GET_PRIVATE (cellpixbuf);
102
103 priv->cellpixbuf = GTK_CELL_RENDERER_PIXBUF (gtk_cell_renderer_pixbuf_new());
104 g_object_ref (priv->cellpixbuf);
105
106 g_value_init (&true_value, G_TYPE_BOOLEAN);
107 g_value_set_boolean (&true_value, TRUE);
108 g_object_set_property (G_OBJECT (priv->cellpixbuf), "is-expander", &true_value);
109 g_value_reset (&true_value);
110
111 g_signal_connect (priv->cellpixbuf, "notify",
112 G_CALLBACK (katze_cell_renderer_2pixbufs_notify),
113 cellpixbuf);
114}
115
116static void
117katze_cell_renderer_2pixbufs_class_init (KatzeCellRenderer2PixbufsClass *class)
118{
119 GObjectClass *object_class = G_OBJECT_CLASS (class);
120 GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class);
121
122 object_class->finalize = katze_cell_renderer_2pixbufs_finalize;
123
124 object_class->get_property = katze_cell_renderer_2pixbufs_get_property;
125 object_class->set_property = katze_cell_renderer_2pixbufs_set_property;
126
127 cell_class->get_size = katze_cell_renderer_2pixbufs_get_size;
128 cell_class->render = katze_cell_renderer_2pixbufs_render;
129
130 g_object_class_install_property (object_class,
131 PROP_PIXBUF_EXPANDER_OPEN,
132 g_param_spec_object ("pixbuf-expander-open",
133 P_("Pixbuf Expander Open"),
134 P_("Pixbuf for open expander"),
135 GDK_TYPE_PIXBUF,
136 GTK_PARAM_READWRITE));
137
138 g_object_class_install_property (object_class,
139 PROP_PIXBUF_EXPANDER_CLOSED,
140 g_param_spec_object ("pixbuf-expander-closed",
141 P_("Pixbuf Expander Closed"),
142 P_("Pixbuf for closed expander"),
143 GDK_TYPE_PIXBUF,
144 GTK_PARAM_READWRITE));
145
146 /**
147 * GtkCellRendererPixbuf:follow-state:
148 *
149 * Specifies whether the rendered pixbuf should be colorized
150 * according to the #GtkCellRendererState.
151 *
152 * Since: 2.8
153 */
154 g_object_class_install_property (object_class,
155 PROP_FOLLOW_STATE,
156 g_param_spec_boolean ("follow-state",
157 P_("Follow State"),
158 P_("Whether the rendered pixbuf should be "
159 "colorized according to the state"),
160 FALSE,
161 GTK_PARAM_READWRITE));
162
163 g_type_class_add_private (object_class, sizeof (KatzeCellRenderer2PixbufsPrivate));
164}
165
166static void
167katze_cell_renderer_2pixbufs_finalize (GObject *object)
168{
169 KatzeCellRenderer2Pixbufs *cellpixbuf = KATZE_CELL_RENDERER_2PIXBUFS (object);
170 KatzeCellRenderer2PixbufsPrivate *priv;
171
172 priv = KATZE_CELL_RENDERER_2PIXBUFS_GET_PRIVATE (object);
173
174 g_object_unref (priv->cellpixbuf);
175
176 G_OBJECT_CLASS (katze_cell_renderer_2pixbufs_parent_class)->finalize (object);
177}
178
179static const gchar* const cell_pixbuf_renderer_property_names[] =
180{
181 /* GtkCellRendererPixbuf args */
182 "pixbuf-expander-open",
183 "pixbuf-expander-closed",
184 "follow-state"
185};
186
187static void
188katze_cell_renderer_2pixbufs_get_property (GObject* object,
189 guint param_id,
190 GValue* value,
191 GParamSpec* pspec)
192{
193 KatzeCellRenderer2Pixbufs *cellpixbuf = KATZE_CELL_RENDERER_2PIXBUFS (object);
194 KatzeCellRenderer2PixbufsPrivate *priv;
195
196 priv = KATZE_CELL_RENDERER_2PIXBUFS_GET_PRIVATE (object);
197
198 switch (param_id)
199 {
200 case PROP_PIXBUF_EXPANDER_OPEN:
201 case PROP_PIXBUF_EXPANDER_CLOSED:
202 case PROP_FOLLOW_STATE:
203 g_object_get_property (G_OBJECT (priv->cellpixbuf), cell_pixbuf_renderer_property_names[param_id-PROP_PIXBUF_EXPANDER_OPEN], value);
204 break;
205 default:
206 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
207 break;
208 }
209}
210
211
212static void
213katze_cell_renderer_2pixbufs_set_property (GObject* object,
214 guint param_id,
215 const GValue* value,
216 GParamSpec* pspec)
217{
218 KatzeCellRenderer2Pixbufs *cellpixbuf = KATZE_CELL_RENDERER_2PIXBUFS (object);
219 KatzeCellRenderer2PixbufsPrivate *priv;
220
221 priv = KATZE_CELL_RENDERER_2PIXBUFS_GET_PRIVATE (object);
222
223 switch (param_id)
224 {
225 case PROP_PIXBUF_EXPANDER_OPEN:
226 case PROP_PIXBUF_EXPANDER_CLOSED:
227 case PROP_FOLLOW_STATE:
228 g_object_set_property (G_OBJECT (priv->cellpixbuf), cell_pixbuf_renderer_property_names[param_id-PROP_PIXBUF_EXPANDER_OPEN], value);
229 break;
230
231 default:
232 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
233 break;
234 }
235}
236
237/**
238 * katze_cell_renderer_2pixbufs_new:
239 *
240 * Creates a new #KatzeCellRenderer2Pixbufs. Adjust how text is drawn using
241 * object properties. Object properties can be
242 * set globally (with g_object_set()). Also, with #GtkTreeViewColumn,
243 * you can bind a property to a value in a #GtkTreeModel. For example,
244 * you can bind the "text" property on the cell renderer to a string
245 * value in the model, thus rendering a different string in each row
246 * of the #GtkTreeView
247 *
248 * Return value: the new cell renderer
249 **/
250GtkCellRenderer *
251katze_cell_renderer_2pixbufs_new (void)
252{
253 return g_object_new (KATZE_TYPE_CELL_RENDERER_2PIXBUFS, NULL);
254}
255
256static GtkCellRendererState
257set_pixbuf(KatzeCellRenderer2Pixbufs* cellpixbuf,
258 GtkWidget* widget,
259 KatzeCellRenderer2PixbufsPrivate* priv,
260 GtkCellRendererState flags)
261{
262 GtkWidget* pwidget = gtk_widget_get_parent (widget);
263 gboolean alternate = FALSE;
264 GValue false_value = {0};
265 GValue true_value = {0};
266 g_value_init (&false_value, G_TYPE_BOOLEAN);
267 g_value_init (&true_value, G_TYPE_BOOLEAN);
268 g_value_set_boolean (&false_value, FALSE);
269 g_value_set_boolean (&true_value, TRUE);
270
271 if (GTK_IS_MENU_ITEM (pwidget))
272 {
273 GtkWidget* menu = gtk_widget_get_parent (pwidget);
274 GList* items;
275
276 if (menu
277 && (GTK_IS_MENU (menu))
278 && (items = gtk_container_get_children (GTK_CONTAINER (menu)))
279 && (GTK_WIDGET (items->data) == pwidget)
280 && (g_list_length (items) > 1)
281 && (GTK_IS_SEPARATOR_MENU_ITEM (g_list_next (items)->data)))
282 {
283 alternate = TRUE;
284 }
285 }
286
287 g_object_set_property (G_OBJECT (priv->cellpixbuf), "is-expander", &true_value);
288 if (alternate)
289 {
290 flags |= (1<<6) /* GTK_CELL_RENDERER_EXPANDED */ ;
291 g_object_set_property (G_OBJECT (priv->cellpixbuf), "is-expanded", &true_value);
292 }
293 else
294 {
295 flags |= (1<<5) /* GTK_CELL_RENDERER_EXPANDABLE*/ ;
296 g_object_set_property (G_OBJECT (priv->cellpixbuf), "is-expanded", &false_value);
297 }
298 return flags;
299}
300
301static void
302katze_cell_renderer_2pixbufs_get_size (GtkCellRenderer *cell,
303 GtkWidget *widget,
304 GdkRectangle *cell_area,
305 gint *x_offset,
306 gint *y_offset,
307 gint *width,
308 gint *height)
309{
310 KatzeCellRenderer2Pixbufs *cellpixbuf = (KatzeCellRenderer2Pixbufs *) cell;
311 KatzeCellRenderer2PixbufsPrivate *priv;
312 priv = KATZE_CELL_RENDERER_2PIXBUFS_GET_PRIVATE (cell);
313
314 gtk_cell_renderer_get_size (GTK_CELL_RENDERER (priv->cellpixbuf),
315 widget, cell_area,
316 x_offset, y_offset, width, height);
317}
318
319static void
320#if GTK_CHECK_VERSION(3,0,0)
321katze_cell_renderer_2pixbufs_render (GtkCellRenderer *cell,
322 cairo_t* cr,
323 GtkWidget *widget,
324 GdkRectangle *background_area,
325 GdkRectangle *cell_area,
326 GtkCellRendererState flags)
327#else
328katze_cell_renderer_2pixbufs_render (GtkCellRenderer *cell,
329 GdkDrawable *window,
330 GtkWidget *widget,
331 GdkRectangle *background_area,
332 GdkRectangle *cell_area,
333 GdkRectangle *expose_area,
334 GtkCellRendererState flags)
335#endif
336{
337 KatzeCellRenderer2Pixbufs *cellpixbuf = (KatzeCellRenderer2Pixbufs *) cell;
338 KatzeCellRenderer2PixbufsPrivate *priv;
339
340 priv = KATZE_CELL_RENDERER_2PIXBUFS_GET_PRIVATE (cell);
341
342
343#if GTK_CHECK_VERSION(3,0,0)
344 gtk_cell_renderer_render (GTK_CELL_RENDERER (priv->cellpixbuf),
345 cr,
346 widget,
347 background_area,
348 cell_area,
349 set_pixbuf (cellpixbuf, widget, priv, flags));
350#else
351 gtk_cell_renderer_render (GTK_CELL_RENDERER (priv->cellpixbuf),
352 window,
353 widget,
354 background_area,
355 cell_area,
356 expose_area,
357 set_pixbuf (cellpixbuf, widget, priv, flags));
358#endif
359}
0360
=== added file 'katze/katze-cellrenderer2pixbufs.h'
--- katze/katze-cellrenderer2pixbufs.h 1970-01-01 00:00:00 +0000
+++ katze/katze-cellrenderer2pixbufs.h 2013-07-18 19:43:28 +0000
@@ -0,0 +1,59 @@
1/*
2 Copyright (C) 2008-2013 Christian Dywan <christian@twotoasts.de>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 See the file COPYING for the full license text.
10*/
11
12#ifndef __KATZE_CELL_RENDERER_2PIXBUFS_H__
13#define __KATZE_CELL_RENDERER_2PIXBUFS_H__
14
15
16#include <gtk/gtk.h>
17
18#ifndef GSEAL
19#define GSEAL(String) String
20#endif
21
22
23G_BEGIN_DECLS
24
25
26#define KATZE_TYPE_CELL_RENDERER_2PIXBUFS (katze_cell_renderer_2pixbufs_get_type ())
27#define KATZE_CELL_RENDERER_2PIXBUFS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KATZE_TYPE_CELL_RENDERER_2PIXBUFS, KatzeCellRenderer2Pixbufs))
28#define KATZE_CELL_RENDERER_2PIXBUFS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KATZE_TYPE_CELL_RENDERER_2PIXBUFS, KatzeCellRenderer2PixbufsClass))
29#define KATZE_IS_CELL_RENDERER_2PIXBUFS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KATZE_TYPE_CELL_RENDERER_2PIXBUFS))
30#define KATZE_IS_CELL_RENDERER_2PIXBUFS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_CELL_RENDERER_2PIXBUFS))
31#define KATZE_CELL_RENDERER_2PIXBUFS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_CELL_RENDERER_2PIXBUFS, GtkCellRenderer2PixbufsClass))
32
33typedef struct _KatzeCellRenderer2Pixbufs KatzeCellRenderer2Pixbufs;
34typedef struct _KatzeCellRenderer2PixbufsClass KatzeCellRenderer2PixbufsClass;
35
36struct _KatzeCellRenderer2Pixbufs
37{
38 GtkCellRenderer parent;
39};
40
41struct _KatzeCellRenderer2PixbufsClass
42{
43 GtkCellRendererClass parent_class;
44
45 /* Padding for future expansion */
46 void (*_gtk_reserved1) (void);
47 void (*_gtk_reserved2) (void);
48 void (*_gtk_reserved3) (void);
49 void (*_gtk_reserved4) (void);
50};
51
52GType katze_cell_renderer_2pixbufs_get_type (void) G_GNUC_CONST;
53GtkCellRenderer *katze_cell_renderer_2pixbufs_new (void);
54
55
56G_END_DECLS
57
58
59#endif /* __KATZE_CELL_RENDERER_2PIXBUFS_H__ */
060
=== added file 'katze/katze-cellrenderer2texts.c'
--- katze/katze-cellrenderer2texts.c 1970-01-01 00:00:00 +0000
+++ katze/katze-cellrenderer2texts.c 2013-07-18 19:43:28 +0000
@@ -0,0 +1,1136 @@
1/*
2 Copyright (C) 2008-2013 Christian Dywan <christian@twotoasts.de>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 See the file COPYING for the full license text.
10*/
11
12#include "katze-cellrenderer2texts.h"
13
14#include "marshal.h"
15
16#include <gdk/gdk.h>
17
18#define P_(String) (String)
19#define I_(String) (String)
20#define GTK_PARAM_READABLE G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
21#define GTK_PARAM_WRITABLE G_PARAM_WRITABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
22#define GTK_PARAM_READWRITE G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
23
24
25static void
26katze_cell_renderer_2texts_finalize (GObject* object);
27
28static void
29katze_cell_renderer_2texts_get_property (GObject* object,
30 guint param_id,
31 GValue* value,
32 GParamSpec* pspec);
33static void
34katze_cell_renderer_2texts_set_property (GObject* object,
35 guint param_id,
36 const GValue* value,
37 GParamSpec* pspec);
38static void
39katze_cell_renderer_2texts_get_size (GtkCellRenderer* cell,
40 GtkWidget* widget,
41 GdkRectangle* cell_area,
42 gint* x_offset,
43 gint* y_offset,
44 gint* width,
45 gint* height);
46static void
47#if GTK_CHECK_VERSION(3,0,0)
48katze_cell_renderer_2texts_render (GtkCellRenderer *cell,
49 cairo_t* cr,
50 GtkWidget *widget,
51 GdkRectangle *background_area,
52 GdkRectangle *cell_area,
53 GtkCellRendererState flags);
54#else
55katze_cell_renderer_2texts_render (GtkCellRenderer *cell,
56 GdkDrawable *window,
57 GtkWidget *widget,
58 GdkRectangle *background_area,
59 GdkRectangle *cell_area,
60 GdkRectangle *expose_area,
61 GtkCellRendererState flags);
62#endif
63
64static GtkCellEditable *
65katze_cell_renderer_2texts_start_editing (GtkCellRenderer *cell,
66 GdkEvent *event,
67 GtkWidget *widget,
68 const gchar *path,
69 GdkRectangle *background_area,
70 GdkRectangle *cell_area,
71 GtkCellRendererState flags);
72
73enum {
74 EDITED,
75 LAST_SIGNAL
76};
77
78enum {
79 PROP_0,
80
81 PROP_TEXT,
82 PROP_MARKUP,
83 PROP_ATTRIBUTES,
84 PROP_ALTERNATE_TEXT,
85 PROP_ALTERNATE_MARKUP,
86 PROP_ALTERNATE_ATTRIBUTES,
87
88 /* GtkCellRendererText args */
89 PROP_SINGLE_PARAGRAPH_MODE,
90 PROP_WIDTH_CHARS,
91 PROP_WRAP_WIDTH,
92 PROP_ALIGN,
93
94 /* Style args */
95 PROP_BACKGROUND,
96 PROP_FOREGROUND,
97 PROP_BACKGROUND_GDK,
98 PROP_FOREGROUND_GDK,
99 PROP_FONT,
100 PROP_FONT_DESC,
101 PROP_FAMILY,
102 PROP_STYLE,
103 PROP_VARIANT,
104 PROP_WEIGHT,
105 PROP_STRETCH,
106 PROP_SIZE,
107 PROP_SIZE_POINTS,
108 PROP_SCALE,
109 PROP_EDITABLE,
110 PROP_STRIKETHROUGH,
111 PROP_UNDERLINE,
112 PROP_RISE,
113 PROP_LANGUAGE,
114 PROP_ELLIPSIZE,
115 PROP_WRAP_MODE,
116
117 /* Whether-a-style-arg-is-set args */
118 PROP_BACKGROUND_SET,
119 PROP_FOREGROUND_SET,
120 PROP_FAMILY_SET,
121 PROP_STYLE_SET,
122 PROP_VARIANT_SET,
123 PROP_WEIGHT_SET,
124 PROP_STRETCH_SET,
125 PROP_SIZE_SET,
126 PROP_SCALE_SET,
127 PROP_EDITABLE_SET,
128 PROP_STRIKETHROUGH_SET,
129 PROP_UNDERLINE_SET,
130 PROP_RISE_SET,
131 PROP_LANGUAGE_SET,
132 PROP_ELLIPSIZE_SET,
133 PROP_ALIGN_SET
134};
135
136static guint _2texts_cell_renderer_signals [LAST_SIGNAL];
137
138#define KATZE_CELL_RENDERER_2TEXTS_PATH "gtk-cell-renderer-text-path"
139
140#define KATZE_CELL_RENDERER_2TEXTS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KATZE_TYPE_CELL_RENDERER_2TEXTS, KatzeCellRenderer2textsPrivate))
141
142typedef struct _KatzeCellRenderer2textsPrivate KatzeCellRenderer2textsPrivate;
143struct _KatzeCellRenderer2textsPrivate
144{
145 GtkCellRendererText* celltext;
146
147 guint markup_set : 1;
148 guint alternate_markup_set : 1;
149};
150
151G_DEFINE_TYPE (KatzeCellRenderer2texts, katze_cell_renderer_2texts, GTK_TYPE_CELL_RENDERER)
152
153static void
154katze_cell_renderer_2texts_notify (GObject *gobject,
155 GParamSpec *pspec,
156 KatzeCellRenderer2texts *celltext)
157{
158 if (!g_strcmp0(P_("text"), pspec->name)
159 || !g_strcmp0(P_("attributes"), pspec->name))
160 return;
161
162 g_object_notify (G_OBJECT (celltext), pspec->name);
163}
164
165static void
166katze_cell_renderer_2texts_init (KatzeCellRenderer2texts *celltext)
167{
168 KatzeCellRenderer2textsPrivate *priv;
169
170 priv = KATZE_CELL_RENDERER_2TEXTS_GET_PRIVATE (celltext);
171
172 priv->celltext = GTK_CELL_RENDERER_TEXT (gtk_cell_renderer_text_new());
173 g_object_ref (priv->celltext);
174
175 priv->markup_set = FALSE;
176 priv->alternate_markup_set = FALSE;
177
178 g_signal_connect (priv->celltext, "notify",
179 G_CALLBACK (katze_cell_renderer_2texts_notify),
180 celltext);
181}
182
183static void
184katze_cell_renderer_2texts_class_init (KatzeCellRenderer2textsClass *class)
185{
186 GObjectClass *object_class = G_OBJECT_CLASS (class);
187 GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class);
188
189 object_class->finalize = katze_cell_renderer_2texts_finalize;
190
191 object_class->get_property = katze_cell_renderer_2texts_get_property;
192 object_class->set_property = katze_cell_renderer_2texts_set_property;
193
194 cell_class->get_size = katze_cell_renderer_2texts_get_size;
195 cell_class->render = katze_cell_renderer_2texts_render;
196 cell_class->start_editing = katze_cell_renderer_2texts_start_editing;
197
198 g_object_class_install_property (object_class,
199 PROP_TEXT,
200 g_param_spec_string ("text",
201 P_("Text"),
202 P_("Text to render"),
203 NULL,
204 GTK_PARAM_READWRITE));
205
206 g_object_class_install_property (object_class,
207 PROP_ALTERNATE_TEXT,
208 g_param_spec_string ("alternate-text",
209 P_("Alternate text"),
210 P_("Text to render if 2texts is opened"),
211 NULL,
212 GTK_PARAM_READWRITE));
213
214 g_object_class_install_property (object_class,
215 PROP_MARKUP,
216 g_param_spec_string ("markup",
217 P_("Markup"),
218 P_("Marked up text to render"),
219 NULL,
220 GTK_PARAM_WRITABLE));
221
222 g_object_class_install_property (object_class,
223 PROP_ALTERNATE_MARKUP,
224 g_param_spec_string ("alternate-markup",
225 P_("Markup"),
226 P_("Marked up text to render if 2texts is opened"),
227 NULL,
228 GTK_PARAM_WRITABLE));
229
230 g_object_class_install_property (object_class,
231 PROP_ATTRIBUTES,
232 g_param_spec_boxed ("attributes",
233 P_("Attributes"),
234 P_("A list of style attributes to apply to the text of the renderer"),
235 PANGO_TYPE_ATTR_LIST,
236 GTK_PARAM_READWRITE));
237
238 g_object_class_install_property (object_class,
239 PROP_ALTERNATE_ATTRIBUTES,
240 g_param_spec_boxed ("alternate-attributes",
241 P_("Attributes"),
242 P_("A list of style attributes to apply to the text of the renderer"),
243 PANGO_TYPE_ATTR_LIST,
244 GTK_PARAM_READWRITE));
245
246 g_object_class_install_property (object_class,
247 PROP_SINGLE_PARAGRAPH_MODE,
248 g_param_spec_boolean ("single-paragraph-mode",
249 P_("Single Paragraph Mode"),
250 P_("Whether or not to keep all text in a single paragraph"),
251 FALSE,
252 GTK_PARAM_READWRITE));
253
254
255 g_object_class_install_property (object_class,
256 PROP_BACKGROUND,
257 g_param_spec_string ("background",
258 P_("Background color name"),
259 P_("Background color as a string"),
260 NULL,
261 GTK_PARAM_WRITABLE));
262
263 g_object_class_install_property (object_class,
264 PROP_BACKGROUND_GDK,
265 g_param_spec_boxed ("background-gdk",
266 P_("Background color"),
267 P_("Background color as a GdkColor"),
268 GDK_TYPE_COLOR,
269 GTK_PARAM_READWRITE));
270
271 g_object_class_install_property (object_class,
272 PROP_FOREGROUND,
273 g_param_spec_string ("foreground",
274 P_("Foreground color name"),
275 P_("Foreground color as a string"),
276 NULL,
277 GTK_PARAM_WRITABLE));
278
279 g_object_class_install_property (object_class,
280 PROP_FOREGROUND_GDK,
281 g_param_spec_boxed ("foreground-gdk",
282 P_("Foreground color"),
283 P_("Foreground color as a GdkColor"),
284 GDK_TYPE_COLOR,
285 GTK_PARAM_READWRITE));
286
287
288 g_object_class_install_property (object_class,
289 PROP_EDITABLE,
290 g_param_spec_boolean ("editable",
291 P_("Editable"),
292 P_("Whether the text can be modified by the user"),
293 FALSE,
294 GTK_PARAM_READWRITE));
295
296 g_object_class_install_property (object_class,
297 PROP_FONT,
298 g_param_spec_string ("font",
299 P_("Font"),
300 P_("Font description as a string, e.g. \"Sans Italic 12\""),
301 NULL,
302 GTK_PARAM_READWRITE));
303
304 g_object_class_install_property (object_class,
305 PROP_FONT_DESC,
306 g_param_spec_boxed ("font-desc",
307 P_("Font"),
308 P_("Font description as a PangoFontDescription struct"),
309 PANGO_TYPE_FONT_DESCRIPTION,
310 GTK_PARAM_READWRITE));
311
312
313 g_object_class_install_property (object_class,
314 PROP_FAMILY,
315 g_param_spec_string ("family",
316 P_("Font family"),
317 P_("Name of the font family, e.g. Sans, Helvetica, Times, Monospace"),
318 NULL,
319 GTK_PARAM_READWRITE));
320
321 g_object_class_install_property (object_class,
322 PROP_STYLE,
323 g_param_spec_enum ("style",
324 P_("Font style"),
325 P_("Font style"),
326 PANGO_TYPE_STYLE,
327 PANGO_STYLE_NORMAL,
328 GTK_PARAM_READWRITE));
329
330 g_object_class_install_property (object_class,
331 PROP_VARIANT,
332 g_param_spec_enum ("variant",
333 P_("Font variant"),
334 P_("Font variant"),
335 PANGO_TYPE_VARIANT,
336 PANGO_VARIANT_NORMAL,
337 GTK_PARAM_READWRITE));
338
339 g_object_class_install_property (object_class,
340 PROP_WEIGHT,
341 g_param_spec_int ("weight",
342 P_("Font weight"),
343 P_("Font weight"),
344 0,
345 G_MAXINT,
346 PANGO_WEIGHT_NORMAL,
347 GTK_PARAM_READWRITE));
348
349 g_object_class_install_property (object_class,
350 PROP_STRETCH,
351 g_param_spec_enum ("stretch",
352 P_("Font stretch"),
353 P_("Font stretch"),
354 PANGO_TYPE_STRETCH,
355 PANGO_STRETCH_NORMAL,
356 GTK_PARAM_READWRITE));
357
358 g_object_class_install_property (object_class,
359 PROP_SIZE,
360 g_param_spec_int ("size",
361 P_("Font size"),
362 P_("Font size"),
363 0,
364 G_MAXINT,
365 0,
366 GTK_PARAM_READWRITE));
367
368 g_object_class_install_property (object_class,
369 PROP_SIZE_POINTS,
370 g_param_spec_double ("size-points",
371 P_("Font points"),
372 P_("Font size in points"),
373 0.0,
374 G_MAXDOUBLE,
375 0.0,
376 GTK_PARAM_READWRITE));
377
378 g_object_class_install_property (object_class,
379 PROP_SCALE,
380 g_param_spec_double ("scale",
381 P_("Font scale"),
382 P_("Font scaling factor"),
383 0.0,
384 G_MAXDOUBLE,
385 1.0,
386 GTK_PARAM_READWRITE));
387
388 g_object_class_install_property (object_class,
389 PROP_RISE,
390 g_param_spec_int ("rise",
391 P_("Rise"),
392 P_("Offset of text above the baseline "
393 "(below the baseline if rise is negative)"),
394 -G_MAXINT,
395 G_MAXINT,
396 0,
397 GTK_PARAM_READWRITE));
398
399
400 g_object_class_install_property (object_class,
401 PROP_STRIKETHROUGH,
402 g_param_spec_boolean ("strikethrough",
403 P_("Strikethrough"),
404 P_("Whether to strike through the text"),
405 FALSE,
406 GTK_PARAM_READWRITE));
407
408 g_object_class_install_property (object_class,
409 PROP_UNDERLINE,
410 g_param_spec_enum ("underline",
411 P_("Underline"),
412 P_("Style of underline for this text"),
413 PANGO_TYPE_UNDERLINE,
414 PANGO_UNDERLINE_NONE,
415 GTK_PARAM_READWRITE));
416
417 g_object_class_install_property (object_class,
418 PROP_LANGUAGE,
419 g_param_spec_string ("language",
420 P_("Language"),
421 P_("The language this text is in, as an ISO code. "
422 "Pango can use this as a hint when rendering the text. "
423 "If you don't understand this parameter, you probably don't need it"),
424 NULL,
425 GTK_PARAM_READWRITE));
426
427
428 /**
429 * KatzeCellRenderer2texts:ellipsize:
430 *
431 * Specifies the preferred place to ellipsize the string, if the cell renderer
432 * does not have enough room to display the entire string. Setting it to
433 * %PANGO_ELLIPSIZE_NONE turns off ellipsizing. See the wrap-width property
434 * for another way of making the text fit into a given width.
435 *
436 * Since: 2.6
437 */
438 g_object_class_install_property (object_class,
439 PROP_ELLIPSIZE,
440 g_param_spec_enum ("ellipsize",
441 P_("Ellipsize"),
442 P_("The preferred place to ellipsize the string, "
443 "if the cell renderer does not have enough room "
444 "to display the entire string"),
445 PANGO_TYPE_ELLIPSIZE_MODE,
446 PANGO_ELLIPSIZE_NONE,
447 GTK_PARAM_READWRITE));
448
449 /**
450 * KatzeCellRenderer2texts:width-chars:
451 *
452 * The desired width of the cell, in characters. If this property is set to
453 * -1, the width will be calculated automatically, otherwise the cell will
454 * request either 3 characters or the property value, whichever is greater.
455 *
456 * Since: 2.6
457 **/
458 g_object_class_install_property (object_class,
459 PROP_WIDTH_CHARS,
460 g_param_spec_int ("width-chars",
461 P_("Width In Characters"),
462 P_("The desired width of the label, in characters"),
463 -1,
464 G_MAXINT,
465 -1,
466 GTK_PARAM_READWRITE));
467
468 /**
469 * KatzeCellRenderer2texts:wrap-mode:
470 *
471 * Specifies how to break the string into multiple lines, if the cell
472 * renderer does not have enough room to display the entire string.
473 * This property has no effect unless the wrap-width property is set.
474 *
475 * Since: 2.8
476 */
477 g_object_class_install_property (object_class,
478 PROP_WRAP_MODE,
479 g_param_spec_enum ("wrap-mode",
480 P_("Wrap mode"),
481 P_("How to break the string into multiple lines, "
482 "if the cell renderer does not have enough room "
483 "to display the entire string"),
484 PANGO_TYPE_WRAP_MODE,
485 PANGO_WRAP_CHAR,
486 GTK_PARAM_READWRITE));
487
488 /**
489 * KatzeCellRenderer2texts:wrap-width:
490 *
491 * Specifies the width at which the text is wrapped. The wrap-mode property can
492 * be used to influence at what character positions the line breaks can be placed.
493 * Setting wrap-width to -1 turns wrapping off.
494 *
495 * Since: 2.8
496 */
497 g_object_class_install_property (object_class,
498 PROP_WRAP_WIDTH,
499 g_param_spec_int ("wrap-width",
500 P_("Wrap width"),
501 P_("The width at which the text is wrapped"),
502 -1,
503 G_MAXINT,
504 -1,
505 GTK_PARAM_READWRITE));
506
507 /**
508 * KatzeCellRenderer2texts:alignment:
509 *
510 * Specifies how to align the lines of text with respect to each other.
511 *
512 * Note that this property describes how to align the lines of text in
513 * case there are several of them. The "xalign" property of #GtkCellRenderer,
514 * on the other hand, sets the horizontal alignment of the whole text.
515 *
516 * Since: 2.10
517 */
518 g_object_class_install_property (object_class,
519 PROP_ALIGN,
520 g_param_spec_enum ("alignment",
521 P_("Alignment"),
522 P_("How to align the lines"),
523 PANGO_TYPE_ALIGNMENT,
524 PANGO_ALIGN_LEFT,
525 GTK_PARAM_READWRITE));
526
527 /* Style props are set or not */
528
529#define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, GTK_PARAM_READWRITE))
530
531 ADD_SET_PROP ("background-set", PROP_BACKGROUND_SET,
532 P_("Background set"),
533 P_("Whether this tag affects the background color"));
534
535 ADD_SET_PROP ("foreground-set", PROP_FOREGROUND_SET,
536 P_("Foreground set"),
537 P_("Whether this tag affects the foreground color"));
538
539 ADD_SET_PROP ("editable-set", PROP_EDITABLE_SET,
540 P_("Editability set"),
541 P_("Whether this tag affects text editability"));
542
543 ADD_SET_PROP ("family-set", PROP_FAMILY_SET,
544 P_("Font family set"),
545 P_("Whether this tag affects the font family"));
546
547 ADD_SET_PROP ("style-set", PROP_STYLE_SET,
548 P_("Font style set"),
549 P_("Whether this tag affects the font style"));
550
551 ADD_SET_PROP ("variant-set", PROP_VARIANT_SET,
552 P_("Font variant set"),
553 P_("Whether this tag affects the font variant"));
554
555 ADD_SET_PROP ("weight-set", PROP_WEIGHT_SET,
556 P_("Font weight set"),
557 P_("Whether this tag affects the font weight"));
558
559 ADD_SET_PROP ("stretch-set", PROP_STRETCH_SET,
560 P_("Font stretch set"),
561 P_("Whether this tag affects the font stretch"));
562
563 ADD_SET_PROP ("size-set", PROP_SIZE_SET,
564 P_("Font size set"),
565 P_("Whether this tag affects the font size"));
566
567 ADD_SET_PROP ("scale-set", PROP_SCALE_SET,
568 P_("Font scale set"),
569 P_("Whether this tag scales the font size by a factor"));
570
571 ADD_SET_PROP ("rise-set", PROP_RISE_SET,
572 P_("Rise set"),
573 P_("Whether this tag affects the rise"));
574
575 ADD_SET_PROP ("strikethrough-set", PROP_STRIKETHROUGH_SET,
576 P_("Strikethrough set"),
577 P_("Whether this tag affects strikethrough"));
578
579 ADD_SET_PROP ("underline-set", PROP_UNDERLINE_SET,
580 P_("Underline set"),
581 P_("Whether this tag affects underlining"));
582
583 ADD_SET_PROP ("language-set", PROP_LANGUAGE_SET,
584 P_("Language set"),
585 P_("Whether this tag affects the language the text is rendered as"));
586
587 ADD_SET_PROP ("ellipsize-set", PROP_ELLIPSIZE_SET,
588 P_("Ellipsize set"),
589 P_("Whether this tag affects the ellipsize mode"));
590
591 ADD_SET_PROP ("align-set", PROP_ALIGN_SET,
592 P_("Align set"),
593 P_("Whether this tag affects the alignment mode"));
594
595 /**
596 * KatzeCellRenderer2texts::edited
597 * @renderer: the object which received the signal
598 * @path: the path identifying the edited cell
599 * @new_text: the new text
600 *
601 * This signal is emitted after @renderer has been edited.
602 *
603 * It is the responsibility of the application to update the model
604 * and store @new_text at the position indicated by @path.
605 */
606 _2texts_cell_renderer_signals [EDITED] =
607 g_signal_new (I_("edited"),
608 G_OBJECT_CLASS_TYPE (object_class),
609 G_SIGNAL_RUN_LAST,
610 G_STRUCT_OFFSET (KatzeCellRenderer2textsClass, edited),
611 NULL, NULL,
612 midori_cclosure_marshal_VOID__STRING_STRING,
613 G_TYPE_NONE, 2,
614 G_TYPE_STRING,
615 G_TYPE_STRING);
616
617 g_type_class_add_private (object_class, sizeof (KatzeCellRenderer2textsPrivate));
618}
619
620static void
621katze_cell_renderer_2texts_finalize (GObject *object)
622{
623 KatzeCellRenderer2texts *celltext = KATZE_CELL_RENDERER_2TEXTS (object);
624 KatzeCellRenderer2textsPrivate *priv;
625
626 priv = KATZE_CELL_RENDERER_2TEXTS_GET_PRIVATE (object);
627
628 g_free (celltext->text);
629 if (celltext->extra_attrs)
630 pango_attr_list_unref (celltext->extra_attrs);
631
632 g_free (celltext->alternate_text);
633 if (celltext->alternate_extra_attrs)
634 pango_attr_list_unref (celltext->alternate_extra_attrs);
635
636 g_object_unref (priv->celltext);
637
638 G_OBJECT_CLASS (katze_cell_renderer_2texts_parent_class)->finalize (object);
639}
640
641static const gchar* const cell_text_renderer_property_names[] =
642{
643 /* GtkCellRendererText args */
644 "single-paragraph-mode",
645 "width-chars",
646 "wrap-width",
647 "align",
648
649 /* Style args */
650 "background",
651 "foreground",
652 "background-gdk",
653 "foreground-gdk",
654 "font",
655 "font-desc",
656 "family",
657 "style",
658 "variant",
659 "weight",
660 "stretch",
661 "size",
662 "size-points",
663 "scale",
664 "editable",
665 "strikethrough",
666 "underline",
667 "rise",
668 "language",
669 "ellipsize",
670 "wrap-mode",
671
672 /* Whether-a-style-arg-is-set args */
673 "background-set",
674 "foreground-set",
675 "family-set",
676 "style-set",
677 "variant-set",
678 "weight-set",
679 "stretch-set",
680 "size-set",
681 "scale-set",
682 "editable-set",
683 "strikethrough-set",
684 "underline-set",
685 "rise-set",
686 "language-set",
687 "ellipsize-set",
688 "align-set"
689};
690
691static void
692katze_cell_renderer_2texts_get_property (GObject* object,
693 guint param_id,
694 GValue* value,
695 GParamSpec* pspec)
696{
697 KatzeCellRenderer2texts *celltext = KATZE_CELL_RENDERER_2TEXTS (object);
698 KatzeCellRenderer2textsPrivate *priv;
699
700 priv = KATZE_CELL_RENDERER_2TEXTS_GET_PRIVATE (object);
701
702 switch (param_id)
703 {
704 case PROP_TEXT:
705 g_value_set_string (value, celltext->text);
706 break;
707
708 case PROP_ATTRIBUTES:
709 g_value_set_boxed (value, celltext->extra_attrs);
710 break;
711
712 case PROP_ALTERNATE_TEXT:
713 g_value_set_string (value, celltext->alternate_text);
714 break;
715
716 case PROP_ALTERNATE_ATTRIBUTES:
717 g_value_set_boxed (value, celltext->alternate_extra_attrs);
718 break;
719
720 case PROP_SINGLE_PARAGRAPH_MODE:
721 case PROP_BACKGROUND_GDK:
722 case PROP_FOREGROUND_GDK:
723 case PROP_FONT:
724 case PROP_FONT_DESC:
725 case PROP_FAMILY:
726 case PROP_STYLE:
727 case PROP_VARIANT:
728 case PROP_WEIGHT:
729 case PROP_STRETCH:
730 case PROP_SIZE:
731 case PROP_SIZE_POINTS:
732 case PROP_SCALE:
733 case PROP_EDITABLE:
734 case PROP_STRIKETHROUGH:
735 case PROP_UNDERLINE:
736 case PROP_RISE:
737 case PROP_LANGUAGE:
738 case PROP_ELLIPSIZE:
739 case PROP_WRAP_MODE:
740 case PROP_WRAP_WIDTH:
741 case PROP_ALIGN:
742 case PROP_BACKGROUND_SET:
743 case PROP_FOREGROUND_SET:
744 case PROP_FAMILY_SET:
745 case PROP_STYLE_SET:
746 case PROP_VARIANT_SET:
747 case PROP_WEIGHT_SET:
748 case PROP_STRETCH_SET:
749 case PROP_SIZE_SET:
750 case PROP_SCALE_SET:
751 case PROP_EDITABLE_SET:
752 case PROP_STRIKETHROUGH_SET:
753 case PROP_UNDERLINE_SET:
754 case PROP_RISE_SET:
755 case PROP_LANGUAGE_SET:
756 case PROP_ELLIPSIZE_SET:
757 case PROP_ALIGN_SET:
758 case PROP_WIDTH_CHARS:
759 case PROP_BACKGROUND:
760 case PROP_FOREGROUND:
761 g_object_get_property (G_OBJECT (priv->celltext), cell_text_renderer_property_names[param_id-PROP_SINGLE_PARAGRAPH_MODE], value);
762 break;
763 case PROP_MARKUP:
764 case PROP_ALTERNATE_MARKUP:
765 default:
766 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
767 break;
768 }
769}
770
771
772static void
773katze_cell_renderer_2texts_set_property (GObject* object,
774 guint param_id,
775 const GValue* value,
776 GParamSpec* pspec)
777{
778 KatzeCellRenderer2texts *celltext = KATZE_CELL_RENDERER_2TEXTS (object);
779 KatzeCellRenderer2textsPrivate *priv;
780
781 priv = KATZE_CELL_RENDERER_2TEXTS_GET_PRIVATE (object);
782
783 switch (param_id)
784 {
785 case PROP_TEXT:
786 g_free (celltext->text);
787
788 if (priv->markup_set)
789 {
790 if (celltext->extra_attrs)
791 pango_attr_list_unref (celltext->extra_attrs);
792 celltext->extra_attrs = NULL;
793 priv->markup_set = FALSE;
794 }
795
796 celltext->text = g_value_dup_string (value);
797 g_object_notify (object, "text");
798 break;
799 case PROP_ATTRIBUTES:
800 if (celltext->extra_attrs)
801 pango_attr_list_unref (celltext->extra_attrs);
802
803 celltext->extra_attrs = g_value_get_boxed (value);
804 if (celltext->extra_attrs)
805 pango_attr_list_ref (celltext->extra_attrs);
806 break;
807 case PROP_MARKUP:
808 {
809 const gchar *str;
810 gchar *text = NULL;
811 GError *error = NULL;
812 PangoAttrList *attrs = NULL;
813
814 str = g_value_get_string (value);
815 if (str && !pango_parse_markup (str,
816 -1,
817 0,
818 &attrs,
819 &text,
820 NULL,
821 &error))
822 {
823 g_warning ("Failed to set text from markup due to error parsing markup: %s",
824 error->message);
825 g_error_free (error);
826 return;
827 }
828
829 g_free (celltext->text);
830
831 if (celltext->extra_attrs)
832 pango_attr_list_unref (celltext->extra_attrs);
833
834 celltext->text = text;
835 celltext->extra_attrs = attrs;
836 priv->markup_set = TRUE;
837 }
838 break;
839
840 case PROP_ALTERNATE_TEXT:
841 g_free (celltext->alternate_text);
842
843 if (priv->alternate_markup_set)
844 {
845 if (celltext->alternate_extra_attrs)
846 pango_attr_list_unref (celltext->alternate_extra_attrs);
847 celltext->alternate_extra_attrs = NULL;
848 priv->alternate_markup_set = FALSE;
849 }
850
851 celltext->alternate_text = g_value_dup_string (value);
852 g_object_notify (object, "alternate-text");
853 break;
854 case PROP_ALTERNATE_ATTRIBUTES:
855 if (celltext->alternate_extra_attrs)
856 pango_attr_list_unref (celltext->alternate_extra_attrs);
857
858 celltext->alternate_extra_attrs = g_value_get_boxed (value);
859 if (celltext->alternate_extra_attrs)
860 pango_attr_list_ref (celltext->alternate_extra_attrs);
861 break;
862 case PROP_ALTERNATE_MARKUP:
863 {
864 const gchar *str;
865 gchar *text = NULL;
866 GError *error = NULL;
867 PangoAttrList *attrs = NULL;
868
869 str = g_value_get_string (value);
870 if (str && !pango_parse_markup (str,
871 -1,
872 0,
873 &attrs,
874 &text,
875 NULL,
876 &error))
877 {
878 g_warning ("Failed to set text from markup due to error parsing markup: %s",
879 error->message);
880 g_error_free (error);
881 return;
882 }
883
884 g_free (celltext->alternate_text);
885
886 if (celltext->alternate_extra_attrs)
887 pango_attr_list_unref (celltext->alternate_extra_attrs);
888
889 celltext->alternate_text = text;
890 celltext->alternate_extra_attrs = attrs;
891 priv->alternate_markup_set = TRUE;
892 }
893 break;
894
895 case PROP_SINGLE_PARAGRAPH_MODE:
896 case PROP_BACKGROUND:
897 case PROP_FOREGROUND:
898 case PROP_BACKGROUND_GDK:
899 case PROP_FOREGROUND_GDK:
900 case PROP_FONT:
901 case PROP_FONT_DESC:
902 case PROP_FAMILY:
903 case PROP_STYLE:
904 case PROP_VARIANT:
905 case PROP_WEIGHT:
906 case PROP_STRETCH:
907 case PROP_SIZE:
908 case PROP_SIZE_POINTS:
909 case PROP_SCALE:
910 case PROP_EDITABLE:
911 case PROP_STRIKETHROUGH:
912 case PROP_UNDERLINE:
913 case PROP_RISE:
914 case PROP_LANGUAGE:
915 case PROP_ELLIPSIZE:
916 case PROP_WRAP_MODE:
917 case PROP_WRAP_WIDTH:
918 case PROP_WIDTH_CHARS:
919 case PROP_ALIGN:
920 case PROP_BACKGROUND_SET:
921 case PROP_FOREGROUND_SET:
922 case PROP_FAMILY_SET:
923 case PROP_STYLE_SET:
924 case PROP_VARIANT_SET:
925 case PROP_WEIGHT_SET:
926 case PROP_STRETCH_SET:
927 case PROP_SIZE_SET:
928 case PROP_SCALE_SET:
929 case PROP_EDITABLE_SET:
930 case PROP_STRIKETHROUGH_SET:
931 case PROP_UNDERLINE_SET:
932 case PROP_RISE_SET:
933 case PROP_LANGUAGE_SET:
934 case PROP_ELLIPSIZE_SET:
935 case PROP_ALIGN_SET:
936 g_object_set_property (G_OBJECT (priv->celltext), cell_text_renderer_property_names[param_id-PROP_SINGLE_PARAGRAPH_MODE], value);
937 break;
938
939 default:
940 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
941 break;
942 }
943}
944
945/**
946 * katze_cell_renderer_2texts_new:
947 *
948 * Creates a new #KatzeCellRenderer2texts. Adjust how text is drawn using
949 * object properties. Object properties can be
950 * set globally (with g_object_set()). Also, with #GtkTreeViewColumn,
951 * you can bind a property to a value in a #GtkTreeModel. For example,
952 * you can bind the "text" property on the cell renderer to a string
953 * value in the model, thus rendering a different string in each row
954 * of the #GtkTreeView
955 *
956 * Return value: the new cell renderer
957 **/
958GtkCellRenderer *
959katze_cell_renderer_2texts_new (void)
960{
961 return g_object_new (KATZE_TYPE_CELL_RENDERER_2TEXTS, NULL);
962}
963
964static void
965set_text(KatzeCellRenderer2texts* celltext,
966 GtkWidget* widget,
967 KatzeCellRenderer2textsPrivate* priv)
968{
969 GValue text_value = {0};
970 GValue attrs_value = {0};
971 GtkWidget* pwidget = gtk_widget_get_parent (widget);
972 gboolean alternate = FALSE;
973
974 if (GTK_IS_MENU_ITEM (pwidget))
975 {
976 GtkWidget* menu = gtk_widget_get_parent (pwidget);
977 GList* items;
978
979 if (menu
980 && (GTK_IS_MENU (menu))
981 && (items = gtk_container_get_children (GTK_CONTAINER (menu)))
982 && (GTK_WIDGET (items->data) == pwidget)
983 && (g_list_length (items) > 1)
984 && (GTK_IS_SEPARATOR_MENU_ITEM (g_list_next (items)->data)))
985 {
986 alternate = TRUE;
987 }
988 }
989
990 g_value_init (&text_value, G_TYPE_STRING);
991 g_value_init (&attrs_value, PANGO_TYPE_ATTR_LIST);
992
993 if (alternate)
994 {
995 g_value_set_static_string (&text_value, celltext->alternate_text);
996 g_value_set_boxed (&attrs_value, celltext->alternate_extra_attrs);
997 }
998 else
999 {
1000 g_value_set_static_string (&text_value, celltext->text);
1001 g_value_set_boxed (&attrs_value, celltext->extra_attrs);
1002 }
1003
1004 g_object_set_property (G_OBJECT (priv->celltext),
1005 "text", &text_value);
1006 g_object_set_property (G_OBJECT (priv->celltext),
1007 "attributes", &attrs_value);
1008
1009}
1010
1011static void
1012katze_cell_renderer_2texts_get_size (GtkCellRenderer *cell,
1013 GtkWidget *widget,
1014 GdkRectangle *cell_area,
1015 gint *x_offset,
1016 gint *y_offset,
1017 gint *width,
1018 gint *height)
1019{
1020 KatzeCellRenderer2texts *celltext = (KatzeCellRenderer2texts *) cell;
1021 KatzeCellRenderer2textsPrivate *priv;
1022 priv = KATZE_CELL_RENDERER_2TEXTS_GET_PRIVATE (cell);
1023
1024 set_text (celltext, widget, priv);
1025
1026 gtk_cell_renderer_get_size (GTK_CELL_RENDERER (priv->celltext),
1027 widget, cell_area,
1028 x_offset, y_offset, width, height);
1029}
1030
1031static void
1032#if GTK_CHECK_VERSION(3,0,0)
1033katze_cell_renderer_2texts_render (GtkCellRenderer *cell,
1034 cairo_t* cr,
1035 GtkWidget *widget,
1036 GdkRectangle *background_area,
1037 GdkRectangle *cell_area,
1038 GtkCellRendererState flags)
1039#else
1040katze_cell_renderer_2texts_render (GtkCellRenderer *cell,
1041 GdkDrawable *window,
1042 GtkWidget *widget,
1043 GdkRectangle *background_area,
1044 GdkRectangle *cell_area,
1045 GdkRectangle *expose_area,
1046 GtkCellRendererState flags)
1047#endif
1048{
1049 KatzeCellRenderer2texts *celltext = (KatzeCellRenderer2texts *) cell;
1050 KatzeCellRenderer2textsPrivate *priv;
1051
1052 priv = KATZE_CELL_RENDERER_2TEXTS_GET_PRIVATE (cell);
1053
1054 set_text (celltext, widget, priv);
1055
1056#if GTK_CHECK_VERSION(3,0,0)
1057 gtk_cell_renderer_render (GTK_CELL_RENDERER (priv->celltext),
1058 cr,
1059 widget,
1060 background_area,
1061 cell_area,
1062 flags);
1063#else
1064 gtk_cell_renderer_render (GTK_CELL_RENDERER (priv->celltext),
1065 window,
1066 widget,
1067 background_area,
1068 cell_area,
1069 expose_area,
1070 flags);
1071#endif
1072}
1073
1074static void
1075katze_cell_renderer_2texts_edited (GtkCellRendererText *celltext,
1076 const gchar* path,
1077 const gchar* new_text,
1078 gpointer data)
1079{
1080 g_signal_emit (data, _2texts_cell_renderer_signals[EDITED], 0, path, new_text);
1081}
1082
1083static GtkCellEditable *
1084katze_cell_renderer_2texts_start_editing (GtkCellRenderer *cell,
1085 GdkEvent *event,
1086 GtkWidget *widget,
1087 const gchar *path,
1088 GdkRectangle *background_area,
1089 GdkRectangle *cell_area,
1090 GtkCellRendererState flags)
1091{
1092 GtkCellEditable *celledit;
1093 GtkRequisition requisition;
1094 KatzeCellRenderer2texts *celltext;
1095 KatzeCellRenderer2textsPrivate *priv;
1096
1097 celltext = KATZE_CELL_RENDERER_2TEXTS (cell);
1098 priv = KATZE_CELL_RENDERER_2TEXTS_GET_PRIVATE (cell);
1099
1100 celledit = gtk_cell_renderer_start_editing (GTK_CELL_RENDERER (priv->celltext), event, widget, path, background_area, cell_area, flags);
1101
1102 if (celledit)
1103 g_signal_connect (priv->celltext,
1104 "edited",
1105 G_CALLBACK (katze_cell_renderer_2texts_edited),
1106 celltext);
1107
1108 return celledit;
1109}
1110
1111/**
1112 * katze_cell_renderer_2texts_set_fixed_height_from_font:
1113 * @renderer: A #KatzeCellRenderer2texts
1114 * @number_of_rows: Number of rows of text each cell renderer is allocated, or -1
1115 *
1116 * Sets the height of a renderer to explicitly be determined by the "font" and
1117 * "y_pad" property set on it. Further changes in these properties do not
1118 * affect the height, so they must be accompanied by a subsequent call to this
1119 * function. Using this function is unflexible, and should really only be used
1120 * if calculating the size of a cell is too slow (ie, a massive number of cells
1121 * displayed). If @number_of_rows is -1, then the fixed height is unset, and
1122 * the height is determined by the properties again.
1123 **/
1124void
1125katze_cell_renderer_2texts_set_fixed_height_from_font (KatzeCellRenderer2texts *renderer,
1126 gint number_of_rows)
1127{
1128 g_return_if_fail (KATZE_IS_CELL_RENDERER_2TEXTS (renderer));
1129 g_return_if_fail (number_of_rows == -1 || number_of_rows > 0);
1130
1131 KatzeCellRenderer2textsPrivate *priv;
1132
1133 priv = KATZE_CELL_RENDERER_2TEXTS_GET_PRIVATE (renderer);
1134
1135 gtk_cell_renderer_text_set_fixed_height_from_font (priv->celltext, number_of_rows);
1136}
01137
=== added file 'katze/katze-cellrenderer2texts.h'
--- katze/katze-cellrenderer2texts.h 1970-01-01 00:00:00 +0000
+++ katze/katze-cellrenderer2texts.h 2013-07-18 19:43:28 +0000
@@ -0,0 +1,71 @@
1/*
2 Copyright (C) 2008-2013 Christian Dywan <christian@twotoasts.de>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 See the file COPYING for the full license text.
10*/
11
12#ifndef __KATZE_CELL_RENDERER_2TEXTS_H__
13#define __KATZE_CELL_RENDERER_2TEXTS_H__
14
15
16#include <gtk/gtk.h>
17
18#ifndef GSEAL
19#define GSEAL(String) String
20#endif
21
22G_BEGIN_DECLS
23
24
25#define KATZE_TYPE_CELL_RENDERER_2TEXTS (katze_cell_renderer_2texts_get_type ())
26#define KATZE_CELL_RENDERER_2TEXTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KATZE_TYPE_CELL_RENDERER_2TEXTS, KatzeCellRenderer2texts))
27#define KATZE_CELL_RENDERER_2TEXTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KATZE_TYPE_CELL_RENDERER_2TEXTS, KatzeCellRenderer2textsClass))
28#define KATZE_IS_CELL_RENDERER_2TEXTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KATZE_TYPE_CELL_RENDERER_2TEXTS))
29#define KATZE_IS_CELL_RENDERER_2TEXTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_CELL_RENDERER_2TEXTS))
30#define KATZE_CELL_RENDERER_2TEXTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_CELL_RENDERER_2TEXTS, KatzeCellRenderer2textsClass))
31
32typedef struct _KatzeCellRenderer2texts KatzeCellRenderer2texts;
33typedef struct _KatzeCellRenderer2textsClass KatzeCellRenderer2textsClass;
34
35struct _KatzeCellRenderer2texts
36{
37 GtkCellRenderer parent;
38
39 /*< private >*/
40 gchar *GSEAL (text);
41 PangoAttrList *GSEAL (extra_attrs);
42
43 gchar *GSEAL (alternate_text);
44 PangoAttrList *GSEAL (alternate_extra_attrs);
45};
46
47struct _KatzeCellRenderer2textsClass
48{
49 GtkCellRendererClass parent_class;
50
51 void (* edited) (KatzeCellRenderer2texts *cell_renderer_2texts,
52 const gchar *path,
53 const gchar *new_text);
54
55 /* Padding for future expansion */
56 void (*_gtk_reserved1) (void);
57 void (*_gtk_reserved2) (void);
58 void (*_gtk_reserved3) (void);
59 void (*_gtk_reserved4) (void);
60};
61
62GType katze_cell_renderer_2texts_get_type (void) G_GNUC_CONST;
63GtkCellRenderer *katze_cell_renderer_2texts_new (void);
64
65void katze_cell_renderer_2texts_set_fixed_height_from_font (KatzeCellRenderer2texts *renderer,
66 gint number_of_rows);
67
68
69G_END_DECLS
70
71#endif /* __KATZE_CELL_RENDERER_2TEXTS_H__ */
072
=== modified file 'midori/midori-browser.c'
--- midori/midori-browser.c 2013-07-15 23:01:23 +0000
+++ midori/midori-browser.c 2013-07-18 19:43:28 +0000
@@ -26,6 +26,8 @@
26#include "midori-privatedata.h"26#include "midori-privatedata.h"
27#include "midori-core.h"27#include "midori-core.h"
28#include "midori-privatedata.h"28#include "midori-privatedata.h"
29#include "katze-cellrenderer2texts.h"
30#include "katze-cellrenderer2pixbufs.h"
2931
30#include "marshal.h"32#include "marshal.h"
3133
@@ -828,52 +830,221 @@
828 }830 }
829}831}
830832
833static gboolean
834midori_bookmark_folder_button_reach_parent (GtkTreeModel* model, GtkTreeIter *iter, gint64 parentid)
835{
836 do
837 {
838 gint64 id;
839
840 gtk_tree_model_get (model, iter, 1, &id, -1);
841
842 if (parentid == id)
843 return TRUE;
844
845 if (gtk_tree_model_iter_has_child (model, iter))
846 {
847 GtkTreeIter child;
848 gtk_tree_model_iter_children (model, &child, iter);
849 if (midori_bookmark_folder_button_reach_parent (model, &child, parentid))
850 {
851 *iter = child;
852 return TRUE;
853 }
854 }
855 }
856 while (gtk_tree_model_iter_next (model, iter));
857
858 return FALSE;
859}
860
861typedef struct _FolderEntry
862{
863 const gchar *title;
864 gint64 id;
865 gint64 parentid;
866} FolderEntry;
867
868static void
869midori_bookmark_folder_free_folder_entry (FolderEntry* folder)
870{
871 g_free ((gpointer)folder->title);
872}
873
831static GtkWidget*874static GtkWidget*
832midori_bookmark_folder_button_new (KatzeArray* array,875midori_bookmark_folder_button_new (KatzeArray* array,
833 gint64 selected,876 gint64 selected_parentid)
834 gint64 parentid)
835{877{
836 GtkListStore* model;878 GtkTreeStore* model;
837 GtkWidget* combo;879 GtkWidget* combo;
838 GtkCellRenderer* renderer;880 GtkCellRenderer* renderer;
839 guint n;881 guint n;
840 sqlite3* db;882 sqlite3* db;
841 sqlite3_stmt* statement;883 sqlite3_stmt* statement;
842 gint result;884 gint result;
843 const gchar* sqlcmd = "SELECT title, id FROM bookmarks WHERE uri='' ORDER BY title ASC";885 const gchar* sqlcmd = "SELECT title, id, parentid FROM bookmarks WHERE uri='' ORDER BY parentid, title ASC";
844886 gint64 current_parentid;
845 model = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT64);887 GtkTreeIter tree_iter;
846 combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (model));888 GtkTreeIter stock_parent_iter;
847 renderer = gtk_cell_renderer_text_new ();889 GtkTreeIter* parent_iter;
848 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);890 GList *folders = NULL;
849 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "text", 0);
850 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "ellipsize", 1);
851 gtk_list_store_insert_with_values (model, NULL, G_MAXINT,
852 0, _("Bookmarks"), 1, PANGO_ELLIPSIZE_END, 2, (gint64)0, -1);
853 gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
854891
855 db = g_object_get_data (G_OBJECT (array), "db");892 db = g_object_get_data (G_OBJECT (array), "db");
856 g_return_val_if_fail (db != NULL, NULL);893 g_return_val_if_fail (db != NULL, NULL);
894
895 /* folder combo box model content:
896 ** 0: title
897 ** 1: id
898 */
899 model = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_INT64);
900 combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (model));
901
902 /* setup combo layout
903 ** 0: a folder icon
904 ** 1: the folder name
905 */
906
907 gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo));
908
909 renderer = katze_cell_renderer_2pixbufs_new ();
910 g_object_set (G_OBJECT (renderer),
911 "pixbuf-expander-open",
912 gtk_widget_render_icon (GTK_WIDGET (combo),
913 GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU, NULL),
914 "pixbuf-expander-closed",
915 gtk_widget_render_icon (GTK_WIDGET (combo),
916 GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU, NULL),
917 NULL);
918 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
919
920 renderer = katze_cell_renderer_2texts_new ();
921 g_object_set (G_OBJECT (renderer),
922 "width-chars", 40, /* FIXME: figure out a way to define an acceptable string length */
923 "ellipsize", PANGO_ELLIPSIZE_END,
924 "alternate-text", _("Select this folder"),
925 NULL);
926 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
927 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "text", 0);
928
929 /* read the folders list from the database */
930 /* FIXME: this should be a service of midori/midori-bookmarks-db */
931
932 if ((result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL)) == SQLITE_OK)
933 {
934 while ((result = sqlite3_step (statement)) == SQLITE_ROW)
935 {
936 FolderEntry* folder = g_new (FolderEntry, 1);
937
938 folder->title = g_strdup ((const gchar*)sqlite3_column_text (statement, 0));
939 folder->id = sqlite3_column_int64 (statement, 1);
940 folder->parentid = sqlite3_column_int64 (statement, 2);
941
942 folders = g_list_append (folders, folder);
943 }
944
945 sqlite3_clear_bindings (statement);
946 sqlite3_reset (statement);
947 }
948
949 /* populate the combo box */
950 /* FIXME: here we should have the root bookmark array's name and id, not hard encoded values */
951
952 gtk_tree_store_insert_with_values (model, &tree_iter, NULL, G_MAXINT,
953 0, _("Bookmarks"), 1, (gint64)0, -1);
954 gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &tree_iter);
955
956 current_parentid = 0;
957 parent_iter = NULL;
857 n = 1;958 n = 1;
858 if ((result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL)) == SQLITE_OK)959 while (g_list_first (folders))
859 while ((result = sqlite3_step (statement)) == SQLITE_ROW)
860 {960 {
861 const unsigned char* name = sqlite3_column_text (statement, 0);961 gboolean something_done = FALSE;
862 gint64 id = sqlite3_column_int64 (statement, 1);962 GList* list_iter = g_list_first (folders);
863963
864 /* do not show the folder itself */964 do
865 if (id != selected)
866 {965 {
867 gtk_list_store_insert_with_values (model, NULL, G_MAXINT,966 FolderEntry* folder = list_iter->data;
868 0, name, 1, PANGO_ELLIPSIZE_END, 2, id, -1);967 const gchar* title = folder->title;
869968 gint64 id = folder->id;
870 if (id == parentid)969 gint64 parentid = folder->parentid;
871 gtk_combo_box_set_active (GTK_COMBO_BOX (combo), n);970
971 if (parentid != current_parentid) /* optimize case of sub-folders of the same parent */
972 {
973 if (!parentid)
974 {
975 /* folder's parent is the stree store root */
976
977 current_parentid = 0;
978 parent_iter = NULL;
979 }
980 else if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &tree_iter))
981 {
982 if (midori_bookmark_folder_button_reach_parent (
983 GTK_TREE_MODEL (model), &tree_iter, parentid))
984 {
985 /* folder's parent found in the tree store */
986
987 current_parentid = parentid;
988 stock_parent_iter = tree_iter;
989 parent_iter = &stock_parent_iter;
990 }
991 else
992 {
993 /* folder's parent not found, skip it */
994
995 list_iter = g_list_next (list_iter);
996 continue;
997 }
998 }
999 else
1000 g_assert_not_reached ();
1001 }
1002
1003 /* insert folder in the tree store and remove it from the folders list */
1004
1005 gtk_tree_store_insert_with_values (model, &tree_iter, parent_iter, G_MAXINT,
1006 0, title, 1, id, -1);
1007
1008 if (id == selected_parentid)
1009 gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &tree_iter);
1010
872 n++;1011 n++;
873 }1012
874 }1013 something_done = TRUE;
1014
1015 g_free ((gpointer)title);
1016 folders = g_list_delete_link (folders, list_iter);
1017
1018 list_iter = g_list_first (folders);
1019 }
1020 while (list_iter);
1021
1022 if (!something_done) /* avoid infinite loop in case of orphan folders */
1023 break;
1024 }
1025
1026 if (g_list_first (folders))
1027 {
1028 GList* iter;
1029 g_printerr ("midori_bookmark_folder_button_new: orphan folder(s) detected in bookmarks db\n");
1030
1031 for (iter = g_list_first (folders) ; iter ; iter = g_list_next (iter))
1032 {
1033 FolderEntry* folder = iter->data;
1034 const gchar* title = folder->title;
1035 gint64 id = folder->id;
1036 gint64 parentid = folder->parentid;
1037
1038 g_printerr (" id=%" G_GINT64_FORMAT ", parentid=%" G_GINT64_FORMAT ", title=%s\n",
1039 id, parentid, title);
1040 }
1041
1042 g_list_free_full (folders, (GDestroyNotify)midori_bookmark_folder_free_folder_entry);
1043 }
1044
875 if (n < 2)1045 if (n < 2)
876 gtk_widget_set_sensitive (combo, FALSE);1046 gtk_widget_set_sensitive (combo, FALSE);
1047
877 return combo;1048 return combo;
878}1049}
8791050
@@ -887,14 +1058,8 @@
8871058
888 if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter))1059 if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter))
889 {1060 {
890 gchar* selected = NULL;
891 GtkTreeModel* model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));1061 GtkTreeModel* model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
892 gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, 0, &selected, 2, &id, -1);1062 gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, 1, &id, -1);
893
894 if (g_str_equal (selected, _("Bookmarks")))
895 id = 0;
896
897 g_free (selected);
898 }1063 }
8991064
900 return id;1065 return id;
@@ -1021,7 +1186,6 @@
1021 }1186 }
10221187
1023 combo_folder = midori_bookmark_folder_button_new (browser->bookmarks,1188 combo_folder = midori_bookmark_folder_button_new (browser->bookmarks,
1024 katze_item_get_meta_integer (bookmark, "id"),
1025 katze_item_get_meta_integer (bookmark, "parentid"));1189 katze_item_get_meta_integer (bookmark, "parentid"));
1026 gtk_box_pack_start (GTK_BOX (vbox), combo_folder, FALSE, FALSE, 0);1190 gtk_box_pack_start (GTK_BOX (vbox), combo_folder, FALSE, FALSE, 0);
10271191
@@ -4460,8 +4624,7 @@
4460 gtk_container_add (GTK_CONTAINER (content_area), hbox);4624 gtk_container_add (GTK_CONTAINER (content_area), hbox);
4461 gtk_widget_show_all (hbox);4625 gtk_widget_show_all (hbox);
44624626
4463 combobox_folder = midori_bookmark_folder_button_new (browser->bookmarks,4627 combobox_folder = midori_bookmark_folder_button_new (browser->bookmarks, 0);
4464 0, 0);
4465 gtk_container_add (GTK_CONTAINER (content_area), combobox_folder);4628 gtk_container_add (GTK_CONTAINER (content_area), combobox_folder);
44664629
4467 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);4630 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);

Subscribers

People subscribed via source and target branches

to all changes: