Refactor Tab Panel into a single file
This commit is contained in:
parent
42ab4b3848
commit
1e28cd3b14
4 changed files with 122 additions and 158 deletions
122
extensions/tab-panel.c
Normal file
122
extensions/tab-panel.c
Normal file
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
Copyright (C) 2008-2009 Christian Dywan <christian@twotoasts.de>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
See the file COPYING for the full license text.
|
||||
*/
|
||||
|
||||
#include <midori/midori.h>
|
||||
|
||||
#define STOCK_TAB_PANEL "tab-panel"
|
||||
|
||||
static void
|
||||
tab_panel_app_add_browser_cb (MidoriApp* app,
|
||||
MidoriBrowser* browser,
|
||||
MidoriExtension* extension);
|
||||
|
||||
static void
|
||||
tab_panel_deactivate_cb (MidoriExtension* extension,
|
||||
GtkWidget* panel)
|
||||
{
|
||||
MidoriApp* app = midori_extension_get_app (extension);
|
||||
|
||||
gtk_widget_destroy (panel);
|
||||
g_signal_handlers_disconnect_by_func (
|
||||
extension, tab_panel_deactivate_cb, panel);
|
||||
g_signal_handlers_disconnect_by_func (
|
||||
app, tab_panel_app_add_browser_cb, extension);
|
||||
}
|
||||
|
||||
static void
|
||||
tab_panel_app_add_browser_cb (MidoriApp* app,
|
||||
MidoriBrowser* browser,
|
||||
MidoriExtension* extension)
|
||||
{
|
||||
GtkWidget* panel;
|
||||
GtkWidget* notebook;
|
||||
GtkWidget* toolbar;
|
||||
/* GtkToolItem* toolitem; */
|
||||
|
||||
panel = katze_object_get_object (browser, "panel");
|
||||
notebook = gtk_notebook_new ();
|
||||
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_RIGHT);
|
||||
gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
|
||||
gtk_widget_show (notebook);
|
||||
toolbar = gtk_toolbar_new ();
|
||||
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
|
||||
gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
|
||||
gtk_widget_show (toolbar);
|
||||
|
||||
/*
|
||||
TODO: Implement optional thumbnail images
|
||||
toolitem = gtk_toggle_tool_button_new_from_stock (STOCK_IMAGE);
|
||||
gtk_tool_item_set_is_important (toolitem, TRUE);
|
||||
g_signal_connect (toolitem, "toggled",
|
||||
G_CALLBACK (tab_panel_button_thumbnail_toggled_cb), notebook);
|
||||
gtk_widget_show (GTK_WIDGET (toolitem));
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1); */
|
||||
|
||||
midori_panel_append_widget (MIDORI_PANEL (panel), notebook,
|
||||
STOCK_TAB_PANEL, _("Tab Panel"), toolbar);
|
||||
g_signal_connect (extension, "deactivate",
|
||||
G_CALLBACK (tab_panel_deactivate_cb), notebook);
|
||||
|
||||
g_object_unref (panel);
|
||||
}
|
||||
|
||||
static void
|
||||
tab_panel_activate_cb (MidoriExtension* extension,
|
||||
MidoriApp* app)
|
||||
{
|
||||
KatzeArray* browsers;
|
||||
MidoriBrowser* browser;
|
||||
guint i;
|
||||
|
||||
browsers = katze_object_get_object (app, "browsers");
|
||||
i = 0;
|
||||
while ((browser = katze_array_get_nth_item (browsers, i++)))
|
||||
tab_panel_app_add_browser_cb (app, browser, extension);
|
||||
g_object_unref (browsers);
|
||||
g_signal_connect (app, "add-browser",
|
||||
G_CALLBACK (tab_panel_app_add_browser_cb), extension);
|
||||
}
|
||||
|
||||
MidoriExtension*
|
||||
extension_init (void)
|
||||
{
|
||||
GtkIconFactory* factory;
|
||||
GtkIconSource* icon_source;
|
||||
GtkIconSet* icon_set;
|
||||
static GtkStockItem items[] =
|
||||
{
|
||||
{ STOCK_TAB_PANEL, N_("T_ab Panel"), 0, 0, NULL },
|
||||
};
|
||||
|
||||
factory = gtk_icon_factory_new ();
|
||||
gtk_stock_add (items, G_N_ELEMENTS (items));
|
||||
icon_set = gtk_icon_set_new ();
|
||||
icon_source = gtk_icon_source_new ();
|
||||
gtk_icon_source_set_icon_name (icon_source, GTK_STOCK_INDEX);
|
||||
gtk_icon_set_add_source (icon_set, icon_source);
|
||||
gtk_icon_source_free (icon_source);
|
||||
gtk_icon_factory_add (factory, STOCK_TAB_PANEL, icon_set);
|
||||
gtk_icon_set_unref (icon_set);
|
||||
gtk_icon_factory_add_default (factory);
|
||||
g_object_unref (factory);
|
||||
|
||||
MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
|
||||
"name", _("Tab Panel"),
|
||||
"description", _("Show tabs in a vertical panel"),
|
||||
"version", "0.1",
|
||||
"authors", "Christian Dywan <christian@twotoasts.de>",
|
||||
NULL);
|
||||
|
||||
g_signal_connect (extension, "activate",
|
||||
G_CALLBACK (tab_panel_activate_cb), NULL);
|
||||
|
||||
return extension;
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
See the file COPYING for the full license text.
|
||||
*/
|
||||
|
||||
#include "tab-panel-extension.h"
|
||||
|
||||
#include <midori/midori.h>
|
||||
|
||||
#define STOCK_TAB_PANEL "tab-panel"
|
||||
|
||||
static void
|
||||
tab_panel_app_add_browser_cb (MidoriApp* app,
|
||||
MidoriBrowser* browser)
|
||||
{
|
||||
GtkWidget* panel;
|
||||
GtkWidget* child;
|
||||
|
||||
/* FIXME: Actually provide a tree view listing all views. */
|
||||
|
||||
panel = katze_object_get_object (browser, "panel");
|
||||
child = midori_view_new (NULL);
|
||||
gtk_widget_show (child);
|
||||
midori_panel_append_widget (MIDORI_PANEL (panel), child,
|
||||
STOCK_TAB_PANEL, _("Tab Panel"), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
tab_panel_activate_cb (MidoriExtension* extension,
|
||||
MidoriApp* app)
|
||||
{
|
||||
g_signal_connect (app, "add-browser",
|
||||
G_CALLBACK (tab_panel_app_add_browser_cb), NULL);
|
||||
}
|
||||
|
||||
MidoriExtension*
|
||||
extension_init (void)
|
||||
{
|
||||
MidoriExtension* extension;
|
||||
GtkIconFactory* factory;
|
||||
GtkIconSource* icon_source;
|
||||
GtkIconSet* icon_set;
|
||||
static GtkStockItem items[] =
|
||||
{
|
||||
{ STOCK_TAB_PANEL, N_("T_ab Panel"), 0, 0, NULL },
|
||||
};
|
||||
|
||||
factory = gtk_icon_factory_new ();
|
||||
gtk_stock_add (items, G_N_ELEMENTS (items));
|
||||
icon_set = gtk_icon_set_new ();
|
||||
icon_source = gtk_icon_source_new ();
|
||||
gtk_icon_source_set_icon_name (icon_source, GTK_STOCK_INDEX);
|
||||
gtk_icon_set_add_source (icon_set, icon_source);
|
||||
gtk_icon_source_free (icon_source);
|
||||
gtk_icon_factory_add (factory, STOCK_TAB_PANEL, icon_set);
|
||||
gtk_icon_set_unref (icon_set);
|
||||
gtk_icon_factory_add_default (factory);
|
||||
g_object_unref (factory);
|
||||
|
||||
extension = g_object_new (TAB_PANEL_TYPE_EXTENSION,
|
||||
"name", _("Tab Panel"),
|
||||
"description", "",
|
||||
"version", "0.1",
|
||||
"authors", "Christian Dywan <christian@twotoasts.de>",
|
||||
NULL);
|
||||
|
||||
g_signal_connect (extension, "activate",
|
||||
G_CALLBACK (tab_panel_activate_cb), NULL);
|
||||
|
||||
return extension;
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
See the file COPYING for the full license text.
|
||||
*/
|
||||
|
||||
#include "tab-panel-extension.h"
|
||||
|
||||
#include <midori/midori.h>
|
||||
|
||||
struct _TabPanelExtension
|
||||
{
|
||||
MidoriExtension parent_instance;
|
||||
};
|
||||
|
||||
struct _TabPanelExtensionClass
|
||||
{
|
||||
MidoriExtensionClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (TabPanelExtension, tab_panel_extension, MIDORI_TYPE_EXTENSION);
|
||||
|
||||
static void
|
||||
tab_panel_extension_class_init (TabPanelExtensionClass* class)
|
||||
{
|
||||
/* Nothing to do. */
|
||||
}
|
||||
|
||||
static void
|
||||
tab_panel_extension_init (TabPanelExtension* extension)
|
||||
{
|
||||
/* Nothing to do. */
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
See the file COPYING for the full license text.
|
||||
*/
|
||||
|
||||
#ifndef __TAB_PANEL_EXTENSION_H__
|
||||
#define __TAB_PANEL_EXTENSION_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define TAB_PANEL_TYPE_EXTENSION \
|
||||
(midori_extension_get_type ())
|
||||
#define TAB_PANEL_EXTENSION(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), TAB_PANEL_TYPE_EXTENSION, TabPanelExtension))
|
||||
#define TAB_PANEL_EXTENSION_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), TAB_PANEL_TYPE_EXTENSION, TabPanelExtensionClass))
|
||||
#define TAB_PANEL_IS_EXTENSION(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), TAB_PANEL_TYPE_EXTENSION))
|
||||
#define TAB_PANEL_IS_EXTENSION_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), TAB_PANEL_TYPE_EXTENSION))
|
||||
#define TAB_PANEL_EXTENSION_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), TAB_PANEL_TYPE_EXTENSION, TabPanelExtensionClass))
|
||||
|
||||
typedef struct _TabPanelExtension TabPanelExtension;
|
||||
typedef struct _TabPanelExtensionClass TabPanelExtensionClass;
|
||||
|
||||
GType
|
||||
tab_panel_extension_get_type (void);
|
||||
|
||||
/* There is no API for TabPanelExtension. Please use the
|
||||
available properties and signals. */
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __TAB_PANEL_EXTENSION_H__ */
|
Loading…
Reference in a new issue