Merge lp:~midori/midori/deathnote into lp:midori

Proposed by Cris Dywan
Status: Merged
Approved by: André Stösel
Approved revision: 6472
Merged at revision: 6509
Proposed branch: lp:~midori/midori/deathnote
Merge into: lp:midori
Diff against target: 3403 lines (+709/-2133)
11 files modified
katze/katze-throbber.c (+0/-932)
katze/katze-throbber.h (+0/-94)
katze/katze.h (+0/-1)
midori/midori-browser.c (+148/-567)
midori/midori-notebook.vala (+526/-0)
midori/midori-preferences.c (+0/-5)
midori/midori-settings.vala (+1/-0)
midori/midori-tab.vala (+14/-1)
midori/midori-view.c (+19/-531)
midori/midori.vapi (+0/-1)
po/POTFILES.in (+1/-1)
To merge this branch: bzr merge lp:~midori/midori/deathnote
Reviewer Review Type Date Requested Status
André Stösel Approve
Paweł Forysiuk Approve
Review via email: mp+192262@code.launchpad.net

Commit message

Introduce notebook class converging separate implementations

Description of the change

Rewritten notebook, one code path to rule them all.
destroy and remove-tab are equivalent.
Tabs are always visible.
Tabbar has a 'new tab' button.
Katze.Throbber is dropped, Gtk.Spinner is enough.
Switch tabs by scrolling (absent from GTK+3 Gtk.Notebook).
Support for clicks logically outside label but visually inside.
New tab by double click.
Tab.colors_changed signal

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

Other bug: scrolling the web-view area while adding a tab with ^T acts like a scroll on the tab-bar.

lp:~midori/midori/deathnote updated
6464. By Cris Dywan

Revert to minimum tab size of one icon without close button

6465. By Cris Dywan

Ensure the spinner is the size of the icon

6466. By Cris Dywan

Don't bother setting "current" which is unused with Tabby anyway

6467. By Cris Dywan

Wrap the spinner in an event box to retain its size when hidden

6468. By Cris Dywan

Always update current index when reordering

6469. By Cris Dywan

Micro-optimization, no need to count pages when -1 means the same

6470. By Cris Dywan

Don't wrap tabs when scrolling with a mouse wheel

6471. By Cris Dywan

Don't handle scrolling when the event is in the tab

6472. By Cris Dywan

Drop incomplete tab strip scrolling support

Revision history for this message
Paweł Forysiuk (tuxator) wrote :

I don't see any major issues at this point. Should be fine to merge.

review: Approve
Revision history for this message
André Stösel (ivaldi) wrote :

Nice :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'katze/katze-throbber.c'
2--- katze/katze-throbber.c 2013-06-20 21:15:42 +0000
3+++ katze/katze-throbber.c 1970-01-01 00:00:00 +0000
4@@ -1,932 +0,0 @@
5-/*
6- Copyright (C) 2007-2010 Christian Dywan <christian@twotoasts.de>
7-
8- This library is free software; you can redistribute it and/or
9- modify it under the terms of the GNU Lesser General Public
10- License as published by the Free Software Foundation; either
11- version 2.1 of the License, or (at your option) any later version.
12-
13- See the file COPYING for the full license text.
14-*/
15-
16-#include "katze-throbber.h"
17-
18-#include "katze-utils.h"
19-
20-#include <glib/gi18n.h>
21-#include <math.h>
22-
23-struct _KatzeThrobber
24-{
25- GtkSpinner parent_instance;
26- GtkIconSize icon_size;
27- gchar* icon_name;
28- GdkPixbuf* pixbuf;
29- gchar* stock_id;
30- gboolean animated;
31- gchar* static_icon_name;
32- GdkPixbuf* static_pixbuf;
33- gchar* static_stock_id;
34-
35- gint index;
36- gint timer_id;
37- gint width;
38- gint height;
39-};
40-
41-struct _KatzeThrobberClass
42-{
43- GtkSpinnerClass parent_class;
44-};
45-
46-G_DEFINE_TYPE (KatzeThrobber, katze_throbber, GTK_TYPE_SPINNER);
47-
48-enum
49-{
50- PROP_0,
51-
52- PROP_ICON_SIZE,
53- PROP_ICON_NAME,
54- PROP_PIXBUF,
55- PROP_ANIMATED,
56- PROP_STATIC_ICON_NAME,
57- PROP_STATIC_PIXBUF,
58- PROP_STATIC_STOCK_ID
59-};
60-
61-static void
62-katze_throbber_dispose (GObject* object);
63-
64-static void
65-katze_throbber_set_property (GObject* object,
66- guint prop_id,
67- const GValue* value,
68- GParamSpec* pspec);
69-
70-static void
71-katze_throbber_get_property (GObject* object,
72- guint prop_id,
73- GValue* value,
74- GParamSpec* pspec);
75-
76-static void
77-#if GTK_CHECK_VERSION (3, 0, 0)
78-katze_throbber_destroy (GtkWidget* object);
79-#else
80-katze_throbber_destroy (GtkObject* object);
81-#endif
82-
83-static void
84-katze_throbber_realize (GtkWidget* widget);
85-
86-#if GTK_CHECK_VERSION (3, 0, 0)
87-static void
88-katze_throbber_get_preferred_height (GtkWidget *widget,
89- gint *minimal_height,
90- gint *natural_height);
91-static void
92-katze_throbber_get_preferred_width (GtkWidget *widget,
93- gint *minimal_width,
94- gint *natural_width);
95-#endif
96-static void
97-katze_throbber_unrealize (GtkWidget* widget);
98-
99-static void
100-katze_throbber_map (GtkWidget* widget);
101-
102-static void
103-katze_throbber_unmap (GtkWidget* widget);
104-
105-static void
106-katze_throbber_style_set (GtkWidget* widget,
107- GtkStyle* style);
108-
109-static void
110-katze_throbber_screen_changed (GtkWidget* widget,
111- GdkScreen* screen_prev);
112-
113-static void
114-katze_throbber_size_request (GtkWidget* widget,
115- GtkRequisition* requisition);
116-
117-static gboolean
118-katze_throbber_expose_event (GtkWidget* widget,
119-#if GTK_CHECK_VERSION (3, 0, 0)
120- cairo_t* cr);
121-#else
122- GdkEventExpose* event);
123-#endif
124-
125-static void
126-icon_theme_changed (KatzeThrobber* throbber);
127-
128-static void
129-katze_throbber_class_init (KatzeThrobberClass* class)
130-{
131- GObjectClass* gobject_class;
132-#if !GTK_CHECK_VERSION (3, 0, 0)
133- GtkObjectClass* object_class;
134-#endif
135- GtkWidgetClass* widget_class;
136- GParamFlags flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
137-
138- gobject_class = G_OBJECT_CLASS (class);
139- gobject_class->dispose = katze_throbber_dispose;
140- gobject_class->set_property = katze_throbber_set_property;
141- gobject_class->get_property = katze_throbber_get_property;
142-
143- widget_class = GTK_WIDGET_CLASS (class);
144-#if GTK_CHECK_VERSION (3, 0, 0)
145- widget_class->destroy = katze_throbber_destroy;
146-#else
147- object_class = GTK_OBJECT_CLASS (class);
148- object_class->destroy = katze_throbber_destroy;
149-#endif
150- widget_class->realize = katze_throbber_realize;
151- widget_class->unrealize = katze_throbber_unrealize;
152- widget_class->map = katze_throbber_map;
153- widget_class->unmap = katze_throbber_unmap;
154- widget_class->style_set = katze_throbber_style_set;
155- widget_class->screen_changed = katze_throbber_screen_changed;
156-#if GTK_CHECK_VERSION (3, 0, 0)
157- widget_class->get_preferred_width= katze_throbber_get_preferred_width;
158- widget_class->get_preferred_height= katze_throbber_get_preferred_height;
159-#else
160- widget_class->size_request = katze_throbber_size_request;
161-#endif
162-#if GTK_CHECK_VERSION (3, 0, 0)
163- widget_class->draw = katze_throbber_expose_event;
164-#else
165- widget_class->expose_event = katze_throbber_expose_event;
166-#endif
167- g_object_class_install_property (gobject_class,
168- PROP_ICON_SIZE,
169- g_param_spec_int (
170- "icon-size",
171- "Icon size",
172- "Symbolic size to use for the animation",
173- 0, G_MAXINT, GTK_ICON_SIZE_MENU,
174- flags));
175-
176- g_object_class_install_property (gobject_class,
177- PROP_ICON_NAME,
178- g_param_spec_string (
179- "icon-name",
180- "Icon Name",
181- "The name of an icon containing animation frames",
182- "process-working",
183- flags));
184-
185- g_object_class_install_property (gobject_class,
186- PROP_PIXBUF,
187- g_param_spec_object (
188- "pixbuf",
189- "Pixbuf",
190- "A GdkPixbuf containing animation frames",
191- GDK_TYPE_PIXBUF,
192- G_PARAM_READWRITE));
193-
194- g_object_class_install_property (gobject_class,
195- PROP_ANIMATED,
196- g_param_spec_boolean (
197- "animated",
198- "Animated",
199- "Whether the throbber should be animated",
200- FALSE,
201- flags));
202-
203- g_object_class_install_property (gobject_class,
204- PROP_STATIC_ICON_NAME,
205- g_param_spec_string (
206- "static-icon-name",
207- "Static Icon Name",
208- "The name of an icon to be used as the static image",
209- NULL,
210- flags));
211-
212- g_object_class_install_property (gobject_class,
213- PROP_STATIC_PIXBUF,
214- g_param_spec_object (
215- "static-pixbuf",
216- "Static Pixbuf",
217- "A GdkPixbuf to be used as the static image",
218- GDK_TYPE_PIXBUF,
219- G_PARAM_READWRITE));
220-
221- g_object_class_install_property (gobject_class,
222- PROP_STATIC_STOCK_ID,
223- g_param_spec_string (
224- "static-stock-id",
225- "Static Stock ID",
226- "The stock ID of an icon to be used as the static image",
227- NULL,
228- flags));
229-}
230-
231-static void
232-katze_throbber_init (KatzeThrobber *throbber)
233-{
234- gtk_widget_set_has_window (GTK_WIDGET (throbber), FALSE);
235-
236- throbber->timer_id = -1;
237-}
238-
239-static void
240-katze_throbber_dispose (GObject* object)
241-{
242- KatzeThrobber* throbber = KATZE_THROBBER (object);
243-
244- if (G_UNLIKELY (throbber->timer_id >= 0))
245- g_source_remove (throbber->timer_id);
246-
247- (*G_OBJECT_CLASS (katze_throbber_parent_class)->dispose) (object);
248-}
249-
250-static void
251-#if GTK_CHECK_VERSION (3, 0, 0)
252-katze_throbber_destroy (GtkWidget* object)
253-#else
254-katze_throbber_destroy (GtkObject* object)
255-#endif
256-{
257- KatzeThrobber* throbber = KATZE_THROBBER (object);
258-
259- katze_assign (throbber->icon_name, NULL);
260- katze_object_assign (throbber->pixbuf, NULL);
261- katze_assign (throbber->static_icon_name, NULL);
262- katze_object_assign (throbber->static_pixbuf, NULL);
263- katze_assign (throbber->static_stock_id, NULL);
264-#if GTK_CHECK_VERSION (3, 0, 0)
265- GTK_WIDGET_CLASS (katze_throbber_parent_class)->destroy (object);
266-#else
267- GTK_OBJECT_CLASS (katze_throbber_parent_class)->destroy (object);
268-#endif
269-}
270-
271-static void
272-katze_throbber_set_property (GObject* object,
273- guint prop_id,
274- const GValue* value,
275- GParamSpec* pspec)
276-{
277- KatzeThrobber* throbber = KATZE_THROBBER (object);
278-
279- switch (prop_id)
280- {
281- case PROP_ICON_SIZE:
282- katze_throbber_set_icon_size (throbber, g_value_get_int (value));
283- break;
284- case PROP_ICON_NAME:
285- katze_throbber_set_icon_name (throbber, g_value_get_string (value));
286- break;
287- case PROP_PIXBUF:
288- katze_throbber_set_pixbuf (throbber, g_value_get_object (value));
289- break;
290- case PROP_ANIMATED:
291- katze_throbber_set_animated (throbber, g_value_get_boolean (value));
292- break;
293- case PROP_STATIC_ICON_NAME:
294- katze_throbber_set_static_icon_name (throbber, g_value_get_string (value));
295- break;
296- case PROP_STATIC_PIXBUF:
297- katze_throbber_set_static_pixbuf (throbber, g_value_get_object (value));
298- break;
299- case PROP_STATIC_STOCK_ID:
300- katze_throbber_set_static_stock_id (throbber, g_value_get_string (value));
301- break;
302- default:
303- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
304- break;
305- }
306-}
307-
308-static void
309-katze_throbber_get_property (GObject* object,
310- guint prop_id,
311- GValue* value,
312- GParamSpec* pspec)
313-{
314- KatzeThrobber* throbber = KATZE_THROBBER (object);
315-
316- switch (prop_id)
317- {
318- case PROP_ICON_SIZE:
319- g_value_set_int (value, katze_throbber_get_icon_size (throbber));
320- break;
321- case PROP_ICON_NAME:
322- g_value_set_string (value, katze_throbber_get_icon_name (throbber));
323- break;
324- case PROP_PIXBUF:
325- g_value_set_object (value, katze_throbber_get_pixbuf (throbber));
326- break;
327- case PROP_ANIMATED:
328- g_value_set_boolean (value, katze_throbber_get_animated (throbber));
329- break;
330- case PROP_STATIC_ICON_NAME:
331- g_value_set_string (value, katze_throbber_get_static_icon_name (throbber));
332- break;
333- case PROP_STATIC_PIXBUF:
334- g_value_set_object (value, katze_throbber_get_static_pixbuf (throbber));
335- break;
336- case PROP_STATIC_STOCK_ID:
337- g_value_set_string (value, katze_throbber_get_static_stock_id (throbber));
338- break;
339- default:
340- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
341- break;
342- }
343-}
344-
345-/**
346- * katze_throbber_new:
347- *
348- * Creates a new throbber widget.
349- *
350- * Return value: a new #KatzeThrobber
351- **/
352-GtkWidget*
353-katze_throbber_new (void)
354-{
355- KatzeThrobber* throbber = g_object_new (KATZE_TYPE_THROBBER,
356- NULL);
357-
358- return GTK_WIDGET (throbber);
359-}
360-
361-/**
362- * katze_throbber_set_icon_size:
363- * @throbber: a #KatzeThrobber
364- * @icon_size: the new icon size
365- *
366- * Sets the desired size of the throbber image. The animation and static image
367- * will be displayed in this size. If a pixbuf is used for the animation every
368- * single frame is assumed to have this size.
369- **/
370-void
371-katze_throbber_set_icon_size (KatzeThrobber* throbber,
372- GtkIconSize icon_size)
373-{
374- GtkSettings* gtk_settings;
375-
376- g_return_if_fail (KATZE_IS_THROBBER (throbber));
377- gtk_settings = gtk_widget_get_settings (GTK_WIDGET (throbber));
378- g_return_if_fail (gtk_icon_size_lookup_for_settings (gtk_settings,
379- icon_size,
380- &throbber->width,
381- &throbber->height));
382-
383- throbber->icon_size = icon_size;
384-
385- g_object_notify (G_OBJECT (throbber), "icon-size");
386-
387- gtk_widget_queue_draw (GTK_WIDGET (throbber));
388-}
389-
390-/**
391- * katze_throbber_set_icon_name:
392- * @throbber: a #KatzeThrobber
393- * @icon_name: an icon name or %NULL
394- *
395- * Sets the name of an icon that should provide the animation frames.
396- *
397- * The pixbuf is automatically invalidated.
398- **/
399-void
400-katze_throbber_set_icon_name (KatzeThrobber* throbber,
401- const gchar* icon_name)
402-{
403- g_return_if_fail (KATZE_IS_THROBBER (throbber));
404-
405- katze_assign (throbber->icon_name, g_strdup (icon_name));
406-
407- if (icon_name)
408- icon_theme_changed (throbber);
409-
410- g_object_notify (G_OBJECT (throbber), "icon-name");
411-}
412-
413-/**
414- * katze_throbber_set_pixbuf:
415- * @throbber: a #KatzeThrobber
416- * @pixbuf: a #GdkPixbuf or %NULL
417- *
418- * Sets the pixbuf that should provide the animation frames. Every frame
419- * is assumed to have the icon size of the throbber, which can be specified
420- * with katze_throbber_set_icon_size ().
421- *
422- * The icon name is automatically invalidated.
423- **/
424-void
425-katze_throbber_set_pixbuf (KatzeThrobber* throbber,
426- GdkPixbuf* pixbuf)
427-{
428- g_return_if_fail (KATZE_IS_THROBBER (throbber));
429- g_return_if_fail (!pixbuf || GDK_IS_PIXBUF (pixbuf));
430-
431- katze_object_assign (throbber->pixbuf, pixbuf);
432-
433- g_object_freeze_notify (G_OBJECT (throbber));
434-
435- if (pixbuf)
436- {
437- g_object_ref (pixbuf);
438-
439- katze_assign (throbber->icon_name, NULL);
440- g_object_notify (G_OBJECT (throbber), "icon-name");
441- }
442-
443- gtk_widget_queue_draw (GTK_WIDGET (throbber));
444-
445- g_object_notify (G_OBJECT (throbber), "pixbuf");
446- g_object_thaw_notify (G_OBJECT (throbber));
447-}
448-
449-/**
450- * katze_throbber_set_animated:
451- * @throbber: a #KatzeThrobber
452- * @animated: %TRUE to animate the throbber
453- *
454- * Sets the animation state of the throbber.
455- **/
456-void
457-katze_throbber_set_animated (KatzeThrobber* throbber,
458- gboolean animated)
459-{
460- g_return_if_fail (KATZE_IS_THROBBER (throbber));
461-
462- if (G_UNLIKELY (throbber->animated == animated))
463- return;
464-
465- throbber->animated = animated;
466-
467- g_object_set (throbber, "active", animated, NULL);
468- gtk_widget_queue_draw (GTK_WIDGET (throbber));
469-
470- g_object_notify (G_OBJECT (throbber), "animated");
471-}
472-
473-/**
474- * katze_throbber_set_static_icon_name:
475- * @throbber: a #KatzeThrobber
476- * @icon_name: an icon name or %NULL
477- *
478- * Sets the name of an icon that should provide the static image.
479- *
480- * The static pixbuf and stock ID are automatically invalidated.
481- **/
482-void
483-katze_throbber_set_static_icon_name (KatzeThrobber* throbber,
484- const gchar* icon_name)
485-{
486- g_return_if_fail (KATZE_IS_THROBBER (throbber));
487-
488- katze_assign (throbber->static_icon_name, g_strdup (icon_name));
489-
490- g_object_freeze_notify (G_OBJECT (throbber));
491-
492- if (icon_name)
493- {
494- katze_assign (throbber->static_stock_id, NULL);
495-
496- icon_theme_changed (throbber);
497-
498- g_object_notify (G_OBJECT (throbber), "static-pixbuf");
499- g_object_notify (G_OBJECT (throbber), "static-stock-id");
500- }
501-
502- g_object_notify (G_OBJECT (throbber), "static-icon-name");
503- g_object_thaw_notify (G_OBJECT (throbber));
504-}
505-
506-/**
507- * katze_throbber_set_static_pixbuf:
508- * @throbber: a #KatzeThrobber
509- * @pixbuf: a #GdkPixbuf or %NULL
510- *
511- * Sets the pixbuf that should provide the static image. The pixbuf is
512- * assumed to have the icon size of the throbber, which can be specified
513- * with katze_throbber_set_icon_size ().
514- *
515- * The static icon name and stock ID are automatically invalidated.
516- **/
517-void
518-katze_throbber_set_static_pixbuf (KatzeThrobber* throbber,
519- GdkPixbuf* pixbuf)
520-{
521- g_return_if_fail (KATZE_IS_THROBBER (throbber));
522- g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));
523-
524- katze_object_assign (throbber->static_pixbuf, pixbuf);
525-
526- g_object_freeze_notify (G_OBJECT (throbber));
527-
528- if (pixbuf)
529- {
530- g_object_ref (pixbuf);
531-
532- katze_assign (throbber->static_icon_name, NULL);
533- katze_assign (throbber->static_stock_id, NULL);
534-
535- gtk_widget_queue_draw (GTK_WIDGET (throbber));
536-
537- g_object_notify (G_OBJECT (throbber), "static-icon-name");
538- g_object_notify (G_OBJECT (throbber), "static-stock-id");
539- }
540-
541- g_object_notify (G_OBJECT (throbber), "static-pixbuf");
542- g_object_thaw_notify (G_OBJECT (throbber));
543-}
544-
545-/**
546- * katze_throbber_set_static_stock_id:
547- * @throbber: a #KatzeThrobber
548- * @stock_id: a stock ID or %NULL
549- *
550- * Sets the stock ID of an icon that should provide the static image.
551- *
552- * The static icon name and pixbuf are automatically invalidated.
553- **/
554-void
555-katze_throbber_set_static_stock_id (KatzeThrobber* throbber,
556- const gchar* stock_id)
557-{
558- g_return_if_fail (KATZE_IS_THROBBER (throbber));
559-
560- g_object_freeze_notify (G_OBJECT (throbber));
561-
562- if (stock_id)
563- {
564- GtkStockItem stock_item;
565- g_return_if_fail (gtk_stock_lookup (stock_id, &stock_item));
566-
567- g_object_notify (G_OBJECT (throbber), "static-icon-name");
568- g_object_notify (G_OBJECT (throbber), "static-pixbuf");
569- }
570-
571- katze_assign (throbber->static_stock_id, g_strdup (stock_id));
572-
573- if (stock_id)
574- icon_theme_changed (throbber);
575-
576- g_object_notify (G_OBJECT (throbber), "static-stock-id");
577- g_object_thaw_notify (G_OBJECT (throbber));
578-}
579-
580-/**
581- * katze_throbber_get_icon_size:
582- * @throbber: a #KatzeThrobber
583- *
584- * Retrieves the size of the throbber.
585- *
586- * Return value: the size of the throbber
587- **/
588-GtkIconSize
589-katze_throbber_get_icon_size (KatzeThrobber* throbber)
590-{
591- g_return_val_if_fail (KATZE_IS_THROBBER (throbber), GTK_ICON_SIZE_INVALID);
592-
593- return throbber->icon_size;
594-}
595-
596-/**
597- * katze_throbber_get_icon_name:
598- * @throbber: a #KatzeThrobber
599- *
600- * Retrieves the name of the icon providing the animation frames.
601- *
602- * Return value: the name of the icon providing the animation frames, or %NULL
603- **/
604-const gchar*
605-katze_throbber_get_icon_name (KatzeThrobber* throbber)
606-{
607- g_return_val_if_fail (KATZE_IS_THROBBER (throbber), NULL);
608-
609- return throbber->icon_name;
610-}
611-
612-/**
613- * katze_throbber_get_pixbuf:
614- * @throbber: a #KatzeThrobber
615- *
616- * Retrieves the #GdkPixbuf providing the animation frames if an icon name
617- * or pixbuf is available. The caller of this function does not own a
618- * reference to the returned pixbuf.
619- *
620- * Return value: the pixbuf providing the animation frames, or %NULL
621- **/
622-GdkPixbuf*
623-katze_throbber_get_pixbuf (KatzeThrobber* throbber)
624-{
625- g_return_val_if_fail (KATZE_IS_THROBBER (throbber), NULL);
626-
627- return throbber->pixbuf;
628-}
629-
630-/**
631- * katze_throbber_get_animated:
632- * @throbber: a #KatzeThrobber
633- *
634- * Retrieves the status of the animation, whcih can be animated or static.
635- *
636- * Return value: %TRUE if the throbber is animated
637- **/
638-gboolean
639-katze_throbber_get_animated (KatzeThrobber* throbber)
640-{
641- g_return_val_if_fail (KATZE_IS_THROBBER (throbber), FALSE);
642-
643- return throbber->animated;
644-}
645-
646-/**
647- * katze_throbber_get_static_icon_name:
648- * @throbber: a #KatzeThrobber
649- *
650- * Retrieves the name of the icon providing the static image, if an icon name
651- * for the static image was specified.
652- *
653- * Return value: the name of the icon providing the static image, or %NULL
654- **/
655-const gchar*
656-katze_throbber_get_static_icon_name (KatzeThrobber* throbber)
657-{
658- g_return_val_if_fail (KATZE_IS_THROBBER (throbber), NULL);
659-
660- return throbber->static_icon_name;
661-}
662-
663-/**
664- * katze_throbber_get_static pixbuf:
665- * @throbber: a #KatzeThrobber
666- *
667- * Retrieves the #GdkPixbuf providing the static image, if an icon name, a
668- * pixbuf or a stock ID for the static image was specified. The caller of this
669- * function does not own a reference to the returned pixbuf.
670- *
671- * Return value: the pixbuf providing the static image, or %NULL
672- **/
673-GdkPixbuf*
674-katze_throbber_get_static_pixbuf (KatzeThrobber* throbber)
675-{
676- g_return_val_if_fail (KATZE_IS_THROBBER (throbber), NULL);
677-
678- return throbber->static_pixbuf;
679-}
680-
681-/**
682- * katze_throbber_get_static_stock_id:
683- * @throbber: a #KatzeThrobber
684- *
685- * Retrieves the stock ID of the icon providing the static image, if a
686- * stock ID for the static image was specified.
687- *
688- * Return value: the stock ID of the icon providing the static image, or %NULL
689- **/
690-const gchar*
691-katze_throbber_get_static_stock_id (KatzeThrobber* throbber)
692-{
693- g_return_val_if_fail (KATZE_IS_THROBBER (throbber), NULL);
694-
695- return throbber->static_stock_id;
696-}
697-
698-static void
699-katze_throbber_realize (GtkWidget* widget)
700-{
701- (*GTK_WIDGET_CLASS (katze_throbber_parent_class)->realize) (widget);
702-
703- icon_theme_changed (KATZE_THROBBER (widget));
704-}
705-
706-static void
707-katze_throbber_unrealize (GtkWidget* widget)
708-{
709- if (GTK_WIDGET_CLASS (katze_throbber_parent_class)->unrealize)
710- GTK_WIDGET_CLASS (katze_throbber_parent_class)->unrealize (widget);
711-}
712-
713-static void
714-pixbuf_assign_icon (GdkPixbuf** pixbuf,
715- const gchar* icon_name,
716- KatzeThrobber* throbber)
717-{
718- GdkScreen* screen;
719- GtkIconTheme* icon_theme;
720-
721- if (*pixbuf)
722- g_object_unref (*pixbuf);
723-
724- screen = gtk_widget_get_screen (GTK_WIDGET (throbber));
725- icon_theme = gtk_icon_theme_get_for_screen (screen);
726- *pixbuf = gtk_icon_theme_load_icon (icon_theme,
727- icon_name,
728- MAX (throbber->width, throbber->height),
729- (GtkIconLookupFlags) 0,
730- NULL);
731-}
732-
733-static void
734-icon_theme_changed (KatzeThrobber* throbber)
735-{
736- if (throbber->icon_name)
737- pixbuf_assign_icon (&throbber->pixbuf,
738- throbber->icon_name, throbber);
739-
740- if (throbber->static_icon_name)
741- pixbuf_assign_icon (&throbber->static_pixbuf,
742- throbber->static_icon_name, throbber);
743- else if (throbber->static_stock_id)
744- katze_object_assign (throbber->static_pixbuf,
745- gtk_widget_render_icon (GTK_WIDGET (throbber),
746- throbber->static_stock_id,
747- throbber->icon_size,
748- NULL));
749-
750- g_object_freeze_notify (G_OBJECT (throbber));
751- g_object_notify (G_OBJECT (throbber), "pixbuf");
752- g_object_notify (G_OBJECT (throbber), "static-pixbuf");
753- g_object_thaw_notify (G_OBJECT (throbber));
754-
755- gtk_widget_queue_draw (GTK_WIDGET (throbber));
756-}
757-
758-static void
759-katze_throbber_map (GtkWidget* widget)
760-{
761- (*GTK_WIDGET_CLASS (katze_throbber_parent_class)->map) (widget);
762-}
763-
764-static void
765-katze_throbber_unmap (GtkWidget* widget)
766-{
767- if (GTK_WIDGET_CLASS (katze_throbber_parent_class)->unmap)
768- GTK_WIDGET_CLASS (katze_throbber_parent_class)->unmap (widget);
769-}
770-
771-static void
772-katze_throbber_style_set (GtkWidget* widget,
773- GtkStyle* prev_style)
774-{
775- if (GTK_WIDGET_CLASS (katze_throbber_parent_class)->style_set)
776- GTK_WIDGET_CLASS (katze_throbber_parent_class)->style_set (widget,
777- prev_style);
778-
779- icon_theme_changed (KATZE_THROBBER (widget));
780-}
781-
782-static void
783-katze_throbber_screen_changed (GtkWidget* widget,
784- GdkScreen* prev_screen)
785-{
786- if (GTK_WIDGET_CLASS (katze_throbber_parent_class)->screen_changed)
787- GTK_WIDGET_CLASS (katze_throbber_parent_class)->screen_changed (
788- widget,
789- prev_screen);
790-
791- icon_theme_changed (KATZE_THROBBER (widget));
792-}
793-
794-static void
795-katze_throbber_size_request (GtkWidget* widget,
796- GtkRequisition* requisition)
797-{
798- KatzeThrobber* throbber = KATZE_THROBBER (widget);
799-
800- requisition->width = throbber->width;
801- requisition->height = throbber->height;
802-#if !GTK_CHECK_VERSION (3, 0, 0)
803- GTK_WIDGET_CLASS (katze_throbber_parent_class)->size_request (widget,
804- requisition);
805-#endif
806-}
807-
808-#if GTK_CHECK_VERSION (3, 0, 0)
809-static void
810-katze_throbber_get_preferred_height (GtkWidget *widget,
811- gint *minimal_height,
812- gint *natural_height)
813-{
814- GtkRequisition requisition;
815-
816- katze_throbber_size_request (widget, &requisition);
817-
818- *minimal_height = *natural_height = requisition.height;
819-}
820-
821-static void
822-katze_throbber_get_preferred_width (GtkWidget *widget,
823- gint *minimal_width,
824- gint *natural_width)
825-{
826- GtkRequisition requisition;
827-
828- katze_throbber_size_request (widget, &requisition);
829-
830- *minimal_width = *natural_width = requisition.width;
831-}
832-#endif
833-
834-static void
835-katze_throbber_aligned_coords (GtkWidget* widget,
836- gint* ax,
837- gint* ay)
838-{
839- gfloat xalign, yalign;
840- gint xpad, ypad;
841- GtkAllocation allocation;
842- GtkRequisition requisition;
843-
844- xalign = 0.0;
845- yalign = 0.5;
846- xpad = ypad = 0.0;
847-
848- #if GTK_CHECK_VERSION (3, 0, 0)
849- allocation.x = allocation.y = 0;
850- allocation.width = gtk_widget_get_allocated_width (widget);
851- allocation.height = gtk_widget_get_allocated_height (widget);
852- gtk_widget_get_preferred_size (widget, &requisition, NULL);
853- #else
854- gtk_widget_get_allocation (widget, &allocation);
855- gtk_widget_size_request (widget, &requisition);
856- #endif
857- *ax = floor (allocation.x + xpad
858- + ((allocation.width - requisition.width) * xalign));
859- *ay = floor (allocation.y + ypad
860- + ((allocation.height - requisition.height) * yalign));
861-}
862-
863-static gboolean
864-katze_throbber_expose_event (GtkWidget* widget,
865-#if GTK_CHECK_VERSION (3, 0, 0)
866- cairo_t* cr)
867-#else
868- GdkEventExpose* event)
869-#endif
870-{
871- KatzeThrobber* throbber = KATZE_THROBBER (widget);
872- gint ax, ay;
873-
874- if (G_UNLIKELY (!throbber->width || !throbber->height))
875- return TRUE;
876-
877- if (G_UNLIKELY (!throbber->pixbuf && !throbber->static_pixbuf))
878- if (throbber->animated && !throbber->pixbuf && !throbber->icon_name)
879- return TRUE;
880-
881- if (!throbber->animated && (throbber->static_pixbuf
882- || throbber->static_icon_name || throbber->static_stock_id))
883- {
884-#if !GTK_CHECK_VERSION (3, 0, 0)
885- cairo_t* cr;
886-#endif
887- if (G_UNLIKELY (!throbber->static_pixbuf && throbber->static_icon_name))
888- {
889- icon_theme_changed (KATZE_THROBBER (widget));
890-
891- if (!throbber->static_pixbuf)
892- {
893- g_warning (_("Named icon '%s' couldn't be loaded"),
894- throbber->static_icon_name);
895- katze_assign (throbber->static_icon_name, NULL);
896- g_object_notify (G_OBJECT (throbber), "static-icon-name");
897- return TRUE;
898- }
899- }
900- else if (G_UNLIKELY (!throbber->static_pixbuf && throbber->static_stock_id))
901- {
902- icon_theme_changed (KATZE_THROBBER (widget));
903-
904- if (!throbber->static_pixbuf)
905- {
906- g_warning (_("Stock icon '%s' couldn't be loaded"),
907- throbber->static_stock_id);
908- katze_assign (throbber->static_stock_id, NULL);
909- g_object_notify (G_OBJECT (throbber), "static-stock-id");
910- return TRUE;
911- }
912- }
913-
914- katze_throbber_aligned_coords (widget, &ax, &ay);
915-
916-#if !GTK_CHECK_VERSION (3, 0, 0)
917- cr = gdk_cairo_create (gtk_widget_get_window (widget));
918-#endif
919- gdk_cairo_set_source_pixbuf (cr, throbber->static_pixbuf, ax, ay);
920- cairo_paint (cr);
921-#if !GTK_CHECK_VERSION (3, 0, 0)
922- cairo_destroy (cr);
923-#endif
924- }
925- else
926- {
927- if (throbber->animated)
928-#if GTK_CHECK_VERSION (3, 0, 0)
929- return GTK_WIDGET_CLASS (katze_throbber_parent_class)->draw (widget, cr);
930-#else
931- return GTK_WIDGET_CLASS (katze_throbber_parent_class)->expose_event (widget, event);
932-#endif
933- }
934-
935- return TRUE;
936-}
937
938=== removed file 'katze/katze-throbber.h'
939--- katze/katze-throbber.h 2010-05-02 14:11:18 +0000
940+++ katze/katze-throbber.h 1970-01-01 00:00:00 +0000
941@@ -1,94 +0,0 @@
942-/*
943- Copyright (C) 2007 Christian Dywan <christian@twotoasts.de>
944-
945- This library is free software; you can redistribute it and/or
946- modify it under the terms of the GNU Lesser General Public
947- License as published by the Free Software Foundation; either
948- version 2.1 of the License, or (at your option) any later version.
949-
950- See the file COPYING for the full license text.
951-*/
952-
953-#ifndef __KATZE_THROBBER_H__
954-#define __KATZE_THROBBER_H__
955-
956-#include <gtk/gtk.h>
957-
958-G_BEGIN_DECLS
959-
960-#define KATZE_TYPE_THROBBER \
961- (katze_throbber_get_type ())
962-#define KATZE_THROBBER(obj) \
963- (G_TYPE_CHECK_INSTANCE_CAST ((obj), KATZE_TYPE_THROBBER, KatzeThrobber))
964-#define KATZE_THROBBER_CLASS(klass) \
965- (G_TYPE_CHECK_CLASS_CAST ((klass), KATZE_TYPE_THROBBER, KatzeThrobberClass))
966-#define KATZE_IS_THROBBER(obj) \
967- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KATZE_TYPE_THROBBER))
968-#define KATZE_IS_THROBBER_CLASS(klass) \
969- (G_TYPE_CHECK_CLASS_TYPE ((klass), KATZE_TYPE_THROBBER))
970-#define KATZE_THROBBER_GET_CLASS(obj) \
971- (G_TYPE_INSTANCE_GET_CLASS ((obj), KATZE_TYPE_THROBBER, KatzeThrobberClass))
972-
973-typedef struct _KatzeThrobber KatzeThrobber;
974-typedef struct _KatzeThrobberPrivate KatzeThrobberPrivate;
975-typedef struct _KatzeThrobberClass KatzeThrobberClass;
976-
977-
978-GType
979-katze_throbber_get_type (void) G_GNUC_CONST;
980-
981-GtkWidget*
982-katze_throbber_new (void);
983-
984-void
985-katze_throbber_set_icon_size (KatzeThrobber* throbber,
986- GtkIconSize icon_size);
987-
988-void
989-katze_throbber_set_icon_name (KatzeThrobber* throbber,
990- const gchar* icon_size);
991-
992-void
993-katze_throbber_set_pixbuf (KatzeThrobber* throbber,
994- GdkPixbuf* pixbuf);
995-
996-void
997-katze_throbber_set_animated (KatzeThrobber* throbber,
998- gboolean animated);
999-
1000-void
1001-katze_throbber_set_static_icon_name (KatzeThrobber* throbber,
1002- const gchar* icon_name);
1003-
1004-void
1005-katze_throbber_set_static_pixbuf (KatzeThrobber* throbber,
1006- GdkPixbuf* pixbuf);
1007-
1008-void
1009-katze_throbber_set_static_stock_id (KatzeThrobber* throbber,
1010- const gchar* stock_id);
1011-
1012-GtkIconSize
1013-katze_throbber_get_icon_size (KatzeThrobber* throbber);
1014-
1015-const gchar*
1016-katze_throbber_get_icon_name (KatzeThrobber* throbber);
1017-
1018-GdkPixbuf*
1019-katze_throbber_get_pixbuf (KatzeThrobber* throbber);
1020-
1021-gboolean
1022-katze_throbber_get_animated (KatzeThrobber* throbber);
1023-
1024-const gchar*
1025-katze_throbber_get_static_icon_name (KatzeThrobber *throbber);
1026-
1027-GdkPixbuf*
1028-katze_throbber_get_static_pixbuf (KatzeThrobber* throbber);
1029-
1030-const gchar*
1031-katze_throbber_get_static_stock_id (KatzeThrobber* throbber);
1032-
1033-G_END_DECLS
1034-
1035-#endif /* __KATZE_THROBBER_H__ */
1036
1037=== modified file 'katze/katze.h'
1038--- katze/katze.h 2013-07-30 21:00:46 +0000
1039+++ katze/katze.h 2013-12-05 00:25:31 +0000
1040@@ -13,7 +13,6 @@
1041 #define __KATZE_H__
1042
1043 #include "katze-http-auth.h"
1044-#include "katze-throbber.h"
1045 #include "katze-utils.h"
1046 #include "katze-item.h"
1047 #include "katze-array.h"
1048
1049=== modified file 'midori/midori-browser.c'
1050--- midori/midori-browser.c 2013-11-27 09:47:37 +0000
1051+++ midori/midori-browser.c 2013-12-05 00:25:31 +0000
1052@@ -82,7 +82,6 @@
1053
1054 gint last_window_width, last_window_height;
1055 guint alloc_timeout;
1056- gint last_tab_size;
1057 guint panel_timeout;
1058
1059 MidoriWebSettings* settings;
1060@@ -202,11 +201,6 @@
1061 midori_browser_add_speed_dial (MidoriBrowser* browser);
1062
1063 static void
1064-midori_browser_notebook_size_allocate_cb (GtkWidget* notebook,
1065- GdkRectangle* allocation,
1066- MidoriBrowser* browser);
1067-
1068-static void
1069 midori_browser_step_history (MidoriBrowser* browser,
1070 MidoriView* view);
1071
1072@@ -220,6 +214,10 @@
1073 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION ( \
1074 _action_by_name (brwsr, nme)), actv);
1075
1076+static void
1077+midori_browser_disconnect_tab (MidoriBrowser* browser,
1078+ MidoriView* view);
1079+
1080 static gboolean
1081 midori_browser_is_fullscreen (MidoriBrowser* browser)
1082 {
1083@@ -236,15 +234,7 @@
1084 gboolean show_tabs = !midori_browser_is_fullscreen (browser) || ignore_fullscreen;
1085 if (!browser->show_tabs)
1086 show_tabs = FALSE;
1087-#ifdef HAVE_GRANITE
1088- granite_widgets_dynamic_notebook_set_show_tabs (
1089- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), show_tabs);
1090-#else
1091- if (!(has_tabs || katze_object_get_boolean (browser->settings, "always-show-tabbar")))
1092- show_tabs = FALSE;
1093- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (browser->notebook), show_tabs);
1094- gtk_notebook_set_show_border (GTK_NOTEBOOK (browser->notebook), show_tabs);
1095-#endif
1096+ midori_notebook_set_labels_visible (MIDORI_NOTEBOOK (browser->notebook), show_tabs);
1097 return has_tabs;
1098 }
1099
1100@@ -451,8 +441,7 @@
1101 "tooltip", _("Stop loading the current page"), NULL);
1102 }
1103
1104- gtk_widget_set_sensitive (browser->throbber, loading);
1105- katze_throbber_set_animated (KATZE_THROBBER (browser->throbber), loading);
1106+ g_object_set (browser->throbber, "active", loading, "visible", loading, NULL);
1107 }
1108
1109 /**
1110@@ -782,23 +771,6 @@
1111 }
1112
1113 static void
1114-midori_view_notify_minimized_cb (GtkWidget* widget,
1115- GParamSpec* pspec,
1116- MidoriBrowser* browser)
1117-{
1118- if (katze_object_get_boolean (widget, "minimized"))
1119- {
1120- #ifndef HAVE_GRANITE
1121- GtkNotebook* notebook = GTK_NOTEBOOK (browser->notebook);
1122- GtkWidget* label = gtk_notebook_get_tab_label (notebook, widget);
1123- gtk_widget_set_size_request (label, -1, -1);
1124- #endif
1125- }
1126- else
1127- midori_browser_notebook_size_allocate_cb (NULL, NULL, browser);
1128-}
1129-
1130-static void
1131 midori_view_notify_zoom_level_cb (GtkWidget* view,
1132 GParamSpec* pspec,
1133 MidoriBrowser* browser)
1134@@ -1401,6 +1373,25 @@
1135 }
1136
1137 static void
1138+midori_view_destroy_cb (GtkWidget* view,
1139+ MidoriBrowser* browser)
1140+{
1141+ if (browser->proxy_array)
1142+ {
1143+ KatzeItem* item = midori_view_get_proxy_item (MIDORI_VIEW (view));
1144+ if (katze_array_get_item_index (browser->proxy_array, item) != -1
1145+ && !midori_tab_is_blank (MIDORI_TAB (view)))
1146+ {
1147+ if (browser->trash)
1148+ katze_array_add_item (browser->trash, item);
1149+ midori_browser_update_history (item, "website", "leave");
1150+ }
1151+ midori_browser_disconnect_tab (browser, MIDORI_VIEW (view));
1152+ g_signal_emit (browser, signals[REMOVE_TAB], 0, view);
1153+ }
1154+}
1155+
1156+static void
1157 midori_view_attach_inspector_cb (GtkWidget* view,
1158 GtkWidget* inspector_view,
1159 MidoriBrowser* browser)
1160@@ -1785,98 +1776,14 @@
1161 gint
1162 midori_browser_get_n_pages (MidoriBrowser* browser)
1163 {
1164- #ifdef HAVE_GRANITE
1165- return granite_widgets_dynamic_notebook_get_n_tabs (
1166- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook));
1167- #else
1168- return gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook));
1169- #endif
1170-}
1171-
1172-static void
1173-midori_browser_disconnect_tab (MidoriBrowser* browser,
1174- MidoriView* view);
1175-
1176-static gboolean
1177-midori_browser_tab_connected (MidoriBrowser* browser,
1178- MidoriView* view)
1179-{
1180- return browser->proxy_array &&
1181- (katze_array_get_item_index (browser->proxy_array, midori_view_get_proxy_item (view)) != -1);
1182+ return midori_notebook_get_count (MIDORI_NOTEBOOK (browser->notebook));
1183 }
1184
1185 static void
1186 _midori_browser_remove_tab (MidoriBrowser* browser,
1187 GtkWidget* widget)
1188 {
1189- MidoriView* view = MIDORI_VIEW (widget);
1190-#ifdef HAVE_GRANITE
1191- granite_widgets_dynamic_notebook_remove_tab (
1192- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), midori_view_get_tab (view));
1193-#else
1194 gtk_widget_destroy (widget);
1195-#endif
1196- if (midori_browser_tab_connected (browser, view))
1197- midori_browser_disconnect_tab (browser, view);
1198-}
1199-
1200-#ifndef HAVE_GRANITE
1201-static void
1202-midori_browser_notebook_resize (MidoriBrowser* browser,
1203- GdkRectangle* allocation)
1204-{
1205- gint new_size = 0;
1206- gint n = MAX (1, gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook)));
1207- const gint max_size = 150;
1208- gint min_size;
1209- gint icon_size = 16;
1210- GtkAllocation notebook_size;
1211- GList* children;
1212-
1213- if (allocation != NULL)
1214- notebook_size.width = allocation->width;
1215- else
1216- gtk_widget_get_allocation (browser->notebook, &notebook_size);
1217- new_size = notebook_size.width / n;
1218-
1219- gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (browser->notebook),
1220- GTK_ICON_SIZE_MENU, &icon_size, NULL);
1221- min_size = icon_size;
1222- if (katze_object_get_boolean (browser->settings, "close-buttons-on-tabs"))
1223- min_size += icon_size;
1224- if (new_size < min_size) new_size = min_size;
1225- if (new_size > max_size) new_size = max_size;
1226-
1227- if (new_size > browser->last_tab_size - 3
1228- && new_size < browser->last_tab_size + 3)
1229- return;
1230- browser->last_tab_size = new_size;
1231-
1232- children = gtk_container_get_children (GTK_CONTAINER (browser->notebook));
1233- for (; children; children = g_list_next (children))
1234- {
1235- GtkWidget* view = children->data;
1236- GtkWidget* label;
1237- label = gtk_notebook_get_tab_label (GTK_NOTEBOOK(browser->notebook), view);
1238- /* Don't resize empty bin, which is used for thumbnail tabs */
1239- if (GTK_IS_BIN (label) && gtk_bin_get_child (GTK_BIN (label))
1240- && !katze_object_get_boolean (view, "minimized"))
1241- gtk_widget_set_size_request (label, new_size, -1);
1242- }
1243-}
1244-#endif
1245-
1246-static void
1247-midori_browser_notebook_size_allocate_cb (GtkWidget* widget,
1248- GdkRectangle* allocation,
1249- MidoriBrowser* browser)
1250-{
1251- #ifndef HAVE_GRANITE
1252- if (!gtk_notebook_get_show_tabs (GTK_NOTEBOOK (browser->notebook)))
1253- return;
1254-
1255- midori_browser_notebook_resize (browser, allocation);
1256- #endif
1257 }
1258
1259 static void
1260@@ -1886,7 +1793,6 @@
1261 KatzeItem* item = midori_view_get_proxy_item (MIDORI_VIEW (view));
1262 katze_array_add_item (browser->proxy_array, item);
1263
1264- gtk_widget_set_can_focus (view, TRUE);
1265 g_object_connect (view,
1266 "signal::notify::icon",
1267 midori_view_notify_icon_cb, browser,
1268@@ -1898,8 +1804,6 @@
1269 midori_view_notify_uri_cb, browser,
1270 "signal::notify::title",
1271 midori_view_notify_title_cb, browser,
1272- "signal::notify::minimized",
1273- midori_view_notify_minimized_cb, browser,
1274 "signal::notify::zoom-level",
1275 midori_view_notify_zoom_level_cb, browser,
1276 "signal::notify::statusbar-text",
1277@@ -1920,30 +1824,12 @@
1278 midori_view_search_text_cb, browser,
1279 "signal::leave-notify-event",
1280 midori_browser_tab_leave_notify_event_cb, browser,
1281+ "signal::destroy",
1282+ midori_view_destroy_cb, browser,
1283 NULL);
1284 }
1285
1286 static void
1287-midori_browser_add_tab_to_trash (MidoriBrowser* browser,
1288- MidoriView* view)
1289-{
1290- if (browser->proxy_array)
1291- {
1292- KatzeItem* item = midori_view_get_proxy_item (view);
1293- if (katze_array_get_item_index (browser->proxy_array, item) != -1)
1294- {
1295- if (!midori_view_is_blank (view))
1296- {
1297- if (browser->trash)
1298- katze_array_add_item (browser->trash, item);
1299- midori_browser_update_history (item, "website", "leave");
1300- }
1301- }
1302- }
1303-}
1304-
1305-
1306-static void
1307 midori_browser_disconnect_tab (MidoriBrowser* browser,
1308 MidoriView* view)
1309 {
1310@@ -1974,8 +1860,6 @@
1311 "any_signal",
1312 midori_view_notify_title_cb, browser,
1313 "any_signal",
1314- midori_view_notify_minimized_cb, browser,
1315- "any_signal",
1316 midori_view_notify_zoom_level_cb, browser,
1317 "any_signal",
1318 midori_view_notify_statusbar_text_cb, browser,
1319@@ -2002,11 +1886,7 @@
1320 _midori_browser_add_tab (MidoriBrowser* browser,
1321 GtkWidget* view)
1322 {
1323- GtkWidget* notebook = browser->notebook;
1324 KatzeItem* item = midori_view_get_proxy_item (MIDORI_VIEW (view));
1325- #ifndef HAVE_GRANITE
1326- GtkWidget* tab_label;
1327- #endif
1328 guint n;
1329
1330 midori_browser_connect_tab (browser, view);
1331@@ -2018,24 +1898,10 @@
1332 katze_array_move_item (browser->proxy_array, item, n);
1333 }
1334 else
1335- n = midori_browser_get_n_pages (browser);
1336+ n = -1;
1337 katze_item_set_meta_integer (item, "append", -1);
1338
1339-#ifdef HAVE_GRANITE
1340- granite_widgets_dynamic_notebook_insert_tab (
1341- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (notebook),
1342- midori_view_get_tab (MIDORI_VIEW (view)), n);
1343-#else
1344- tab_label = midori_view_get_proxy_tab_label (MIDORI_VIEW (view));
1345- /* Don't resize empty bin, which is used for thumbnail tabs */
1346- if (GTK_IS_BIN (tab_label) && gtk_bin_get_child (GTK_BIN (tab_label))
1347- && !katze_object_get_boolean (view, "minimized"))
1348- gtk_widget_set_size_request (tab_label, browser->last_tab_size, -1);
1349- gtk_notebook_insert_page (GTK_NOTEBOOK (notebook), view, tab_label, n);
1350- gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (notebook), view, TRUE);
1351- gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (notebook), view, TRUE);
1352- midori_browser_notebook_size_allocate_cb (browser->notebook, NULL, browser);
1353-#endif
1354+ midori_notebook_insert (MIDORI_NOTEBOOK (browser->notebook), MIDORI_TAB (view), n);
1355
1356 _midori_browser_update_actions (browser);
1357 }
1358@@ -3697,13 +3563,7 @@
1359 gtk_widget_hide (browser->bookmarkbar);
1360 gtk_widget_hide (browser->navigationbar);
1361 gtk_widget_hide (browser->statusbar);
1362- #ifdef HAVE_GRANITE
1363- granite_widgets_dynamic_notebook_set_show_tabs (
1364- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), FALSE);
1365- #else
1366- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (browser->notebook), FALSE);
1367- gtk_notebook_set_show_border (GTK_NOTEBOOK (browser->notebook), FALSE);
1368- #endif
1369+ midori_notebook_set_labels_visible (MIDORI_NOTEBOOK (browser->notebook), FALSE);
1370
1371 gtk_window_fullscreen (GTK_WINDOW (browser));
1372 }
1373@@ -4741,13 +4601,7 @@
1374 else
1375 g_assert_not_reached ();
1376
1377- #ifdef HAVE_GRANITE
1378- granite_widgets_dynamic_notebook_set_tab_position (
1379- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook),
1380- midori_view_get_tab (MIDORI_VIEW (widget)), new_pos);
1381- #else
1382- gtk_notebook_reorder_child (GTK_NOTEBOOK (browser->notebook), widget, new_pos);
1383- #endif
1384+ midori_notebook_move (MIDORI_NOTEBOOK (browser->notebook), MIDORI_TAB (widget), new_pos);
1385 g_signal_emit (browser, signals[MOVE_TAB], 0, browser->notebook, cur_pos, new_pos);
1386 }
1387
1388@@ -4798,7 +4652,9 @@
1389 _action_tab_duplicate_activate (GtkAction* action,
1390 MidoriBrowser* browser)
1391 {
1392- GtkWidget* view = midori_browser_get_current_tab (browser);
1393+ GtkWidget* view = g_object_get_data (G_OBJECT (action), "tab");
1394+ if (view == NULL)
1395+ view = midori_browser_get_current_tab (browser);
1396 midori_view_duplicate (MIDORI_VIEW (view));
1397 }
1398
1399@@ -5034,10 +4890,10 @@
1400 }
1401
1402 static void
1403-midori_browser_switched_tab (MidoriBrowser* browser,
1404- GtkWidget* old_widget,
1405- MidoriView* new_view,
1406- gint new_page)
1407+midori_browser_switched_tab_cb (MidoriNotebook* notebook,
1408+ GtkWidget* old_widget,
1409+ MidoriView* new_view,
1410+ MidoriBrowser* browser)
1411 {
1412 GtkAction* action;
1413 const gchar* text;
1414@@ -5051,13 +4907,8 @@
1415 g_strdup (text), g_free);
1416 }
1417
1418- if (new_view == NULL)
1419- {
1420- g_signal_emit (browser, signals[SWITCH_TAB], 0, old_widget, new_view);
1421- return;
1422- }
1423-
1424 g_return_if_fail (MIDORI_IS_VIEW (new_view));
1425+ g_return_if_fail (new_view != MIDORI_VIEW (old_widget));
1426
1427 uri = g_object_get_data (G_OBJECT (new_view), "midori-browser-typed-text");
1428 if (!uri)
1429@@ -5068,9 +4919,10 @@
1430 if (midori_paths_get_runtime_mode () == MIDORI_RUNTIME_MODE_APP)
1431 gtk_window_set_icon (GTK_WINDOW (browser), midori_view_get_icon (new_view));
1432
1433- if (browser->proxy_array)
1434- katze_item_set_meta_integer (KATZE_ITEM (browser->proxy_array), "current", new_page);
1435+ g_object_freeze_notify (G_OBJECT (browser));
1436+ g_object_notify (G_OBJECT (browser), "uri");
1437 g_object_notify (G_OBJECT (browser), "tab");
1438+ g_object_thaw_notify (G_OBJECT (browser));
1439 g_signal_emit (browser, signals[SWITCH_TAB], 0, old_widget, new_view);
1440
1441 _midori_browser_set_statusbar_text (browser, new_view, NULL);
1442@@ -5079,17 +4931,17 @@
1443 }
1444
1445 static void
1446-midori_browser_notebook_page_reordered_cb (GtkWidget* notebook,
1447- MidoriView* view,
1448- guint page_num,
1449- MidoriBrowser* browser)
1450+midori_browser_tab_moved_cb (GtkWidget* notebook,
1451+ MidoriView* view,
1452+ guint page_num,
1453+ MidoriBrowser* browser)
1454 {
1455 KatzeItem* item = midori_view_get_proxy_item (view);
1456 katze_array_move_item (browser->proxy_array, item, page_num);
1457 g_object_notify (G_OBJECT (browser), "tab");
1458 }
1459
1460-static GtkWidget*
1461+static void
1462 midori_browser_notebook_create_window_cb (GtkWidget* notebook,
1463 GtkWidget* view,
1464 gint x,
1465@@ -5100,216 +4952,53 @@
1466 g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &new_browser);
1467 if (new_browser)
1468 {
1469- GtkWidget* new_notebook = new_browser->notebook;
1470 gtk_window_move (GTK_WINDOW (new_browser), x, y);
1471- return new_notebook;
1472- }
1473- else /* No MidoriApp, so this is app or private mode */
1474- return NULL;
1475-}
1476-
1477-#ifdef HAVE_GRANITE
1478-static void
1479-midori_browser_notebook_tab_added_cb (GtkWidget* notebook,
1480- GraniteWidgetsTab* tab,
1481- MidoriBrowser* browser)
1482-{
1483- gint n = granite_widgets_dynamic_notebook_get_tab_position (
1484- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (notebook), tab);
1485- midori_browser_set_current_page (browser, n);
1486- GtkWidget* view = midori_view_new_with_item (NULL, browser->settings);
1487- midori_view_set_tab (MIDORI_VIEW (view), tab);
1488- midori_browser_connect_tab (browser, view);
1489- midori_view_set_uri (MIDORI_VIEW (view), "about:new");
1490- /* FIXME: signal add-tab */
1491- _midori_browser_update_actions (browser);
1492- midori_browser_notebook_page_reordered_cb (GTK_WIDGET (notebook),
1493- MIDORI_VIEW (view), n, browser);
1494-}
1495-
1496-static gboolean
1497-midori_browser_notebook_tab_removed_cb (GtkWidget* notebook,
1498- GraniteWidgetsTab* tab,
1499- MidoriBrowser* browser)
1500-{
1501-
1502- MidoriView* view = MIDORI_VIEW (granite_widgets_tab_get_page (tab));
1503- if (midori_browser_tab_connected (browser, MIDORI_VIEW (view)))
1504- midori_browser_disconnect_tab (browser, MIDORI_VIEW (view));
1505-
1506- return TRUE;
1507-}
1508-
1509-static void
1510-midori_browser_move_tab_to_notebook (MidoriBrowser* browser,
1511- GtkWidget* view,
1512- GraniteWidgetsTab* tab,
1513- GtkWidget* new_notebook)
1514-{
1515- GraniteWidgetsTab* new_tab = granite_widgets_tab_new ("", NULL, NULL);
1516- g_object_ref (view);
1517- _midori_browser_remove_tab (browser, view);
1518- granite_widgets_dynamic_notebook_insert_tab (
1519- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (new_notebook), new_tab, 0);
1520- midori_view_set_tab (MIDORI_VIEW (view), new_tab);
1521- _midori_browser_update_actions (browser);
1522- midori_browser_connect_tab (midori_browser_get_for_widget (new_notebook), view);
1523- g_object_unref (view);
1524-}
1525-
1526-static void
1527-midori_browser_notebook_tab_switched_cb (GraniteWidgetsDynamicNotebook* notebook,
1528- GraniteWidgetsTab* old_tab,
1529- GraniteWidgetsTab* new_tab,
1530- MidoriBrowser* browser)
1531-{
1532- gint new_pos = granite_widgets_dynamic_notebook_get_tab_position (notebook, new_tab);
1533-
1534- midori_browser_switched_tab (browser,
1535- old_tab ? granite_widgets_tab_get_page (old_tab) : NULL,
1536- MIDORI_VIEW (granite_widgets_tab_get_page (new_tab)), new_pos);
1537-}
1538-
1539-static void
1540-midori_browser_notebook_tab_moved_cb (GtkWidget* notebook,
1541- GraniteWidgetsTab* tab,
1542- gint old_pos,
1543- gboolean new_window,
1544- gint x,
1545- gint y,
1546- MidoriBrowser* browser)
1547-{
1548- GtkWidget* view = granite_widgets_tab_get_page (tab);
1549- if (new_window)
1550- {
1551- GtkWidget* notebook = midori_browser_notebook_create_window_cb (
1552- browser->notebook, view, x, y, browser);
1553- if (notebook != NULL)
1554- midori_browser_move_tab_to_notebook (browser, view, tab, notebook);
1555- }
1556- else
1557- {
1558- gint new_pos = granite_widgets_dynamic_notebook_get_tab_position (
1559- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (notebook), tab);
1560- midori_browser_notebook_page_reordered_cb (notebook,
1561- MIDORI_VIEW (view), new_pos, browser);
1562- }
1563-}
1564-
1565-static void
1566-midori_browser_notebook_tab_duplicated_cb (GtkWidget* notebook,
1567- GraniteWidgetsTab* tab,
1568- MidoriBrowser* browser)
1569-{
1570- GtkWidget* view = granite_widgets_tab_get_page (tab);
1571- midori_view_duplicate (MIDORI_VIEW (view));
1572-}
1573-
1574-#else
1575-static void
1576-midori_browser_notebook_page_added_cb (GtkNotebook* notebook,
1577- GtkWidget* child,
1578- guint page_num,
1579- MidoriBrowser* browser)
1580-{
1581- if (!midori_browser_tab_connected (browser, MIDORI_VIEW (child)))
1582- midori_browser_connect_tab (browser, child);
1583- midori_browser_notebook_page_reordered_cb (GTK_WIDGET (notebook),
1584- MIDORI_VIEW (child), page_num, browser);
1585-}
1586-
1587-static void
1588-midori_browser_notebook_switch_page_cb (GtkWidget* notebook,
1589- gpointer page,
1590- guint page_num,
1591- MidoriBrowser* browser)
1592-{
1593- midori_browser_switched_tab (browser,
1594- midori_browser_get_current_tab (browser),
1595- MIDORI_VIEW (midori_browser_get_nth_tab (browser, page_num)), page_num);
1596-}
1597-
1598-static void
1599-midori_browser_notebook_page_removed_cb (GtkWidget* notebook,
1600- GtkWidget* view,
1601- guint page_num,
1602- MidoriBrowser* browser)
1603-{
1604- if (midori_browser_tab_connected (browser, MIDORI_VIEW (view)))
1605- midori_browser_disconnect_tab (browser, MIDORI_VIEW (view));
1606- midori_browser_notebook_size_allocate_cb (browser->notebook, NULL, browser);
1607-}
1608-
1609-static gboolean
1610-midori_browser_notebook_reorder_tab_cb (GtkNotebook* notebook,
1611- GtkDirectionType arg1,
1612- gboolean arg2,
1613- gpointer user_data)
1614-{
1615- g_signal_stop_emission_by_name (notebook, "reorder-tab");
1616- return TRUE;
1617-}
1618-
1619-static void
1620-midori_browser_menu_item_switch_tab_cb (GtkWidget* menuitem,
1621- MidoriBrowser* browser)
1622-{
1623- gint page = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menuitem), "index"));
1624- midori_browser_set_current_page (browser, page);
1625-}
1626-
1627-static gboolean
1628-midori_browser_notebook_button_press_event_after_cb (GtkNotebook* notebook,
1629- GdkEventButton* event,
1630- MidoriBrowser* browser)
1631-{
1632-#if !GTK_CHECK_VERSION(3,0,0) /* TODO */
1633- if (event->window != notebook->event_window)
1634- return FALSE;
1635-#endif
1636-
1637- /* FIXME: Handle double click only when it wasn't handled by GtkNotebook */
1638-
1639- /* Open a new tab on double click or middle mouse click */
1640- if (/*(event->type == GDK_2BUTTON_PRESS && event->button == 1)
1641- || */(event->type == GDK_BUTTON_PRESS && MIDORI_EVENT_NEW_TAB (event)))
1642- {
1643- GtkWidget* view = midori_browser_add_uri (browser, "about:new");
1644- midori_browser_set_current_tab (browser, view);
1645-
1646- return TRUE;
1647- }
1648- else if (event->type == GDK_BUTTON_PRESS && MIDORI_EVENT_CONTEXT_MENU (event))
1649- {
1650- MidoriContextAction* menu = midori_context_action_new ("NotebookContextMenu", NULL, NULL, NULL);
1651- midori_context_action_add_action_group (menu, browser->action_group);
1652- GList* tabs = midori_browser_get_tabs (browser);
1653- midori_context_action_add_by_name (menu, "TabNew");
1654- midori_context_action_add_by_name (menu, "UndoTabClose");
1655- midori_context_action_add (menu, NULL);
1656- gint i = 0;
1657- for (; tabs != NULL; tabs = g_list_next (tabs))
1658- {
1659- const gchar* title = midori_view_get_display_title (tabs->data);
1660- gchar* tab_option = g_strdup_printf ("Tab%u", i);
1661- GtkAction* action = gtk_action_new (tab_option, title, NULL, NULL);
1662- g_free (tab_option);
1663- gtk_action_set_gicon (GTK_ACTION (action), G_ICON (midori_view_get_icon (tabs->data)));
1664- g_object_set_data (G_OBJECT (action), "index", GINT_TO_POINTER (i));
1665- g_signal_connect (action, "activate",
1666- G_CALLBACK (midori_browser_menu_item_switch_tab_cb), browser);
1667- midori_context_action_add (menu, action);
1668- i++;
1669- }
1670- g_list_free (tabs);
1671- GtkMenu* context_menu = midori_context_action_create_menu (menu, NULL, FALSE);
1672- katze_widget_popup (GTK_WIDGET (notebook), context_menu, NULL,
1673- KATZE_MENU_POSITION_CURSOR);
1674- }
1675-
1676- return FALSE;
1677-}
1678-#endif
1679+ g_object_ref (view);
1680+ midori_browser_disconnect_tab (browser, MIDORI_VIEW (view));
1681+ midori_notebook_remove (MIDORI_NOTEBOOK (browser->notebook), MIDORI_TAB (view));
1682+ midori_browser_add_tab (new_browser, view);
1683+ g_object_unref (view);
1684+ }
1685+}
1686+
1687+static void
1688+midori_browser_notebook_new_tab_cb (GtkWidget* notebook,
1689+ MidoriBrowser* browser)
1690+{
1691+ GtkWidget* view = midori_browser_add_uri (browser, "about:new");
1692+ midori_browser_set_current_tab (browser, view);
1693+}
1694+
1695+static void
1696+midori_browser_notebook_context_menu_cb (MidoriNotebook* notebook,
1697+ MidoriContextAction* menu,
1698+ MidoriBrowser* browser)
1699+{
1700+ midori_context_action_add_action_group (menu, browser->action_group);
1701+ midori_context_action_add (menu, NULL);
1702+ midori_context_action_add_by_name (menu, "TabNew");
1703+ midori_context_action_add_by_name (menu, "UndoTabClose");
1704+}
1705+
1706+static void
1707+midori_browser_notebook_tab_context_menu_cb (MidoriNotebook* notebook,
1708+ MidoriTab* tab,
1709+ MidoriContextAction* menu,
1710+ MidoriBrowser* browser)
1711+{
1712+ midori_context_action_add_action_group (menu, browser->action_group);
1713+ midori_context_action_add (menu, NULL);
1714+ midori_context_action_add_by_name (menu, "TabNew");
1715+ midori_context_action_add_by_name (menu, "UndoTabClose");
1716+ if (MIDORI_IS_VIEW (tab))
1717+ {
1718+ GtkAction* action = gtk_action_new ("TabDuplicate", _("_Duplicate Current Tab"), NULL, NULL);
1719+ g_object_set_data (G_OBJECT (action), "tab", tab);
1720+ g_signal_connect (action, "activate",
1721+ G_CALLBACK (_action_tab_duplicate_activate), browser);
1722+ midori_context_action_add (menu, action);
1723+ }
1724+}
1725
1726 static void
1727 _action_undo_tab_close_activate (GtkAction* action,
1728@@ -5760,14 +5449,6 @@
1729
1730 /* Destroy panel first, so panels don't need special care */
1731 gtk_widget_destroy (browser->panel);
1732- #ifndef HAVE_GRANITE
1733- g_signal_handlers_disconnect_by_func (browser->notebook,
1734- midori_browser_notebook_reorder_tab_cb,
1735- NULL);
1736- g_signal_handlers_disconnect_by_func (browser->notebook,
1737- midori_browser_notebook_size_allocate_cb,
1738- browser);
1739- #endif
1740 /* Destroy tabs second, so child widgets don't need special care */
1741 gtk_container_foreach (GTK_CONTAINER (browser->notebook),
1742 (GtkCallback) gtk_widget_destroy, NULL);
1743@@ -6288,10 +5969,17 @@
1744
1745 menuitem = gtk_menu_item_new ();
1746 gtk_widget_show (menuitem);
1747- browser->throbber = katze_throbber_new ();
1748- gtk_widget_show (browser->throbber);
1749- gtk_container_add (GTK_CONTAINER (menuitem), browser->throbber);
1750- gtk_widget_set_sensitive (menuitem, FALSE);
1751+ browser->throbber = gtk_spinner_new ();
1752+ /* Wrap the spinner in an event box to retain its size when hidden */
1753+ GtkWidget* throbber_box = gtk_event_box_new ();
1754+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (throbber_box), FALSE);
1755+ gint icon_size = 16;
1756+ gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (GTK_WIDGET (browser)),
1757+ GTK_ICON_SIZE_MENU, &icon_size, NULL);
1758+ gtk_widget_set_size_request (throbber_box, icon_size, icon_size);
1759+ gtk_container_add (GTK_CONTAINER (throbber_box), browser->throbber);
1760+ gtk_widget_show (throbber_box);
1761+ gtk_container_add (GTK_CONTAINER (menuitem), throbber_box);
1762 #if GTK_CHECK_VERSION (3, 2, 0)
1763 /* FIXME: Doesn't work */
1764 gtk_widget_set_hexpand (menuitem, TRUE);
1765@@ -6390,78 +6078,24 @@
1766 vpaned = gtk_vpaned_new ();
1767 gtk_paned_pack2 (GTK_PANED (hpaned), vpaned, TRUE, FALSE);
1768 gtk_widget_show (vpaned);
1769- #ifdef HAVE_GRANITE
1770- /* FIXME: granite: should return GtkWidget* like GTK+ */
1771- browser->notebook = (GtkWidget*)granite_widgets_dynamic_notebook_new ();
1772- granite_widgets_dynamic_notebook_set_allow_new_window (
1773- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), TRUE);
1774- granite_widgets_dynamic_notebook_set_allow_duplication (
1775- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), TRUE);
1776- /* FIXME: work-around a bug */
1777- gtk_widget_show_all (browser->notebook);
1778- granite_widgets_dynamic_notebook_set_group_name (
1779- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), PACKAGE_NAME);
1780- #else
1781- browser->notebook = gtk_notebook_new ();
1782- gtk_notebook_set_scrollable (GTK_NOTEBOOK (browser->notebook), TRUE);
1783- #if GTK_CHECK_VERSION (3, 0, 0)
1784- gtk_notebook_set_group_name (GTK_NOTEBOOK (browser->notebook), PACKAGE_NAME);
1785- #else
1786- gtk_notebook_set_group_id (GTK_NOTEBOOK (browser->notebook), GPOINTER_TO_INT (PACKAGE_NAME));
1787- #endif
1788- #endif
1789+ browser->notebook = midori_notebook_new ();
1790
1791- #if !GTK_CHECK_VERSION (3, 0, 0)
1792- {
1793- /* Remove the inner border between scrollbars and the window border */
1794- GtkRcStyle* rcstyle = gtk_rc_style_new ();
1795- rcstyle->xthickness = 0;
1796- gtk_widget_modify_style (browser->notebook, rcstyle);
1797- g_object_unref (rcstyle);
1798- }
1799- #endif
1800 gtk_paned_pack1 (GTK_PANED (vpaned), browser->notebook, FALSE, FALSE);
1801- #ifdef HAVE_GRANITE
1802- /* FIXME menu items */
1803- g_signal_connect (browser->notebook, "tab-added",
1804- G_CALLBACK (midori_browser_notebook_tab_added_cb),
1805- browser);
1806- g_signal_connect (browser->notebook, "tab-removed",
1807- G_CALLBACK (midori_browser_notebook_tab_removed_cb),
1808- browser);
1809 g_signal_connect (browser->notebook, "tab-switched",
1810- G_CALLBACK (midori_browser_notebook_tab_switched_cb),
1811+ G_CALLBACK (midori_browser_switched_tab_cb),
1812 browser);
1813 g_signal_connect (browser->notebook, "tab-moved",
1814- G_CALLBACK (midori_browser_notebook_tab_moved_cb),
1815- browser);
1816- g_signal_connect (browser->notebook, "tab-duplicated",
1817- G_CALLBACK (midori_browser_notebook_tab_duplicated_cb),
1818- browser);
1819- #else
1820- g_signal_connect (browser->notebook, "switch-page",
1821- G_CALLBACK (midori_browser_notebook_switch_page_cb),
1822- browser);
1823- g_signal_connect (browser->notebook, "page-reordered",
1824- G_CALLBACK (midori_browser_notebook_page_reordered_cb),
1825- browser);
1826- g_signal_connect (browser->notebook, "page-added",
1827- G_CALLBACK (midori_browser_notebook_page_added_cb),
1828- browser);
1829- g_signal_connect (browser->notebook, "page-removed",
1830- G_CALLBACK (midori_browser_notebook_page_removed_cb),
1831- browser);
1832- g_signal_connect (browser->notebook, "size-allocate",
1833- G_CALLBACK (midori_browser_notebook_size_allocate_cb),
1834- browser);
1835- g_signal_connect_after (browser->notebook, "button-press-event",
1836- G_CALLBACK (midori_browser_notebook_button_press_event_after_cb),
1837- browser);
1838- g_signal_connect (browser->notebook, "reorder-tab",
1839- G_CALLBACK (midori_browser_notebook_reorder_tab_cb), NULL);
1840- g_signal_connect (browser->notebook, "create-window",
1841+ G_CALLBACK (midori_browser_tab_moved_cb),
1842+ browser);
1843+ g_signal_connect (browser->notebook, "context-menu",
1844+ G_CALLBACK (midori_browser_notebook_context_menu_cb),
1845+ browser);
1846+ g_signal_connect (browser->notebook, "tab-context-menu",
1847+ G_CALLBACK (midori_browser_notebook_tab_context_menu_cb), browser);
1848+ g_signal_connect (browser->notebook, "tab-detached",
1849 G_CALLBACK (midori_browser_notebook_create_window_cb), browser);
1850- #endif
1851+ g_signal_connect (browser->notebook, "new-tab",
1852+ G_CALLBACK (midori_browser_notebook_new_tab_cb), browser);
1853 gtk_widget_show (browser->notebook);
1854
1855 /* Inspector container */
1856@@ -6768,11 +6402,9 @@
1857 }
1858 else if (token_current != token_dontcare && token_last == token_dontcare)
1859 continue;
1860- #ifdef HAVE_GRANITE
1861 /* A "new tab" button is already part of the notebook */
1862 else if (!strcmp (gtk_action_get_name (action), "TabNew"))
1863 continue;
1864- #endif
1865 else
1866 toolitem = gtk_action_create_tool_item (action);
1867
1868@@ -6839,7 +6471,7 @@
1869 gboolean show_panel;
1870 MidoriToolbarStyle toolbar_style;
1871 gchar* toolbar_items;
1872- gboolean close_buttons_on_tabs;
1873+ gboolean close_buttons_left, close_buttons_on_tabs;
1874
1875 g_object_get (browser->settings,
1876 "remember-last-window-size", &remember_last_window_size,
1877@@ -6859,19 +6491,19 @@
1878 "show-statusbar", &browser->show_statusbar,
1879 "toolbar-style", &toolbar_style,
1880 "toolbar-items", &toolbar_items,
1881+ "close-buttons-left", &close_buttons_left,
1882 "close-buttons-on-tabs", &close_buttons_on_tabs,
1883 "maximum-history-age", &browser->maximum_history_age,
1884 NULL);
1885
1886- #ifdef HAVE_GRANITE
1887- granite_widgets_dynamic_notebook_set_tabs_closable (
1888- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), close_buttons_on_tabs);
1889- #endif
1890+ midori_notebook_set_close_buttons_visible (
1891+ MIDORI_NOTEBOOK (browser->notebook), close_buttons_on_tabs);
1892+ midori_notebook_set_close_buttons_left (
1893+ MIDORI_NOTEBOOK (browser->notebook), close_buttons_left);
1894 midori_findbar_set_close_button_left (MIDORI_FINDBAR (browser->find),
1895- katze_object_get_boolean (browser->settings, "close-buttons-left"));
1896+ close_buttons_left);
1897 if (browser->dial != NULL)
1898- midori_speed_dial_set_close_buttons_left (browser->dial,
1899- katze_object_get_boolean (browser->settings, "close-buttons-left"));
1900+ midori_speed_dial_set_close_buttons_left (browser->dial, close_buttons_left);
1901
1902 midori_browser_set_inactivity_reset (browser, inactivity_reset);
1903
1904@@ -6992,17 +6624,17 @@
1905 }
1906 else if (name == g_intern_string ("maximum-history-age"))
1907 browser->maximum_history_age = g_value_get_int (&value);
1908- #ifdef HAVE_GRANITE
1909 else if (name == g_intern_string ("close-buttons-on-tabs"))
1910- granite_widgets_dynamic_notebook_set_tabs_closable (
1911- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), g_value_get_boolean (&value));
1912- #endif
1913+ midori_notebook_set_close_buttons_visible (
1914+ MIDORI_NOTEBOOK (browser->notebook), g_value_get_boolean (&value));
1915 else if (name == g_intern_string ("close-buttons-left"))
1916 {
1917 midori_findbar_set_close_button_left (MIDORI_FINDBAR (browser->find),
1918 g_value_get_boolean (&value));
1919 midori_speed_dial_set_close_buttons_left (browser->dial,
1920- katze_object_get_boolean (browser->settings, "close-buttons-left"));
1921+ g_value_get_boolean (&value));
1922+ midori_notebook_set_close_buttons_left (
1923+ MIDORI_NOTEBOOK (browser->notebook), g_value_get_boolean (&value));
1924 }
1925 else if (name == g_intern_string ("inactivity-reset"))
1926 midori_browser_set_inactivity_reset (browser, g_value_get_uint (&value));
1927@@ -7325,7 +6957,7 @@
1928 g_value_set_object (value, browser->navigationbar);
1929 break;
1930 case PROP_NOTEBOOK:
1931- g_value_set_object (value, browser->notebook);
1932+ g_value_set_object (value, MIDORI_NOTEBOOK (browser->notebook)->notebook);
1933 break;
1934 case PROP_PANEL:
1935 g_value_set_object (value, browser->panel);
1936@@ -7446,13 +7078,7 @@
1937 g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
1938 g_return_val_if_fail (MIDORI_IS_VIEW (view), -1);
1939
1940-#ifdef HAVE_GRANITE
1941- return granite_widgets_dynamic_notebook_get_tab_position (
1942- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook),
1943- midori_view_get_tab (MIDORI_VIEW (view)));
1944-#else
1945- return gtk_notebook_page_num (GTK_NOTEBOOK (browser->notebook), view);
1946-#endif
1947+ return midori_notebook_get_tab_index (MIDORI_NOTEBOOK (browser->notebook), MIDORI_TAB (view));
1948 }
1949
1950
1951@@ -7471,7 +7097,6 @@
1952 g_return_if_fail (MIDORI_IS_BROWSER (browser));
1953 g_return_if_fail (GTK_IS_WIDGET (view));
1954
1955- midori_browser_add_tab_to_trash (browser, MIDORI_VIEW (view));
1956 g_signal_emit (browser, signals[REMOVE_TAB], 0, view);
1957 }
1958
1959@@ -7697,22 +7322,7 @@
1960 view = midori_browser_get_nth_tab (browser, n);
1961 g_return_if_fail (view != NULL);
1962
1963- #ifdef HAVE_GRANITE
1964- granite_widgets_dynamic_notebook_set_current (
1965- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook),
1966- midori_view_get_tab (MIDORI_VIEW (view)));
1967- #else
1968- gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), n);
1969- #endif
1970- if (midori_view_is_blank (MIDORI_VIEW (view)))
1971- midori_browser_activate_action (browser, "Location");
1972- else
1973- gtk_widget_grab_focus (view);
1974-
1975- g_object_freeze_notify (G_OBJECT (browser));
1976- g_object_notify (G_OBJECT (browser), "uri");
1977- g_object_notify (G_OBJECT (browser), "tab");
1978- g_object_thaw_notify (G_OBJECT (browser));
1979+ midori_browser_set_tab (browser, view);
1980 }
1981
1982 /**
1983@@ -7730,14 +7340,7 @@
1984 {
1985 g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1);
1986
1987- #ifdef HAVE_GRANITE
1988- GraniteWidgetsTab* tab = granite_widgets_dynamic_notebook_get_current (
1989- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook));
1990- return tab ? granite_widgets_dynamic_notebook_get_tab_position (
1991- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), tab) : -1;
1992- #else
1993- return gtk_notebook_get_current_page (GTK_NOTEBOOK (browser->notebook));
1994- #endif
1995+ return midori_notebook_get_index (MIDORI_NOTEBOOK (browser->notebook));
1996 }
1997
1998 /**
1999@@ -7783,19 +7386,9 @@
2000 midori_browser_get_nth_tab (MidoriBrowser* browser,
2001 gint page)
2002 {
2003-#ifdef HAVE_GRANITE
2004- GraniteWidgetsTab* tab;
2005-
2006- g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
2007-
2008- tab = granite_widgets_dynamic_notebook_get_tab_by_index (
2009- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook), page);
2010- return tab != NULL ? granite_widgets_tab_get_page (tab) : NULL;
2011-#else
2012- g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
2013-
2014- return gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), page);
2015-#endif
2016+ g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
2017+
2018+ return (GtkWidget*)midori_notebook_get_nth_tab (MIDORI_NOTEBOOK (browser->notebook), page);
2019 }
2020
2021 /**
2022@@ -7813,13 +7406,19 @@
2023 midori_browser_set_current_tab (MidoriBrowser* browser,
2024 GtkWidget* view)
2025 {
2026- gint n;
2027-
2028 g_return_if_fail (MIDORI_IS_BROWSER (browser));
2029 g_return_if_fail (GTK_IS_WIDGET (view));
2030
2031- n = midori_browser_page_num (browser, view);
2032- midori_browser_set_current_page (browser, n);
2033+ midori_notebook_set_tab (MIDORI_NOTEBOOK (browser->notebook), MIDORI_TAB (view));
2034+ if (midori_tab_is_blank (MIDORI_TAB (view)))
2035+ midori_browser_activate_action (browser, "Location");
2036+ else
2037+ gtk_widget_grab_focus (view);
2038+
2039+ g_object_freeze_notify (G_OBJECT (browser));
2040+ g_object_notify (G_OBJECT (browser), "uri");
2041+ g_object_notify (G_OBJECT (browser), "tab");
2042+ g_object_thaw_notify (G_OBJECT (browser));
2043 }
2044
2045 /**
2046@@ -7839,22 +7438,9 @@
2047 GtkWidget*
2048 midori_browser_get_current_tab (MidoriBrowser* browser)
2049 {
2050- #if 0 // def HAVE_GRANITE
2051- GraniteWidgetsTab* tab;
2052- #else
2053- gint n;
2054- #endif
2055-
2056 g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
2057
2058- #if 0 // FIXME: not reliable def HAVE_GRANITE
2059- tab = granite_widgets_dynamic_notebook_get_current (
2060- GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook));
2061- return tab ? granite_widgets_tab_get_page (tab) : NULL;
2062- #else
2063- n = midori_browser_get_current_page (browser);
2064- return (n >= 0) ? midori_browser_get_nth_tab (browser, n) : NULL;
2065- #endif
2066+ return (GtkWidget*)midori_notebook_get_tab (MIDORI_NOTEBOOK (browser->notebook));
2067 }
2068
2069 /**
2070@@ -7872,12 +7458,7 @@
2071 {
2072 g_return_val_if_fail (MIDORI_IS_BROWSER (browser), NULL);
2073
2074- #ifdef HAVE_GRANITE
2075- /* FIXME: granite doesn't correctly implemented gtk.container */
2076- return granite_widgets_dynamic_notebook_get_children (GRANITE_WIDGETS_DYNAMIC_NOTEBOOK (browser->notebook));
2077- #else
2078 return gtk_container_get_children (GTK_CONTAINER (browser->notebook));
2079- #endif
2080 }
2081
2082 /**
2083
2084=== added file 'midori/midori-notebook.vala'
2085--- midori/midori-notebook.vala 1970-01-01 00:00:00 +0000
2086+++ midori/midori-notebook.vala 2013-12-05 00:25:31 +0000
2087@@ -0,0 +1,526 @@
2088+/*
2089+ Copyright (C) 2013 Christian Dywan <christian@twotoasts.de>
2090+
2091+ This library is free software; you can redistribute it and/or
2092+ modify it under the terms of the GNU Lesser General Public
2093+ License as published by the Free Software Foundation; either
2094+ version 2.1 of the License, or (at your option) any later version.
2095+
2096+ See the file COPYING for the full license text.
2097+*/
2098+
2099+namespace Midori {
2100+ protected class Tally : Gtk.EventBox {
2101+ public Midori.Tab tab { get; set; }
2102+ Gtk.Spinner spinner;
2103+ public Gtk.Label label;
2104+ Gtk.HBox box;
2105+ public Gtk.Image icon;
2106+ Gtk.Alignment align;
2107+ Gtk.Button close;
2108+
2109+ public bool close_button_left { get; set; default = false; }
2110+ public bool close_button_visible { get; set; default = false; }
2111+
2112+ protected Tally (Midori.Tab tab) {
2113+ this.tab = tab;
2114+ box = new Gtk.HBox (false, 1);
2115+ add (box);
2116+
2117+ spinner = new Gtk.Spinner ();
2118+ spinner.active = true;
2119+ /* Ensure the spinner is the size of the icon */
2120+ int icon_size = 16;
2121+ Gtk.icon_size_lookup_for_settings (get_settings (),
2122+ Gtk.IconSize.MENU, out icon_size, null);
2123+ spinner.set_size_request (icon_size, icon_size);
2124+ box.pack_start (spinner, false, false, 0);
2125+ label = new Gtk.Label (null);
2126+ label.set_alignment (0.0f, 0.5f);
2127+ label.set_padding (0, 0);
2128+ box.pack_start (label, true, true, 0);
2129+ close = new Gtk.Button ();
2130+ close.relief = Gtk.ReliefStyle.NONE;
2131+ close.focus_on_click = false;
2132+#if !HAVE_GTK3
2133+ close.name = "midori-close-button";
2134+ close.style_set.connect (close_style_set);
2135+#endif
2136+ icon = new Gtk.Image.from_gicon (new ThemedIcon.with_default_fallbacks ("window-close-symbolic"), Gtk.IconSize.MENU);
2137+ close.add (icon);
2138+ align = new Gtk.Alignment (1.0f, 0.5f, 0.0f, 0.0f);
2139+ align.add (close);
2140+ box.pack_start (align, false, false, 0);
2141+ close.clicked.connect (close_clicked);
2142+ icon = new Gtk.Image.from_gicon (new ThemedIcon.with_default_fallbacks ("text-html-symbolic"), Gtk.IconSize.MENU);
2143+ box.pack_start (icon, false, false, 0);
2144+ box.show_all ();
2145+
2146+ tab.notify["uri"].connect (uri_changed);
2147+ tab.notify["title"].connect (title_changed);
2148+ tab.notify["icon"].connect (icon_changed);
2149+ tab.notify["minimized"].connect (minimized_changed);
2150+ tab.notify["progress"].connect (progress_changed);
2151+ tab.colors_changed.connect (colors_changed);
2152+ update_label ();
2153+ label.visible = !tab.minimized;
2154+ spinner.visible = tab.progress > 0.0;
2155+ icon.visible = !spinner.visible;
2156+ update_color ();
2157+
2158+ notify["close-button-left"].connect (close_button_left_changed);
2159+ notify_property ("close-button-left");
2160+ notify["close-button-visible"].connect (close_button_visible_changed);
2161+ notify_property ("close-button-visible");
2162+
2163+ Gtk.drag_dest_set (this, Gtk.DestDefaults.ALL, (Gtk.TargetEntry[])null, Gdk.DragAction.COPY);
2164+ Gtk.drag_dest_add_text_targets (this);
2165+ Gtk.drag_dest_add_uri_targets (this);
2166+ drag_data_received.connect (uri_dragged);
2167+ }
2168+
2169+#if !HAVE_GTK3
2170+ void close_style_set (Gtk.Style? previous_style) {
2171+ Gtk.Requisition size;
2172+ close.child.size_request (out size);
2173+ close.set_size_request (size.width, size.height);
2174+ }
2175+#endif
2176+
2177+ void close_clicked () {
2178+ tab.destroy ();
2179+ }
2180+
2181+ void uri_changed (GLib.ParamSpec pspec) {
2182+ label.label = tab.uri;
2183+ }
2184+
2185+ void title_changed (GLib.ParamSpec pspec) {
2186+ update_label ();
2187+ }
2188+
2189+ void update_label () {
2190+ string? title;
2191+ tab.get ("title", out title);
2192+ label.label = Midori.Tab.get_display_title (title, tab.uri);
2193+ /* Use computed label below! */
2194+ label.ellipsize = Midori.Tab.get_display_ellipsize (label.label, tab.uri);
2195+ tooltip_text = label.label;
2196+ }
2197+
2198+ void icon_changed (GLib.ParamSpec pspec) {
2199+ Icon? icon;
2200+ tab.get ("icon", out icon);
2201+ this.icon.set_from_gicon (icon, Gtk.IconSize.MENU);
2202+ }
2203+
2204+ void colors_changed () {
2205+ update_color ();
2206+ }
2207+
2208+ void update_color () {
2209+ visible_window = tab.fg_color != null || tab.bg_color != null;
2210+ label.modify_fg (Gtk.StateType.NORMAL, tab.fg_color);
2211+ label.modify_fg (Gtk.StateType.ACTIVE, tab.fg_color);
2212+ modify_bg (Gtk.StateType.NORMAL, tab.bg_color);
2213+ modify_bg (Gtk.StateType.ACTIVE, tab.bg_color);
2214+ }
2215+
2216+ void close_button_left_changed (GLib.ParamSpec pspec) {
2217+ if (close_button_left) {
2218+ box.reorder_child (align, 0);
2219+ box.reorder_child (label, 1);
2220+ box.reorder_child (icon, 2);
2221+ box.reorder_child (spinner, 3);
2222+ } else {
2223+ box.reorder_child (spinner, 0);
2224+ box.reorder_child (icon, 1);
2225+ box.reorder_child (label, 2);
2226+ box.reorder_child (align, 3);
2227+ }
2228+ }
2229+
2230+ void close_button_visible_changed (GLib.ParamSpec pspec) {
2231+ align.visible = !tab.minimized && close_button_visible;
2232+ }
2233+
2234+ void minimized_changed (GLib.ParamSpec pspec) {
2235+ label.visible = !tab.minimized;
2236+ notify_property ("close-button-visible");
2237+ }
2238+
2239+ void progress_changed (GLib.ParamSpec pspec) {
2240+ spinner.visible = tab.progress > 0.0;
2241+ icon.visible = !spinner.visible;
2242+ }
2243+
2244+ void uri_dragged (Gdk.DragContext context, int x, int y, Gtk.SelectionData data, uint ttype, uint timestamp) {
2245+ /* FIXME: Navigate to the URI
2246+ string[] uri = data.get_uris ();
2247+ if (uri != null)
2248+ tab.uri = uri[0];
2249+ else
2250+ tab.uri = data.get_text ();
2251+ */
2252+ }
2253+ }
2254+
2255+ public class Notebook : Gtk.EventBox {
2256+ public Gtk.Notebook notebook;
2257+ int last_tab_size = 0;
2258+
2259+#if !HAVE_GTK3
2260+ static const string style_fixup = """
2261+ style "midori-close-button-style"
2262+ {
2263+ GtkWidget::focus-padding = 0
2264+ GtkWidget::focus-line-width = 0
2265+ xthickness = 0
2266+ ythickness = 0
2267+ }
2268+ widget "*.midori-close-button" style "midori-close-button-style"
2269+ """;
2270+#endif
2271+
2272+ /* Since: 0.5.7 */
2273+ public uint count { get; private set; default = 0; }
2274+ /* Since: 0.5.7 */
2275+ public int index { get; set; default = -1; }
2276+ /* Since: 0.5.7 */
2277+ public Midori.Tab? tab { get; set; default = null; }
2278+ /* Since: 0.5.7 */
2279+ private Midori.Tab? previous { get; set; default = null; }
2280+
2281+ /* Since: 0.5.7 */
2282+ public bool close_buttons_left { get; set; default = true; }
2283+ /* Since: 0.5.7 */
2284+ public bool close_buttons_visible { get; set; default = true; }
2285+ /* Since: 0.5.7 */
2286+ public bool labels_visible { get; set; default = true; }
2287+
2288+ /* Since: 0.5.7 */
2289+ public signal void tab_context_menu (Midori.Tab tab, ContextAction menu);
2290+ /* Since: 0.5.7 */
2291+ public signal void context_menu (ContextAction menu);
2292+ /* The current tab is about to switch, but the old tab still has focus.
2293+ Since: 0.5.7 */
2294+ public signal void tab_switched (Midori.Tab? old, Midori.Tab @new);
2295+ /* A tab is about to move to a new position.
2296+ Since: 0.5.7 */
2297+ public signal void tab_moved (Midori.Tab tab, uint new_index);
2298+ /* A tab is being dragging out of the window.
2299+ Since: 0.5.7 */
2300+ public signal void tab_detached (Midori.Tab tab, int x, int y);
2301+ /* Since: 0.5.7 */
2302+ public signal void new_tab ();
2303+
2304+ [CCode (type = "GtkWidget*")]
2305+ public Notebook () {
2306+ visible_window = false;
2307+ notebook = new Gtk.Notebook ();
2308+ notebook.visible = notebook.scrollable = true;
2309+ notebook.show_border = false;
2310+ notebook.set ("group-name", PACKAGE_NAME);
2311+ add (notebook);
2312+
2313+#if !HAVE_GTK3
2314+ /* Remove the inner border between scrollbars and window border */
2315+ Gtk.RcStyle rcstyle = new Gtk.RcStyle ();
2316+ rcstyle.xthickness = 0;
2317+ notebook.modify_style (rcstyle);
2318+ Gtk.rc_parse_string (style_fixup);
2319+#endif
2320+ notify["index"].connect (index_changed);
2321+ notify["tab"].connect (tab_changed);
2322+ notify["labels-visible"].connect (labels_visible_changed);
2323+ notify["close-buttons-visible"].connect (close_buttons_visible_changed);
2324+ notify["close-buttons-left"].connect (close_buttons_left_changed);
2325+
2326+ notebook.size_allocate.connect (size_allocated);
2327+ notebook.switch_page.connect (page_switched);
2328+ notebook.page_reordered.connect (page_moved);
2329+ notebook.create_window.connect (window_created);
2330+
2331+ var add = new Gtk.Button ();
2332+ add.relief = Gtk.ReliefStyle.NONE;
2333+ add.add (new Gtk.Image.from_gicon (new ThemedIcon.with_default_fallbacks ("tab-new-symbolic"), Gtk.IconSize.MENU));
2334+ add.show_all ();
2335+ notebook.set_action_widget (add, Gtk.PackType.START);
2336+ add.clicked.connect (()=>{
2337+ new_tab ();
2338+ });
2339+
2340+ button_press_event.connect (button_pressed);
2341+ }
2342+
2343+ ~Notebook () {
2344+ notebook.size_allocate.disconnect (size_allocated);
2345+ notebook.switch_page.disconnect (page_switched);
2346+ notebook.page_reordered.disconnect (page_moved);
2347+ notebook.create_window.disconnect (window_created);
2348+ }
2349+
2350+ bool button_pressed (Gdk.EventButton event) {
2351+ /* Propagate events in logical label area */
2352+ foreach (var child in notebook.get_children ()) {
2353+ var tally = notebook.get_tab_label (tab) as Tally;
2354+ Gtk.Allocation size;
2355+ tally.get_allocation (out size);
2356+ if (tally.get_mapped ()
2357+ && event.x_root >= size.x
2358+ && event.x_root <= (size.x + size.width)) {
2359+ tally.button_press_event (event);
2360+ return true;
2361+ }
2362+ }
2363+
2364+ if (event.type == Gdk.EventType.2BUTTON_PRESS && event.button == 1
2365+ || event.button == 2) {
2366+ new_tab ();
2367+ return true;
2368+ }
2369+ else if (event.button == 3) {
2370+ var menu = new Midori.ContextAction ("NotebookContextMenu", null, null, null);
2371+ uint counter = 0;
2372+ foreach (var child in notebook.get_children ()) {
2373+ var tab = child as Midori.Tab;
2374+ var tally = notebook.get_tab_label (tab) as Tally;
2375+ var action = new Gtk.Action ("Tab%u".printf (counter), tally.label.label, null, null);
2376+ action.gicon = tally.icon.gicon;
2377+ action.activate.connect (()=>{
2378+ notebook.set_current_page (notebook.page_num (tab));
2379+ });
2380+ menu.add (action);
2381+ counter++;
2382+ }
2383+ context_menu (menu);
2384+ var popup = menu.create_menu (null, false);
2385+ popup.show ();
2386+ popup.attach_to_widget (this, null);
2387+ popup.popup (null, null, null, event.button, event.time);
2388+ return true;
2389+ }
2390+ return false;
2391+ }
2392+
2393+ public void insert (Midori.Tab tab, int index) {
2394+ var tally = new Tally (tab);
2395+ tally.close_button_left = close_buttons_left;
2396+ tally.close_button_visible = close_buttons_visible;
2397+ tally.button_press_event.connect (tab_button_pressed);
2398+ tally.show ();
2399+ tally.set_size_request (tab.minimized ? -1 : last_tab_size, -1);
2400+
2401+ /* Minimum requirements for any tab */
2402+ tab.can_focus = tab.visible = true;
2403+ notebook.insert_page (tab, tally, index);
2404+ notebook.set_tab_reorderable (tab, true);
2405+ notebook.set_tab_detachable (tab, true);
2406+ tab.destroy.connect (tab_removed);
2407+ tab.notify["minimized"].connect (tab_minimized);
2408+ count++;
2409+ tab.ref ();
2410+ relayout ();
2411+ }
2412+
2413+ void tab_removed () {
2414+ count--;
2415+ if (count > 0)
2416+ relayout ();
2417+ }
2418+
2419+ void relayout () {
2420+ Gtk.Allocation size;
2421+ notebook.get_allocation (out size);
2422+ resize (size.width);
2423+ }
2424+
2425+ bool tab_button_pressed (Gtk.Widget label, Gdk.EventButton event) {
2426+ Tally tally = label as Tally;
2427+ if (event.button == 1) {
2428+ /* Leave switching and dragging up to the notebook */
2429+ return false;
2430+ } else if (event.button == 2)
2431+ tally.tab.destroy ();
2432+ else if (event.button == 3) {
2433+ var menu = new Midori.ContextAction ("TabContextMenu", null, null, null);
2434+ tab_context_menu (tally.tab, menu);
2435+ var action_window = new Midori.ContextAction ("TabWindowNew", _("Open in New _Window"), null, "window-new");
2436+ action_window.activate.connect (()=>{
2437+ tab_detached (tally.tab, 128, 128);
2438+ });
2439+ menu.add (action_window);
2440+ var action_minimize = new Midori.ContextAction ("TabMinimize", tally.tab.minimized ? _("Show Tab _Label") : _("Show Tab _Icon Only"), null, null);
2441+ action_minimize.activate.connect (()=>{
2442+ tally.tab.minimized = !tally.tab.minimized;
2443+ });
2444+ menu.add (action_minimize);
2445+ var action_right = new Midori.ContextAction ("TabCloseRight", ngettext ("Close Tab to the R_ight", "Close Tabs to the R_ight", count - 1), null, null);
2446+ action_right.sensitive = count > 1;
2447+ action_right.activate.connect (()=>{
2448+ bool found_tab = false;
2449+ foreach (var child in notebook.get_children ()) {
2450+ if (found_tab)
2451+ child.destroy ();
2452+ else
2453+ found_tab = child == tally.tab;
2454+ }
2455+ });
2456+ menu.add (action_right);
2457+ var action_other = new Midori.ContextAction ("TabCloseOther", ngettext ("Close Ot_her Tab", "Close Ot_her Tabs", count - 1), null, null);
2458+ action_other.sensitive = count > 1;
2459+ action_other.activate.connect (()=>{
2460+ foreach (var child in notebook.get_children ())
2461+ if (child != tally.tab)
2462+ child.destroy ();
2463+ });
2464+ menu.add (action_other);
2465+ var action_close = new Midori.ContextAction ("TabClose", null, null, Gtk.STOCK_CLOSE);
2466+ action_close.activate.connect (()=>{
2467+ tally.tab.destroy ();
2468+ });
2469+ menu.add (action_close);
2470+ var popup = menu.create_menu (null, false);
2471+ popup.show ();
2472+ popup.attach_to_widget (this, null);
2473+ popup.popup (null, null, null, event.button, event.time);
2474+ }
2475+ return true;
2476+ }
2477+
2478+ public void move (Midori.Tab tab, int index) {
2479+ notebook.reorder_child (tab, index);
2480+ }
2481+
2482+ /* Chain up drawing manually to circumvent parent checks */
2483+#if HAVE_GTK3
2484+ public override bool draw (Cairo.Context cr) {
2485+ notebook.draw (cr);
2486+ return true;
2487+ }
2488+#else
2489+ public override bool expose_event (Gdk.EventExpose event) {
2490+ notebook.expose_event (event);
2491+ return true;
2492+ }
2493+#endif
2494+
2495+ public override void forall_internal (bool include_internal, Gtk.Callback callback) {
2496+ if (include_internal)
2497+ callback (notebook);
2498+ foreach (var child in notebook.get_children ())
2499+ callback (child);
2500+ }
2501+
2502+ /* Can't override Gtk.Container.remove because it checks the parent */
2503+ public new void remove (Midori.Tab tab) {
2504+ return_if_fail (notebook.get_children ().find (tab) != null);
2505+
2506+ notebook.remove (tab);
2507+ tab.destroy.disconnect (tab_removed);
2508+ tab.notify["minimized"].disconnect (tab_minimized);
2509+ tab_removed ();
2510+ tab.unref ();
2511+ }
2512+
2513+ void tab_minimized (GLib.ParamSpec pspec) {
2514+ var tally = notebook.get_tab_label (tab) as Tally;
2515+ tally.set_size_request (tab.minimized ? -1 : last_tab_size, -1);
2516+ }
2517+
2518+ public Midori.Tab get_nth_tab (int index) {
2519+ return notebook.get_nth_page (index) as Midori.Tab;
2520+ }
2521+
2522+ public int get_tab_index (Midori.Tab tab) {
2523+ return notebook.page_num (tab);
2524+ }
2525+
2526+ void index_changed (GLib.ParamSpec pspec) {
2527+ notebook.set_current_page (index);
2528+ }
2529+
2530+ void tab_changed (GLib.ParamSpec pspec) {
2531+ notebook.set_current_page (notebook.page_num (tab));
2532+ }
2533+
2534+ void labels_visible_changed (GLib.ParamSpec pspec) {
2535+ notebook.show_tabs = labels_visible;
2536+ }
2537+
2538+ void close_buttons_visible_changed (GLib.ParamSpec pspec) {
2539+ foreach (var child in notebook.get_children ()) {
2540+ var tally = notebook.get_tab_label (child) as Tally;
2541+ tally.close_button_visible = close_buttons_visible;
2542+ }
2543+ }
2544+
2545+ void close_buttons_left_changed (GLib.ParamSpec pspec) {
2546+ foreach (var child in notebook.get_children ()) {
2547+ var tally = notebook.get_tab_label (child) as Tally;
2548+ tally.close_button_left = close_buttons_left;
2549+ }
2550+ }
2551+
2552+#if HAVE_GTK3
2553+ void size_allocated (Gtk.Allocation allocation) {
2554+#else
2555+ void size_allocated (Gdk.Rectangle allocation) {
2556+#endif
2557+ if (labels_visible && count > 0)
2558+ resize (allocation.width);
2559+ }
2560+
2561+#if HAVE_GTK3
2562+ void page_switched (Gtk.Widget new_tab, uint new_index) {
2563+#else
2564+ void page_switched (Gtk.NotebookPage new_tab, uint new_index) {
2565+#endif
2566+ tab_switched (previous, new_tab as Tab);
2567+ previous = (Midori.Tab)new_tab;
2568+
2569+ notify["index"].disconnect (index_changed);
2570+ notify["tab"].disconnect (tab_changed);
2571+ index = (int)new_index;
2572+ tab = (Midori.Tab)new_tab;
2573+ notify["index"].connect (index_changed);
2574+ notify["tab"].connect (tab_changed);
2575+ }
2576+
2577+ void page_moved (Gtk.Widget moving_tab, uint new_index) {
2578+ tab_moved (moving_tab as Midori.Tab, new_index);
2579+ /* Indices change, current tab is not in the same position */
2580+ notify["index"].disconnect (index_changed);
2581+ index = (int)get_tab_index (tab);
2582+ notify["index"].connect (index_changed);
2583+ }
2584+
2585+ unowned Gtk.Notebook window_created (Gtk.Widget tab, int x, int y) {
2586+ tab_detached (tab as Tab, x, y);
2587+ /* The API allows now, the cast is due to bindings not having ? */
2588+ return (Gtk.Notebook)null;
2589+ }
2590+
2591+ void resize (int new_size) {
2592+ int n = int.max (1, (int)count);
2593+ new_size /= n;
2594+ int icon_size = 16;
2595+ Gtk.icon_size_lookup_for_settings (get_settings (),
2596+ Gtk.IconSize.MENU, out icon_size, null);
2597+ int max_size = 150;
2598+ int min_size = icon_size;
2599+ if (close_buttons_visible)
2600+ min_size += icon_size;
2601+ new_size = new_size.clamp (min_size, max_size);
2602+ if ((new_size - last_tab_size).abs () < 3)
2603+ return;
2604+
2605+ last_tab_size = new_size;
2606+ foreach (var child in notebook.get_children ()) {
2607+ var tab = child as Midori.Tab;
2608+ var tally = notebook.get_tab_label (child) as Tally;
2609+ tally.set_size_request (tab.minimized ? -1 : last_tab_size, -1);
2610+ }
2611+ }
2612+ }
2613+}
2614
2615=== modified file 'midori/midori-preferences.c'
2616--- midori/midori-preferences.c 2013-11-25 23:12:58 +0000
2617+++ midori/midori-preferences.c 2013-12-05 00:25:31 +0000
2618@@ -482,11 +482,6 @@
2619 button = katze_property_proxy (settings, "close-buttons-on-tabs", NULL);
2620 gtk_button_set_label (GTK_BUTTON (button), _("Close Buttons on Tabs"));
2621 INDENTED_ADD (button);
2622- #ifndef HAVE_GRANITE
2623- button = katze_property_proxy (settings, "always-show-tabbar", NULL);
2624- gtk_button_set_label (GTK_BUTTON (button), _("Always Show Tabbar"));
2625- SPANNED_ADD (button);
2626- #endif
2627 button = katze_property_proxy (settings, "open-tabs-next-to-current", NULL);
2628 gtk_button_set_label (GTK_BUTTON (button), _("Open Tabs next to Current"));
2629 gtk_widget_set_tooltip_text (button, _("Whether to open new tabs next to the current tab or after the last one"));
2630
2631=== modified file 'midori/midori-settings.vala'
2632--- midori/midori-settings.vala 2013-08-04 14:27:34 +0000
2633+++ midori/midori-settings.vala 2013-12-05 00:25:31 +0000
2634@@ -153,6 +153,7 @@
2635 public bool close_buttons_on_tabs { get; set; default = true; }
2636 public bool open_tabs_in_the_background { get; set; default = true; }
2637 public bool open_tabs_next_to_current { get; set; default = true; }
2638+ // [Deprecated (since = "0.5.7")]
2639 public bool always_show_tabbar { get; set; default = true; }
2640
2641 public string homepage { get; set; default = "about:search"; }
2642
2643=== modified file 'midori/midori-tab.vala'
2644--- midori/midori-tab.vala 2013-10-08 20:13:36 +0000
2645+++ midori/midori-tab.vala 2013-12-05 00:25:31 +0000
2646@@ -51,6 +51,9 @@
2647
2648 /* Special is an error, blank or delayed page */
2649 public bool special { get; protected set; default = false; }
2650+ /* Minimizing a tab indicates that only the icon should be shown.
2651+ Since: 0.1.8 */
2652+ public bool minimized { get; set; default = false; }
2653 /* Since: 0.4.8 */
2654 public string mime_type { get; protected set; default = "text/plain"; }
2655 /* Since: 0.1.2 */
2656@@ -58,8 +61,18 @@
2657 public LoadStatus load_status { get; protected set; default = LoadStatus.FINISHED; }
2658 public string? statusbar_text { get; protected set; default = null; }
2659 /* Since: 0.5.0 */
2660+
2661 public Gdk.Color? fg_color { get; protected set; default = null; }
2662- public Gdk.Color? bg_color { get; protected set; default = null; }
2663+ private Gdk.Color? bg_color_ = null;
2664+ public Gdk.Color? bg_color { get {
2665+ return bg_color_;
2666+ } protected set {
2667+ bg_color_ = value;
2668+ colors_changed ();
2669+ } }
2670+ /* After fg_color and bg_color have changed.
2671+ Since: 0.5.7 */
2672+ public signal void colors_changed ();
2673
2674 /* Special pages don't convey progress */
2675 private double current_progress = 0.0;
2676
2677=== modified file 'midori/midori-view.c'
2678--- midori/midori-view.c 2013-11-22 18:03:14 +0000
2679+++ midori/midori-view.c 2013-12-05 00:25:31 +0000
2680@@ -109,21 +109,13 @@
2681 KatzeArray* news_feeds;
2682
2683 gboolean open_tabs_in_the_background;
2684- gboolean close_buttons_on_tabs;
2685 MidoriNewPage open_new_pages_in;
2686 gint find_links;
2687 gint alerts;
2688
2689+ GtkWidget* tab_label;
2690 GtkWidget* menu_item;
2691 PangoEllipsizeMode ellipsize;
2692- #ifdef HAVE_GRANITE
2693- GraniteWidgetsTab* tab;
2694- #else
2695- GtkWidget* tab_label;
2696- GtkWidget* tab_icon;
2697- GtkWidget* tab_title;
2698- GtkWidget* tab_close;
2699- #endif
2700 KatzeItem* item;
2701 gint scrollh, scrollv;
2702 GtkWidget* scrolled_window;
2703@@ -355,26 +347,6 @@
2704 GDK_TYPE_PIXBUF,
2705 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
2706
2707- /**
2708- * MidoriView:minimized:
2709- *
2710- * Whether the view is minimized or in normal state.
2711- *
2712- * Minimizing a view indicates that only the icon should
2713- * be advertised rather than the full blown tab label and
2714- * it might otherwise be presented specially.
2715- *
2716- * Since: 0.1.8
2717- */
2718- g_object_class_install_property (gobject_class,
2719- PROP_MINIMIZED,
2720- g_param_spec_boolean (
2721- "minimized",
2722- "Minimized",
2723- "Whether the view is minimized or in normal state",
2724- FALSE,
2725- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
2726-
2727 g_object_class_install_property (gobject_class,
2728 PROP_ZOOM_LEVEL,
2729 g_param_spec_float (
2730@@ -428,21 +400,6 @@
2731 const gchar* uri = midori_tab_get_uri (MIDORI_TAB (view));
2732 katze_assign (view->title, g_strdup (midori_tab_get_display_title (title, uri)));
2733 view->ellipsize = midori_tab_get_display_ellipsize (view->title, uri);
2734-
2735- #ifdef HAVE_GRANITE
2736- if (view->tab)
2737- g_object_set (view->tab,
2738- "label", view->title, "ellipsize-mode", view->ellipsize, NULL);
2739- #else
2740- if (view->tab_label)
2741- {
2742- gtk_label_set_text (GTK_LABEL (view->tab_title), view->title);
2743- gtk_widget_set_tooltip_text (view->tab_icon, view->title);
2744- gtk_widget_set_tooltip_text (view->tab_title, view->title);
2745- if (gtk_label_get_angle (GTK_LABEL (view->tab_title)) == 0.0)
2746- gtk_label_set_ellipsize (GTK_LABEL (view->tab_title), view->ellipsize);
2747- }
2748- #endif
2749 if (view->menu_item)
2750 gtk_label_set_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN (
2751 view->menu_item))), view->title);
2752@@ -463,20 +420,6 @@
2753 katze_object_assign (view->icon, icon);
2754 g_object_notify (G_OBJECT (view), "icon");
2755
2756- #ifdef HAVE_GRANITE
2757- if (view->tab)
2758- g_object_set (view->tab, "icon", icon, NULL);
2759- #else
2760- if (view->tab_icon)
2761- {
2762- if (icon_name && !strchr (icon_name, '/'))
2763- katze_throbber_set_static_icon_name (KATZE_THROBBER (view->tab_icon),
2764- icon_name);
2765- else
2766- katze_throbber_set_static_pixbuf (KATZE_THROBBER (view->tab_icon),
2767- view->icon);
2768- }
2769- #endif
2770 if (view->menu_item)
2771 {
2772 GtkWidget* image = katze_item_get_image (view->item, view->web_view);
2773@@ -543,19 +486,6 @@
2774 {
2775 if (midori_tab_get_load_status (MIDORI_TAB (view)) != load_status)
2776 midori_tab_set_load_status (MIDORI_TAB (view), load_status);
2777-
2778- #ifdef HAVE_GRANITE
2779- if (view->tab)
2780- {
2781- g_object_set (view->tab, "working",
2782- midori_view_get_progress (view) > 0.0, NULL);
2783- g_object_set (view->tab, "menu", midori_view_get_tab_menu (view), NULL);
2784- }
2785- #else
2786- if (view->tab_icon)
2787- katze_throbber_set_animated (KATZE_THROBBER (view->tab_icon),
2788- midori_view_get_progress (view) > 0.0);
2789- #endif
2790 }
2791
2792 #if defined (HAVE_LIBSOUP_2_29_91)
2793@@ -3056,7 +2986,6 @@
2794 view->title = NULL;
2795 view->icon = NULL;
2796 view->icon_uri = NULL;
2797- view->minimized = FALSE;
2798 view->hit_test = NULL;
2799 view->link_uri = NULL;
2800 view->selected_text = NULL;
2801@@ -3129,16 +3058,6 @@
2802 view->minimized ? 1 : -1);
2803 g_signal_handlers_unblock_by_func (view->item,
2804 midori_view_item_meta_data_changed, view);
2805- #ifdef HAVE_GRANITE
2806- if (view->tab)
2807- g_object_set (view->tab,
2808- "fixed", view->minimized,
2809- "label", midori_view_get_display_title (view),
2810- NULL);
2811- #else
2812- if (view->tab_label)
2813- sokoke_widget_set_visible (view->tab_title, !view->minimized);
2814- #endif
2815 break;
2816 case PROP_ZOOM_LEVEL:
2817 midori_view_set_zoom_level (view, g_value_get_float (value));
2818@@ -3168,9 +3087,6 @@
2819 case PROP_ICON:
2820 g_value_set_object (value, view->icon);
2821 break;
2822- case PROP_MINIMIZED:
2823- g_value_set_boolean (value, view->minimized);
2824- break;
2825 case PROP_ZOOM_LEVEL:
2826 g_value_set_float (value, midori_view_get_zoom_level (view));
2827 break;
2828@@ -3217,7 +3133,6 @@
2829 g_object_get (view->settings,
2830 "zoom-level", &zoom_level,
2831 "zoom-text-and-images", &zoom_text_and_images,
2832- "close-buttons-on-tabs", &view->close_buttons_on_tabs,
2833 "open-new-pages-in", &view->open_new_pages_in,
2834 "open-tabs-in-the-background", &view->open_tabs_in_the_background,
2835 NULL);
2836@@ -3279,8 +3194,8 @@
2837 if (item)
2838 {
2839 katze_object_assign (view->item, katze_item_copy (item));
2840- view->minimized = katze_item_get_meta_string (
2841- view->item, "minimized") != NULL;
2842+ midori_tab_set_minimized (MIDORI_TAB (view),
2843+ katze_item_get_meta_string (view->item, "minimized") != NULL);
2844 }
2845 gtk_widget_show ((GtkWidget*)view);
2846 return (GtkWidget*)view;
2847@@ -3308,14 +3223,6 @@
2848 g_value_get_boolean (&value));
2849 }
2850 #endif
2851- else if (name == g_intern_string ("close-buttons-on-tabs"))
2852- {
2853- view->close_buttons_on_tabs = g_value_get_boolean (&value);
2854- #ifndef HAVE_GRANITE
2855- sokoke_widget_set_visible (view->tab_close,
2856- view->close_buttons_on_tabs);
2857- #endif
2858- }
2859 else if (name == g_intern_string ("open-tabs-in-the-background"))
2860 view->open_tabs_in_the_background = g_value_get_boolean (&value);
2861 else if (name == g_intern_string ("enable-javascript"))
2862@@ -4395,14 +4302,6 @@
2863 return view->menu_item;
2864 }
2865
2866-static void
2867-midori_view_tab_label_menu_duplicate_tab_cb (GtkAction* action,
2868- gpointer user_data)
2869-{
2870- MidoriView* view = user_data;
2871- midori_view_duplicate (view);
2872-}
2873-
2874 GtkWidget*
2875 midori_view_duplicate (MidoriView* view)
2876 {
2877@@ -4415,58 +4314,6 @@
2878 return new_view;
2879 }
2880
2881-static void
2882-midori_view_tab_label_menu_close_tabs_right_cb (GtkAction* action,
2883- gpointer user_data)
2884-{
2885- GtkWidget* view = user_data;
2886- MidoriBrowser* browser = midori_browser_get_for_widget (view);
2887- GList* tabs = midori_browser_get_tabs (browser);
2888- gboolean found_tab = FALSE;
2889- for (; tabs; tabs = g_list_next (tabs))
2890- {
2891- if (tabs->data == view)
2892- {
2893- found_tab = TRUE;
2894- continue;
2895- }
2896- if (found_tab)
2897- midori_browser_close_tab (browser, tabs->data);
2898- }
2899- g_list_free (tabs);
2900-}
2901-
2902-static void
2903-midori_view_tab_label_menu_close_other_tabs_cb (GtkAction* action,
2904- gpointer user_data)
2905-{
2906- GtkWidget* view = user_data;
2907- MidoriBrowser* browser = midori_browser_get_for_widget (view);
2908- GList* tabs = midori_browser_get_tabs (browser);
2909- for (; tabs; tabs = g_list_next (tabs))
2910- {
2911- if (tabs->data != view)
2912- midori_browser_close_tab (browser, tabs->data);
2913- }
2914- g_list_free (tabs);
2915-}
2916-
2917-static void
2918-midori_view_tab_label_menu_minimize_tab_cb (GtkAction* action,
2919- gpointer user_data)
2920-{
2921- MidoriView* view = user_data;
2922- g_object_set (view, "minimized", !view->minimized, NULL);
2923-}
2924-
2925-static void
2926-midori_view_tab_label_menu_close_cb (GtkAction* action,
2927- gpointer user_data)
2928-{
2929- GtkWidget* view = user_data;
2930- midori_browser_close_tab (midori_browser_get_for_widget (view), view);
2931-}
2932-
2933 /**
2934 * midori_view_get_tab_menu:
2935 * @view: a #MidoriView
2936@@ -4477,242 +4324,14 @@
2937 * Return value: a #GtkMenu
2938 *
2939 * Since: 0.1.8
2940+ * Deprecated: 0.5.7: Use MidoriNotebook API instead.
2941 **/
2942 GtkWidget*
2943 midori_view_get_tab_menu (MidoriView* view)
2944 {
2945 g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
2946
2947- MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (view));
2948- g_return_val_if_fail (browser != NULL, NULL);
2949-
2950- GtkActionGroup* actions = midori_browser_get_action_group (browser);
2951- MidoriContextAction* menu = midori_context_action_new ("TabContextMenu", NULL, NULL, NULL);
2952- midori_context_action_add_action_group (menu, actions);
2953- gint pages = midori_browser_get_n_pages (browser);
2954-
2955- midori_context_action_add_by_name (menu, "TabNew");
2956- midori_context_action_add_by_name (menu, "UndoTabClose");
2957- midori_context_action_add (menu, NULL);
2958- midori_context_action_add_simple (menu, "TabWindowNew", _("Open in New _Window"), NULL, STOCK_WINDOW_NEW,
2959- midori_view_tab_label_menu_window_new_cb, view);
2960- midori_context_action_add_simple (menu, "TabDuplicate", _("_Duplicate Tab"), NULL, NULL,
2961- midori_view_tab_label_menu_duplicate_tab_cb, view);
2962- midori_context_action_add_simple (menu, "TabMinimize",
2963- view->minimized ? _("Show Tab _Label") : _("Show Tab _Icon Only"), NULL, NULL,
2964- midori_view_tab_label_menu_minimize_tab_cb, view);
2965- midori_context_action_add (menu, NULL);
2966- midori_context_action_add_simple (menu, "TabCloseRight", _("Close Tabs to the R_ight"), NULL, NULL,
2967- midori_view_tab_label_menu_close_tabs_right_cb, view);
2968- GtkAction* action = gtk_action_new ("TabCloseOther", g_dngettext (NULL, "Close Ot_her Tab", "Close Ot_her Tabs", pages - 1), NULL, NULL);
2969- g_signal_connect (action, "activate", G_CALLBACK (midori_view_tab_label_menu_close_other_tabs_cb), view);
2970- gtk_action_set_sensitive (action, pages > 1);
2971- midori_context_action_add (menu, action);
2972- midori_context_action_add_simple (menu, "TabClose", NULL, NULL, GTK_STOCK_CLOSE,
2973- midori_view_tab_label_menu_close_cb, view);
2974-
2975- return GTK_WIDGET (midori_context_action_create_menu (menu, NULL, FALSE));
2976-}
2977-
2978-#ifdef HAVE_GRANITE
2979-GraniteWidgetsTab*
2980-midori_view_get_tab (MidoriView* view)
2981-{
2982- if (view->tab == NULL)
2983- {
2984- view->tab = granite_widgets_tab_new (
2985- midori_view_get_display_title (view), G_ICON (view->icon), GTK_WIDGET (view));
2986- g_object_set (view->tab, "fixed", view->minimized, NULL);
2987- }
2988- return view->tab;
2989-}
2990-
2991-void
2992-midori_view_set_tab (MidoriView* view,
2993- GraniteWidgetsTab* tab)
2994-{
2995- g_return_if_fail (MIDORI_IS_VIEW (view));
2996-
2997- view->tab = tab;
2998- g_object_set (tab,
2999- "label", midori_view_get_display_title (view),
3000- "icon", G_ICON (view->icon),
3001- "page", GTK_WIDGET (view),
3002- "fixed", view->minimized,
3003- NULL);
3004-}
3005-
3006-GtkWidget*
3007-midori_view_get_proxy_tab_label (MidoriView* view)
3008-{
3009- g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
3010-
3011- GtkWidget* tab = GTK_WIDGET (midori_view_get_tab (view));
3012- return tab;
3013-}
3014-
3015-#else
3016-static gboolean
3017-midori_view_tab_label_button_press_event (GtkWidget* tab_label,
3018- GdkEventButton* event,
3019- GtkWidget* widget)
3020-{
3021- if (event->button == 2)
3022- {
3023- /* Close the widget on middle click */
3024- midori_browser_close_tab (midori_browser_get_for_widget (widget), widget);
3025- return TRUE;
3026- }
3027- else if (MIDORI_EVENT_CONTEXT_MENU (event))
3028- {
3029- /* Show a context menu on right click */
3030- GtkWidget* menu = midori_view_get_tab_menu (MIDORI_VIEW (widget));
3031-
3032- katze_widget_popup (widget, GTK_MENU (menu),
3033- event, KATZE_MENU_POSITION_CURSOR);
3034- return TRUE;
3035- }
3036-
3037- return FALSE;
3038-}
3039-
3040-static void
3041-midori_view_tab_close_clicked (GtkWidget* tab_close,
3042- GtkWidget* widget)
3043-{
3044- midori_browser_close_tab (midori_browser_get_for_widget (widget), widget);
3045-}
3046-
3047-#if !GTK_CHECK_VERSION (3, 0, 0)
3048-static void
3049-midori_view_tab_icon_style_set_cb (GtkWidget* tab_close,
3050- GtkStyle* previous_style)
3051-{
3052- GtkRequisition size;
3053- gtk_widget_size_request (gtk_bin_get_child (GTK_BIN (tab_close)), &size);
3054- gtk_widget_set_size_request (tab_close, size.width, size.height);
3055-}
3056-#endif
3057-
3058-static void
3059-midori_view_update_tab_title (MidoriView* view,
3060- gdouble angle)
3061-{
3062- if (angle == 0.0)
3063- gtk_label_set_ellipsize (GTK_LABEL (view->tab_title), view->ellipsize);
3064- else
3065- gtk_label_set_ellipsize (GTK_LABEL (view->tab_title), PANGO_ELLIPSIZE_NONE);
3066- gtk_label_set_angle (GTK_LABEL (view->tab_title), angle);
3067-}
3068-
3069-static void
3070-gtk_box_repack (GtkBox* box,
3071- GtkWidget* child)
3072-{
3073- GtkWidget* old_box;
3074- gboolean expand, fill;
3075- guint padding;
3076- GtkPackType pack_type;
3077-
3078- old_box = gtk_widget_get_parent (child);
3079- g_return_if_fail (GTK_IS_BOX (old_box));
3080-
3081- gtk_box_query_child_packing (GTK_BOX (old_box), child,
3082- &expand, &fill, &padding, &pack_type);
3083-
3084- g_object_ref (child);
3085- gtk_container_remove (GTK_CONTAINER (old_box), child);
3086- if (pack_type == GTK_PACK_START)
3087- gtk_box_pack_start (box, child, expand, fill, padding);
3088- else
3089- gtk_box_pack_end (box, child, expand, fill, padding);
3090- g_object_unref (child);
3091-}
3092-
3093-static void
3094-midori_view_tab_label_parent_set (GtkWidget* tab_label,
3095-#if GTK_CHECK_VERSION(3,0,0)
3096- GObject* old_parent,
3097-#else
3098- GtkObject* old_parent,
3099-#endif
3100- MidoriView* view)
3101-{
3102- GtkWidget* parent;
3103-
3104- /* FIXME: Disconnect orientation notification
3105- if (old_parent)
3106- ; */
3107-
3108- if (!(parent = gtk_widget_get_parent (tab_label)))
3109- return;
3110-
3111- if (GTK_IS_NOTEBOOK (parent))
3112- {
3113- GtkPositionType pos;
3114- gdouble old_angle, angle;
3115- GtkWidget* box;
3116-
3117- pos = gtk_notebook_get_tab_pos (GTK_NOTEBOOK (parent));
3118- old_angle = gtk_label_get_angle (GTK_LABEL (view->tab_title));
3119- switch (pos)
3120- {
3121- case GTK_POS_LEFT:
3122- angle = 90.0;
3123- break;
3124- case GTK_POS_RIGHT:
3125- angle = 270.0;
3126- break;
3127- default:
3128- angle = 0.0;
3129- }
3130-
3131- if (old_angle != angle)
3132- {
3133- GtkWidget* align;
3134-
3135- if (angle == 0.0)
3136- box = gtk_hbox_new (FALSE, 1);
3137- else
3138- box = gtk_vbox_new (FALSE, 1);
3139- gtk_box_repack (GTK_BOX (box), view->tab_icon);
3140- gtk_box_repack (GTK_BOX (box), view->tab_title);
3141- align = gtk_widget_get_parent (view->tab_close);
3142- gtk_box_repack (GTK_BOX (box), align);
3143-
3144- gtk_container_remove (GTK_CONTAINER (tab_label),
3145- gtk_bin_get_child (GTK_BIN (tab_label)));
3146- gtk_container_add (GTK_CONTAINER (tab_label), GTK_WIDGET (box));
3147- gtk_widget_show (box);
3148- }
3149-
3150- midori_view_update_tab_title (view, angle);
3151-
3152- /* FIXME: Connect orientation notification */
3153- }
3154-}
3155-
3156-static void midori_view_tab_label_data_received (GtkWidget* widget,
3157- GdkDragContext* context,
3158- gint x,
3159- gint y,
3160- GtkSelectionData* data,
3161- guint ttype,
3162- guint timestamp,
3163- MidoriView* view)
3164-{
3165- gchar** uri = gtk_selection_data_get_uris (data);
3166- if (uri != NULL)
3167- {
3168- midori_view_set_uri (view, uri[0]);
3169- g_strfreev (uri);
3170- }
3171- else
3172- {
3173- gchar* text = (gchar*) gtk_selection_data_get_text (data);
3174- midori_view_set_uri (view, text);
3175- g_free (text);
3176- }
3177+ return gtk_menu_new ();
3178 }
3179
3180 /**
3181@@ -4722,115 +4341,22 @@
3182 * Retrieves a proxy tab label that is typically used when
3183 * adding the view to a notebook.
3184 *
3185- * Note that the label actually adjusts its orientation
3186- * to the according tab position when used in a notebook.
3187- *
3188- * The label is created on the first call and will be updated to reflect
3189- * changes of the loading progress and title.
3190- *
3191- * The label is valid until it is removed from its container.
3192- *
3193 * Return value: the proxy #GtkEventBox
3194+ *
3195+ * Deprecated: 0.5.7: Don't use this label.
3196 **/
3197 GtkWidget*
3198 midori_view_get_proxy_tab_label (MidoriView* view)
3199 {
3200- GtkWidget* event_box;
3201- GtkWidget* hbox;
3202- #if !GTK_CHECK_VERSION (3, 0, 0)
3203- static const gchar style_fixup[] =
3204- "style \"midori-close-button-style\"\n"
3205- "{\n"
3206- "GtkWidget::focus-padding = 0\n"
3207- "GtkWidget::focus-line-width = 0\n"
3208- "xthickness = 0\n"
3209- "ythickness = 0\n"
3210- "}\n"
3211- "widget \"*.midori-close-button\" style \"midori-close-button-style\"";
3212- #endif
3213- GtkWidget* image;
3214- GtkWidget* align;
3215-
3216 g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
3217
3218 if (!view->tab_label)
3219 {
3220- view->tab_icon = katze_throbber_new ();
3221- katze_throbber_set_static_pixbuf (KATZE_THROBBER (view->tab_icon),
3222- midori_view_get_icon (view));
3223-
3224- view->tab_title = gtk_label_new (midori_view_get_display_title (view));
3225- gtk_misc_set_alignment (GTK_MISC (view->tab_title), 0.0, 0.5);
3226- gtk_misc_set_padding (GTK_MISC (view->tab_title), 0, 0);
3227-
3228- event_box = gtk_event_box_new ();
3229- gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box), FALSE);
3230- hbox = gtk_hbox_new (FALSE, 1);
3231- gtk_container_add (GTK_CONTAINER (event_box), GTK_WIDGET (hbox));
3232- midori_view_update_tab_title (view, 0.0);
3233-
3234- view->tab_close = gtk_button_new ();
3235- gtk_button_set_relief (GTK_BUTTON (view->tab_close), GTK_RELIEF_NONE);
3236- gtk_button_set_focus_on_click (GTK_BUTTON (view->tab_close), FALSE);
3237- #if !GTK_CHECK_VERSION (3, 0, 0)
3238- gtk_rc_parse_string (style_fixup);
3239- gtk_widget_set_name (view->tab_close, "midori-close-button");
3240- g_signal_connect (view->tab_close, "style-set",
3241- G_CALLBACK (midori_view_tab_icon_style_set_cb), NULL);
3242- #endif
3243- image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
3244- gtk_container_add (GTK_CONTAINER (view->tab_close), image);
3245- align = gtk_alignment_new (1.0, 0.5, 0.0, 0.0);
3246- gtk_container_add (GTK_CONTAINER (align), view->tab_close);
3247-
3248- if (katze_object_get_boolean (view->settings, "close-buttons-left"))
3249- {
3250- gtk_box_pack_end (GTK_BOX (hbox), view->tab_icon, FALSE, FALSE, 0);
3251- gtk_box_pack_end (GTK_BOX (hbox), view->tab_title, TRUE, TRUE, 0);
3252- gtk_box_pack_start (GTK_BOX (hbox), align, FALSE, FALSE, 0);
3253- }
3254- else
3255- {
3256- gtk_box_pack_start (GTK_BOX (hbox), view->tab_icon, FALSE, FALSE, 0);
3257- gtk_box_pack_start (GTK_BOX (hbox), view->tab_title, TRUE, TRUE, 0);
3258- gtk_box_pack_end (GTK_BOX (hbox), align, FALSE, FALSE, 0);
3259- }
3260- gtk_widget_show_all (GTK_WIDGET (event_box));
3261-
3262- if (view->minimized)
3263- gtk_widget_hide (view->tab_title);
3264- if (!view->close_buttons_on_tabs)
3265- gtk_widget_hide (view->tab_close);
3266-
3267- g_signal_connect (event_box, "button-press-event",
3268- G_CALLBACK (midori_view_tab_label_button_press_event), view);
3269- g_signal_connect (view->tab_close, "button-press-event",
3270- G_CALLBACK (midori_view_tab_label_button_press_event), view);
3271- g_signal_connect (view->tab_close, "clicked",
3272- G_CALLBACK (midori_view_tab_close_clicked), view);
3273-
3274- view->tab_label = event_box;
3275- g_signal_connect (view->tab_icon, "destroy",
3276- G_CALLBACK (gtk_widget_destroyed),
3277- &view->tab_icon);
3278- g_signal_connect (view->tab_label, "destroy",
3279- G_CALLBACK (gtk_widget_destroyed),
3280- &view->tab_label);
3281-
3282- g_signal_connect (view->tab_label, "parent-set",
3283- G_CALLBACK (midori_view_tab_label_parent_set),
3284- view);
3285- gtk_drag_dest_set (view->tab_label, GTK_DEST_DEFAULT_ALL, NULL,
3286- 0, GDK_ACTION_COPY);
3287- gtk_drag_dest_add_text_targets (view->tab_label);
3288- gtk_drag_dest_add_uri_targets (view->tab_label);
3289- g_signal_connect (view->tab_label, "drag-data-received",
3290- G_CALLBACK (midori_view_tab_label_data_received),
3291- view);
3292+ view->tab_label = gtk_label_new ("dummy");
3293+ gtk_widget_show (view->tab_label);
3294 }
3295 return view->tab_label;
3296 }
3297-#endif
3298
3299 /**
3300 * midori_view_get_label_ellipsize:
3301@@ -5450,60 +4976,22 @@
3302 #endif
3303 return MIDORI_VIEW (view);
3304 }
3305-
3306+/**
3307+ * midori_view_set_colors:
3308+ * @view: a #MidoriView
3309+ * @fg_color: a #GdkColor, or %NULL
3310+ * @bg_color: a #GdkColor, or %NULL
3311+ *
3312+ * Sets colors on the label.
3313+ *
3314+ * Deprecated: 0.5.7: Use fg_color/ bg_color on Midori.Tab.
3315+ **/
3316 void
3317 midori_view_set_colors (MidoriView* view,
3318 GdkColor* fg_color,
3319 GdkColor* bg_color)
3320 {
3321- /*
3322- The proxy tab label is what's put in the notebook,
3323- in all known cases a GtkEventBox
3324- Contained can be a GtkLabel or a GtkBox including a GtkLabel
3325- Granite as of this writing uses a GtkLabel (which may change)
3326- */
3327- GtkWidget* box = midori_view_get_proxy_tab_label (view);
3328- GtkWidget* event_box = box;
3329- if (GTK_IS_BOX (box))
3330- {
3331- GList* children = gtk_container_get_children (GTK_CONTAINER (box));
3332- for (; children != NULL; children = g_list_next (children))
3333- if (GTK_IS_EVENT_BOX (children->data))
3334- {
3335- event_box = children->data;
3336- break;
3337- }
3338- g_list_free (children);
3339- }
3340-
3341- GtkWidget* label = gtk_bin_get_child (GTK_BIN (event_box));
3342- if (GTK_IS_BOX (label))
3343- {
3344- GList* children = gtk_container_get_children (GTK_CONTAINER (label));
3345- for (; children != NULL; children = g_list_next (children))
3346- if (GTK_IS_LABEL (children->data))
3347- {
3348- label = children->data;
3349- break;
3350- }
3351- g_list_free (children);
3352- }
3353-
3354 midori_tab_set_fg_color (MIDORI_TAB (view), fg_color);
3355 midori_tab_set_bg_color (MIDORI_TAB (view), bg_color);
3356-
3357- gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box),
3358- fg_color != NULL || bg_color != NULL);
3359-
3360- gtk_widget_modify_fg (label, GTK_STATE_NORMAL, fg_color);
3361- gtk_widget_modify_fg (label, GTK_STATE_ACTIVE, fg_color);
3362-
3363- #if GTK_CHECK_VERSION (3, 0, 0)
3364- gtk_widget_modify_bg (event_box, GTK_STATE_NORMAL, bg_color);
3365- gtk_widget_modify_bg (event_box, GTK_STATE_ACTIVE, bg_color);
3366- #else
3367- gtk_widget_modify_bg (box, GTK_STATE_NORMAL, bg_color);
3368- gtk_widget_modify_bg (box, GTK_STATE_ACTIVE, bg_color);
3369- #endif
3370 }
3371
3372
3373=== modified file 'midori/midori.vapi'
3374--- midori/midori.vapi 2013-11-19 19:30:54 +0000
3375+++ midori/midori.vapi 2013-12-05 00:25:31 +0000
3376@@ -197,7 +197,6 @@
3377
3378 public string title { get; }
3379 public Gdk.Pixbuf icon { get; }
3380- public bool minimized { get; }
3381 public float zoom_level { get; }
3382 public Katze.Array news_feeds { get; }
3383 [NoAccessorMethod]
3384
3385=== modified file 'po/POTFILES.in'
3386--- po/POTFILES.in 2013-10-09 09:15:33 +0000
3387+++ po/POTFILES.in 2013-12-05 00:25:31 +0000
3388@@ -14,6 +14,7 @@
3389 midori/midori-settings.vala
3390 midori/midori-websettings.c
3391 midori/midori-tab.vala
3392+midori/midori-notebook.vala
3393 midori/midori-view.c
3394 midori/midori-download.vala
3395 midori/midori-speeddial.vala
3396@@ -28,7 +29,6 @@
3397 panels/midori-extensions.c
3398 panels/midori-history.c
3399 katze/katze-http-auth.c
3400-katze/katze-throbber.c
3401 katze/katze-utils.c
3402 katze/katze-item.c
3403 katze/katze-array.c

Subscribers

People subscribed via source and target branches

to all changes: