mirror of
https://github.com/GNOME/gedit
synced 2024-07-05 03:30:23 +00:00
Readd bus interface to extend the filebrowser context menu
https://bugzilla.gnome.org/show_bug.cgi?id=725424
This commit is contained in:
parent
54b5405909
commit
22bdaaae18
|
@ -20,8 +20,8 @@ plugins_filebrowser_BUILTSOURCES = \
|
||||||
|
|
||||||
plugins_filebrowser_messages_NOINST_H_FILES = \
|
plugins_filebrowser_messages_NOINST_H_FILES = \
|
||||||
plugins/filebrowser/messages/gedit-file-browser-message-activation.h \
|
plugins/filebrowser/messages/gedit-file-browser-message-activation.h \
|
||||||
plugins/filebrowser/messages/gedit-file-browser-message-add-context-item.h \
|
|
||||||
plugins/filebrowser/messages/gedit-file-browser-message-add-filter.h \
|
plugins/filebrowser/messages/gedit-file-browser-message-add-filter.h \
|
||||||
|
plugins/filebrowser/messages/gedit-file-browser-message-extend-context-menu.h \
|
||||||
plugins/filebrowser/messages/gedit-file-browser-message-get-root.h \
|
plugins/filebrowser/messages/gedit-file-browser-message-get-root.h \
|
||||||
plugins/filebrowser/messages/gedit-file-browser-message-get-view.h \
|
plugins/filebrowser/messages/gedit-file-browser-message-get-view.h \
|
||||||
plugins/filebrowser/messages/gedit-file-browser-message-id.h \
|
plugins/filebrowser/messages/gedit-file-browser-message-id.h \
|
||||||
|
@ -44,8 +44,8 @@ plugins_filebrowser_libfilebrowser_la_NOINST_H_FILES = \
|
||||||
|
|
||||||
plugins_filebrowser_messages_sources = \
|
plugins_filebrowser_messages_sources = \
|
||||||
plugins/filebrowser/messages/gedit-file-browser-message-activation.c \
|
plugins/filebrowser/messages/gedit-file-browser-message-activation.c \
|
||||||
plugins/filebrowser/messages/gedit-file-browser-message-add-context-item.c \
|
|
||||||
plugins/filebrowser/messages/gedit-file-browser-message-add-filter.c \
|
plugins/filebrowser/messages/gedit-file-browser-message-add-filter.c \
|
||||||
|
plugins/filebrowser/messages/gedit-file-browser-message-extend-context-menu.c \
|
||||||
plugins/filebrowser/messages/gedit-file-browser-message-get-root.c \
|
plugins/filebrowser/messages/gedit-file-browser-message-get-root.c \
|
||||||
plugins/filebrowser/messages/gedit-file-browser-message-get-view.c \
|
plugins/filebrowser/messages/gedit-file-browser-message-get-view.c \
|
||||||
plugins/filebrowser/messages/gedit-file-browser-message-id.c \
|
plugins/filebrowser/messages/gedit-file-browser-message-id.c \
|
||||||
|
|
|
@ -69,6 +69,9 @@
|
||||||
</item>
|
</item>
|
||||||
</section>
|
</section>
|
||||||
</submenu>
|
</submenu>
|
||||||
|
<section>
|
||||||
|
<attribute name="id">extension-section</attribute>
|
||||||
|
</section>
|
||||||
</menu>
|
</menu>
|
||||||
<menu id="bookmarks-menu">
|
<menu id="bookmarks-menu">
|
||||||
<section>
|
<section>
|
||||||
|
|
|
@ -532,6 +532,22 @@ message_remove_filter_cb (GeditMessageBus *bus,
|
||||||
gedit_file_browser_widget_remove_filter (data->widget, id);
|
gedit_file_browser_widget_remove_filter (data->widget, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
message_extend_context_menu_cb (GeditMessageBus *bus,
|
||||||
|
GeditMessage *message,
|
||||||
|
GeditWindow *window)
|
||||||
|
{
|
||||||
|
WindowData *data;
|
||||||
|
GeditMenuExtension *ext;
|
||||||
|
|
||||||
|
data = get_window_data (window);
|
||||||
|
|
||||||
|
ext = gedit_file_browser_widget_extend_context_menu (data->widget);
|
||||||
|
|
||||||
|
g_object_set (message, "extension", ext, NULL);
|
||||||
|
g_object_unref (ext);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
message_up_cb (GeditMessageBus *bus,
|
message_up_cb (GeditMessageBus *bus,
|
||||||
GeditMessage *message,
|
GeditMessage *message,
|
||||||
|
@ -675,6 +691,11 @@ register_methods (GeditWindow *window,
|
||||||
MESSAGE_OBJECT_PATH,
|
MESSAGE_OBJECT_PATH,
|
||||||
"remove_filter");
|
"remove_filter");
|
||||||
|
|
||||||
|
gedit_message_bus_register (bus,
|
||||||
|
GEDIT_TYPE_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU,
|
||||||
|
MESSAGE_OBJECT_PATH,
|
||||||
|
"extend_context_menu");
|
||||||
|
|
||||||
gedit_message_bus_register (bus,
|
gedit_message_bus_register (bus,
|
||||||
GEDIT_TYPE_MESSAGE,
|
GEDIT_TYPE_MESSAGE,
|
||||||
MESSAGE_OBJECT_PATH,
|
MESSAGE_OBJECT_PATH,
|
||||||
|
@ -726,6 +747,7 @@ register_methods (GeditWindow *window,
|
||||||
BUS_CONNECT (bus, set_markup, data);
|
BUS_CONNECT (bus, set_markup, data);
|
||||||
BUS_CONNECT (bus, add_filter, window);
|
BUS_CONNECT (bus, add_filter, window);
|
||||||
BUS_CONNECT (bus, remove_filter, data);
|
BUS_CONNECT (bus, remove_filter, data);
|
||||||
|
BUS_CONNECT (bus, extend_context_menu, window);
|
||||||
|
|
||||||
BUS_CONNECT (bus, up, data);
|
BUS_CONNECT (bus, up, data);
|
||||||
BUS_CONNECT (bus, history_back, data);
|
BUS_CONNECT (bus, history_back, data);
|
||||||
|
|
|
@ -2221,6 +2221,32 @@ gedit_file_browser_widget_refresh (GeditFileBrowserWidget *obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GeditMenuExtension *
|
||||||
|
gedit_file_browser_widget_extend_context_menu (GeditFileBrowserWidget *obj)
|
||||||
|
{
|
||||||
|
gint i, n_items;
|
||||||
|
GMenuModel *section = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GEDIT_IS_FILE_BROWSER_WIDGET (obj), NULL);
|
||||||
|
|
||||||
|
n_items = g_menu_model_get_n_items (obj->priv->dir_menu);
|
||||||
|
|
||||||
|
for (i = 0; i < n_items && !section; i++)
|
||||||
|
{
|
||||||
|
gchar *id = NULL;
|
||||||
|
|
||||||
|
if (g_menu_model_get_item_attribute (obj->priv->dir_menu, i, "id", "s", &id) &&
|
||||||
|
strcmp (id, "extension-section") == 0)
|
||||||
|
{
|
||||||
|
section = g_menu_model_get_item_link (obj->priv->dir_menu, i, G_MENU_LINK_SECTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return section != NULL ? gedit_menu_extension_new (G_MENU (section)) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gedit_file_browser_widget_history_back (GeditFileBrowserWidget *obj)
|
gedit_file_browser_widget_history_back (GeditFileBrowserWidget *obj)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#define __GEDIT_FILE_BROWSER_WIDGET_H__
|
#define __GEDIT_FILE_BROWSER_WIDGET_H__
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <gedit/gedit-menu-extension.h>
|
||||||
#include "gedit-file-browser-store.h"
|
#include "gedit-file-browser-store.h"
|
||||||
#include "gedit-file-bookmarks-store.h"
|
#include "gedit-file-bookmarks-store.h"
|
||||||
#include "gedit-file-browser-view.h"
|
#include "gedit-file-browser-view.h"
|
||||||
|
@ -111,7 +112,8 @@ void gedit_file_browser_widget_remove_filter (GeditFileBrowserWidget *obj,
|
||||||
gulong id);
|
gulong id);
|
||||||
void gedit_file_browser_widget_set_filter_pattern (GeditFileBrowserWidget *obj,
|
void gedit_file_browser_widget_set_filter_pattern (GeditFileBrowserWidget *obj,
|
||||||
gchar const *pattern);
|
gchar const *pattern);
|
||||||
|
GeditMenuExtension *
|
||||||
|
gedit_file_browser_widget_extend_context_menu (GeditFileBrowserWidget *obj);
|
||||||
void gedit_file_browser_widget_refresh (GeditFileBrowserWidget *obj);
|
void gedit_file_browser_widget_refresh (GeditFileBrowserWidget *obj);
|
||||||
void gedit_file_browser_widget_history_back (GeditFileBrowserWidget *obj);
|
void gedit_file_browser_widget_history_back (GeditFileBrowserWidget *obj);
|
||||||
void gedit_file_browser_widget_history_forward (GeditFileBrowserWidget *obj);
|
void gedit_file_browser_widget_history_forward (GeditFileBrowserWidget *obj);
|
||||||
|
|
|
@ -25,11 +25,9 @@
|
||||||
<message namespace="Gedit" name="FileBrowserMessageId">
|
<message namespace="Gedit" name="FileBrowserMessageId">
|
||||||
<property name="id" type="uint"/>
|
<property name="id" type="uint"/>
|
||||||
</message>
|
</message>
|
||||||
<message namespace="Gedit" name="FileBrowserMessageAddContextItem">
|
<message namespace="Gedit" name="FileBrowserMessageExtendContextMenu">
|
||||||
<include system="yes">gtk/gtk.h</include>
|
<include system="yes">gedit/gedit-menu-extension.h</include>
|
||||||
<property name="action" type="object" gtype="GTK_TYPE_ACTION"/>
|
<property name="extension" type="object" gtype="GEDIT_TYPE_MENU_EXTENSION"/>
|
||||||
<property name="path" type="string"/>
|
|
||||||
<property name="id" type="uint"/>
|
|
||||||
</message>
|
</message>
|
||||||
<message namespace="Gedit" name="FileBrowserMessageActivation">
|
<message namespace="Gedit" name="FileBrowserMessageActivation">
|
||||||
<property name="active" type="boolean"/>
|
<property name="active" type="boolean"/>
|
||||||
|
|
|
@ -1,171 +0,0 @@
|
||||||
|
|
||||||
/*
|
|
||||||
* gedit-file-browser-message-add-context-item.c
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011 - Jesse van den Kieboom
|
|
||||||
*
|
|
||||||
* gedit is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* gedit is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with gedit; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "gedit-file-browser-message-add-context-item.h"
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
|
|
||||||
#define GEDIT_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GEDIT_TYPE_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM, GeditFileBrowserMessageAddContextItemPrivate))
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
PROP_0,
|
|
||||||
|
|
||||||
PROP_ACTION,
|
|
||||||
PROP_PATH,
|
|
||||||
PROP_ID,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GeditFileBrowserMessageAddContextItemPrivate
|
|
||||||
{
|
|
||||||
GtkAction *action;
|
|
||||||
gchar *path;
|
|
||||||
guint id;
|
|
||||||
};
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GeditFileBrowserMessageAddContextItem, gedit_file_browser_message_add_context_item, GEDIT_TYPE_MESSAGE)
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_file_browser_message_add_context_item_finalize (GObject *obj)
|
|
||||||
{
|
|
||||||
GeditFileBrowserMessageAddContextItem *msg = GEDIT_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM (obj);
|
|
||||||
|
|
||||||
if (msg->priv->action)
|
|
||||||
{
|
|
||||||
g_object_unref (msg->priv->action);
|
|
||||||
}
|
|
||||||
g_free (msg->priv->path);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gedit_file_browser_message_add_context_item_parent_class)->finalize (obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_file_browser_message_add_context_item_get_property (GObject *obj,
|
|
||||||
guint prop_id,
|
|
||||||
GValue *value,
|
|
||||||
GParamSpec *pspec)
|
|
||||||
{
|
|
||||||
GeditFileBrowserMessageAddContextItem *msg;
|
|
||||||
|
|
||||||
msg = GEDIT_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM (obj);
|
|
||||||
|
|
||||||
switch (prop_id)
|
|
||||||
{
|
|
||||||
case PROP_ACTION:
|
|
||||||
g_value_set_object (value, msg->priv->action);
|
|
||||||
break;
|
|
||||||
case PROP_PATH:
|
|
||||||
g_value_set_string (value, msg->priv->path);
|
|
||||||
break;
|
|
||||||
case PROP_ID:
|
|
||||||
g_value_set_uint (value, msg->priv->id);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_file_browser_message_add_context_item_set_property (GObject *obj,
|
|
||||||
guint prop_id,
|
|
||||||
GValue const *value,
|
|
||||||
GParamSpec *pspec)
|
|
||||||
{
|
|
||||||
GeditFileBrowserMessageAddContextItem *msg;
|
|
||||||
|
|
||||||
msg = GEDIT_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM (obj);
|
|
||||||
|
|
||||||
switch (prop_id)
|
|
||||||
{
|
|
||||||
case PROP_ACTION:
|
|
||||||
{
|
|
||||||
if (msg->priv->action)
|
|
||||||
{
|
|
||||||
g_object_unref (msg->priv->action);
|
|
||||||
}
|
|
||||||
msg->priv->action = g_value_dup_object (value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PROP_PATH:
|
|
||||||
{
|
|
||||||
g_free (msg->priv->path);
|
|
||||||
msg->priv->path = g_value_dup_string (value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PROP_ID:
|
|
||||||
msg->priv->id = g_value_get_uint (value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_file_browser_message_add_context_item_class_init (GeditFileBrowserMessageAddContextItemClass *klass)
|
|
||||||
{
|
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
|
||||||
|
|
||||||
object_class->finalize = gedit_file_browser_message_add_context_item_finalize;
|
|
||||||
|
|
||||||
object_class->get_property = gedit_file_browser_message_add_context_item_get_property;
|
|
||||||
object_class->set_property = gedit_file_browser_message_add_context_item_set_property;
|
|
||||||
|
|
||||||
g_object_class_install_property (object_class,
|
|
||||||
PROP_ACTION,
|
|
||||||
g_param_spec_object ("action",
|
|
||||||
"Action",
|
|
||||||
"Action",
|
|
||||||
GTK_TYPE_ACTION,
|
|
||||||
G_PARAM_READWRITE |
|
|
||||||
G_PARAM_CONSTRUCT |
|
|
||||||
G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
g_object_class_install_property (object_class,
|
|
||||||
PROP_PATH,
|
|
||||||
g_param_spec_string ("path",
|
|
||||||
"Path",
|
|
||||||
"Path",
|
|
||||||
NULL,
|
|
||||||
G_PARAM_READWRITE |
|
|
||||||
G_PARAM_CONSTRUCT |
|
|
||||||
G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
g_object_class_install_property (object_class,
|
|
||||||
PROP_ID,
|
|
||||||
g_param_spec_uint ("id",
|
|
||||||
"Id",
|
|
||||||
"Id",
|
|
||||||
0,
|
|
||||||
G_MAXUINT,
|
|
||||||
0,
|
|
||||||
G_PARAM_READWRITE |
|
|
||||||
G_PARAM_CONSTRUCT |
|
|
||||||
G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
g_type_class_add_private (object_class, sizeof (GeditFileBrowserMessageAddContextItemPrivate));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gedit_file_browser_message_add_context_item_init (GeditFileBrowserMessageAddContextItem *message)
|
|
||||||
{
|
|
||||||
message->priv = GEDIT_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM_GET_PRIVATE (message);
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
|
|
||||||
/*
|
|
||||||
* gedit-file-browser-message-add-context-item.h
|
|
||||||
* This file is part of gedit
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011 - Jesse van den Kieboom
|
|
||||||
*
|
|
||||||
* gedit is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* gedit is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with gedit; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
* Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GEDIT_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM_H__
|
|
||||||
#define __GEDIT_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM_H__
|
|
||||||
|
|
||||||
#include <gedit/gedit-message.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define GEDIT_TYPE_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM (gedit_file_browser_message_add_context_item_get_type ())
|
|
||||||
#define GEDIT_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
|
|
||||||
GEDIT_TYPE_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM,\
|
|
||||||
GeditFileBrowserMessageAddContextItem))
|
|
||||||
#define GEDIT_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
|
|
||||||
GEDIT_TYPE_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM,\
|
|
||||||
GeditFileBrowserMessageAddContextItem const))
|
|
||||||
#define GEDIT_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\
|
|
||||||
GEDIT_TYPE_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM,\
|
|
||||||
GeditFileBrowserMessageAddContextItemClass))
|
|
||||||
#define GEDIT_IS_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
|
|
||||||
GEDIT_TYPE_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM))
|
|
||||||
#define GEDIT_IS_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\
|
|
||||||
GEDIT_TYPE_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM))
|
|
||||||
#define GEDIT_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
|
|
||||||
GEDIT_TYPE_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM,\
|
|
||||||
GeditFileBrowserMessageAddContextItemClass))
|
|
||||||
|
|
||||||
typedef struct _GeditFileBrowserMessageAddContextItem GeditFileBrowserMessageAddContextItem;
|
|
||||||
typedef struct _GeditFileBrowserMessageAddContextItemClass GeditFileBrowserMessageAddContextItemClass;
|
|
||||||
typedef struct _GeditFileBrowserMessageAddContextItemPrivate GeditFileBrowserMessageAddContextItemPrivate;
|
|
||||||
|
|
||||||
struct _GeditFileBrowserMessageAddContextItem
|
|
||||||
{
|
|
||||||
GeditMessage parent;
|
|
||||||
|
|
||||||
GeditFileBrowserMessageAddContextItemPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GeditFileBrowserMessageAddContextItemClass
|
|
||||||
{
|
|
||||||
GeditMessageClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType gedit_file_browser_message_add_context_item_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __GEDIT_FILE_BROWSER_MESSAGE_ADD_CONTEXT_ITEM_H__ */
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gedit-file-browser-message-extend-context-menu.c
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 - Paolo Borelli
|
||||||
|
*
|
||||||
|
* gedit is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gedit is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gedit; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "gedit-file-browser-message-extend-context-menu.h"
|
||||||
|
#include <gedit/gedit-menu-extension.h>
|
||||||
|
|
||||||
|
#define GEDIT_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GEDIT_TYPE_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU, GeditFileBrowserMessageExtendContextMenuPrivate))
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
|
||||||
|
PROP_EXTENSION,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GeditFileBrowserMessageExtendContextMenuPrivate
|
||||||
|
{
|
||||||
|
GeditMenuExtension *extension;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GeditFileBrowserMessageExtendContextMenu, gedit_file_browser_message_extend_context_menu, GEDIT_TYPE_MESSAGE)
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_file_browser_message_extend_context_menu_finalize (GObject *obj)
|
||||||
|
{
|
||||||
|
GeditFileBrowserMessageExtendContextMenu *msg = GEDIT_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU (obj);
|
||||||
|
|
||||||
|
if (msg->priv->extension)
|
||||||
|
{
|
||||||
|
g_object_unref (msg->priv->extension);
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gedit_file_browser_message_extend_context_menu_parent_class)->finalize (obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_file_browser_message_extend_context_menu_get_property (GObject *obj,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GeditFileBrowserMessageExtendContextMenu *msg;
|
||||||
|
|
||||||
|
msg = GEDIT_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU (obj);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_EXTENSION:
|
||||||
|
g_value_set_object (value, msg->priv->extension);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_file_browser_message_extend_context_menu_set_property (GObject *obj,
|
||||||
|
guint prop_id,
|
||||||
|
GValue const *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GeditFileBrowserMessageExtendContextMenu *msg;
|
||||||
|
|
||||||
|
msg = GEDIT_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU (obj);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_EXTENSION:
|
||||||
|
{
|
||||||
|
if (msg->priv->extension)
|
||||||
|
{
|
||||||
|
g_object_unref (msg->priv->extension);
|
||||||
|
}
|
||||||
|
msg->priv->extension = g_value_dup_object (value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_file_browser_message_extend_context_menu_class_init (GeditFileBrowserMessageExtendContextMenuClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||||
|
|
||||||
|
object_class->finalize = gedit_file_browser_message_extend_context_menu_finalize;
|
||||||
|
|
||||||
|
object_class->get_property = gedit_file_browser_message_extend_context_menu_get_property;
|
||||||
|
object_class->set_property = gedit_file_browser_message_extend_context_menu_set_property;
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_EXTENSION,
|
||||||
|
g_param_spec_object ("extension",
|
||||||
|
"Extension",
|
||||||
|
"Extension",
|
||||||
|
GEDIT_TYPE_MENU_EXTENSION,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_type_class_add_private (object_class, sizeof (GeditFileBrowserMessageExtendContextMenuPrivate));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_file_browser_message_extend_context_menu_init (GeditFileBrowserMessageExtendContextMenu *message)
|
||||||
|
{
|
||||||
|
message->priv = GEDIT_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU_GET_PRIVATE (message);
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gedit-file-browser-message-extend-context-menu.h
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 - Paolo Borelli
|
||||||
|
*
|
||||||
|
* gedit is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gedit is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gedit; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GEDIT_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU_H__
|
||||||
|
#define __GEDIT_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU_H__
|
||||||
|
|
||||||
|
#include <gedit/gedit-message.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU (gedit_file_browser_message_extend_context_menu_get_type ())
|
||||||
|
#define GEDIT_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
|
||||||
|
GEDIT_TYPE_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU,\
|
||||||
|
GeditFileBrowserMessageExtendContextMenu))
|
||||||
|
#define GEDIT_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
|
||||||
|
GEDIT_TYPE_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU,\
|
||||||
|
GeditFileBrowserMessageExtendContextMenu const))
|
||||||
|
#define GEDIT_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\
|
||||||
|
GEDIT_TYPE_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU,\
|
||||||
|
GeditFileBrowserMessageExtendContextMenuClass))
|
||||||
|
#define GEDIT_IS_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
|
||||||
|
GEDIT_TYPE_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU))
|
||||||
|
#define GEDIT_IS_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\
|
||||||
|
GEDIT_TYPE_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU))
|
||||||
|
#define GEDIT_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
|
||||||
|
GEDIT_TYPE_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU,\
|
||||||
|
GeditFileBrowserMessageExtendContextMenuClass))
|
||||||
|
|
||||||
|
typedef struct _GeditFileBrowserMessageExtendContextMenu GeditFileBrowserMessageExtendContextMenu;
|
||||||
|
typedef struct _GeditFileBrowserMessageExtendContextMenuClass GeditFileBrowserMessageExtendContextMenuClass;
|
||||||
|
typedef struct _GeditFileBrowserMessageExtendContextMenuPrivate GeditFileBrowserMessageExtendContextMenuPrivate;
|
||||||
|
|
||||||
|
struct _GeditFileBrowserMessageExtendContextMenu
|
||||||
|
{
|
||||||
|
GeditMessage parent;
|
||||||
|
|
||||||
|
GeditFileBrowserMessageExtendContextMenuPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GeditFileBrowserMessageExtendContextMenuClass
|
||||||
|
{
|
||||||
|
GeditMessageClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType gedit_file_browser_message_extend_context_menu_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GEDIT_FILE_BROWSER_MESSAGE_EXTEND_CONTEXT_MENU_H__ */
|
|
@ -2,8 +2,8 @@
|
||||||
#define __GEDIT_FILE_BROWER_MESSAGES_MESSAGES_H__
|
#define __GEDIT_FILE_BROWER_MESSAGES_MESSAGES_H__
|
||||||
|
|
||||||
#include "gedit-file-browser-message-activation.h"
|
#include "gedit-file-browser-message-activation.h"
|
||||||
#include "gedit-file-browser-message-add-context-item.h"
|
|
||||||
#include "gedit-file-browser-message-add-filter.h"
|
#include "gedit-file-browser-message-add-filter.h"
|
||||||
|
#include "gedit-file-browser-message-extend-context-menu.h"
|
||||||
#include "gedit-file-browser-message-get-root.h"
|
#include "gedit-file-browser-message-get-root.h"
|
||||||
#include "gedit-file-browser-message-get-view.h"
|
#include "gedit-file-browser-message-get-view.h"
|
||||||
#include "gedit-file-browser-message-id.h"
|
#include "gedit-file-browser-message-id.h"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user