New header mooeditor-private.h; new property MooEditor::focused-doc
This commit is contained in:
parent
4d2848c401
commit
e3c2711e87
@ -56,6 +56,7 @@ mooedit_noinst_headers = \
|
||||
mooeditdialogs.h \
|
||||
mooeditfileops.h \
|
||||
mooeditfiltersettings.h \
|
||||
mooeditor-private.h \
|
||||
mooeditprefs-glade.h \
|
||||
mooeditprogress-glade.h \
|
||||
mooeditsavemultiple-glade.h \
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "mooedit/mootextbuffer.h"
|
||||
#include "mooedit/mooeditprogress-glade.h"
|
||||
#include "mooedit/mooeditfiltersettings.h"
|
||||
#include "mooedit/mooeditor-private.h"
|
||||
#include "mooutils/moomarshals.h"
|
||||
#include "mooutils/moocompat.h"
|
||||
#include "mooutils/mooutils-gobject.h"
|
||||
@ -47,6 +48,10 @@ static void moo_edit_get_property (GObject *object,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static gboolean moo_edit_focus_in (GtkWidget *widget,
|
||||
GdkEventFocus *event);
|
||||
static gboolean moo_edit_focus_out (GtkWidget *widget,
|
||||
GdkEventFocus *event);
|
||||
static gboolean moo_edit_popup_menu (GtkWidget *widget);
|
||||
static gboolean moo_edit_drag_motion (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
@ -103,6 +108,8 @@ static void
|
||||
moo_edit_class_init (MooEditClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
MooTextViewClass *textview_class = MOO_TEXT_VIEW_CLASS (klass);
|
||||
|
||||
gobject_class->set_property = moo_edit_set_property;
|
||||
gobject_class->get_property = moo_edit_get_property;
|
||||
@ -110,10 +117,13 @@ moo_edit_class_init (MooEditClass *klass)
|
||||
gobject_class->finalize = moo_edit_finalize;
|
||||
gobject_class->dispose = moo_edit_dispose;
|
||||
|
||||
MOO_TEXT_VIEW_CLASS(klass)->line_mark_clicked = _moo_edit_line_mark_clicked;
|
||||
GTK_WIDGET_CLASS(klass)->popup_menu = moo_edit_popup_menu;
|
||||
GTK_WIDGET_CLASS(klass)->drag_motion = moo_edit_drag_motion;
|
||||
GTK_WIDGET_CLASS(klass)->drag_drop = moo_edit_drag_drop;
|
||||
widget_class->popup_menu = moo_edit_popup_menu;
|
||||
widget_class->drag_motion = moo_edit_drag_motion;
|
||||
widget_class->drag_drop = moo_edit_drag_drop;
|
||||
widget_class->focus_in_event = moo_edit_focus_in;
|
||||
widget_class->focus_out_event = moo_edit_focus_out;
|
||||
|
||||
textview_class->line_mark_clicked = _moo_edit_line_mark_clicked;
|
||||
|
||||
klass->filename_changed = moo_edit_filename_changed;
|
||||
klass->config_notify = moo_edit_config_notify;
|
||||
@ -570,6 +580,38 @@ moo_edit_get_property (GObject *object,
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
moo_edit_focus_in (GtkWidget *widget,
|
||||
GdkEventFocus *event)
|
||||
{
|
||||
gboolean retval = FALSE;
|
||||
MooEdit *doc = MOO_EDIT (widget);
|
||||
|
||||
_moo_editor_set_focused_doc (doc->priv->editor, doc);
|
||||
|
||||
if (GTK_WIDGET_CLASS(moo_edit_parent_class)->focus_in_event)
|
||||
retval = GTK_WIDGET_CLASS(moo_edit_parent_class)->focus_in_event (widget, event);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
moo_edit_focus_out (GtkWidget *widget,
|
||||
GdkEventFocus *event)
|
||||
{
|
||||
gboolean retval = FALSE;
|
||||
MooEdit *doc = MOO_EDIT (widget);
|
||||
|
||||
_moo_editor_unset_focused_doc (doc->priv->editor, doc);
|
||||
|
||||
if (GTK_WIDGET_CLASS(moo_edit_parent_class)->focus_out_event)
|
||||
retval = GTK_WIDGET_CLASS(moo_edit_parent_class)->focus_out_event (widget, event);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
GType
|
||||
moo_edit_file_info_get_type (void)
|
||||
{
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#define MOOEDIT_COMPILATION
|
||||
#include "mooedit/mooedit-private.h"
|
||||
#include "mooedit/mooeditor-private.h"
|
||||
#include "mooedit/mooeditfileops.h"
|
||||
#include "mooedit/mooeditdialogs.h"
|
||||
#include "mooedit/mootextbuffer.h"
|
||||
|
57
moo/mooedit/mooeditor-private.h
Normal file
57
moo/mooedit/mooeditor-private.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* mooeditor-private.h
|
||||
*
|
||||
* Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* See COPYING file that comes with this distribution.
|
||||
*/
|
||||
|
||||
#ifndef MOOEDIT_COMPILATION
|
||||
#error "This file may not be used directly"
|
||||
#endif
|
||||
|
||||
#ifndef __MOO_EDITOR_PRIVATE_H__
|
||||
#define __MOO_EDITOR_PRIVATE_H__
|
||||
|
||||
#include "mooedit/mooeditor.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
void _moo_edit_window_insert_doc (MooEditWindow *window,
|
||||
MooEdit *doc,
|
||||
int position);
|
||||
void _moo_edit_window_remove_doc (MooEditWindow *window,
|
||||
MooEdit *doc);
|
||||
|
||||
void _moo_editor_set_focused_doc (MooEditor *editor,
|
||||
MooEdit *doc);
|
||||
void _moo_editor_unset_focused_doc (MooEditor *editor,
|
||||
MooEdit *doc);
|
||||
|
||||
gpointer _moo_editor_get_file_watch (MooEditor *editor);
|
||||
void _moo_editor_reload (MooEditor *editor,
|
||||
MooEdit *doc,
|
||||
GError **error);
|
||||
gboolean _moo_editor_save (MooEditor *editor,
|
||||
MooEdit *doc,
|
||||
GError **error);
|
||||
gboolean _moo_editor_save_as (MooEditor *editor,
|
||||
MooEdit *doc,
|
||||
const char *filename,
|
||||
const char *encoding,
|
||||
GError **error);
|
||||
void _moo_editor_post_message (MooEditor *editor,
|
||||
GQuark domain,
|
||||
const char *message);
|
||||
void _moo_editor_apply_prefs (MooEditor *editor);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MOO_EDITOR_PRIVATE_H__ */
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
#define MOOEDIT_COMPILATION
|
||||
#include "mooedit/mooeditor.h"
|
||||
#include "mooedit/mooeditor-private.h"
|
||||
#include "mooedit/mooeditdialogs.h"
|
||||
#include "mooedit/mooeditfileops.h"
|
||||
#include "mooedit/mooplugin.h"
|
||||
@ -120,6 +120,8 @@ struct _MooEditorPrivate {
|
||||
gboolean allow_empty_window;
|
||||
gboolean single_window;
|
||||
|
||||
MooEdit *focused_doc;
|
||||
|
||||
gboolean save_backups;
|
||||
gboolean strip_whitespace;
|
||||
gboolean silent;
|
||||
@ -154,7 +156,8 @@ enum {
|
||||
PROP_STRIP_WHITESPACE,
|
||||
PROP_SILENT,
|
||||
PROP_AUTOSAVE,
|
||||
PROP_AUTOSAVE_INTERVAL
|
||||
PROP_AUTOSAVE_INTERVAL,
|
||||
PROP_FOCUSED_DOC
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -249,6 +252,14 @@ moo_editor_class_init (MooEditorClass *klass)
|
||||
1, 1000, 5,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_FOCUSED_DOC,
|
||||
g_param_spec_object ("focused-doc",
|
||||
"focused-doc",
|
||||
"focused-doc",
|
||||
MOO_TYPE_EDIT,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
signals[ALL_WINDOWS_CLOSED] =
|
||||
_moo_signal_new_cb ("all-windows-closed",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
@ -408,6 +419,9 @@ moo_editor_get_property (GObject *object,
|
||||
g_value_set_uint (value, editor->priv->autosave_interval);
|
||||
break;
|
||||
|
||||
case PROP_FOCUSED_DOC:
|
||||
g_value_set_object (value, editor->priv->focused_doc);
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -465,6 +479,37 @@ moo_editor_finalize (GObject *object)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_moo_editor_set_focused_doc (MooEditor *editor,
|
||||
MooEdit *doc)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_EDITOR (editor));
|
||||
g_return_if_fail (MOO_IS_EDIT (doc));
|
||||
g_return_if_fail (doc->priv->editor == editor);
|
||||
|
||||
if (editor->priv->focused_doc != doc)
|
||||
{
|
||||
editor->priv->focused_doc = doc;
|
||||
g_object_notify (G_OBJECT (editor), "focused-doc");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_moo_editor_unset_focused_doc (MooEditor *editor,
|
||||
MooEdit *doc)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_EDITOR (editor));
|
||||
g_return_if_fail (MOO_IS_EDIT (doc));
|
||||
g_return_if_fail (doc->priv->editor == editor);
|
||||
|
||||
if (editor->priv->focused_doc == doc)
|
||||
{
|
||||
editor->priv->focused_doc = NULL;
|
||||
g_object_notify (G_OBJECT (editor), "focused-doc");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static Message *
|
||||
message_new (GQuark domain,
|
||||
const char *text)
|
||||
|
@ -141,31 +141,6 @@ gboolean moo_editor_save_copy (MooEditor *editor,
|
||||
const char *encoding,
|
||||
GError **error);
|
||||
|
||||
#ifdef MOOEDIT_COMPILATION
|
||||
void _moo_edit_window_insert_doc (MooEditWindow *window,
|
||||
MooEdit *doc,
|
||||
int position);
|
||||
void _moo_edit_window_remove_doc (MooEditWindow *window,
|
||||
MooEdit *doc);
|
||||
|
||||
gpointer _moo_editor_get_file_watch (MooEditor *editor);
|
||||
void _moo_editor_reload (MooEditor *editor,
|
||||
MooEdit *doc,
|
||||
GError **error);
|
||||
gboolean _moo_editor_save (MooEditor *editor,
|
||||
MooEdit *doc,
|
||||
GError **error);
|
||||
gboolean _moo_editor_save_as (MooEditor *editor,
|
||||
MooEdit *doc,
|
||||
const char *filename,
|
||||
const char *encoding,
|
||||
GError **error);
|
||||
void _moo_editor_post_message (MooEditor *editor,
|
||||
GQuark domain,
|
||||
const char *message);
|
||||
void _moo_editor_apply_prefs (MooEditor *editor);
|
||||
#endif /* MOOEDIT_COMPILATION */
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#define MOOEDIT_COMPILATION
|
||||
#include "mooedit/mooedit-private.h"
|
||||
#include "mooedit/mooeditor-private.h"
|
||||
#include "mooedit/mooeditprefs.h"
|
||||
#include "mooedit/mooeditprefs-glade.h"
|
||||
#include "mooedit/moolangmgr.h"
|
||||
|
@ -18,8 +18,8 @@
|
||||
#define MOOEDIT_COMPILATION
|
||||
#include "mooedit/statusbar-glade.h"
|
||||
#include "mooedit/mooedit-private.h"
|
||||
#include "mooedit/mooeditor-private.h"
|
||||
#include "mooedit/moolang.h"
|
||||
#include "mooedit/mooeditor.h"
|
||||
#include "mooedit/mootextbuffer.h"
|
||||
#include "mooedit/mooeditprefs.h"
|
||||
#include "mooedit/mooplugin.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user