Add new (App/Window/View)Activatable interfaces for plugins
Currently only the modelines and filebrowser plugins are updated to these new interfaces
This commit is contained in:
parent
d45e07b7a1
commit
b9e5097250
|
@ -1,7 +1,7 @@
|
|||
usr/share/appdata
|
||||
usr/share/xed/plugins
|
||||
usr/share/glib-2.0
|
||||
usr/share/help
|
||||
usr/share/locale
|
||||
usr/share/xed/icons
|
||||
usr/share/xed/plugins
|
||||
usr/share/xed/ui/
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
usr/bin/xed
|
||||
usr/lib/*/xed/plugins/*.plugin
|
||||
usr/lib/*/xed/girepository-1.0/
|
||||
usr/lib/xed/xed-bugreport.sh
|
||||
usr/lib/*/xed/plugins/*.plugin
|
||||
usr/lib/*/xed/plugins/*.so
|
||||
usr/lib/xed/xed-bugreport.sh
|
||||
usr/share/applications/xed.desktop
|
||||
usr/share/man/
|
||||
|
|
|
@ -1,26 +1,9 @@
|
|||
DIST_SUBDIRS = \
|
||||
changecase \
|
||||
docinfo \
|
||||
filebrowser \
|
||||
modelines \
|
||||
sort \
|
||||
spell \
|
||||
taglist \
|
||||
time \
|
||||
trailsave
|
||||
modelines
|
||||
|
||||
SUBDIRS = \
|
||||
changecase \
|
||||
docinfo \
|
||||
filebrowser \
|
||||
modelines \
|
||||
sort \
|
||||
taglist \
|
||||
time \
|
||||
trailsave
|
||||
|
||||
if ENABLE_ENCHANT
|
||||
SUBDIRS += spell
|
||||
endif
|
||||
modelines
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
||||
|
|
|
@ -77,7 +77,7 @@ struct _XedFileBookmarksStoreClass
|
|||
};
|
||||
|
||||
GType xed_file_bookmarks_store_get_type (void) G_GNUC_CONST;
|
||||
void _xed_file_bookmarks_store_register_type (GTypeModule * module);
|
||||
void _xed_file_bookmarks_store_register_type (GTypeModule *type_module);
|
||||
|
||||
XedFileBookmarksStore *xed_file_bookmarks_store_new (void);
|
||||
gchar *xed_file_bookmarks_store_get_uri (XedFileBookmarksStore * model,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -81,8 +81,7 @@ typedef struct _XedFileBrowserStore XedFileBrowserStore;
|
|||
typedef struct _XedFileBrowserStoreClass XedFileBrowserStoreClass;
|
||||
typedef struct _XedFileBrowserStorePrivate XedFileBrowserStorePrivate;
|
||||
|
||||
typedef gboolean (*XedFileBrowserStoreFilterFunc) (XedFileBrowserStore
|
||||
* model,
|
||||
typedef gboolean (*XedFileBrowserStoreFilterFunc) (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data);
|
||||
|
||||
|
@ -116,30 +115,23 @@ struct _XedFileBrowserStoreClass {
|
|||
};
|
||||
|
||||
GType xed_file_browser_store_get_type (void) G_GNUC_CONST;
|
||||
void _xed_file_browser_store_register_type (GTypeModule * module);
|
||||
void _xed_file_browser_store_register_type (GTypeModule *type_module);
|
||||
|
||||
XedFileBrowserStore *xed_file_browser_store_new (gchar const *root);
|
||||
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_set_root_and_virtual_root (XedFileBrowserStore * model,
|
||||
XedFileBrowserStoreResult xed_file_browser_store_set_root_and_virtual_root (XedFileBrowserStore *model,
|
||||
gchar const *root,
|
||||
gchar const *virtual_root);
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_set_root (XedFileBrowserStore * model,
|
||||
XedFileBrowserStoreResult xed_file_browser_store_set_root (XedFileBrowserStore *model,
|
||||
gchar const *root);
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_set_virtual_root (XedFileBrowserStore * model,
|
||||
XedFileBrowserStoreResult xed_file_browser_store_set_virtual_root (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter);
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_set_virtual_root_from_string (XedFileBrowserStore * model,
|
||||
XedFileBrowserStoreResult xed_file_browser_store_set_virtual_root_from_string (XedFileBrowserStore *model,
|
||||
gchar const *root);
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_set_virtual_root_up (XedFileBrowserStore * model);
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_set_virtual_root_top (XedFileBrowserStore * model);
|
||||
XedFileBrowserStoreResult xed_file_browser_store_set_virtual_root_up (XedFileBrowserStore *model);
|
||||
XedFileBrowserStoreResult xed_file_browser_store_set_virtual_root_top (XedFileBrowserStore *model);
|
||||
|
||||
gboolean
|
||||
xed_file_browser_store_get_iter_virtual_root (XedFileBrowserStore * model,
|
||||
gboolean xed_file_browser_store_get_iter_virtual_root (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter);
|
||||
gboolean xed_file_browser_store_get_iter_root (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter);
|
||||
|
@ -160,28 +152,24 @@ void _xed_file_browser_store_iter_expanded (XedFileBrowserStore * model
|
|||
void _xed_file_browser_store_iter_collapsed (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter);
|
||||
|
||||
XedFileBrowserStoreFilterMode
|
||||
xed_file_browser_store_get_filter_mode (XedFileBrowserStore * model);
|
||||
XedFileBrowserStoreFilterMode xed_file_browser_store_get_filter_mode (XedFileBrowserStore *model);
|
||||
void xed_file_browser_store_set_filter_mode (XedFileBrowserStore *model,
|
||||
XedFileBrowserStoreFilterMode mode);
|
||||
void xed_file_browser_store_set_filter_func (XedFileBrowserStore *model,
|
||||
XedFileBrowserStoreFilterFunc func,
|
||||
gpointer user_data);
|
||||
void xed_file_browser_store_refilter (XedFileBrowserStore *model);
|
||||
XedFileBrowserStoreFilterMode
|
||||
xed_file_browser_store_filter_mode_get_default (void);
|
||||
XedFileBrowserStoreFilterMode xed_file_browser_store_filter_mode_get_default (void);
|
||||
|
||||
void xed_file_browser_store_refresh (XedFileBrowserStore * model);
|
||||
gboolean xed_file_browser_store_rename (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter,
|
||||
gchar const *new_name,
|
||||
GError **error);
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_delete (XedFileBrowserStore * model,
|
||||
XedFileBrowserStoreResult xed_file_browser_store_delete (XedFileBrowserStore *model,
|
||||
GtkTreeIter *iter,
|
||||
gboolean trash);
|
||||
XedFileBrowserStoreResult
|
||||
xed_file_browser_store_delete_all (XedFileBrowserStore * model,
|
||||
XedFileBrowserStoreResult xed_file_browser_store_delete_all (XedFileBrowserStore *model,
|
||||
GList *rows,
|
||||
gboolean trash);
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <glib-object.h>
|
||||
#include <gio/gio.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
@ -85,8 +86,7 @@ static const GtkTargetEntry drag_source_targets[] = {
|
|||
{ "text/uri-list", 0, 0 }
|
||||
};
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE (XedFileBrowserView, xed_file_browser_view,
|
||||
GTK_TYPE_TREE_VIEW)
|
||||
G_DEFINE_DYNAMIC_TYPE (XedFileBrowserView, xed_file_browser_view, GTK_TYPE_TREE_VIEW)
|
||||
|
||||
static void on_cell_edited (GtkCellRendererText *cell,
|
||||
gchar *path,
|
||||
|
@ -113,10 +113,14 @@ xed_file_browser_view_finalize (GObject * object)
|
|||
XedFileBrowserView *obj = XED_FILE_BROWSER_VIEW(object);
|
||||
|
||||
if (obj->priv->hand_cursor)
|
||||
{
|
||||
g_object_unref (obj->priv->hand_cursor);
|
||||
}
|
||||
|
||||
if (obj->priv->hover_path)
|
||||
{
|
||||
gtk_tree_path_free (obj->priv->hover_path);
|
||||
}
|
||||
|
||||
if (obj->priv->expand_state)
|
||||
{
|
||||
|
@ -126,8 +130,7 @@ xed_file_browser_view_finalize (GObject * object)
|
|||
|
||||
g_object_unref (obj->priv->busy_cursor);
|
||||
|
||||
G_OBJECT_CLASS (xed_file_browser_view_parent_class)->
|
||||
finalize (object);
|
||||
G_OBJECT_CLASS (xed_file_browser_view_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -137,15 +140,21 @@ add_expand_state (XedFileBrowserView * view,
|
|||
GFile * file;
|
||||
|
||||
if (!uri)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
|
||||
if (view->priv->expand_state)
|
||||
{
|
||||
g_hash_table_insert (view->priv->expand_state, file, file);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_object_unref (file);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
remove_expand_state (XedFileBrowserView *view,
|
||||
|
@ -154,12 +163,16 @@ remove_expand_state (XedFileBrowserView * view,
|
|||
GFile * file;
|
||||
|
||||
if (!uri)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
|
||||
if (view->priv->expand_state)
|
||||
{
|
||||
g_hash_table_remove (view->priv->expand_state, file);
|
||||
}
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
@ -173,25 +186,24 @@ row_expanded (GtkTreeView * tree_view,
|
|||
gchar *uri;
|
||||
|
||||
if (GTK_TREE_VIEW_CLASS (xed_file_browser_view_parent_class)->row_expanded)
|
||||
{
|
||||
GTK_TREE_VIEW_CLASS (xed_file_browser_view_parent_class)->row_expanded (tree_view, iter, path);
|
||||
}
|
||||
|
||||
if (!XED_IS_FILE_BROWSER_STORE (view->priv->model))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (view->priv->restore_expand_state)
|
||||
{
|
||||
gtk_tree_model_get (view->priv->model,
|
||||
iter,
|
||||
XED_FILE_BROWSER_STORE_COLUMN_URI,
|
||||
&uri,
|
||||
-1);
|
||||
gtk_tree_model_get (view->priv->model, iter, XED_FILE_BROWSER_STORE_COLUMN_URI, &uri, -1);
|
||||
|
||||
add_expand_state (view, uri);
|
||||
g_free (uri);
|
||||
}
|
||||
|
||||
_xed_file_browser_store_iter_expanded (XED_FILE_BROWSER_STORE (view->priv->model),
|
||||
iter);
|
||||
_xed_file_browser_store_iter_expanded (XED_FILE_BROWSER_STORE (view->priv->model), iter);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -203,25 +215,24 @@ row_collapsed (GtkTreeView * tree_view,
|
|||
gchar * uri;
|
||||
|
||||
if (GTK_TREE_VIEW_CLASS (xed_file_browser_view_parent_class)->row_collapsed)
|
||||
{
|
||||
GTK_TREE_VIEW_CLASS (xed_file_browser_view_parent_class)->row_collapsed (tree_view, iter, path);
|
||||
}
|
||||
|
||||
if (!XED_IS_FILE_BROWSER_STORE (view->priv->model))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (view->priv->restore_expand_state)
|
||||
{
|
||||
gtk_tree_model_get (view->priv->model,
|
||||
iter,
|
||||
XED_FILE_BROWSER_STORE_COLUMN_URI,
|
||||
&uri,
|
||||
-1);
|
||||
gtk_tree_model_get (view->priv->model, iter, XED_FILE_BROWSER_STORE_COLUMN_URI, &uri, -1);
|
||||
|
||||
remove_expand_state (view, uri);
|
||||
g_free (uri);
|
||||
}
|
||||
|
||||
_xed_file_browser_store_iter_collapsed (XED_FILE_BROWSER_STORE (view->priv->model),
|
||||
iter);
|
||||
_xed_file_browser_store_iter_collapsed (XED_FILE_BROWSER_STORE (view->priv->model), iter);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -231,7 +242,8 @@ leave_notify_event (GtkWidget *widget,
|
|||
XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (widget);
|
||||
|
||||
if (view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE &&
|
||||
view->priv->hover_path != NULL) {
|
||||
view->priv->hover_path != NULL)
|
||||
{
|
||||
gtk_tree_path_free (view->priv->hover_path);
|
||||
view->priv->hover_path = NULL;
|
||||
}
|
||||
|
@ -246,9 +258,12 @@ enter_notify_event (GtkWidget *widget,
|
|||
{
|
||||
XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (widget);
|
||||
|
||||
if (view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) {
|
||||
if (view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
|
||||
{
|
||||
if (view->priv->hover_path != NULL)
|
||||
{
|
||||
gtk_tree_path_free (view->priv->hover_path);
|
||||
}
|
||||
|
||||
gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
|
||||
event->x, event->y,
|
||||
|
@ -256,8 +271,9 @@ enter_notify_event (GtkWidget *widget,
|
|||
NULL, NULL, NULL);
|
||||
|
||||
if (view->priv->hover_path != NULL)
|
||||
gdk_window_set_cursor (gtk_widget_get_window (widget),
|
||||
view->priv->hand_cursor);
|
||||
{
|
||||
gdk_window_set_cursor (gtk_widget_get_window (widget), view->priv->hand_cursor);
|
||||
}
|
||||
}
|
||||
|
||||
// Chainup
|
||||
|
@ -271,25 +287,31 @@ motion_notify_event (GtkWidget * widget,
|
|||
GtkTreePath *old_hover_path;
|
||||
XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (widget);
|
||||
|
||||
if (view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) {
|
||||
if (view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
|
||||
{
|
||||
old_hover_path = view->priv->hover_path;
|
||||
gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
|
||||
event->x, event->y,
|
||||
&view->priv->hover_path,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
if ((old_hover_path != NULL) != (view->priv->hover_path != NULL)) {
|
||||
if ((old_hover_path != NULL) != (view->priv->hover_path != NULL))
|
||||
{
|
||||
if (view->priv->hover_path != NULL)
|
||||
gdk_window_set_cursor (gtk_widget_get_window (widget),
|
||||
view->priv->hand_cursor);
|
||||
{
|
||||
gdk_window_set_cursor (gtk_widget_get_window (widget), view->priv->hand_cursor);
|
||||
}
|
||||
else
|
||||
gdk_window_set_cursor (gtk_widget_get_window (widget),
|
||||
NULL);
|
||||
{
|
||||
gdk_window_set_cursor (gtk_widget_get_window (widget), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (old_hover_path != NULL)
|
||||
{
|
||||
gtk_tree_path_free (old_hover_path);
|
||||
}
|
||||
}
|
||||
|
||||
// Chainup
|
||||
return GTK_WIDGET_CLASS (xed_file_browser_view_parent_class)->motion_notify_event (widget, event);
|
||||
|
@ -305,31 +327,41 @@ set_click_policy_property (XedFileBrowserView *obj,
|
|||
|
||||
obj->priv->click_policy = click_policy;
|
||||
|
||||
if (click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) {
|
||||
if (click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
|
||||
{
|
||||
if (obj->priv->hand_cursor == NULL)
|
||||
{
|
||||
obj->priv->hand_cursor = gdk_cursor_new(GDK_HAND2);
|
||||
} else if (click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE) {
|
||||
if (obj->priv->hover_path != NULL) {
|
||||
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (obj->priv->model),
|
||||
&iter, obj->priv->hover_path))
|
||||
gtk_tree_model_row_changed (GTK_TREE_MODEL (obj->priv->model),
|
||||
obj->priv->hover_path, &iter);
|
||||
}
|
||||
}
|
||||
else if (click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE)
|
||||
{
|
||||
if (obj->priv->hover_path != NULL)
|
||||
{
|
||||
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (obj->priv->model), &iter, obj->priv->hover_path))
|
||||
{
|
||||
gtk_tree_model_row_changed (GTK_TREE_MODEL (obj->priv->model), obj->priv->hover_path, &iter);
|
||||
}
|
||||
|
||||
gtk_tree_path_free (obj->priv->hover_path);
|
||||
obj->priv->hover_path = NULL;
|
||||
}
|
||||
|
||||
if (gtk_widget_get_realized (GTK_WIDGET (obj))) {
|
||||
if (gtk_widget_get_realized (GTK_WIDGET (obj)))
|
||||
{
|
||||
win = gtk_widget_get_window (GTK_WIDGET (obj));
|
||||
gdk_window_set_cursor (win, NULL);
|
||||
|
||||
display = gtk_widget_get_display (GTK_WIDGET (obj));
|
||||
|
||||
if (display != NULL)
|
||||
{
|
||||
gdk_display_flush (display);
|
||||
}
|
||||
}
|
||||
|
||||
if (obj->priv->hand_cursor) {
|
||||
if (obj->priv->hand_cursor)
|
||||
{
|
||||
g_object_unref (obj->priv->hand_cursor);
|
||||
obj->priv->hand_cursor = NULL;
|
||||
}
|
||||
|
@ -344,7 +376,8 @@ directory_activated (XedFileBrowserView *view,
|
|||
}
|
||||
|
||||
static void
|
||||
activate_selected_files (XedFileBrowserView *view) {
|
||||
activate_selected_files (XedFileBrowserView *view)
|
||||
{
|
||||
GtkTreeView *tree_view = GTK_TREE_VIEW (view);
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection (tree_view);
|
||||
GList *rows, *row;
|
||||
|
@ -355,51 +388,69 @@ activate_selected_files (XedFileBrowserView *view) {
|
|||
|
||||
rows = gtk_tree_selection_get_selected_rows (selection, &view->priv->model);
|
||||
|
||||
for (row = rows; row; row = row->next) {
|
||||
for (row = rows; row; row = row->next)
|
||||
{
|
||||
path = (GtkTreePath *)(row->data);
|
||||
|
||||
/* Get iter from path */
|
||||
if (!gtk_tree_model_get_iter (view->priv->model, &iter, path))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
gtk_tree_model_get (view->priv->model, &iter, XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, -1);
|
||||
|
||||
if (FILE_IS_DIR (flags)) {
|
||||
if (FILE_IS_DIR (flags))
|
||||
{
|
||||
if (directory == NULL)
|
||||
{
|
||||
directory = path;
|
||||
}
|
||||
|
||||
} else if (!FILE_IS_DUMMY (flags)) {
|
||||
}
|
||||
else if (!FILE_IS_DUMMY (flags))
|
||||
{
|
||||
g_signal_emit (view, signals[FILE_ACTIVATED], 0, &iter);
|
||||
}
|
||||
}
|
||||
|
||||
if (directory != NULL) {
|
||||
if (directory != NULL)
|
||||
{
|
||||
if (gtk_tree_model_get_iter (view->priv->model, &iter, directory))
|
||||
{
|
||||
g_signal_emit (view, signals[DIRECTORY_ACTIVATED], 0, &iter);
|
||||
}
|
||||
}
|
||||
|
||||
g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
|
||||
g_list_free (rows);
|
||||
}
|
||||
|
||||
static void
|
||||
activate_selected_bookmark (XedFileBrowserView *view) {
|
||||
activate_selected_bookmark (XedFileBrowserView *view)
|
||||
{
|
||||
GtkTreeView *tree_view = GTK_TREE_VIEW (view);
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection (tree_view);
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (gtk_tree_selection_get_selected (selection, &view->priv->model, &iter))
|
||||
{
|
||||
g_signal_emit (view, signals[BOOKMARK_ACTIVATED], 0, &iter);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
activate_selected_items (XedFileBrowserView *view)
|
||||
{
|
||||
if (XED_IS_FILE_BROWSER_STORE (view->priv->model))
|
||||
{
|
||||
activate_selected_files (view);
|
||||
}
|
||||
else if (XED_IS_FILE_BOOKMARKS_STORE (view->priv->model))
|
||||
{
|
||||
activate_selected_bookmark (view);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_hidden_filter (XedFileBrowserView *view)
|
||||
|
@ -408,11 +459,9 @@ toggle_hidden_filter (XedFileBrowserView *view)
|
|||
|
||||
if (XED_IS_FILE_BROWSER_STORE (view->priv->model))
|
||||
{
|
||||
mode = xed_file_browser_store_get_filter_mode
|
||||
(XED_FILE_BROWSER_STORE (view->priv->model));
|
||||
mode = xed_file_browser_store_get_filter_mode (XED_FILE_BROWSER_STORE (view->priv->model));
|
||||
mode ^= XED_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN;
|
||||
xed_file_browser_store_set_filter_mode
|
||||
(XED_FILE_BROWSER_STORE (view->priv->model), mode);
|
||||
xed_file_browser_store_set_filter_mode (XED_FILE_BROWSER_STORE (view->priv->model), mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,21 +495,27 @@ did_not_drag (XedFileBrowserView *view,
|
|||
tree_view = GTK_TREE_VIEW (view);
|
||||
selection = gtk_tree_view_get_selection (tree_view);
|
||||
|
||||
if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
|
||||
&path, NULL, NULL, NULL)) {
|
||||
if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y, &path, NULL, NULL, NULL))
|
||||
{
|
||||
if ((view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
|
||||
&& !button_event_modifies_selection(event)
|
||||
&& (event->button == 1 || event->button == 2)) {
|
||||
&& (event->button == 1 || event->button == 2))
|
||||
{
|
||||
/* Activate all selected items, and leave them selected */
|
||||
activate_selected_items (view);
|
||||
} else if ((event->button == 1 || event->button == 2)
|
||||
}
|
||||
else if ((event->button == 1 || event->button == 2)
|
||||
&& ((event->state & GDK_CONTROL_MASK) != 0 ||
|
||||
(event->state & GDK_SHIFT_MASK) == 0)
|
||||
&& view->priv->selected_on_button_down) {
|
||||
if (!button_event_modifies_selection (event)) {
|
||||
&& view->priv->selected_on_button_down)
|
||||
{
|
||||
if (!button_event_modifies_selection (event))
|
||||
{
|
||||
gtk_tree_selection_unselect_all (selection);
|
||||
gtk_tree_selection_select_path (selection, path);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_tree_selection_unselect_path (selection, path);
|
||||
}
|
||||
}
|
||||
|
@ -475,13 +530,15 @@ button_release_event (GtkWidget *widget,
|
|||
{
|
||||
XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (widget);
|
||||
|
||||
if (event->button == view->priv->drag_button) {
|
||||
if (event->button == view->priv->drag_button)
|
||||
{
|
||||
view->priv->drag_button = 0;
|
||||
|
||||
if (!view->priv->drag_started &&
|
||||
!view->priv->ignore_release)
|
||||
if (!view->priv->drag_started && !view->priv->ignore_release)
|
||||
{
|
||||
did_not_drag (view, event);
|
||||
}
|
||||
}
|
||||
|
||||
/* Chain up */
|
||||
return GTK_WIDGET_CLASS (xed_file_browser_view_parent_class)->button_release_event (widget, event);
|
||||
|
@ -516,42 +573,53 @@ button_press_event (GtkWidget *widget,
|
|||
|
||||
/* Determine click count */
|
||||
if (event->time - last_click_time < double_click_time)
|
||||
{
|
||||
click_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
click_count = 0;
|
||||
}
|
||||
|
||||
last_click_time = event->time;
|
||||
|
||||
/* Ignore double click if we are in single click mode */
|
||||
if (view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE &&
|
||||
click_count >= 2) {
|
||||
if (view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE && click_count >= 2)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
view->priv->ignore_release = FALSE;
|
||||
call_parent = TRUE;
|
||||
|
||||
if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
|
||||
&path, NULL, NULL, NULL)) {
|
||||
if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y, &path, NULL, NULL, NULL))
|
||||
{
|
||||
/* Keep track of path of last click so double clicks only happen
|
||||
* on the same item */
|
||||
if ((event->button == 1 || event->button == 2) &&
|
||||
event->type == GDK_BUTTON_PRESS) {
|
||||
if ((event->button == 1 || event->button == 2) && event->type == GDK_BUTTON_PRESS)
|
||||
{
|
||||
if (view->priv->double_click_path[1])
|
||||
{
|
||||
gtk_tree_path_free (view->priv->double_click_path[1]);
|
||||
}
|
||||
|
||||
view->priv->double_click_path[1] = view->priv->double_click_path[0];
|
||||
view->priv->double_click_path[0] = gtk_tree_path_copy (path);
|
||||
}
|
||||
|
||||
if (event->type == GDK_2BUTTON_PRESS) {
|
||||
if (event->type == GDK_2BUTTON_PRESS)
|
||||
{
|
||||
if (view->priv->double_click_path[1] &&
|
||||
gtk_tree_path_compare (view->priv->double_click_path[0], view->priv->double_click_path[1]) == 0)
|
||||
{
|
||||
activate_selected_items (view);
|
||||
}
|
||||
|
||||
/* Chain up */
|
||||
widget_parent->button_press_event (widget, event);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We're going to filter out some situations where
|
||||
* we can't let the default code run because all
|
||||
* but one row would be would be deselected. We don't
|
||||
|
@ -560,51 +628,66 @@ button_press_event (GtkWidget *widget,
|
|||
selected = gtk_tree_selection_path_is_selected (selection, path);
|
||||
|
||||
if (event->button == 3 && selected)
|
||||
{
|
||||
call_parent = FALSE;
|
||||
}
|
||||
|
||||
if ((event->button == 1 || event->button == 2) &&
|
||||
((event->state & GDK_CONTROL_MASK) != 0 ||
|
||||
(event->state & GDK_SHIFT_MASK) == 0)) {
|
||||
(event->state & GDK_SHIFT_MASK) == 0))
|
||||
{
|
||||
gtk_widget_style_get (widget,
|
||||
"expander-size", &expander_size,
|
||||
"horizontal-separator", &horizontal_separator,
|
||||
NULL);
|
||||
on_expander = (event->x <= horizontal_separator / 2 +
|
||||
gtk_tree_path_get_depth (path) * expander_size);
|
||||
on_expander = (event->x <= horizontal_separator / 2 + gtk_tree_path_get_depth (path) * expander_size);
|
||||
|
||||
view->priv->selected_on_button_down = selected;
|
||||
|
||||
if (selected) {
|
||||
if (selected)
|
||||
{
|
||||
call_parent = on_expander || gtk_tree_selection_count_selected_rows (selection) == 1;
|
||||
view->priv->ignore_release = call_parent && view->priv->click_policy != XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE;
|
||||
} else if ((event->state & GDK_CONTROL_MASK) != 0) {
|
||||
}
|
||||
else if ((event->state & GDK_CONTROL_MASK) != 0)
|
||||
{
|
||||
call_parent = FALSE;
|
||||
gtk_tree_selection_select_path (selection, path);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
view->priv->ignore_release = on_expander;
|
||||
}
|
||||
}
|
||||
|
||||
if (call_parent) {
|
||||
if (call_parent)
|
||||
{
|
||||
/* Chain up */
|
||||
widget_parent->button_press_event (widget, event);
|
||||
} else if (selected) {
|
||||
}
|
||||
else if (selected)
|
||||
{
|
||||
gtk_widget_grab_focus (widget);
|
||||
}
|
||||
|
||||
if ((event->button == 1 || event->button == 2) &&
|
||||
event->type == GDK_BUTTON_PRESS) {
|
||||
event->type == GDK_BUTTON_PRESS)
|
||||
{
|
||||
view->priv->drag_started = FALSE;
|
||||
view->priv->drag_button = event->button;
|
||||
}
|
||||
}
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
} else {
|
||||
if ((event->button == 1 || event->button == 2) &&
|
||||
event->type == GDK_BUTTON_PRESS) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((event->button == 1 || event->button == 2) && event->type == GDK_BUTTON_PRESS)
|
||||
{
|
||||
if (view->priv->double_click_path[1])
|
||||
{
|
||||
gtk_tree_path_free (view->priv->double_click_path[1]);
|
||||
}
|
||||
|
||||
view->priv->double_click_path[1] = view->priv->double_click_path[0];
|
||||
view->priv->double_click_path[0] = NULL;
|
||||
|
@ -632,13 +715,16 @@ key_press_event (GtkWidget *widget,
|
|||
|
||||
modifiers = gtk_accelerator_get_default_mod_mask ();
|
||||
|
||||
switch (event->keyval) {
|
||||
switch (event->keyval)
|
||||
{
|
||||
case GDK_KEY_space:
|
||||
if (event->state & GDK_CONTROL_MASK) {
|
||||
if (event->state & GDK_CONTROL_MASK)
|
||||
{
|
||||
handled = FALSE;
|
||||
break;
|
||||
}
|
||||
if (!gtk_widget_has_focus (widget)) {
|
||||
if (!gtk_widget_has_focus (widget))
|
||||
{
|
||||
handled = FALSE;
|
||||
break;
|
||||
}
|
||||
|
@ -654,7 +740,8 @@ key_press_event (GtkWidget *widget,
|
|||
break;
|
||||
|
||||
case GDK_KEY_h:
|
||||
if ((event->state & modifiers) == GDK_CONTROL_MASK) {
|
||||
if ((event->state & modifiers) == GDK_CONTROL_MASK)
|
||||
{
|
||||
toggle_hidden_filter (view);
|
||||
handled = TRUE;
|
||||
break;
|
||||
|
@ -666,20 +753,25 @@ key_press_event (GtkWidget *widget,
|
|||
|
||||
/* Chain up */
|
||||
if (!handled)
|
||||
{
|
||||
return GTK_WIDGET_CLASS (xed_file_browser_view_parent_class)->key_press_event (widget, event);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
fill_expand_state (XedFileBrowserView * view, GtkTreeIter * iter)
|
||||
fill_expand_state (XedFileBrowserView *view,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
GtkTreePath * path;
|
||||
GtkTreeIter child;
|
||||
gchar * uri;
|
||||
|
||||
if (!gtk_tree_model_iter_has_child (view->priv->model, iter))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
path = gtk_tree_model_get_path (view->priv->model, iter);
|
||||
|
||||
|
@ -697,7 +789,8 @@ fill_expand_state (XedFileBrowserView * view, GtkTreeIter * iter)
|
|||
|
||||
if (gtk_tree_model_iter_children (view->priv->model, &child, iter))
|
||||
{
|
||||
do {
|
||||
do
|
||||
{
|
||||
fill_expand_state (view, &child);
|
||||
} while (gtk_tree_model_iter_next (view->priv->model, &child));
|
||||
}
|
||||
|
@ -709,46 +802,24 @@ static void
|
|||
uninstall_restore_signals (XedFileBrowserView *tree_view,
|
||||
GtkTreeModel *model)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (model,
|
||||
on_begin_refresh,
|
||||
tree_view);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (model,
|
||||
on_end_refresh,
|
||||
tree_view);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (model,
|
||||
on_unload,
|
||||
tree_view);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (model,
|
||||
on_row_inserted,
|
||||
tree_view);
|
||||
g_signal_handlers_disconnect_by_func (model, on_begin_refresh, tree_view);
|
||||
g_signal_handlers_disconnect_by_func (model, on_end_refresh, tree_view);
|
||||
g_signal_handlers_disconnect_by_func (model, on_unload, tree_view);
|
||||
g_signal_handlers_disconnect_by_func (model, on_row_inserted, tree_view);
|
||||
}
|
||||
|
||||
static void
|
||||
install_restore_signals (XedFileBrowserView *tree_view,
|
||||
GtkTreeModel *model)
|
||||
{
|
||||
g_signal_connect (model,
|
||||
"begin-refresh",
|
||||
G_CALLBACK (on_begin_refresh),
|
||||
tree_view);
|
||||
|
||||
g_signal_connect (model,
|
||||
"end-refresh",
|
||||
G_CALLBACK (on_end_refresh),
|
||||
tree_view);
|
||||
|
||||
g_signal_connect (model,
|
||||
"unload",
|
||||
G_CALLBACK (on_unload),
|
||||
tree_view);
|
||||
|
||||
g_signal_connect_after (model,
|
||||
"row-inserted",
|
||||
G_CALLBACK (on_row_inserted),
|
||||
tree_view);
|
||||
g_signal_connect (model, "begin-refresh",
|
||||
G_CALLBACK (on_begin_refresh), tree_view);
|
||||
g_signal_connect (model, "end-refresh",
|
||||
G_CALLBACK (on_end_refresh), tree_view);
|
||||
g_signal_connect (model, "unload",
|
||||
G_CALLBACK (on_unload), tree_view);
|
||||
g_signal_connect_after (model, "row-inserted",
|
||||
G_CALLBACK (on_row_inserted), tree_view);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -756,7 +827,9 @@ set_restore_expand_state (XedFileBrowserView * view,
|
|||
gboolean state)
|
||||
{
|
||||
if (state == view->priv->restore_expand_state)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (view->priv->expand_state)
|
||||
{
|
||||
|
@ -905,8 +978,7 @@ xed_file_browser_view_class_init (XedFileBrowserViewClass * klass)
|
|||
g_cclosure_marshal_VOID__BOXED,
|
||||
G_TYPE_NONE, 1, GTK_TYPE_TREE_ITER);
|
||||
|
||||
g_type_class_add_private (object_class,
|
||||
sizeof (XedFileBrowserViewPrivate));
|
||||
g_type_class_add_private (object_class, sizeof (XedFileBrowserViewPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -916,8 +988,10 @@ xed_file_browser_view_class_finalize (XedFileBrowserViewClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
cell_data_cb (GtkTreeViewColumn * tree_column, GtkCellRenderer * cell,
|
||||
GtkTreeModel * tree_model, GtkTreeIter * iter,
|
||||
cell_data_cb (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *tree_model,
|
||||
GtkTreeIter *iter,
|
||||
XedFileBrowserView *obj)
|
||||
{
|
||||
GtkTreePath *path;
|
||||
|
@ -926,16 +1000,17 @@ cell_data_cb (GtkTreeViewColumn * tree_column, GtkCellRenderer * cell,
|
|||
|
||||
path = gtk_tree_model_get_path (tree_model, iter);
|
||||
|
||||
if (obj->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) {
|
||||
if (obj->priv->hover_path != NULL &&
|
||||
gtk_tree_path_compare (path, obj->priv->hover_path) == 0)
|
||||
if (obj->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
|
||||
{
|
||||
if (obj->priv->hover_path != NULL && gtk_tree_path_compare (path, obj->priv->hover_path) == 0)
|
||||
{
|
||||
underline = PANGO_UNDERLINE_SINGLE;
|
||||
}
|
||||
}
|
||||
|
||||
if (XED_IS_FILE_BROWSER_STORE (tree_model))
|
||||
{
|
||||
if (obj->priv->editable != NULL &&
|
||||
gtk_tree_row_reference_valid (obj->priv->editable))
|
||||
if (obj->priv->editable != NULL && gtk_tree_row_reference_valid (obj->priv->editable))
|
||||
{
|
||||
GtkTreePath *edpath = gtk_tree_row_reference_get_path (obj->priv->editable);
|
||||
|
||||
|
@ -955,17 +1030,14 @@ xed_file_browser_view_init (XedFileBrowserView * obj)
|
|||
obj->priv->column = gtk_tree_view_column_new ();
|
||||
|
||||
obj->priv->pixbuf_renderer = gtk_cell_renderer_pixbuf_new ();
|
||||
gtk_tree_view_column_pack_start (obj->priv->column,
|
||||
obj->priv->pixbuf_renderer,
|
||||
FALSE);
|
||||
gtk_tree_view_column_pack_start (obj->priv->column, obj->priv->pixbuf_renderer, FALSE);
|
||||
gtk_tree_view_column_add_attribute (obj->priv->column,
|
||||
obj->priv->pixbuf_renderer,
|
||||
"pixbuf",
|
||||
XED_FILE_BROWSER_STORE_COLUMN_ICON);
|
||||
|
||||
obj->priv->text_renderer = gtk_cell_renderer_text_new ();
|
||||
gtk_tree_view_column_pack_start (obj->priv->column,
|
||||
obj->priv->text_renderer, TRUE);
|
||||
gtk_tree_view_column_pack_start (obj->priv->column, obj->priv->text_renderer, TRUE);
|
||||
gtk_tree_view_column_add_attribute (obj->priv->column,
|
||||
obj->priv->text_renderer,
|
||||
"text",
|
||||
|
@ -974,8 +1046,7 @@ xed_file_browser_view_init (XedFileBrowserView * obj)
|
|||
g_signal_connect (obj->priv->text_renderer, "edited",
|
||||
G_CALLBACK (on_cell_edited), obj);
|
||||
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (obj),
|
||||
obj->priv->column);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (obj), obj->priv->column);
|
||||
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (obj), FALSE);
|
||||
|
||||
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (obj),
|
||||
|
@ -988,14 +1059,13 @@ xed_file_browser_view_init (XedFileBrowserView * obj)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
bookmarks_separator_func (GtkTreeModel * model, GtkTreeIter * iter,
|
||||
bookmarks_separator_func (GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data)
|
||||
{
|
||||
guint flags;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS,
|
||||
&flags, -1);
|
||||
gtk_tree_model_get (model, iter, XED_FILE_BOOKMARKS_STORE_COLUMN_FLAGS, &flags, -1);
|
||||
|
||||
return (flags & XED_FILE_BOOKMARKS_STORE_IS_SEPARATOR);
|
||||
}
|
||||
|
@ -1004,9 +1074,7 @@ bookmarks_separator_func (GtkTreeModel * model, GtkTreeIter * iter,
|
|||
GtkWidget *
|
||||
xed_file_browser_view_new (void)
|
||||
{
|
||||
XedFileBrowserView *obj =
|
||||
XED_FILE_BROWSER_VIEW (g_object_new
|
||||
(XED_TYPE_FILE_BROWSER_VIEW, NULL));
|
||||
XedFileBrowserView *obj = XED_FILE_BROWSER_VIEW (g_object_new (XED_TYPE_FILE_BROWSER_VIEW, NULL));
|
||||
|
||||
return GTK_WIDGET (obj);
|
||||
}
|
||||
|
@ -1018,11 +1086,14 @@ xed_file_browser_view_set_model (XedFileBrowserView * tree_view,
|
|||
GtkTreeSelection *selection;
|
||||
|
||||
if (tree_view->priv->model == model)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
|
||||
|
||||
if (XED_IS_FILE_BOOKMARKS_STORE (model)) {
|
||||
if (XED_IS_FILE_BOOKMARKS_STORE (model))
|
||||
{
|
||||
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
|
||||
gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW
|
||||
(tree_view),
|
||||
|
@ -1035,7 +1106,9 @@ xed_file_browser_view_set_model (XedFileBrowserView * tree_view,
|
|||
(GtkTreeCellDataFunc)
|
||||
cell_data_cb,
|
||||
tree_view, NULL);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
|
||||
gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW
|
||||
(tree_view), NULL,
|
||||
|
@ -1049,19 +1122,24 @@ xed_file_browser_view_set_model (XedFileBrowserView * tree_view,
|
|||
tree_view, NULL);
|
||||
|
||||
if (tree_view->priv->restore_expand_state)
|
||||
{
|
||||
install_restore_signals (tree_view, model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (tree_view->priv->hover_path != NULL) {
|
||||
if (tree_view->priv->hover_path != NULL)
|
||||
{
|
||||
gtk_tree_path_free (tree_view->priv->hover_path);
|
||||
tree_view->priv->hover_path = NULL;
|
||||
}
|
||||
|
||||
if (XED_IS_FILE_BROWSER_STORE (tree_view->priv->model)) {
|
||||
if (XED_IS_FILE_BROWSER_STORE (tree_view->priv->model))
|
||||
{
|
||||
if (tree_view->priv->restore_expand_state)
|
||||
uninstall_restore_signals (tree_view,
|
||||
tree_view->priv->model);
|
||||
{
|
||||
uninstall_restore_signals (tree_view, tree_view->priv->model);
|
||||
}
|
||||
}
|
||||
|
||||
tree_view->priv->model = model;
|
||||
|
@ -1077,16 +1155,15 @@ xed_file_browser_view_start_rename (XedFileBrowserView * tree_view,
|
|||
GtkTreePath *path;
|
||||
|
||||
g_return_if_fail (XED_IS_FILE_BROWSER_VIEW (tree_view));
|
||||
g_return_if_fail (XED_IS_FILE_BROWSER_STORE
|
||||
(tree_view->priv->model));
|
||||
g_return_if_fail (XED_IS_FILE_BROWSER_STORE (tree_view->priv->model));
|
||||
g_return_if_fail (iter != NULL);
|
||||
|
||||
gtk_tree_model_get (tree_view->priv->model, iter,
|
||||
XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags,
|
||||
-1);
|
||||
gtk_tree_model_get (tree_view->priv->model, iter, XED_FILE_BROWSER_STORE_COLUMN_FLAGS, &flags, -1);
|
||||
|
||||
if (!(FILE_IS_DIR (flags) || !FILE_IS_DUMMY (flags)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
path = gtk_tree_model_get_path (tree_view->priv->model, iter);
|
||||
rowref = gtk_tree_row_reference_new (tree_view->priv->model, path);
|
||||
|
@ -1095,8 +1172,9 @@ xed_file_browser_view_start_rename (XedFileBrowserView * tree_view,
|
|||
gtk_widget_grab_focus (GTK_WIDGET (tree_view));
|
||||
|
||||
if (gtk_tree_path_up (path))
|
||||
gtk_tree_view_expand_to_path (GTK_TREE_VIEW (tree_view),
|
||||
path);
|
||||
{
|
||||
gtk_tree_view_expand_to_path (GTK_TREE_VIEW (tree_view), path);
|
||||
}
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
tree_view->priv->editable = rowref;
|
||||
|
@ -1134,7 +1212,9 @@ xed_file_browser_view_set_restore_expand_state (XedFileBrowserView * tree_view,
|
|||
|
||||
/* Signal handlers */
|
||||
static void
|
||||
on_cell_edited (GtkCellRendererText * cell, gchar * path, gchar * new_text,
|
||||
on_cell_edited (GtkCellRendererText *cell,
|
||||
gchar *path,
|
||||
gchar *new_text,
|
||||
XedFileBrowserView *tree_view)
|
||||
{
|
||||
GtkTreePath * treepath;
|
||||
|
@ -1146,25 +1226,27 @@ on_cell_edited (GtkCellRendererText * cell, gchar * path, gchar * new_text,
|
|||
tree_view->priv->editable = NULL;
|
||||
|
||||
if (new_text == NULL || *new_text == '\0')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
treepath = gtk_tree_path_new_from_string (path);
|
||||
ret = gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_view->priv->model), &iter, treepath);
|
||||
gtk_tree_path_free (treepath);
|
||||
|
||||
if (ret) {
|
||||
if (xed_file_browser_store_rename (XED_FILE_BROWSER_STORE (tree_view->priv->model),
|
||||
&iter, new_text, &error)) {
|
||||
if (ret)
|
||||
{
|
||||
if (xed_file_browser_store_rename (XED_FILE_BROWSER_STORE (tree_view->priv->model), &iter, new_text, &error))
|
||||
{
|
||||
treepath = gtk_tree_model_get_path (GTK_TREE_MODEL (tree_view->priv->model), &iter);
|
||||
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tree_view),
|
||||
treepath, NULL,
|
||||
FALSE, 0.0, 0.0);
|
||||
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tree_view), treepath, NULL, FALSE, 0.0, 0.0);
|
||||
gtk_tree_path_free (treepath);
|
||||
}
|
||||
else {
|
||||
if (error) {
|
||||
g_signal_emit (tree_view, signals[ERROR], 0,
|
||||
error->code, error->message);
|
||||
else
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
g_signal_emit (tree_view, signals[ERROR], 0, error->code, error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
@ -1196,7 +1278,9 @@ on_unload (XedFileBrowserStore * model,
|
|||
{
|
||||
/* Don't remove the expand state if we are refreshing */
|
||||
if (!view->priv->restore_expand_state || view->priv->is_refresh)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
remove_expand_state (view, uri);
|
||||
}
|
||||
|
@ -1217,16 +1301,16 @@ restore_expand_state (XedFileBrowserView * view,
|
|||
-1);
|
||||
|
||||
if (!uri)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter);
|
||||
|
||||
if (g_hash_table_lookup (view->priv->expand_state, file))
|
||||
{
|
||||
gtk_tree_view_expand_row (GTK_TREE_VIEW (view),
|
||||
path,
|
||||
FALSE);
|
||||
gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, FALSE);
|
||||
}
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
|
@ -1245,7 +1329,9 @@ on_row_inserted (XedFileBrowserStore * model,
|
|||
GtkTreePath * copy;
|
||||
|
||||
if (gtk_tree_model_iter_has_child (GTK_TREE_MODEL (model), iter))
|
||||
{
|
||||
restore_expand_state (view, model, iter);
|
||||
}
|
||||
|
||||
copy = gtk_tree_path_copy (path);
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ typedef struct _XedFileBrowserView XedFileBrowserView;
|
|||
typedef struct _XedFileBrowserViewClass XedFileBrowserViewClass;
|
||||
typedef struct _XedFileBrowserViewPrivate XedFileBrowserViewPrivate;
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
XED_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE,
|
||||
XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE
|
||||
} XedFileBrowserViewClickPolicy;
|
||||
|
@ -66,7 +67,7 @@ struct _XedFileBrowserViewClass
|
|||
};
|
||||
|
||||
GType xed_file_browser_view_get_type (void) G_GNUC_CONST;
|
||||
void _xed_file_browser_view_register_type (GTypeModule * module);
|
||||
void _xed_file_browser_view_register_type (GTypeModule *type_module);
|
||||
|
||||
GtkWidget *xed_file_browser_view_new (void);
|
||||
void xed_file_browser_view_set_model (XedFileBrowserView *tree_view,
|
||||
|
|
|
@ -800,18 +800,15 @@ static GtkActionEntry toplevel_actions[] =
|
|||
static const GtkActionEntry tree_actions_selection[] =
|
||||
{
|
||||
{"FileMoveToTrash", "user-trash", N_("_Move to Trash"), NULL,
|
||||
N_("Move selected file or folder to trash"),
|
||||
G_CALLBACK (on_action_file_move_to_trash)},
|
||||
N_("Move selected file or folder to trash"), G_CALLBACK (on_action_file_move_to_trash)},
|
||||
{"FileDelete", "edit-delete-symbolic", N_("_Delete"), NULL,
|
||||
N_("Delete selected file or folder"),
|
||||
G_CALLBACK (on_action_file_delete)}
|
||||
N_("Delete selected file or folder"), G_CALLBACK (on_action_file_delete)}
|
||||
};
|
||||
|
||||
static const GtkActionEntry tree_actions_file_selection[] =
|
||||
{
|
||||
{"FileOpen", "document-open-symbolic", N_("Open"), NULL,
|
||||
N_("Open selected file"),
|
||||
G_CALLBACK (on_action_file_open)}
|
||||
{"FileOpen", "document-open-symbolic", N_("_Open"), NULL,
|
||||
N_("Open selected file"), G_CALLBACK (on_action_file_open)}
|
||||
};
|
||||
|
||||
static const GtkActionEntry tree_actions[] =
|
||||
|
@ -823,8 +820,7 @@ static const GtkActionEntry tree_actions[] =
|
|||
static const GtkActionEntry tree_actions_single_most_selection[] =
|
||||
{
|
||||
{"DirectoryNew", "folder-new-symbolic", N_("_New Folder"), NULL,
|
||||
N_("Add new empty folder"),
|
||||
G_CALLBACK (on_action_directory_new)},
|
||||
N_("Add new empty folder"), G_CALLBACK (on_action_directory_new)},
|
||||
{"FileNew", "document-new-symbolic", N_("New F_ile"), NULL,
|
||||
N_("Add new empty file"), G_CALLBACK (on_action_file_new)}
|
||||
};
|
||||
|
@ -832,33 +828,27 @@ static const GtkActionEntry tree_actions_single_most_selection[] =
|
|||
static const GtkActionEntry tree_actions_single_selection[] =
|
||||
{
|
||||
{"FileRename", NULL, N_("_Rename"), NULL,
|
||||
N_("Rename selected file or folder"),
|
||||
G_CALLBACK (on_action_file_rename)}
|
||||
N_("Rename selected file or folder"), G_CALLBACK (on_action_file_rename)}
|
||||
};
|
||||
|
||||
static const GtkActionEntry tree_actions_sensitive[] =
|
||||
{
|
||||
{"DirectoryPrevious", "go-previous-symbolic", N_("_Previous Location"), NULL,
|
||||
N_("Go to the previous visited location"),
|
||||
G_CALLBACK (on_action_directory_previous)},
|
||||
N_("Go to the previous visited location"), G_CALLBACK (on_action_directory_previous)},
|
||||
{"DirectoryNext", "go-next-symbolic", N_("_Next Location"), NULL,
|
||||
N_("Go to the next visited location"), G_CALLBACK (on_action_directory_next)},
|
||||
{"DirectoryRefresh", "view-refresh-symbolic", N_("Re_fresh View"), NULL,
|
||||
N_("Refresh the view"), G_CALLBACK (on_action_directory_refresh)},
|
||||
{"DirectoryOpen", "folder-open-symbolic", N_("_View Folder"), NULL,
|
||||
N_("View folder in file manager"),
|
||||
G_CALLBACK (on_action_directory_open)}
|
||||
N_("View folder in file manager"), G_CALLBACK (on_action_directory_open)}
|
||||
};
|
||||
|
||||
static const GtkToggleActionEntry tree_actions_toggle[] =
|
||||
{
|
||||
{"FilterHidden", GTK_STOCK_DIALOG_AUTHENTICATION,
|
||||
N_("Show _Hidden"), NULL,
|
||||
N_("Show hidden files and folders"),
|
||||
G_CALLBACK (on_action_filter_hidden), FALSE},
|
||||
{"FilterHidden", GTK_STOCK_DIALOG_AUTHENTICATION, N_("Show _Hidden"), NULL,
|
||||
N_("Show hidden files and folders"), G_CALLBACK (on_action_filter_hidden), FALSE},
|
||||
{"FilterBinary", NULL, N_("Show _Binary"), NULL,
|
||||
N_("Show binary files"), G_CALLBACK (on_action_filter_binary),
|
||||
FALSE}
|
||||
N_("Show binary files"), G_CALLBACK (on_action_filter_binary), FALSE}
|
||||
};
|
||||
|
||||
static const GtkActionEntry bookmark_actions[] =
|
||||
|
|
|
@ -71,7 +71,7 @@ struct _XedFileBrowserWidgetClass
|
|||
};
|
||||
|
||||
GType xed_file_browser_widget_get_type (void) G_GNUC_CONST;
|
||||
void _xed_file_browser_widget_register_type (GTypeModule * module);
|
||||
void _xed_file_browser_widget_register_type (GTypeModule *type_module);
|
||||
|
||||
GtkWidget *xed_file_browser_widget_new (const gchar *data_dir);
|
||||
|
||||
|
|
|
@ -79,9 +79,12 @@ has_option (ModelineOptions *options,
|
|||
|
||||
void
|
||||
modeline_parser_init (const gchar *data_dir)
|
||||
{
|
||||
if (modelines_data_dir == NULL)
|
||||
{
|
||||
modelines_data_dir = g_strdup (data_dir);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
modeline_parser_shutdown ()
|
||||
|
@ -100,6 +103,7 @@ modeline_parser_shutdown ()
|
|||
kate_languages = NULL;
|
||||
|
||||
g_free (modelines_data_dir);
|
||||
modelines_data_dir = NULL;
|
||||
}
|
||||
|
||||
static GHashTable *
|
||||
|
@ -326,7 +330,7 @@ parse_vim_modeline (gchar *s,
|
|||
|
||||
options->set |= MODELINE_SET_WRAP_MODE;
|
||||
}
|
||||
else if (strcmp (key->str, "textwidth") == 0)
|
||||
else if (strcmp (key->str, "textwidth") == 0 || strcmp (key->str, "tw") == 0)
|
||||
{
|
||||
intval = atoi (value->str);
|
||||
|
||||
|
@ -825,6 +829,7 @@ modeline_parser_apply_modeline (GtkSourceView *view)
|
|||
|
||||
if (previous)
|
||||
{
|
||||
g_free (previous->language_id);
|
||||
*previous = options;
|
||||
previous->language_id = g_strdup (options.language_id);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#define __MODELINE_PARSER_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <gtksourceview/gtksourceview.h>
|
||||
#include <gtksourceview/gtksource.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
|
@ -25,50 +25,35 @@
|
|||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <gmodule.h>
|
||||
#include <libpeas/peas-activatable.h>
|
||||
#include "xed-modeline-plugin.h"
|
||||
#include "modeline-parser.h"
|
||||
|
||||
#include <xed/xed-window.h>
|
||||
#include <xed/xed-debug.h>
|
||||
#include <xed/xed-utils.h>
|
||||
|
||||
#define DOCUMENT_DATA_KEY "XedModelinePluginDocumentData"
|
||||
#include <xed/xed-view-activatable.h>
|
||||
#include <xed/xed-view.h>
|
||||
|
||||
struct _XedModelinePluginPrivate
|
||||
{
|
||||
GtkWidget *window;
|
||||
XedView *view;
|
||||
|
||||
gulong tab_added_handler_id;
|
||||
gulong tab_removed_handler_id;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gulong document_loaded_handler_id;
|
||||
gulong document_saved_handler_id;
|
||||
} DocumentData;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_OBJECT
|
||||
PROP_VIEW
|
||||
};
|
||||
|
||||
static void peas_activatable_iface_init (PeasActivatableInterface *iface);
|
||||
static void xed_view_activatable_iface_init (XedViewActivatableInterface *iface);
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedModelinePlugin,
|
||||
xed_modeline_plugin,
|
||||
PEAS_TYPE_EXTENSION_BASE,
|
||||
0,
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE,
|
||||
peas_activatable_iface_init))
|
||||
|
||||
static void
|
||||
document_data_free (DocumentData *ddata)
|
||||
{
|
||||
g_slice_free (DocumentData, ddata);
|
||||
}
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (XED_TYPE_VIEW_ACTIVATABLE,
|
||||
xed_view_activatable_iface_init))
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_constructed (GObject *object)
|
||||
|
@ -94,6 +79,18 @@ xed_modeline_plugin_init (XedModelinePlugin *plugin)
|
|||
XedModelinePluginPrivate);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_dispose (GObject *object)
|
||||
{
|
||||
XedModelinePlugin *plugin = XED_MODELINE_PLUGIN (object);
|
||||
|
||||
xed_debug_message (DEBUG_PLUGINS, "XedModelinePlugin disposing");
|
||||
|
||||
g_clear_object (&plugin->priv->view);
|
||||
|
||||
G_OBJECT_CLASS (xed_modeline_plugin_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_finalize (GObject *object)
|
||||
{
|
||||
|
@ -104,22 +101,6 @@ xed_modeline_plugin_finalize (GObject *object)
|
|||
G_OBJECT_CLASS (xed_modeline_plugin_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_dispose (GObject *object)
|
||||
{
|
||||
XedModelinePlugin *plugin = XED_MODELINE_PLUGIN (object);
|
||||
|
||||
xed_debug_message (DEBUG_PLUGINS, "XedModelinePlugin disposing");
|
||||
|
||||
if (plugin->priv->window != NULL)
|
||||
{
|
||||
g_object_unref (plugin->priv->window);
|
||||
plugin->priv->window = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (xed_modeline_plugin_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
|
@ -130,8 +111,8 @@ xed_modeline_plugin_set_property (GObject *object,
|
|||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_OBJECT:
|
||||
plugin->priv->window = GTK_WIDGET (g_value_dup_object (value));
|
||||
case PROP_VIEW:
|
||||
plugin->priv->view = XED_VIEW (g_value_dup_object (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -149,8 +130,8 @@ xed_modeline_plugin_get_property (GObject *object,
|
|||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_OBJECT:
|
||||
g_value_set_object (value, plugin->priv->window);
|
||||
case PROP_VIEW:
|
||||
g_value_set_object (value, plugin->priv->view);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -167,123 +148,41 @@ on_document_loaded_or_saved (XedDocument *document,
|
|||
}
|
||||
|
||||
static void
|
||||
connect_handlers (XedView *view)
|
||||
xed_modeline_plugin_activate (XedViewActivatable *activatable)
|
||||
{
|
||||
DocumentData *data;
|
||||
XedModelinePlugin *plugin;
|
||||
GtkTextBuffer *doc;
|
||||
|
||||
doc = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
data = g_slice_new (DocumentData);
|
||||
plugin = XED_MODELINE_PLUGIN (activatable);
|
||||
|
||||
data->document_loaded_handler_id =
|
||||
modeline_parser_apply_modeline (GTK_SOURCE_VIEW (plugin->priv->view));
|
||||
|
||||
doc = gtk_text_view_get_buffer (GTK_TEXT_VIEW (plugin->priv->view));
|
||||
|
||||
plugin->priv->document_loaded_handler_id =
|
||||
g_signal_connect (doc, "loaded",
|
||||
G_CALLBACK (on_document_loaded_or_saved),
|
||||
view);
|
||||
data->document_saved_handler_id =
|
||||
G_CALLBACK (on_document_loaded_or_saved), plugin->priv->view);
|
||||
plugin->priv->document_saved_handler_id =
|
||||
g_signal_connect (doc, "saved",
|
||||
G_CALLBACK (on_document_loaded_or_saved),
|
||||
view);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (doc), DOCUMENT_DATA_KEY,
|
||||
data, (GDestroyNotify) document_data_free);
|
||||
G_CALLBACK (on_document_loaded_or_saved), plugin->priv->view);
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect_handlers (XedView *view)
|
||||
xed_modeline_plugin_deactivate (XedViewActivatable *activatable)
|
||||
{
|
||||
DocumentData *data;
|
||||
XedModelinePlugin *plugin;
|
||||
GtkTextBuffer *doc;
|
||||
|
||||
doc = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
|
||||
data = g_object_steal_data (G_OBJECT (doc), DOCUMENT_DATA_KEY);
|
||||
|
||||
if (data)
|
||||
{
|
||||
g_signal_handler_disconnect (doc, data->document_loaded_handler_id);
|
||||
g_signal_handler_disconnect (doc, data->document_saved_handler_id);
|
||||
|
||||
document_data_free (data);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Modeline handlers not found");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_window_tab_added (XedWindow *window,
|
||||
XedTab *tab,
|
||||
gpointer user_data)
|
||||
{
|
||||
connect_handlers (xed_tab_get_view (tab));
|
||||
}
|
||||
|
||||
static void
|
||||
on_window_tab_removed (XedWindow *window,
|
||||
XedTab *tab,
|
||||
gpointer user_data)
|
||||
{
|
||||
disconnect_handlers (xed_tab_get_view (tab));
|
||||
}
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_activate (PeasActivatable *activatable)
|
||||
{
|
||||
XedModelinePluginPrivate *data;
|
||||
XedWindow *window;
|
||||
GList *views;
|
||||
GList *l;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
data = XED_MODELINE_PLUGIN (activatable)->priv;
|
||||
window = XED_WINDOW (data->window);
|
||||
plugin = XED_MODELINE_PLUGIN (activatable);
|
||||
|
||||
views = xed_window_get_views (window);
|
||||
for (l = views; l != NULL; l = l->next)
|
||||
{
|
||||
connect_handlers (XED_VIEW (l->data));
|
||||
modeline_parser_apply_modeline (GTK_SOURCE_VIEW (l->data));
|
||||
}
|
||||
g_list_free (views);
|
||||
doc = gtk_text_view_get_buffer (GTK_TEXT_VIEW (plugin->priv->view));
|
||||
|
||||
data->tab_added_handler_id =
|
||||
g_signal_connect (window, "tab-added",
|
||||
G_CALLBACK (on_window_tab_added), NULL);
|
||||
|
||||
data->tab_removed_handler_id =
|
||||
g_signal_connect (window, "tab-removed",
|
||||
G_CALLBACK (on_window_tab_removed), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_deactivate (PeasActivatable *activatable)
|
||||
{
|
||||
XedModelinePluginPrivate *data;
|
||||
XedWindow *window;
|
||||
GList *views;
|
||||
GList *l;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
data = XED_MODELINE_PLUGIN (activatable)->priv;
|
||||
window = XED_WINDOW (data->window);
|
||||
|
||||
g_signal_handler_disconnect (window, data->tab_added_handler_id);
|
||||
g_signal_handler_disconnect (window, data->tab_removed_handler_id);
|
||||
|
||||
views = xed_window_get_views (window);
|
||||
|
||||
for (l = views; l != NULL; l = l->next)
|
||||
{
|
||||
disconnect_handlers (XED_VIEW (l->data));
|
||||
|
||||
modeline_parser_deactivate (GTK_SOURCE_VIEW (l->data));
|
||||
}
|
||||
|
||||
g_list_free (views);
|
||||
g_signal_handler_disconnect (doc, plugin->priv->document_loaded_handler_id);
|
||||
g_signal_handler_disconnect (doc, plugin->priv->document_saved_handler_id);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -292,35 +191,35 @@ xed_modeline_plugin_class_init (XedModelinePluginClass *klass)
|
|||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->constructed = xed_modeline_plugin_constructed;
|
||||
object_class->finalize = xed_modeline_plugin_finalize;
|
||||
object_class->dispose = xed_modeline_plugin_dispose;
|
||||
object_class->finalize = xed_modeline_plugin_finalize;
|
||||
object_class->set_property = xed_modeline_plugin_set_property;
|
||||
object_class->get_property = xed_modeline_plugin_get_property;
|
||||
|
||||
g_object_class_override_property (object_class, PROP_OBJECT, "object");
|
||||
g_object_class_override_property (object_class, PROP_VIEW, "view");
|
||||
|
||||
g_type_class_add_private (klass, sizeof (XedModelinePluginPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
xed_view_activatable_iface_init (XedViewActivatableInterface *iface)
|
||||
{
|
||||
iface->activate = xed_modeline_plugin_activate;
|
||||
iface->deactivate = xed_modeline_plugin_deactivate;
|
||||
}
|
||||
|
||||
static void
|
||||
xed_modeline_plugin_class_finalize (XedModelinePluginClass *klass)
|
||||
{
|
||||
/* dummy function - used by G_DEFINE_DYNAMIC_TYPE_EXTENDED */
|
||||
}
|
||||
|
||||
static void
|
||||
peas_activatable_iface_init (PeasActivatableInterface *iface)
|
||||
{
|
||||
iface->activate = xed_modeline_plugin_activate;
|
||||
iface->deactivate = xed_modeline_plugin_deactivate;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
peas_register_types (PeasObjectModule *module)
|
||||
{
|
||||
xed_modeline_plugin_register_type (G_TYPE_MODULE (module));
|
||||
|
||||
peas_object_module_register_extension_type (module,
|
||||
PEAS_TYPE_ACTIVATABLE,
|
||||
XED_TYPE_VIEW_ACTIVATABLE,
|
||||
XED_TYPE_MODELINE_PLUGIN);
|
||||
}
|
||||
|
|
|
@ -39,10 +39,11 @@ G_BEGIN_DECLS
|
|||
/* Private structure type */
|
||||
typedef struct _XedModelinePlugin XedModelinePlugin;
|
||||
typedef struct _XedModelinePluginPrivate XedModelinePluginPrivate;
|
||||
typedef struct _XedModelinePluginClass XedModelinePluginClass;
|
||||
|
||||
struct _XedModelinePlugin
|
||||
{
|
||||
PeasExtensionBase parent_instance;
|
||||
PeasExtensionBase parent;
|
||||
|
||||
/*< private >*/
|
||||
XedModelinePluginPrivate *priv;
|
||||
|
|
|
@ -70,6 +70,7 @@ NOINST_H_FILES = \
|
|||
|
||||
INST_H_FILES = \
|
||||
xed-app.h \
|
||||
xed-app-activatable.h \
|
||||
xed-commands.h \
|
||||
xed-debug.h \
|
||||
xed-document.h \
|
||||
|
@ -91,7 +92,9 @@ INST_H_FILES = \
|
|||
xed-tab.h \
|
||||
xed-utils.h \
|
||||
xed-view.h \
|
||||
xed-window.h
|
||||
xed-view-activatable.h \
|
||||
xed-window.h \
|
||||
xed-window-activatable.h
|
||||
|
||||
if !ENABLE_GVFS_METADATA
|
||||
INST_H_FILES += xed-metadata-manager.h
|
||||
|
@ -105,6 +108,7 @@ header_DATA = \
|
|||
|
||||
libxed_c_files = \
|
||||
xed-app.c \
|
||||
xed-app-activatable.c \
|
||||
xed-close-button.c \
|
||||
xed-commands-documents.c \
|
||||
xed-commands-edit.c \
|
||||
|
@ -152,7 +156,9 @@ libxed_c_files = \
|
|||
xed-tab-label.c \
|
||||
xed-utils.c \
|
||||
xed-view.c \
|
||||
xed-view-activatable.c \
|
||||
xed-window.c \
|
||||
xed-window-activatable.c \
|
||||
xedtextregion.c
|
||||
|
||||
libxed_la_SOURCES = \
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* xed-app-activatable.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2010 Steve Frécinaux
|
||||
* Copyright (C) 2010 Jesse van den Kieboom
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xed-app-activatable.h"
|
||||
#include "xed-app.h"
|
||||
|
||||
/**
|
||||
* SECTION:xed-app-activatable
|
||||
* @short_description: Interface for activatable extensions on apps
|
||||
* @see_also: #PeasExtensionSet
|
||||
*
|
||||
* #XedAppActivatable is an interface which should be implemented by
|
||||
* extensions that should be activated on a xed application.
|
||||
**/
|
||||
|
||||
G_DEFINE_INTERFACE(XedAppActivatable, xed_app_activatable, G_TYPE_OBJECT)
|
||||
|
||||
void
|
||||
xed_app_activatable_default_init (XedAppActivatableInterface *iface)
|
||||
{
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
/**
|
||||
* XedAppActivatable:app:
|
||||
*
|
||||
* The app property contains the xed app for this
|
||||
* #XedAppActivatable instance.
|
||||
*/
|
||||
g_object_interface_install_property (iface,
|
||||
g_param_spec_object ("app",
|
||||
"App",
|
||||
"The xed app",
|
||||
XED_TYPE_APP,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
initialized = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_app_activatable_activate:
|
||||
* @activatable: A #XedAppActivatable.
|
||||
*
|
||||
* Activates the extension on the application.
|
||||
*/
|
||||
void
|
||||
xed_app_activatable_activate (XedAppActivatable *activatable)
|
||||
{
|
||||
XedAppActivatableInterface *iface;
|
||||
|
||||
g_return_if_fail (XED_IS_APP_ACTIVATABLE (activatable));
|
||||
|
||||
iface = XED_APP_ACTIVATABLE_GET_IFACE (activatable);
|
||||
|
||||
if (iface->activate != NULL)
|
||||
{
|
||||
iface->activate (activatable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_app_activatable_deactivate:
|
||||
* @activatable: A #XedAppActivatable.
|
||||
*
|
||||
* Deactivates the extension from the application.
|
||||
*
|
||||
*/
|
||||
void
|
||||
xed_app_activatable_deactivate (XedAppActivatable *activatable)
|
||||
{
|
||||
XedAppActivatableInterface *iface;
|
||||
|
||||
g_return_if_fail (XED_IS_APP_ACTIVATABLE (activatable));
|
||||
|
||||
iface = XED_APP_ACTIVATABLE_GET_IFACE (activatable);
|
||||
|
||||
if (iface->deactivate != NULL)
|
||||
{
|
||||
iface->deactivate (activatable);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* xed-app-activatable.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2010 - Steve Frécinaux
|
||||
* Copyright (C) 2010 - Jesse van den Kieboom
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __XED_APP_ACTIVATABLE_H__
|
||||
#define __XED_APP_ACTIVATABLE_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Type checking and casting macros
|
||||
*/
|
||||
#define XED_TYPE_APP_ACTIVATABLE (xed_app_activatable_get_type ())
|
||||
#define XED_APP_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_APP_ACTIVATABLE, XedAppActivatable))
|
||||
#define XED_APP_ACTIVATABLE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XED_TYPE_APP_ACTIVATABLE, XedAppActivatableInterface))
|
||||
#define XED_IS_APP_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_APP_ACTIVATABLE))
|
||||
#define XED_APP_ACTIVATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), XED_TYPE_APP_ACTIVATABLE, XedAppActivatableInterface))
|
||||
|
||||
typedef struct _XedAppActivatable XedAppActivatable; /* dummy typedef */
|
||||
typedef struct _XedAppActivatableInterface XedAppActivatableInterface;
|
||||
|
||||
struct _XedAppActivatableInterface
|
||||
{
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/* Virtual public methods */
|
||||
void (*activate) (XedAppActivatable *activatable);
|
||||
void (*deactivate) (XedAppActivatable *activatable);
|
||||
};
|
||||
|
||||
/*
|
||||
* Public methods
|
||||
*/
|
||||
GType xed_app_activatable_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void xed_app_activatable_activate (XedAppActivatable *activatable);
|
||||
void xed_app_activatable_deactivate (XedAppActivatable *activatable);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XED_APP_ACTIVATABLE_H__ */
|
|
@ -36,6 +36,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <libpeas/peas-extension-set.h>
|
||||
|
||||
#include "xed-app.h"
|
||||
#include "xed-prefs-manager-app.h"
|
||||
|
@ -45,6 +46,8 @@
|
|||
#include "xed-utils.h"
|
||||
#include "xed-enum-types.h"
|
||||
#include "xed-dirs.h"
|
||||
#include "xed-app-activatable.h"
|
||||
#include "xed-plugins-engine.h"
|
||||
|
||||
#define XED_PAGE_SETUP_FILE "xed-page-setup"
|
||||
#define XED_PRINT_SETTINGS_FILE "xed-print-settings"
|
||||
|
@ -61,8 +64,11 @@ struct _XedAppPrivate
|
|||
{
|
||||
GList *windows;
|
||||
XedWindow *active_window;
|
||||
|
||||
GtkPageSetup *page_setup;
|
||||
GtkPrintSettings *print_settings;
|
||||
|
||||
PeasExtensionSet *extensions;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(XedApp, xed_app, G_TYPE_OBJECT)
|
||||
|
@ -87,6 +93,16 @@ xed_app_finalize (GObject *object)
|
|||
G_OBJECT_CLASS (xed_app_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_app_dispose (GObject *object)
|
||||
{
|
||||
XedApp *app = XED_APP (object);
|
||||
|
||||
g_clear_object (&app->priv->extensions);
|
||||
|
||||
G_OBJECT_CLASS (xed_app_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_app_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
|
@ -107,6 +123,7 @@ xed_app_class_init (XedAppClass *klass)
|
|||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = xed_app_finalize;
|
||||
object_class->dispose = xed_app_dispose;
|
||||
object_class->get_property = xed_app_get_property;
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (XedAppPrivate));
|
||||
|
@ -308,19 +325,40 @@ save_print_settings (XedApp *app)
|
|||
g_free (filename);
|
||||
}
|
||||
|
||||
static void
|
||||
extension_added (PeasExtensionSet *extensions,
|
||||
PeasPluginInfo *info,
|
||||
PeasExtension *exten,
|
||||
XedApp *app)
|
||||
{
|
||||
peas_extension_call (exten, "activate");
|
||||
}
|
||||
|
||||
static void
|
||||
extension_removed (PeasExtensionSet *extensions,
|
||||
PeasPluginInfo *info,
|
||||
PeasExtension *exten,
|
||||
XedApp *app)
|
||||
{
|
||||
peas_extension_call (exten, "deactivate");
|
||||
}
|
||||
|
||||
static void
|
||||
xed_app_init (XedApp *app)
|
||||
{
|
||||
app->priv = XED_APP_GET_PRIVATE (app);
|
||||
|
||||
load_accels ();
|
||||
}
|
||||
|
||||
static void
|
||||
app_weak_notify (gpointer data,
|
||||
GObject *where_the_app_was)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
app->priv->extensions = peas_extension_set_new (PEAS_ENGINE (xed_plugins_engine_get_default ()),
|
||||
XED_TYPE_APP_ACTIVATABLE, "app", app, NULL);
|
||||
|
||||
g_signal_connect (app->priv->extensions, "extension-added",
|
||||
G_CALLBACK (extension_added), app);
|
||||
g_signal_connect (app->priv->extensions, "extension-removed",
|
||||
G_CALLBACK (extension_removed), app);
|
||||
|
||||
peas_extension_set_call (app->priv->extensions, "activate");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -342,7 +380,6 @@ xed_app_get_default (void)
|
|||
app = XED_APP (g_object_new (XED_TYPE_APP, NULL));
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (app), (gpointer) &app);
|
||||
g_object_weak_ref (G_OBJECT (app), app_weak_notify, NULL);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
@ -421,7 +458,7 @@ window_destroy (XedWindow *window,
|
|||
save_page_setup (app);
|
||||
save_print_settings (app);
|
||||
|
||||
g_object_unref (app);
|
||||
gtk_main_quit ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* xed-view-activatable.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2010 Steve Frécinaux
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xed-view-activatable.h"
|
||||
#include "xed-view.h"
|
||||
|
||||
/**
|
||||
* SECTION:xed-view-activatable
|
||||
* @short_description: Interface for activatable extensions on views
|
||||
* @see_also: #PeasExtensionSet
|
||||
*
|
||||
* #XedViewActivatable is an interface which should be implemented by
|
||||
* extensions that should be activated on a xed view.
|
||||
**/
|
||||
G_DEFINE_INTERFACE(XedViewActivatable, xed_view_activatable, G_TYPE_OBJECT)
|
||||
|
||||
void
|
||||
xed_view_activatable_default_init (XedViewActivatableInterface *iface)
|
||||
{
|
||||
/**
|
||||
* XedViewActivatable:view:
|
||||
*
|
||||
* The window property contains the xed window for this
|
||||
* #XedViewActivatable instance.
|
||||
*/
|
||||
g_object_interface_install_property (iface,
|
||||
g_param_spec_object ("view",
|
||||
"view",
|
||||
"A xed view",
|
||||
XED_TYPE_VIEW,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_view_activatable_activate:
|
||||
* @activatable: A #XedViewActivatable.
|
||||
*
|
||||
* Activates the extension on the window property.
|
||||
*/
|
||||
void
|
||||
xed_view_activatable_activate (XedViewActivatable *activatable)
|
||||
{
|
||||
XedViewActivatableInterface *iface;
|
||||
|
||||
g_return_if_fail (XED_IS_VIEW_ACTIVATABLE (activatable));
|
||||
|
||||
iface = XED_VIEW_ACTIVATABLE_GET_IFACE (activatable);
|
||||
if (iface->activate != NULL)
|
||||
{
|
||||
iface->activate (activatable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_view_activatable_deactivate:
|
||||
* @activatable: A #XedViewActivatable.
|
||||
*
|
||||
* Deactivates the extension on the window property.
|
||||
*/
|
||||
void
|
||||
xed_view_activatable_deactivate (XedViewActivatable *activatable)
|
||||
{
|
||||
XedViewActivatableInterface *iface;
|
||||
|
||||
g_return_if_fail (XED_IS_VIEW_ACTIVATABLE (activatable));
|
||||
|
||||
iface = XED_VIEW_ACTIVATABLE_GET_IFACE (activatable);
|
||||
if (iface->deactivate != NULL)
|
||||
{
|
||||
iface->deactivate (activatable);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* xed-view-activatable.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2010 - Steve Frécinaux
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __XED_VIEW_ACTIVATABLE_H__
|
||||
#define __XED_VIEW_ACTIVATABLE_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Type checking and casting macros
|
||||
*/
|
||||
#define XED_TYPE_VIEW_ACTIVATABLE (xed_view_activatable_get_type ())
|
||||
#define XED_VIEW_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_VIEW_ACTIVATABLE, XedViewActivatable))
|
||||
#define XED_VIEW_ACTIVATABLE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XED_TYPE_VIEW_ACTIVATABLE, XedViewActivatableInterface))
|
||||
#define XED_IS_VIEW_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_VIEW_ACTIVATABLE))
|
||||
#define XED_VIEW_ACTIVATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), XED_TYPE_VIEW_ACTIVATABLE, XedViewActivatableInterface))
|
||||
|
||||
typedef struct _XedViewActivatable XedViewActivatable; /* dummy typedef */
|
||||
typedef struct _XedViewActivatableInterface XedViewActivatableInterface;
|
||||
|
||||
struct _XedViewActivatableInterface
|
||||
{
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/* Virtual public methods */
|
||||
void (*activate) (XedViewActivatable *activatable);
|
||||
void (*deactivate) (XedViewActivatable *activatable);
|
||||
};
|
||||
|
||||
/*
|
||||
* Public methods
|
||||
*/
|
||||
GType xed_view_activatable_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void xed_view_activatable_activate (XedViewActivatable *activatable);
|
||||
void xed_view_activatable_deactivate (XedViewActivatable *activatable);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XED_VIEW_ACTIVATABLE_H__ */
|
|
@ -6,9 +6,12 @@
|
|||
#include <stdlib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <libpeas/peas-extension-set.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "xed-view.h"
|
||||
#include "xed-view-activatable.h"
|
||||
#include "xed-plugins-engine.h"
|
||||
#include "xed-debug.h"
|
||||
#include "xed-prefs-manager.h"
|
||||
#include "xed-prefs-manager-app.h"
|
||||
|
@ -34,10 +37,13 @@ struct _XedViewPrivate
|
|||
guint search_entry_changed_id;
|
||||
gboolean disable_popdown;
|
||||
GtkTextBuffer *current_buffer;
|
||||
PeasExtensionSet *extensions;
|
||||
guint view_realized : 1;
|
||||
};
|
||||
|
||||
static void xed_view_dispose (GObject *object);
|
||||
static void xed_view_finalize (GObject *object);
|
||||
static void xed_view_realize (GtkWidget *widget);
|
||||
static gint xed_view_focus_out (GtkWidget *widget, GdkEventFocus *event);
|
||||
static gboolean xed_view_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint timestamp);
|
||||
static void xed_view_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y,
|
||||
|
@ -107,6 +113,7 @@ xed_view_class_init (XedViewClass *klass)
|
|||
widget_class->drag_data_received = xed_view_drag_data_received;
|
||||
widget_class->drag_drop = xed_view_drag_drop;
|
||||
widget_class->button_press_event = xed_view_button_press_event;
|
||||
widget_class->realize = xed_view_realize;
|
||||
klass->start_interactive_goto_line = start_interactive_goto_line;
|
||||
|
||||
text_view_class->delete_from_cursor = xed_view_delete_from_cursor;
|
||||
|
@ -152,6 +159,24 @@ current_buffer_removed (XedView *view)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
extension_added (PeasExtensionSet *extensions,
|
||||
PeasPluginInfo *info,
|
||||
PeasExtension *exten,
|
||||
XedView *view)
|
||||
{
|
||||
peas_extension_call (exten, "activate");
|
||||
}
|
||||
|
||||
static void
|
||||
extension_removed (PeasExtensionSet *extensions,
|
||||
PeasPluginInfo *info,
|
||||
PeasExtension *exten,
|
||||
XedView *view)
|
||||
{
|
||||
peas_extension_call (exten, "deactivate");
|
||||
}
|
||||
|
||||
static void
|
||||
on_notify_buffer_cb (XedView *view,
|
||||
GParamSpec *arg1,
|
||||
|
@ -223,6 +248,14 @@ xed_view_init (XedView *view)
|
|||
gtk_target_list_add_uri_targets (tl, TARGET_URI_LIST);
|
||||
}
|
||||
|
||||
view->priv->extensions = peas_extension_set_new (PEAS_ENGINE (xed_plugins_engine_get_default ()),
|
||||
XED_TYPE_VIEW_ACTIVATABLE, "view", view, NULL);
|
||||
|
||||
g_signal_connect (view->priv->extensions, "extension-added",
|
||||
G_CALLBACK (extension_added), view);
|
||||
g_signal_connect (view->priv->extensions, "extension-removed",
|
||||
G_CALLBACK (extension_removed), view);
|
||||
|
||||
/* Act on buffer change */
|
||||
g_signal_connect(view, "notify::buffer", G_CALLBACK (on_notify_buffer_cb), NULL);
|
||||
}
|
||||
|
@ -234,6 +267,12 @@ xed_view_dispose (GObject *object)
|
|||
|
||||
view = XED_VIEW(object);
|
||||
|
||||
if (view->priv->extensions != NULL)
|
||||
{
|
||||
g_object_unref (view->priv->extensions);
|
||||
view->priv->extensions = NULL;
|
||||
}
|
||||
|
||||
if (view->priv->search_window != NULL)
|
||||
{
|
||||
gtk_widget_destroy (view->priv->search_window);
|
||||
|
@ -261,7 +300,8 @@ xed_view_finalize (GObject *object)
|
|||
XedView *view;
|
||||
view = XED_VIEW(object);
|
||||
current_buffer_removed (view);
|
||||
(* G_OBJECT_CLASS (xed_view_parent_class)->finalize) (object);
|
||||
|
||||
G_OBJECT_CLASS (xed_view_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static gint
|
||||
|
@ -1141,6 +1181,20 @@ xed_view_button_press_event (GtkWidget *widget,
|
|||
return GTK_WIDGET_CLASS (xed_view_parent_class)->button_press_event (widget, event);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_view_realize (GtkWidget *widget)
|
||||
{
|
||||
XedView *view = XED_VIEW (widget);
|
||||
|
||||
if (!view->priv->view_realized)
|
||||
{
|
||||
peas_extension_set_call (view->priv->extensions, "activate");
|
||||
view->priv->view_realized = TRUE;
|
||||
}
|
||||
|
||||
GTK_WIDGET_CLASS (xed_view_parent_class)->realize (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
search_highlight_updated_cb (XedDocument *doc,
|
||||
GtkTextIter *start,
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* xed-window-activatable.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2010 Steve Frécinaux
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xed-window-activatable.h"
|
||||
#include "xed-window.h"
|
||||
|
||||
/**
|
||||
* SECTION:xed-window-activatable
|
||||
* @short_description: Interface for activatable extensions on windows
|
||||
* @see_also: #PeasExtensionSet
|
||||
*
|
||||
* #XedWindowActivatable is an interface which should be implemented by
|
||||
* extensions that should be activated on a xed main window.
|
||||
**/
|
||||
G_DEFINE_INTERFACE(XedWindowActivatable, xed_window_activatable, G_TYPE_OBJECT)
|
||||
|
||||
void
|
||||
xed_window_activatable_default_init (XedWindowActivatableInterface *iface)
|
||||
{
|
||||
/**
|
||||
* XedWindowActivatable:window:
|
||||
*
|
||||
* The window property contains the xed window for this
|
||||
* #XedWindowActivatable instance.
|
||||
*/
|
||||
g_object_interface_install_property (iface,
|
||||
g_param_spec_object ("window",
|
||||
"Window",
|
||||
"The xed window",
|
||||
XED_TYPE_WINDOW,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_window_activatable_activate:
|
||||
* @activatable: A #XedWindowActivatable.
|
||||
*
|
||||
* Activates the extension on the window property.
|
||||
*/
|
||||
void
|
||||
xed_window_activatable_activate (XedWindowActivatable *activatable)
|
||||
{
|
||||
XedWindowActivatableInterface *iface;
|
||||
|
||||
g_return_if_fail (XED_IS_WINDOW_ACTIVATABLE (activatable));
|
||||
|
||||
iface = XED_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
|
||||
if (iface->activate != NULL)
|
||||
{
|
||||
iface->activate (activatable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_window_activatable_deactivate:
|
||||
* @activatable: A #XedWindowActivatable.
|
||||
*
|
||||
* Deactivates the extension on the window property.
|
||||
*/
|
||||
void
|
||||
xed_window_activatable_deactivate (XedWindowActivatable *activatable)
|
||||
{
|
||||
XedWindowActivatableInterface *iface;
|
||||
|
||||
g_return_if_fail (XED_IS_WINDOW_ACTIVATABLE (activatable));
|
||||
|
||||
iface = XED_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
|
||||
if (iface->deactivate != NULL)
|
||||
{
|
||||
iface->deactivate (activatable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_window_activatable_update_state:
|
||||
* @activatable: A #XedWindowActivatable.
|
||||
*
|
||||
* Triggers an update of the extension insternal state to take into account
|
||||
* state changes in the window state, due to some event or user action.
|
||||
*/
|
||||
void
|
||||
xed_window_activatable_update_state (XedWindowActivatable *activatable)
|
||||
{
|
||||
XedWindowActivatableInterface *iface;
|
||||
|
||||
g_return_if_fail (XED_IS_WINDOW_ACTIVATABLE (activatable));
|
||||
|
||||
iface = XED_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
|
||||
if (iface->update_state != NULL)
|
||||
{
|
||||
iface->update_state (activatable);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* xed-window-activatable.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2010 - Steve Frécinaux
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __XED_WINDOW_ACTIVATABLE_H__
|
||||
#define __XED_WINDOW_ACTIVATABLE_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Type checking and casting macros
|
||||
*/
|
||||
#define XED_TYPE_WINDOW_ACTIVATABLE (xed_window_activatable_get_type ())
|
||||
#define XED_WINDOW_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_WINDOW_ACTIVATABLE, XedWindowActivatable))
|
||||
#define XED_WINDOW_ACTIVATABLE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XED_TYPE_WINDOW_ACTIVATABLE, XedWindowActivatableInterface))
|
||||
#define XED_IS_WINDOW_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_WINDOW_ACTIVATABLE))
|
||||
#define XED_WINDOW_ACTIVATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), XED_TYPE_WINDOW_ACTIVATABLE, XedWindowActivatableInterface))
|
||||
|
||||
typedef struct _XedWindowActivatable XedWindowActivatable; /* dummy typedef */
|
||||
typedef struct _XedWindowActivatableInterface XedWindowActivatableInterface;
|
||||
|
||||
struct _XedWindowActivatableInterface
|
||||
{
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/* Virtual public methods */
|
||||
void (*activate) (XedWindowActivatable *activatable);
|
||||
void (*deactivate) (XedWindowActivatable *activatable);
|
||||
void (*update_state) (XedWindowActivatable *activatable);
|
||||
};
|
||||
|
||||
/*
|
||||
* Public methods
|
||||
*/
|
||||
GType xed_window_activatable_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void xed_window_activatable_activate (XedWindowActivatable *activatable);
|
||||
void xed_window_activatable_deactivate (XedWindowActivatable *activatable);
|
||||
void xed_window_activatable_update_state (XedWindowActivatable *activatable);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XED_WINDOW_ACTIVATABLE_H__ */
|
|
@ -9,7 +9,6 @@
|
|||
#include <gio/gio.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtksourceview/gtksource.h>
|
||||
#include <libpeas/peas-activatable.h>
|
||||
#include <libpeas/peas-extension-set.h>
|
||||
|
||||
#include "xed-ui.h"
|
||||
|
@ -27,6 +26,7 @@
|
|||
#include "xed-panel.h"
|
||||
#include "xed-documents-panel.h"
|
||||
#include "xed-plugins-engine.h"
|
||||
#include "xed-window-activatable.h"
|
||||
#include "xed-enum-types.h"
|
||||
#include "xed-dirs.h"
|
||||
#include "xed-status-combo-box.h"
|
||||
|
@ -163,11 +163,13 @@ xed_window_dispose (GObject *object)
|
|||
if (!window->priv->dispose_has_run)
|
||||
{
|
||||
save_panes_state (window);
|
||||
|
||||
/* Note that unreffing the extension will automatically remove
|
||||
all extensions which in turn will deactivate the extension */
|
||||
g_object_unref (window->priv->extensions);
|
||||
|
||||
peas_engine_garbage_collect (PEAS_ENGINE (xed_plugins_engine_get_default ()));
|
||||
|
||||
window->priv->dispose_has_run = TRUE;
|
||||
}
|
||||
|
||||
|
@ -191,23 +193,10 @@ xed_window_dispose (GObject *object)
|
|||
window->priv->recents_handler_id = 0;
|
||||
}
|
||||
|
||||
if (window->priv->manager != NULL)
|
||||
{
|
||||
g_object_unref (window->priv->manager);
|
||||
window->priv->manager = NULL;
|
||||
}
|
||||
|
||||
if (window->priv->message_bus != NULL)
|
||||
{
|
||||
g_object_unref (window->priv->message_bus);
|
||||
window->priv->message_bus = NULL;
|
||||
}
|
||||
|
||||
if (window->priv->window_group != NULL)
|
||||
{
|
||||
g_object_unref (window->priv->window_group);
|
||||
window->priv->window_group = NULL;
|
||||
}
|
||||
g_clear_object (&window->priv->manager);
|
||||
g_clear_object (&window->priv->message_bus);
|
||||
g_clear_object (&window->priv->window_group);
|
||||
g_clear_object (&window->priv->default_location);
|
||||
|
||||
/* Now that there have broken some reference loops, force collection again. */
|
||||
peas_engine_garbage_collect (PEAS_ENGINE (xed_plugins_engine_get_default ()));
|
||||
|
@ -218,13 +207,8 @@ xed_window_dispose (GObject *object)
|
|||
static void
|
||||
xed_window_finalize (GObject *object)
|
||||
{
|
||||
XedWindow *window;
|
||||
xed_debug (DEBUG_WINDOW);
|
||||
window = XED_WINDOW(object);
|
||||
if (window->priv->default_location != NULL)
|
||||
{
|
||||
g_object_unref (window->priv->default_location);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (xed_window_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
@ -646,7 +630,7 @@ set_sensitivity_according_to_tab (XedWindow *window,
|
|||
|
||||
update_next_prev_doc_sensitivity (window, tab);
|
||||
|
||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2376,7 +2360,7 @@ sync_name (XedTab *tab,
|
|||
g_free (escaped_name);
|
||||
g_free (tip);
|
||||
|
||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||
}
|
||||
|
||||
static XedWindow *
|
||||
|
@ -2789,7 +2773,7 @@ selection_changed (XedDocument *doc,
|
|||
gtk_action_set_sensitive (action,
|
||||
state_normal && editable && gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER(doc)));
|
||||
|
||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2798,7 +2782,7 @@ sync_languages_menu (XedDocument *doc,
|
|||
XedWindow *window)
|
||||
{
|
||||
update_languages_menu (window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2808,7 +2792,7 @@ readonly_changed (XedDocument *doc,
|
|||
{
|
||||
set_sensitivity_according_to_tab (window, window->priv->active_tab);
|
||||
sync_name (window->priv->active_tab, NULL, window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2816,7 +2800,7 @@ editable_changed (XedView *view,
|
|||
GParamSpec *arg1,
|
||||
XedWindow *window)
|
||||
{
|
||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2964,7 +2948,7 @@ notebook_tab_removed (XedNotebook *notebook,
|
|||
|
||||
if (window->priv->num_tabs == 0)
|
||||
{
|
||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||
}
|
||||
|
||||
update_window_state (window);
|
||||
|
@ -3374,21 +3358,21 @@ add_notebook (XedWindow *window,
|
|||
}
|
||||
|
||||
static void
|
||||
on_extension_added (PeasExtensionSet *extensions,
|
||||
extension_added (PeasExtensionSet *extensions,
|
||||
PeasPluginInfo *info,
|
||||
PeasExtension *exten,
|
||||
XedWindow *window)
|
||||
{
|
||||
peas_extension_call (exten, "activate", window);
|
||||
peas_extension_call (exten, "activate");
|
||||
}
|
||||
|
||||
static void
|
||||
on_extension_removed (PeasExtensionSet *extensions,
|
||||
extension_removed (PeasExtensionSet *extensions,
|
||||
PeasPluginInfo *info,
|
||||
PeasExtension *exten,
|
||||
XedWindow *window)
|
||||
{
|
||||
peas_extension_call (exten, "deactivate", window);
|
||||
peas_extension_call (exten, "deactivate");
|
||||
|
||||
/* Ensure update of the ui manager, because we suspect it does something with expected static strings in the
|
||||
* type module (when unloaded the strings don't exist anymore, and the ui manager update in a idle func) */
|
||||
|
@ -3501,13 +3485,13 @@ xed_window_init (XedWindow *window)
|
|||
xed_debug_message (DEBUG_WINDOW, "Update plugins ui");
|
||||
|
||||
window->priv->extensions = peas_extension_set_new (PEAS_ENGINE (xed_plugins_engine_get_default ()),
|
||||
PEAS_TYPE_ACTIVATABLE, "object", window, NULL);
|
||||
XED_TYPE_WINDOW_ACTIVATABLE, "window", window, NULL);
|
||||
|
||||
g_signal_connect (window->priv->extensions, "extension-added", G_CALLBACK (extension_added), window);
|
||||
g_signal_connect (window->priv->extensions, "extension-removed", G_CALLBACK (extension_removed), window);
|
||||
|
||||
peas_extension_set_call (window->priv->extensions, "activate");
|
||||
|
||||
g_signal_connect (window->priv->extensions, "extension-added", G_CALLBACK (on_extension_added), window);
|
||||
g_signal_connect (window->priv->extensions, "extension-removed", G_CALLBACK (on_extension_removed), window);
|
||||
|
||||
/* set visibility of panes.
|
||||
* This needs to be done after plugins activatation */
|
||||
init_panels_visibility (window);
|
||||
|
|
Loading…
Reference in New Issue