~ubuntu-branches/ubuntu/vivid/liferea/vivid-proposed

« back to all changes in this revision

Viewing changes to src/ui/browser_tabs.c

  • Committer: Package Import Robot
  • Author(s): bojo42
  • Date: 2012-03-29 14:17:21 UTC
  • mfrom: (1.3.9) (3.2.5 sid)
  • Revision ID: package-import@ubuntu.com-20120329141721-tbfopcrc5797wxt7
Tags: 1.8.3-0.1ubuntu1
* New upstream release (LP: #290666, #371754, #741543, #716688)
* Merge from Debian unstable (LP: #935147), remaining changes:
* debian/patches:
  - drop gtk-status-icon.patch & notification-append as in upstream
  - drop fix_systray_behavior as mostly upstreamed and rest seems unused
  - 01_ubuntu_feedlists: update & rename, move planets to "Open Source"  
  - add_X-Ubuntu-Gettext-Domain: rebase
  - libunity.patch: rebase, apply before indicator patch (liferea_shell.c)
  - libindicate_increase_version.patch: exclude from libindicate.patch
  - deactivate libindicate.patch, seems partly upstreamed and needs rework
* debian/control: libindicate-dev, libindicate-gtk-dev & libunity-dev
* debian/liferea.indicate & liferea.install: ship indicator desktop file
* debian/rules: enable libindicate

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
2
 * @file browser_tabs.c  internal browsing using multiple tabs
3
3
 *
4
 
 * Copyright (C) 2004-2009 Lars Lindner <lars.lindner@gmail.com>
 
4
 * Copyright (C) 2004-2011 Lars Lindner <lars.lindner@gmail.com>
5
5
 * Copyright (C) 2006 Nathan Conrad <conrad@bungled.net>
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or modify
27
27
#include "common.h"
28
28
#include "itemlist.h"
29
29
#include "ui/liferea_shell.h"
30
 
#include "ui/ui_itemlist.h"
 
30
#include "ui/item_list_view.h"
31
31
 
32
32
/* single tab history handling */
33
33
 
142
142
}
143
143
 
144
144
static void
145
 
on_tab_switched (GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer user_data)
146
 
{
147
 
        /* needed because switching does sometimes returns to the tree 
148
 
           view with a very disturbing horizontal scrolling state */
149
 
        if (0 == page_num)
150
 
                ui_itemlist_scroll_left ();
151
 
}
152
 
 
153
 
static void
154
145
on_tab_history_back (GtkWidget *widget, gpointer user_data)
155
146
{
156
147
        tabInfo         *tab = (tabInfo *)user_data;
190
181
 
191
182
/* browser tabs object */
192
183
 
193
 
static void browser_tabs_class_init     (BrowserTabsClass *klass);
194
 
static void browser_tabs_init           (BrowserTabs *ls);
195
 
 
196
184
#define BROWSER_TABS_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), BROWSER_TABS_TYPE, BrowserTabsPrivate))
197
185
 
198
186
struct BrowserTabsPrivate {
199
187
        GtkNotebook     *notebook;
 
188
 
 
189
        GtkWidget       *headlines;     /**< widget of the headlines tab */
200
190
        
201
191
        GSList          *list;          /**< tabInfo structures for all tabs */
202
192
};
204
194
static GObjectClass *parent_class = NULL;
205
195
static BrowserTabs *tabs = NULL;
206
196
 
207
 
GType
208
 
browser_tabs_get_type (void) 
209
 
{
210
 
        static GType type = 0;
211
 
 
212
 
        if (G_UNLIKELY (type == 0)) 
213
 
        {
214
 
                static const GTypeInfo our_info = 
215
 
                {
216
 
                        sizeof (BrowserTabsClass),
217
 
                        NULL, /* base_init */
218
 
                        NULL, /* base_finalize */
219
 
                        (GClassInitFunc) browser_tabs_class_init,
220
 
                        NULL,
221
 
                        NULL, /* class_data */
222
 
                        sizeof (BrowserTabs),
223
 
                        0, /* n_preallocs */
224
 
                        (GInstanceInitFunc) browser_tabs_init,
225
 
                        NULL /* value_table */
226
 
                };
227
 
 
228
 
                type = g_type_register_static (G_TYPE_OBJECT,
229
 
                                               "BrowserTabs",
230
 
                                               &our_info, 0);
231
 
        }
232
 
 
233
 
        return type;
234
 
}
 
197
G_DEFINE_TYPE (BrowserTabs, browser_tabs, G_TYPE_OBJECT);
235
198
 
236
199
/** Removes tab info structure */
237
200
static void
239
202
{
240
203
        tabs->priv->list = g_slist_remove (tabs->priv->list, tab);
241
204
        browser_tab_history_free (tab->history);
242
 
        g_free (tab);   
 
205
        g_object_unref (tab->htmlview);
 
206
        g_free (tab);
243
207
}
244
208
 
245
209
static void
284
248
        g_object_new (BROWSER_TABS_TYPE, NULL);
285
249
        
286
250
        tabs->priv->notebook = notebook;
287
 
        
 
251
        tabs->priv->headlines = gtk_notebook_get_nth_page (notebook, 0);
 
252
 
288
253
        gtk_notebook_set_show_tabs (tabs->priv->notebook, FALSE);
289
 
        g_signal_connect ((gpointer)tabs->priv->notebook, "switch-page", G_CALLBACK (on_tab_switched), NULL);
290
254
        
291
255
        return tabs;
292
256
}
320
284
{
321
285
        const gchar     *tmp;
322
286
 
323
 
        tmp = (title && *title) ? title : _("New tab");
 
287
        tmp = (title && *title) ? title : _("Untitled");
324
288
 
325
289
        tmp = remove_string_prefix (tmp, "http://");
326
290
        tmp = remove_string_prefix (tmp, "https://");
339
303
}
340
304
 
341
305
static void
342
 
on_htmlview_open_tab (gpointer object, gchar *url, gpointer user_data)
343
 
{
344
 
        browser_tabs_add_new (url, url, FALSE);
345
 
}
346
 
 
347
 
static void
348
306
on_htmlview_close_tab (gpointer object, gpointer user_data)
349
307
{
350
308
        browser_tabs_close_tab((tabInfo *)user_data);
391
349
 
392
350
        g_signal_connect (tab->htmlview, "title-changed", G_CALLBACK (on_htmlview_title_changed), tab);
393
351
        g_signal_connect (tab->htmlview, "location-changed", G_CALLBACK (on_htmlview_location_changed), tab);
394
 
        g_signal_connect (tab->htmlview, "open-tab", G_CALLBACK (on_htmlview_open_tab), tab);
395
 
        g_signal_connect (tab->htmlview, "close-tab", G_CALLBACK (on_htmlview_close_tab), tab);
396
352
        g_signal_connect (tab->htmlview, "statusbar-changed", G_CALLBACK (on_htmlview_status_message), NULL);
397
353
        
398
354
        /* create tab widgets */
452
408
        g_signal_connect (gtk_notebook_get_nth_page (tabs->priv->notebook, i), 
453
409
                          "key-press-event", G_CALLBACK (on_tab_key_press), (gpointer)tab);
454
410
        gtk_notebook_set_show_tabs (tabs->priv->notebook, TRUE);
455
 
        
 
411
        gtk_notebook_set_tab_reorderable (tabs->priv->notebook, tab->widget, TRUE);     
 
412
                
456
413
        if (activate && (i != -1))
457
414
                gtk_notebook_set_current_page (tabs->priv->notebook, i);
458
415
         
466
423
void
467
424
browser_tabs_show_headlines (void)
468
425
{
469
 
        gtk_notebook_set_current_page (tabs->priv->notebook, 0);
 
426
        gtk_notebook_set_current_page (tabs->priv->notebook, gtk_notebook_page_num (tabs->priv->notebook, tabs->priv->headlines));
470
427
}
471
428
 
472
429
LifereaHtmlView *