Implement MidoriViewable in MidoriAddons
This commit is contained in:
parent
cc329ec706
commit
c78f775142
2 changed files with 53 additions and 14 deletions
|
@ -40,6 +40,11 @@ struct _MidoriAddons
|
||||||
GSList* elements;
|
GSList* elements;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _MidoriAddonsClass
|
||||||
|
{
|
||||||
|
GtkVBoxClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
struct AddonElement
|
struct AddonElement
|
||||||
{
|
{
|
||||||
gchar *fullpath;
|
gchar *fullpath;
|
||||||
|
@ -52,7 +57,12 @@ struct AddonElement
|
||||||
GSList* excludes;
|
GSList* excludes;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (MidoriAddons, midori_addons, GTK_TYPE_VBOX)
|
static void
|
||||||
|
midori_addons_viewable_iface_init (MidoriViewableIface* iface);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_CODE (MidoriAddons, midori_addons, GTK_TYPE_VBOX,
|
||||||
|
G_IMPLEMENT_INTERFACE (MIDORI_TYPE_VIEWABLE,
|
||||||
|
midori_addons_viewable_iface_init));
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -127,6 +137,36 @@ midori_addons_class_init (MidoriAddonsClass* class)
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const gchar*
|
||||||
|
midori_addons_get_label (MidoriViewable* viewable)
|
||||||
|
{
|
||||||
|
if (MIDORI_ADDONS (viewable)->kind == MIDORI_ADDON_USER_SCRIPTS)
|
||||||
|
return _("Userscripts");
|
||||||
|
else if (MIDORI_ADDONS (viewable)->kind == MIDORI_ADDON_USER_SCRIPTS)
|
||||||
|
return _("Userstyles");
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const gchar*
|
||||||
|
midori_addons_get_stock_id (MidoriViewable* viewable)
|
||||||
|
{
|
||||||
|
if (MIDORI_ADDONS (viewable)->kind == MIDORI_ADDON_USER_SCRIPTS)
|
||||||
|
return STOCK_SCRIPTS;
|
||||||
|
else if (MIDORI_ADDONS (viewable)->kind == MIDORI_ADDON_USER_STYLES)
|
||||||
|
return STOCK_STYLES;
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
midori_addons_viewable_iface_init (MidoriViewableIface* iface)
|
||||||
|
{
|
||||||
|
iface->get_stock_id = midori_addons_get_stock_id;
|
||||||
|
iface->get_label = midori_addons_get_label;
|
||||||
|
iface->get_toolbar = midori_addons_get_toolbar;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_addons_set_property (GObject* object,
|
midori_addons_set_property (GObject* object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
|
@ -941,16 +981,18 @@ midori_addons_new (MidoriAddonKind kind,
|
||||||
* is created on the first call of this function.
|
* is created on the first call of this function.
|
||||||
*
|
*
|
||||||
* Return value: a toolbar widget
|
* Return value: a toolbar widget
|
||||||
|
*
|
||||||
|
* Deprecated: 0.1.2: Use midori_viewable_get_toolbar() instead.
|
||||||
**/
|
**/
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
midori_addons_get_toolbar (MidoriAddons* addons)
|
midori_addons_get_toolbar (MidoriViewable* addons)
|
||||||
{
|
{
|
||||||
GtkWidget* toolbar;
|
GtkWidget* toolbar;
|
||||||
GtkToolItem* toolitem;
|
GtkToolItem* toolitem;
|
||||||
|
|
||||||
g_return_val_if_fail (MIDORI_IS_ADDONS (addons), NULL);
|
g_return_val_if_fail (MIDORI_IS_ADDONS (addons), NULL);
|
||||||
|
|
||||||
if (!addons->toolbar)
|
if (!MIDORI_ADDONS (addons)->toolbar)
|
||||||
{
|
{
|
||||||
toolbar = gtk_toolbar_new ();
|
toolbar = gtk_toolbar_new ();
|
||||||
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
|
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
|
||||||
|
@ -992,18 +1034,18 @@ midori_addons_get_toolbar (MidoriAddons* addons)
|
||||||
G_CALLBACK (midori_addons_button_add_clicked_cb), addons);
|
G_CALLBACK (midori_addons_button_add_clicked_cb), addons);
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
|
||||||
gtk_widget_show (GTK_WIDGET (toolitem));
|
gtk_widget_show (GTK_WIDGET (toolitem));
|
||||||
addons->toolbar = toolbar;
|
MIDORI_ADDONS (addons)->toolbar = toolbar;
|
||||||
|
|
||||||
g_signal_connect (addons->treeview, "cursor-changed",
|
g_signal_connect (MIDORI_ADDONS (addons)->treeview, "cursor-changed",
|
||||||
G_CALLBACK (midori_addons_treeview_cursor_changed),
|
G_CALLBACK (midori_addons_treeview_cursor_changed),
|
||||||
addons);
|
addons);
|
||||||
|
|
||||||
g_signal_connect (addons->toolbar, "destroy",
|
g_signal_connect (toolbar, "destroy",
|
||||||
G_CALLBACK (gtk_widget_destroyed),
|
G_CALLBACK (gtk_widget_destroyed),
|
||||||
&addons->toolbar);
|
&MIDORI_ADDONS (addons)->toolbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
return addons->toolbar;
|
return MIDORI_ADDONS (addons)->toolbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
#include <katze/katze.h>
|
#include <katze/katze.h>
|
||||||
|
|
||||||
|
#include "midori-viewable.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define MIDORI_TYPE_ADDONS \
|
#define MIDORI_TYPE_ADDONS \
|
||||||
|
@ -34,11 +36,6 @@ G_BEGIN_DECLS
|
||||||
typedef struct _MidoriAddons MidoriAddons;
|
typedef struct _MidoriAddons MidoriAddons;
|
||||||
typedef struct _MidoriAddonsClass MidoriAddonsClass;
|
typedef struct _MidoriAddonsClass MidoriAddonsClass;
|
||||||
|
|
||||||
struct _MidoriAddonsClass
|
|
||||||
{
|
|
||||||
GtkVBoxClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
MIDORI_ADDON_NONE,
|
MIDORI_ADDON_NONE,
|
||||||
|
@ -60,7 +57,7 @@ midori_addons_new (MidoriAddonKind kind,
|
||||||
GtkWidget* web_widget);
|
GtkWidget* web_widget);
|
||||||
|
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
midori_addons_get_toolbar (MidoriAddons* addons);
|
midori_addons_get_toolbar (MidoriViewable* addons);
|
||||||
|
|
||||||
void
|
void
|
||||||
midori_addons_update_elements (MidoriAddons* addons);
|
midori_addons_update_elements (MidoriAddons* addons);
|
||||||
|
|
Loading…
Reference in a new issue