26 Commits
1.0.6 ... 1.2.0

Author SHA1 Message Date
Clement Lefebvre
111fc4946b 1.2.0 2016-11-02 15:56:01 +00:00
Clement Lefebvre
4d48da0e6a Update pot file 2016-11-02 15:50:29 +00:00
Clement Lefebvre
a6fd36b004 Merge pull request #44 from JosephMcc/documents-panel
Documents panel
2016-10-07 11:22:40 +01:00
Clement Lefebvre
4e1a63347a Merge pull request #43 from JosephMcc/notebook-button
xed-close-button: Convert to using a symbolic icon
2016-10-07 11:22:32 +01:00
Clement Lefebvre
cfd631779e Merge pull request #42 from JosephMcc/fullscreen-tabs
ui: Don't hide the main notebook tabs in fullscreen
2016-10-07 11:22:22 +01:00
Clement Lefebvre
9bf99cc84f Merge pull request #41 from JosephMcc/toolbar-revamp1
toolbar: Revamp the main toolbar style
2016-10-07 11:22:16 +01:00
JosephMcc
cadb9c72c6 filebrowser-plugin: Convert most icons to symbolic icons 2016-10-06 13:24:36 -07:00
JosephMcc
a187bb016d filbrowser-plugin: Convert indentation to spaces and remove extra whitespace 2016-10-06 12:17:48 -07:00
JosephMcc
1e9f14ebee xed-close-button: Convert to using a symbolic icon
Also remove some use of deprecated GtkRcStyle
2016-10-06 11:39:05 -07:00
JosephMcc
14c5bc1a99 ui: Don't hide the main notebook tabs in fullscreen
Not sure why this was being done but keep the open tabs visible when swithcing
to fullscreen so you can still access all open tabs
2016-10-06 11:20:12 -07:00
JosephMcc
2ecb36178a prefs: Remove now unused toolbar style prefs
We no longer set a toolbar button style so remove some of the left over code for
handling it.
2016-10-06 10:33:53 -07:00
JosephMcc
46c8d8adc8 ui: Convert the remaining actions to use symbolic icons
With the toolbar icons converted to symbolic icons we now have a mix of symbolic
and non-symbolic icons in the menu since they share the same GtkAction's.
Convert the remaining actions along with a couple that are placed in the menu
by plugins to use symbolic style icons.
2016-10-05 12:20:30 -07:00
JosephMcc
94dae95b95 toolbar: Revamp the main toolbar style
Get rid of the text and switch all icons to slightly smaller symoblic icons.
This will allow it to behave much better with dark gtk themes. Replace the
recent documents button with a button for file open. Changing the style of
the buttons on the main toolbar also effects the fullscreen toolbar so
update this as well to use a matching layout.
2016-10-04 11:32:30 -07:00
Clement Lefebvre
bafaeaca98 Default Settings: Changed line width to 120 chars and enabled "insert-spaces".
This follows the Developer Guidelines.
2016-09-25 11:39:23 +01:00
Clement Lefebvre
26d0ac85a0 Reformated code to conform to Mint coding style
As discussed within the team.
2016-09-21 13:44:19 +01:00
Clement Lefebvre
f4236351ae Give Xed a Sublime-like searchbar
The search dialog is replaced with a searchbar similar to the one used in Sublime.

The following features are implicit and therefore removed:
  - "incremental search"
  - "remove highlights"
  - "parse \n characters"

Code style is applied to impacted files (should have been done in a separate commit but it was being discussed during WIP and the new committed code followed neither the new style nor the old).
2016-09-20 16:32:54 +01:00
Clement Lefebvre
c8f0c14add Toolbar: Don't emphasize toolbar items (save, open, undo) 2016-08-19 10:44:43 +02:00
Clement Lefebvre
c8ef96a94d When running as root, add an infobar to warn about Elevated Privileges 2016-08-18 20:09:35 +01:00
Clement Lefebvre
6cb2e56365 Revert "Fixed some UI elements not localized"
This reverts commit 2dbb1bea6b.
2016-08-18 14:42:01 +02:00
Clement Lefebvre
459311abd8 Revert "Makepot"
This reverts commit f38949ed09.
2016-08-18 14:41:58 +02:00
Clement Lefebvre
f38949ed09 Makepot 2016-08-18 14:11:04 +02:00
Clement Lefebvre
2dbb1bea6b Fixed some UI elements not localized 2016-08-17 17:28:36 +02:00
Clement Lefebvre
817f782040 Add "notepad" to the list of menu item keywords 2016-08-17 13:04:51 +02:00
Clement Lefebvre
3b10e7f2d0 Fixed NEWS files 2016-08-17 13:03:34 +02:00
Clement Lefebvre
f9d4e0cb1d Merge pull request #26 from JosephMcc/configure-fix1
configure: Don't require passing --with-gtk=3.0 to build
2016-07-22 10:37:52 +02:00
JosephMcc
ff223deb29 configure: Don't require passing --with-gtk=3.0 to build
Xed is a gtk3 application. We don't need to default to trying to build with gtk2

Fixes https://github.com/linuxmint/xed/issues/23
2016-07-20 00:50:32 -07:00
34 changed files with 7527 additions and 9990 deletions

69
NEWS
View File

@@ -1,69 +0,0 @@
xed 1.13.0
============
xed 1.12.1
============
* Add --without-matedesktop option to enable build without
dependency on libmate-desktop
xed 1.12.0
============
* Add --enable-tests option to enable/disable running tests
during the build
* Add plugin to strip trailing spaces on saving
* Bring back active plugins listing in bugreport script
* Drop support for win32/osx and checkupdate plugin
* Retrieve strings directly from gschema (requires intltool 0.50.1)
* Capitalize Xed in window titles and desktop file
* GTK3. fix print-preview
* Some annotation fixes
* Some minor fixes and cleanups
xed 1.10.2
============
* Window title: display full path to files on mounted drives
* Close confirmation dialog: make text unfocusable
* Quickopen plugin: fix filebrowser plugin support
* Time plugin: GTK+3 fix
* Multiple help fixes
xed 1.10.1
============
* Fix gschema translations
* GTK3 fixes
* Fix man page formatting
* Build system fixes
xed 1.10.0
============
* Use MateAboutDialog from libmate-desktop
xed 1.8.1
===========
* Fix go to line crash
* Translations updates
xed 1.8.0
===========
* Add GTK3 support
* Use yelp-tools instead of mate-doc-utils
* Move user plugin dir from config_dir to data_dir. Plugins should have
never been installed in the config dir as they are not part of the
configuration. This means user will need to move the plugins directory
from: $HOME/.config/xed/ to $HOME/.local/share/xed/.
xed 1.5.0
===========
* Migration to GSettings and drop mateconf
(All code is migrated, except pythonconsole plugin. The plugin works,
except you cant configure it; the configurable things were command
and error colors; this will be fixed migrating the plugin to Gir
instead of python-gtk)

69
NEWS.PLUMA Normal file
View File

@@ -0,0 +1,69 @@
xed 1.13.0
============
xed 1.12.1
============
* Add --without-matedesktop option to enable build without
dependency on libmate-desktop
xed 1.12.0
============
* Add --enable-tests option to enable/disable running tests
during the build
* Add plugin to strip trailing spaces on saving
* Bring back active plugins listing in bugreport script
* Drop support for win32/osx and checkupdate plugin
* Retrieve strings directly from gschema (requires intltool 0.50.1)
* Capitalize Xed in window titles and desktop file
* GTK3. fix print-preview
* Some annotation fixes
* Some minor fixes and cleanups
xed 1.10.2
============
* Window title: display full path to files on mounted drives
* Close confirmation dialog: make text unfocusable
* Quickopen plugin: fix filebrowser plugin support
* Time plugin: GTK+3 fix
* Multiple help fixes
xed 1.10.1
============
* Fix gschema translations
* GTK3 fixes
* Fix man page formatting
* Build system fixes
xed 1.10.0
============
* Use MateAboutDialog from libmate-desktop
xed 1.8.1
===========
* Fix go to line crash
* Translations updates
xed 1.8.0
===========
* Add GTK3 support
* Use yelp-tools instead of mate-doc-utils
* Move user plugin dir from config_dir to data_dir. Plugins should have
never been installed in the config dir as they are not part of the
configuration. This means user will need to move the plugins directory
from: $HOME/.config/xed/ to $HOME/.local/share/xed/.
xed 1.5.0
===========
* Migration to GSettings and drop mateconf
(All code is migrated, except pythonconsole plugin. The plugin works,
except you cant configure it; the configurable things were command
and error colors; this will be fixed migrating the plugin to Gir
instead of python-gtk)

View File

@@ -3,8 +3,8 @@ dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.63.2)
m4_define(xed_major_version, 1)
m4_define(xed_minor_version, 0)
m4_define(xed_micro_version, 6)
m4_define(xed_minor_version, 2)
m4_define(xed_micro_version, 0)
m4_define(xed_version, xed_major_version.xed_minor_version.xed_micro_version)
AC_INIT([xed], [xed_version],
@@ -148,26 +148,6 @@ dnl ================================================================
dnl Start of pkg-config checks
dnl ================================================================
AC_MSG_CHECKING([which gtk+ version to compile against])
AC_ARG_WITH([gtk],
[AS_HELP_STRING([--with-gtk=2.0|3.0],[which gtk+ version to compile against (default: 2.0)])],
[case "$with_gtk" in
2.0|3.0) ;;
*) AC_MSG_ERROR([invalid gtk version specified]) ;;
esac],
[with_gtk=2.0])
AC_MSG_RESULT([$with_gtk])
case "$with_gtk" in
2.0) GTK_API_VERSION=2.0
GTK_REQUIRED=2.24.0
;;
3.0) GTK_API_VERSION=3.0
GTK_REQUIRED=3.0.0
;;
esac
AC_SUBST(GTK_API_VERSION)
PKG_CHECK_MODULES(GMODULE,gmodule-2.0,[GMODULE_ADD="gmodule-2.0"],[GMODULE_ADD=""])
PKG_CHECK_MODULES(XED, [
libxml-2.0 >= 2.5.0
@@ -175,8 +155,8 @@ PKG_CHECK_MODULES(XED, [
$GMODULE_ADD
gthread-2.0 >= 2.13.0
gio-2.0 >= 2.26.0
gtk+-$GTK_API_VERSION >= $GTK_REQUIRED
gtksourceview-$GTK_API_VERSION >= 2.9.7
gtk+-3.0 >= 3.10.0
gtksourceview-3.0 >= 2.9.7
])
PKG_CHECK_MODULES(X11, [x11])
@@ -402,7 +382,6 @@ Configuration:
Source code location: ${srcdir}
Compiler: ${CC}
GTK API version: $GTK_API_VERSION
Python Plugins Support: $enable_python
Spell Plugin enabled: $enable_enchant
Gvfs metadata enabled: $enable_gvfs_metadata

View File

@@ -52,7 +52,7 @@
<description>Specifies the number of spaces that should be displayed instead of Tab characters.</description>
</key>
<key name="insert-spaces" type="b">
<default>false</default>
<default>true</default>
<summary>Insert spaces</summary>
<description>Whether xed should insert spaces instead of tabs.</description>
</key>
@@ -82,7 +82,7 @@
<description>Whether xed should display the right margin in the editing area.</description>
</key>
<key name="right-margin-position" type="i">
<default>80</default>
<default>120</default>
<summary>Right Margin Position</summary>
<description>Specifies the position of the right margin.</description>
</key>
@@ -111,11 +111,6 @@
<summary>Toolbar is Visible</summary>
<description>Whether the toolbar should be visible in editing windows.</description>
</key>
<key name="toolbar-buttons-style" type="s">
<default>'@TOOLBAR_STYLE@'</default>
<summary>Toolbar Buttons Style</summary>
<description>Style for the toolbar buttons. Possible values are "XED_TOOLBAR_SYSTEM" to use the system's default style, "XED_TOOLBAR_ICONS" to display icons only, "XED_TOOLBAR_ICONS_AND_TEXT" to display both icons and text, and "XED_TOOLBAR_ICONS_BOTH_HORIZ" to display prioritized text beside icons. Note that the values are case-sensitive, so make sure they appear exactly as mentioned here.</description>
</key>
<key name="statusbar-visible" type="b">
<default>true</default>
<summary>Status Bar is Visible</summary>

View File

@@ -8,5 +8,5 @@ StartupNotify=true
MimeType=text/plain;
Icon=accessories-text-editor
Categories=GTK;Utility;TextEditor;
Keywords=text;editor;tabs;highlighting;code;multiple;files;pluggable;
Keywords=text;editor;tabs;highlighting;code;multiple;files;pluggable;notepad;
X-MATE-DocPath=xed/xed.xml

32
debian/changelog vendored
View File

@@ -1,3 +1,35 @@
xed (1.2.0) serena; urgency=medium
[ JosephMcc ]
* configure: Don't require passing --with-gtk=3.0 to build
[ Clement Lefebvre ]
* Fixed NEWS files
* Add "notepad" to the list of menu item keywords
* Fixed some UI elements not localized
* Makepot
* Revert "Makepot"
* Revert "Fixed some UI elements not localized"
* When running as root, add an infobar to warn about Elevated Privileges
* Toolbar: Don't emphasize toolbar items (save, open, undo)
* Give Xed a Sublime-like searchbar
* Reformated code to conform to Mint coding style
* Default Settings: Changed line width to 120 chars and enabled "insert-spaces".
[ JosephMcc ]
* toolbar: Revamp the main toolbar style
* ui: Convert the remaining actions to use symbolic icons
* prefs: Remove now unused toolbar style prefs
* ui: Don't hide the main notebook tabs in fullscreen
* xed-close-button: Convert to using a symbolic icon
* filbrowser-plugin: Convert indentation to spaces and remove extra whitespace
* filebrowser-plugin: Convert most icons to symbolic icons
[ Clement Lefebvre ]
* Update pot file
-- Clement Lefebvre <root@linuxmint.com> Wed, 02 Nov 2016 15:55:04 +0000
xed (1.0.6) sarah; urgency=medium
[ Michael Webster ]

View File

@@ -404,7 +404,7 @@ on_selection_changed_cb (GtkTreeSelection *selection,
static GtkActionEntry extra_actions[] =
{
{"SetActiveRoot", GTK_STOCK_JUMP_TO, N_("_Set root to active document"),
{"SetActiveRoot", "go-jump-symbolic", N_("_Set root to active document"),
NULL,
N_("Set the root to the active document location"),
G_CALLBACK (on_action_set_active_root)}

File diff suppressed because it is too large Load Diff

View File

@@ -84,7 +84,7 @@ static void sort_real (SortDialog *dialog);
static const GtkActionEntry action_entries[] =
{
{ "Sort",
GTK_STOCK_SORT_ASCENDING,
"view-sort-ascending-symbolic",
N_("S_ort..."),
NULL,
N_("Sort the current document or selection"),

View File

@@ -88,7 +88,7 @@ static void auto_spell_cb (GtkAction *action, XedWindow *window);
static const GtkActionEntry action_entries[] =
{
{ "CheckSpell",
GTK_STOCK_SPELL_CHECK,
"tools-check-spelling-symbolic",
N_("_Check Spelling..."),
"<shift>F7",
N_("Check the current document for incorrect spelling"),

View File

@@ -9,8 +9,6 @@ xed/dialogs/xed-encodings-dialog.c
[type: gettext/glade]xed/dialogs/xed-encodings-dialog.ui
xed/dialogs/xed-preferences-dialog.c
[type: gettext/glade]xed/dialogs/xed-preferences-dialog.ui
xed/dialogs/xed-search-dialog.c
[type: gettext/glade]xed/dialogs/xed-search-dialog.ui
xed/xed.c
xed/xed-app.c
xed/xed-commands-file.c
@@ -34,8 +32,10 @@ xed/xed-plugins-engine.c
xed/xed-prefs-manager.c
xed/xed-print-job.c
[type: gettext/glade]xed/xed-print-preferences.ui
[type: gettext/glade]xed/xed-searchbar.ui
xed/xed-print-preview.c
xed/xed-smart-charset-converter.c
xed/xed-searchbar.c
xed/xed-statusbar.c
xed/xed-style-scheme-manager.c
xed/xed-tab.c

File diff suppressed because it is too large Load Diff

View File

@@ -86,6 +86,7 @@ INST_H_FILES = \
xed-prefs-manager-app.h \
xed-prefs-manager.h \
xed-progress-message-area.h \
xed-searchbar.h \
xed-statusbar.h \
xed-status-combo-box.h \
xed-tab.h \
@@ -152,6 +153,7 @@ libxed_la_SOURCES = \
xed-progress-message-area.c \
xed-session.c \
xed-smart-charset-converter.c \
xed-searchbar.c \
xed-statusbar.c \
xed-status-combo-box.c \
xed-style-scheme-manager.c \
@@ -184,6 +186,7 @@ xed-marshal.c: xed-marshal.list $(GLIB_GENMARSHAL)
uidir = $(datadir)/xed/ui/
ui_DATA = \
xed-ui.xml \
xed-searchbar.ui \
xed-print-preferences.ui
EXTRA_DIST = \

View File

@@ -17,14 +17,11 @@ libdialogs_la_SOURCES = \
xed-close-confirmation-dialog.c \
xed-close-confirmation-dialog.h \
xed-encodings-dialog.c \
xed-encodings-dialog.h \
xed-search-dialog.h \
xed-search-dialog.c
xed-encodings-dialog.h
ui_DATA = \
xed-encodings-dialog.ui \
xed-preferences-dialog.ui \
xed-search-dialog.ui
xed-preferences-dialog.ui
EXTRA_DIST = $(ui_DATA)

View File

@@ -1,654 +0,0 @@
/*
* xed-search-dialog.c
* This file is part of xed
*
* Copyright (C) 2005 Paolo Maggi
*
* 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.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Modified by the xed Team, 2005. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "xed-search-dialog.h"
#include "xed-history-entry.h"
#include "xed-utils.h"
#include "xed-marshal.h"
#include "xed-dirs.h"
#define XED_SEARCH_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
XED_TYPE_SEARCH_DIALOG, \
XedSearchDialogPrivate))
/* Signals */
enum
{
SHOW_REPLACE,
LAST_SIGNAL
};
static guint dialog_signals [LAST_SIGNAL] = { 0 };
struct _XedSearchDialogPrivate
{
gboolean show_replace;
GtkWidget *table;
GtkWidget *search_label;
GtkWidget *search_entry;
GtkWidget *search_text_entry;
GtkWidget *replace_label;
GtkWidget *replace_entry;
GtkWidget *replace_text_entry;
GtkWidget *match_case_checkbutton;
GtkWidget *entire_word_checkbutton;
GtkWidget *backwards_checkbutton;
GtkWidget *wrap_around_checkbutton;
GtkWidget *parse_escapes_checkbutton;
GtkWidget *find_button;
GtkWidget *replace_button;
GtkWidget *replace_all_button;
gboolean ui_error;
};
G_DEFINE_TYPE(XedSearchDialog, xed_search_dialog, GTK_TYPE_DIALOG)
enum
{
PROP_0,
PROP_SHOW_REPLACE
};
static void
xed_search_dialog_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
XedSearchDialog *dlg = XED_SEARCH_DIALOG (object);
switch (prop_id)
{
case PROP_SHOW_REPLACE:
xed_search_dialog_set_show_replace (dlg,
g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
xed_search_dialog_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
XedSearchDialog *dlg = XED_SEARCH_DIALOG (object);
switch (prop_id)
{
case PROP_SHOW_REPLACE:
g_value_set_boolean (value, dlg->priv->show_replace);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
void
xed_search_dialog_present_with_time (XedSearchDialog *dialog,
guint32 timestamp)
{
g_return_if_fail (XED_SEARCH_DIALOG (dialog));
gtk_window_present_with_time (GTK_WINDOW (dialog), timestamp);
gtk_widget_grab_focus (dialog->priv->search_text_entry);
}
static gboolean
show_replace (XedSearchDialog *dlg)
{
xed_search_dialog_set_show_replace (dlg, TRUE);
return TRUE;
}
static void
xed_search_dialog_class_init (XedSearchDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkBindingSet *binding_set;
object_class->set_property = xed_search_dialog_set_property;
object_class->get_property = xed_search_dialog_get_property;
klass->show_replace = show_replace;
dialog_signals[SHOW_REPLACE] =
g_signal_new ("show_replace",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (XedSearchDialogClass, show_replace),
NULL, NULL,
xed_marshal_BOOLEAN__NONE,
G_TYPE_BOOLEAN, 0);
g_object_class_install_property (object_class, PROP_SHOW_REPLACE,
g_param_spec_boolean ("show-replace",
"Show Replace",
"Whether the dialog is used for Search&Replace",
FALSE,
G_PARAM_READWRITE));
g_type_class_add_private (object_class, sizeof (XedSearchDialogPrivate));
binding_set = gtk_binding_set_by_class (klass);
/* Note: we cannot use the keyval/modifier associated with the
* GTK_STOCK_FIND_AND_REPLACE stock item since MATE HIG suggests Ctrl+h
* for Replace while gtk+ uses Ctrl+r */
gtk_binding_entry_add_signal (binding_set, GDK_KEY_h, GDK_CONTROL_MASK, "show_replace", 0);
gtk_binding_entry_add_signal (binding_set, GDK_KEY_H, GDK_CONTROL_MASK, "show_replace", 0);
}
static void
insert_text_handler (GtkEditable *editable,
const gchar *text,
gint length,
gint *position,
gpointer data)
{
static gboolean insert_text = FALSE;
gchar *escaped_text;
gint new_len;
/* To avoid recursive behavior */
if (insert_text)
return;
escaped_text = xed_utils_escape_search_text (text);
new_len = strlen (escaped_text);
if (new_len == length)
{
g_free (escaped_text);
return;
}
insert_text = TRUE;
g_signal_stop_emission_by_name (editable, "insert_text");
gtk_editable_insert_text (editable, escaped_text, new_len, position);
insert_text = FALSE;
g_free (escaped_text);
}
static void
search_text_entry_changed (GtkEditable *editable,
XedSearchDialog *dialog)
{
const gchar *search_string;
search_string = gtk_entry_get_text (GTK_ENTRY (editable));
g_return_if_fail (search_string != NULL);
if (*search_string != '\0')
{
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
XED_SEARCH_DIALOG_FIND_RESPONSE, TRUE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
XED_SEARCH_DIALOG_REPLACE_ALL_RESPONSE, TRUE);
}
else
{
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
XED_SEARCH_DIALOG_FIND_RESPONSE, FALSE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
XED_SEARCH_DIALOG_REPLACE_RESPONSE, FALSE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
XED_SEARCH_DIALOG_REPLACE_ALL_RESPONSE, FALSE);
}
}
static void
response_handler (XedSearchDialog *dialog,
gint response_id,
gpointer data)
{
const gchar *str;
switch (response_id)
{
case XED_SEARCH_DIALOG_REPLACE_RESPONSE:
case XED_SEARCH_DIALOG_REPLACE_ALL_RESPONSE:
str = gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_text_entry));
if (*str != '\0')
{
gchar *text;
text = xed_utils_unescape_search_text (str);
xed_history_entry_prepend_text
(XED_HISTORY_ENTRY (dialog->priv->replace_entry),
text);
g_free (text);
}
/* fall through, so that we also save the find entry */
case XED_SEARCH_DIALOG_FIND_RESPONSE:
str = gtk_entry_get_text (GTK_ENTRY (dialog->priv->search_text_entry));
if (*str != '\0')
{
gchar *text;
text = xed_utils_unescape_search_text (str);
xed_history_entry_prepend_text
(XED_HISTORY_ENTRY (dialog->priv->search_entry),
text);
g_free (text);
}
}
}
static void
show_replace_widgets (XedSearchDialog *dlg,
gboolean show_replace)
{
if (show_replace)
{
gtk_widget_show (dlg->priv->replace_label);
gtk_widget_show (dlg->priv->replace_entry);
gtk_widget_show (dlg->priv->replace_all_button);
gtk_widget_show (dlg->priv->replace_button);
gtk_table_set_row_spacings (GTK_TABLE (dlg->priv->table), 12);
gtk_window_set_title (GTK_WINDOW (dlg), _("Replace"));
}
else
{
gtk_widget_hide (dlg->priv->replace_label);
gtk_widget_hide (dlg->priv->replace_entry);
gtk_widget_hide (dlg->priv->replace_all_button);
gtk_widget_hide (dlg->priv->replace_button);
gtk_table_set_row_spacings (GTK_TABLE (dlg->priv->table), 0);
gtk_window_set_title (GTK_WINDOW (dlg), _("Find"));
}
gtk_widget_show (dlg->priv->find_button);
}
static void
xed_search_dialog_init (XedSearchDialog *dlg)
{
GtkWidget *content;
GtkWidget *error_widget;
gboolean ret;
gchar *file;
gchar *root_objects[] = {
"search_dialog_content",
NULL
};
dlg->priv = XED_SEARCH_DIALOG_GET_PRIVATE (dlg);
gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
NULL);
/* HIG defaults */
gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dlg))),
5);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dlg))),
6);
file = xed_dirs_get_ui_file ("xed-search-dialog.ui");
ret = xed_utils_get_ui_objects (file,
root_objects,
&error_widget,
"search_dialog_content", &content,
"table", &dlg->priv->table,
"search_label", &dlg->priv->search_label,
"replace_with_label", &dlg->priv->replace_label,
"match_case_checkbutton", &dlg->priv->match_case_checkbutton,
"entire_word_checkbutton", &dlg->priv->entire_word_checkbutton,
"search_backwards_checkbutton", &dlg->priv->backwards_checkbutton,
"wrap_around_checkbutton", &dlg->priv->wrap_around_checkbutton,
"parse_escapes_checkbutton", &dlg->priv->parse_escapes_checkbutton,
NULL);
g_free (file);
if (!ret)
{
gtk_widget_show (error_widget);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
error_widget,
TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (error_widget),
5);
dlg->priv->ui_error = TRUE;
return;
}
dlg->priv->search_entry = xed_history_entry_new ("history-search-for",
TRUE);
gtk_widget_set_size_request (dlg->priv->search_entry, 300, -1);
xed_history_entry_set_escape_func
(XED_HISTORY_ENTRY (dlg->priv->search_entry),
(XedHistoryEntryEscapeFunc) xed_utils_escape_search_text);
dlg->priv->search_text_entry = xed_history_entry_get_entry
(XED_HISTORY_ENTRY (dlg->priv->search_entry));
gtk_entry_set_activates_default (GTK_ENTRY (dlg->priv->search_text_entry),
TRUE);
gtk_widget_show (dlg->priv->search_entry);
gtk_table_attach_defaults (GTK_TABLE (dlg->priv->table),
dlg->priv->search_entry,
1, 2, 0, 1);
dlg->priv->replace_entry = xed_history_entry_new ("history-replace-with",
TRUE);
xed_history_entry_set_escape_func
(XED_HISTORY_ENTRY (dlg->priv->replace_entry),
(XedHistoryEntryEscapeFunc) xed_utils_escape_search_text);
dlg->priv->replace_text_entry = xed_history_entry_get_entry
(XED_HISTORY_ENTRY (dlg->priv->replace_entry));
gtk_entry_set_activates_default (GTK_ENTRY (dlg->priv->replace_text_entry),
TRUE);
gtk_widget_show (dlg->priv->replace_entry);
gtk_table_attach_defaults (GTK_TABLE (dlg->priv->table),
dlg->priv->replace_entry,
1, 2, 1, 2);
gtk_label_set_mnemonic_widget (GTK_LABEL (dlg->priv->search_label),
dlg->priv->search_entry);
gtk_label_set_mnemonic_widget (GTK_LABEL (dlg->priv->replace_label),
dlg->priv->replace_entry);
dlg->priv->find_button = gtk_button_new_from_stock (GTK_STOCK_FIND);
dlg->priv->replace_all_button = gtk_button_new_with_mnemonic (_("Replace _All"));
dlg->priv->replace_button = xed_gtk_button_new_with_stock_icon (_("_Replace"),
GTK_STOCK_FIND_AND_REPLACE);
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
dlg->priv->replace_all_button,
XED_SEARCH_DIALOG_REPLACE_ALL_RESPONSE);
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
dlg->priv->replace_button,
XED_SEARCH_DIALOG_REPLACE_RESPONSE);
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
dlg->priv->find_button,
XED_SEARCH_DIALOG_FIND_RESPONSE);
g_object_set (G_OBJECT (dlg->priv->find_button),
"can-default", TRUE,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dlg),
XED_SEARCH_DIALOG_FIND_RESPONSE);
/* insensitive by default */
gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
XED_SEARCH_DIALOG_FIND_RESPONSE,
FALSE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
XED_SEARCH_DIALOG_REPLACE_RESPONSE,
FALSE);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
XED_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
FALSE);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
content, FALSE, FALSE, 0);
g_object_unref (content);
gtk_container_set_border_width (GTK_CONTAINER (content), 5);
g_signal_connect (dlg->priv->search_text_entry,
"insert_text",
G_CALLBACK (insert_text_handler),
NULL);
g_signal_connect (dlg->priv->replace_text_entry,
"insert_text",
G_CALLBACK (insert_text_handler),
NULL);
g_signal_connect (dlg->priv->search_text_entry,
"changed",
G_CALLBACK (search_text_entry_changed),
dlg);
g_signal_connect (dlg,
"response",
G_CALLBACK (response_handler),
NULL);
}
GtkWidget *
xed_search_dialog_new (GtkWindow *parent,
gboolean show_replace)
{
XedSearchDialog *dlg;
dlg = g_object_new (XED_TYPE_SEARCH_DIALOG,
"show-replace", show_replace,
NULL);
if (parent != NULL)
{
gtk_window_set_transient_for (GTK_WINDOW (dlg),
parent);
gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg),
TRUE);
}
return GTK_WIDGET (dlg);
}
gboolean
xed_search_dialog_get_show_replace (XedSearchDialog *dialog)
{
g_return_val_if_fail (XED_IS_SEARCH_DIALOG (dialog), FALSE);
return dialog->priv->show_replace;
}
void
xed_search_dialog_set_show_replace (XedSearchDialog *dialog,
gboolean show_replace)
{
g_return_if_fail (XED_IS_SEARCH_DIALOG (dialog));
if (dialog->priv->ui_error)
return;
dialog->priv->show_replace = show_replace != FALSE;
show_replace_widgets (dialog, dialog->priv->show_replace);
g_object_notify (G_OBJECT (dialog), "show-replace");
}
void
xed_search_dialog_set_search_text (XedSearchDialog *dialog,
const gchar *text)
{
g_return_if_fail (XED_IS_SEARCH_DIALOG (dialog));
g_return_if_fail (text != NULL);
gtk_entry_set_text (GTK_ENTRY (dialog->priv->search_text_entry),
text);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
XED_SEARCH_DIALOG_FIND_RESPONSE,
(text != '\0'));
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
XED_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
(text != '\0'));
}
/*
* The text must be unescaped before searching.
*/
const gchar *
xed_search_dialog_get_search_text (XedSearchDialog *dialog)
{
g_return_val_if_fail (XED_IS_SEARCH_DIALOG (dialog), NULL);
return gtk_entry_get_text (GTK_ENTRY (dialog->priv->search_text_entry));
}
void
xed_search_dialog_set_replace_text (XedSearchDialog *dialog,
const gchar *text)
{
g_return_if_fail (XED_IS_SEARCH_DIALOG (dialog));
g_return_if_fail (text != NULL);
gtk_entry_set_text (GTK_ENTRY (dialog->priv->replace_text_entry),
text);
}
const gchar *
xed_search_dialog_get_replace_text (XedSearchDialog *dialog)
{
g_return_val_if_fail (XED_IS_SEARCH_DIALOG (dialog), NULL);
return gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_text_entry));
}
void
xed_search_dialog_set_match_case (XedSearchDialog *dialog,
gboolean match_case)
{
g_return_if_fail (XED_IS_SEARCH_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->match_case_checkbutton),
match_case);
}
gboolean
xed_search_dialog_get_match_case (XedSearchDialog *dialog)
{
g_return_val_if_fail (XED_IS_SEARCH_DIALOG (dialog), FALSE);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->match_case_checkbutton));
}
void
xed_search_dialog_set_entire_word (XedSearchDialog *dialog,
gboolean entire_word)
{
g_return_if_fail (XED_IS_SEARCH_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->entire_word_checkbutton),
entire_word);
}
gboolean
xed_search_dialog_get_entire_word (XedSearchDialog *dialog)
{
g_return_val_if_fail (XED_IS_SEARCH_DIALOG (dialog), FALSE);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->entire_word_checkbutton));
}
void
xed_search_dialog_set_backwards (XedSearchDialog *dialog,
gboolean backwards)
{
g_return_if_fail (XED_IS_SEARCH_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->backwards_checkbutton),
backwards);
}
gboolean
xed_search_dialog_get_backwards (XedSearchDialog *dialog)
{
g_return_val_if_fail (XED_IS_SEARCH_DIALOG (dialog), FALSE);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->backwards_checkbutton));
}
void
xed_search_dialog_set_wrap_around (XedSearchDialog *dialog,
gboolean wrap_around)
{
g_return_if_fail (XED_IS_SEARCH_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->wrap_around_checkbutton),
wrap_around);
}
gboolean
xed_search_dialog_get_wrap_around (XedSearchDialog *dialog)
{
g_return_val_if_fail (XED_IS_SEARCH_DIALOG (dialog), FALSE);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->wrap_around_checkbutton));
}
void
xed_search_dialog_set_parse_escapes (XedSearchDialog *dialog,
gboolean parse_escapes)
{
g_return_if_fail (XED_IS_SEARCH_DIALOG (dialog));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->parse_escapes_checkbutton),
parse_escapes);
}
gboolean
xed_search_dialog_get_parse_escapes (XedSearchDialog *dialog)
{
g_return_val_if_fail (XED_IS_SEARCH_DIALOG (dialog), FALSE);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->parse_escapes_checkbutton));
}

View File

@@ -1,133 +0,0 @@
/*
* xed-search-dialog.h
* This file is part of xed
*
* Copyright (C) 2005 Paolo Maggi
*
* 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.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Modified by the xed Team, 2005. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
#ifndef __XED_SEARCH_DIALOG_H__
#define __XED_SEARCH_DIALOG_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
/*
* Type checking and casting macros
*/
#define XED_TYPE_SEARCH_DIALOG (xed_search_dialog_get_type())
#define XED_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_SEARCH_DIALOG, XedSearchDialog))
#define XED_SEARCH_DIALOG_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_SEARCH_DIALOG, XedSearchDialog const))
#define XED_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_SEARCH_DIALOG, XedSearchDialogClass))
#define XED_IS_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XED_TYPE_SEARCH_DIALOG))
#define XED_IS_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_SEARCH_DIALOG))
#define XED_SEARCH_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_SEARCH_DIALOG, XedSearchDialogClass))
/* Private structure type */
typedef struct _XedSearchDialogPrivate XedSearchDialogPrivate;
/*
* Main object structure
*/
typedef struct _XedSearchDialog XedSearchDialog;
struct _XedSearchDialog
{
GtkDialog dialog;
/*< private > */
XedSearchDialogPrivate *priv;
};
/*
* Class definition
*/
typedef struct _XedSearchDialogClass XedSearchDialogClass;
struct _XedSearchDialogClass
{
GtkDialogClass parent_class;
/* Key bindings */
gboolean (* show_replace) (XedSearchDialog *dlg);
};
enum
{
XED_SEARCH_DIALOG_FIND_RESPONSE = 100,
XED_SEARCH_DIALOG_REPLACE_RESPONSE,
XED_SEARCH_DIALOG_REPLACE_ALL_RESPONSE
};
/*
* Public methods
*/
GType xed_search_dialog_get_type (void) G_GNUC_CONST;
GtkWidget *xed_search_dialog_new (GtkWindow *parent,
gboolean show_replace);
void xed_search_dialog_present_with_time (XedSearchDialog *dialog,
guint32 timestamp);
gboolean xed_search_dialog_get_show_replace (XedSearchDialog *dialog);
void xed_search_dialog_set_show_replace (XedSearchDialog *dialog,
gboolean show_replace);
void xed_search_dialog_set_search_text (XedSearchDialog *dialog,
const gchar *text);
const gchar *xed_search_dialog_get_search_text (XedSearchDialog *dialog);
void xed_search_dialog_set_replace_text (XedSearchDialog *dialog,
const gchar *text);
const gchar *xed_search_dialog_get_replace_text (XedSearchDialog *dialog);
void xed_search_dialog_set_match_case (XedSearchDialog *dialog,
gboolean match_case);
gboolean xed_search_dialog_get_match_case (XedSearchDialog *dialog);
void xed_search_dialog_set_entire_word (XedSearchDialog *dialog,
gboolean entire_word);
gboolean xed_search_dialog_get_entire_word (XedSearchDialog *dialog);
void xed_search_dialog_set_backwards (XedSearchDialog *dialog,
gboolean backwards);
gboolean xed_search_dialog_get_backwards (XedSearchDialog *dialog);
void xed_search_dialog_set_wrap_around (XedSearchDialog *dialog,
gboolean wrap_around);
gboolean xed_search_dialog_get_wrap_around (XedSearchDialog *dialog);
void xed_search_dialog_set_parse_escapes (XedSearchDialog *dialog,
gboolean parse_escapes);
gboolean xed_search_dialog_get_parse_escapes (XedSearchDialog *dialog);
G_END_DECLS
#endif /* __XED_SEARCH_DIALOG_H__ */

View File

@@ -1,272 +0,0 @@
<?xml version="1.0"?>
<!--*- mode: xml -*-->
<interface>
<object class="GtkDialog" id="dialog">
<property name="title" translatable="yes">Replace</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">8</property>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_DEFAULT_STYLE</property>
<child>
<object class="GtkButton" id="close_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</object>
</child>
<child>
<object class="GtkButton" id="replace_all_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Replace All</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</object>
</child>
<child>
<object class="GtkButton" id="replace_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Replace</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</object>
</child>
<child>
<object class="GtkButton" id="find_next_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-find</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</object>
</child>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="search_dialog_content">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">18</property>
<child>
<object class="GtkTable" id="table">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">12</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkLabel" id="search_label">
<property name="visible">True</property>
<property name="label" translatable="yes">_Search for: </property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkLabel" id="replace_with_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Replace _with: </property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"/>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkCheckButton" id="match_case_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Match case</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="entire_word_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Match _entire word only</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="search_backwards_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Search _backwards</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="wrap_around_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Wrap around</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="parse_escapes_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Parse escape sequences (e.g. \n)</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</object>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">close_button</action-widget>
<action-widget response="0">replace_all_button</action-widget>
<action-widget response="0">replace_button</action-widget>
<action-widget response="0">find_next_button</action-widget>
</action-widgets>
</object>
</interface>

View File

@@ -47,17 +47,9 @@ xed_close_button_class_init (XedCloseButtonClass *klass)
static void
xed_close_button_init (XedCloseButton *button)
{
GtkRcStyle *rcstyle;
GtkWidget *image;
/* make it as small as possible */
rcstyle = gtk_rc_style_new ();
rcstyle->xthickness = rcstyle->ythickness = 0;
gtk_widget_modify_style (GTK_WIDGET (button), rcstyle);
g_object_unref (rcstyle);
image = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
GTK_ICON_SIZE_MENU);
image = gtk_image_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_MENU);
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (button), image);

View File

@@ -1,35 +1,3 @@
/*
* xed-search-commands.c
* This file is part of xed
*
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
* Copyright (C) 2002-2006 Paolo Maggi
*
* 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.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Modified by the xed Team, 1998-2006. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -41,750 +9,69 @@
#include "xed-commands.h"
#include "xed-debug.h"
#include "xed-statusbar.h"
#include "xed-window.h"
#include "xed-window-private.h"
#include "xed-utils.h"
#include "dialogs/xed-search-dialog.h"
#include "xed-searchbar.h"
#define XED_SEARCH_DIALOG_KEY "xed-search-dialog-key"
#define XED_LAST_SEARCH_DATA_KEY "xed-last-search-data-key"
typedef struct _LastSearchData LastSearchData;
struct _LastSearchData
void
_xed_cmd_search_find (GtkAction *action,
XedWindow *window)
{
gint x;
gint y;
};
static void
last_search_data_free (LastSearchData *data)
{
g_slice_free (LastSearchData, data);
}
static void
last_search_data_restore_position (XedSearchDialog *dlg)
{
LastSearchData *data;
data = g_object_get_data (G_OBJECT (dlg), XED_LAST_SEARCH_DATA_KEY);
if (data != NULL)
{
gtk_window_move (GTK_WINDOW (dlg),
data->x,
data->y);
}
}
static void
last_search_data_store_position (XedSearchDialog *dlg)
{
LastSearchData *data;
data = g_object_get_data (G_OBJECT (dlg), XED_LAST_SEARCH_DATA_KEY);
if (data == NULL)
{
data = g_slice_new (LastSearchData);
g_object_set_data_full (G_OBJECT (dlg),
XED_LAST_SEARCH_DATA_KEY,
data,
(GDestroyNotify) last_search_data_free);
}
gtk_window_get_position (GTK_WINDOW (dlg),
&data->x,
&data->y);
}
/* Use occurrences only for Replace All */
static void
text_found (XedWindow *window,
gint occurrences)
{
if (occurrences > 1)
{
xed_statusbar_flash_message (XED_STATUSBAR (window->priv->statusbar),
window->priv->generic_message_cid,
ngettext("Found and replaced %d occurrence",
"Found and replaced %d occurrences",
occurrences),
occurrences);
}
else
{
if (occurrences == 1)
xed_statusbar_flash_message (XED_STATUSBAR (window->priv->statusbar),
window->priv->generic_message_cid,
_("Found and replaced one occurrence"));
else
xed_statusbar_flash_message (XED_STATUSBAR (window->priv->statusbar),
window->priv->generic_message_cid,
" ");
}
}
#define MAX_MSG_LENGTH 40
static void
text_not_found (XedWindow *window,
const gchar *text)
{
gchar *searched;
searched = xed_utils_str_end_truncate (text, MAX_MSG_LENGTH);
xed_statusbar_flash_message (XED_STATUSBAR (window->priv->statusbar),
window->priv->generic_message_cid,
/* Translators: %s is replaced by the text
entered by the user in the search box */
_("\"%s\" not found"), searched);
g_free (searched);
}
static gboolean
run_search (XedView *view,
gboolean wrap_around,
gboolean search_backwards)
{
XedDocument *doc;
GtkTextIter start_iter;
GtkTextIter match_start;
GtkTextIter match_end;
gboolean found = FALSE;
doc = XED_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
if (!search_backwards)
{
gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc),
NULL,
&start_iter);
found = xed_document_search_forward (doc,
&start_iter,
NULL,
&match_start,
&match_end);
}
else
{
gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc),
&start_iter,
NULL);
found = xed_document_search_backward (doc,
NULL,
&start_iter,
&match_start,
&match_end);
}
if (!found && wrap_around)
{
if (!search_backwards)
found = xed_document_search_forward (doc,
NULL,
NULL, /* FIXME: set the end_inter */
&match_start,
&match_end);
else
found = xed_document_search_backward (doc,
NULL, /* FIXME: set the start_inter */
NULL,
&match_start,
&match_end);
}
if (found)
{
gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc),
&match_start);
gtk_text_buffer_move_mark_by_name (GTK_TEXT_BUFFER (doc),
"selection_bound",
&match_end);
xed_view_scroll_to_cursor (view);
}
else
{
gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc),
&start_iter);
}
return found;
}
static void
do_find (XedSearchDialog *dialog,
XedWindow *window)
{
XedView *active_view;
XedDocument *doc;
gchar *search_text;
const gchar *entry_text;
gboolean match_case;
gboolean entire_word;
gboolean wrap_around;
gboolean search_backwards;
gboolean parse_escapes;
guint flags = 0;
guint old_flags = 0;
gboolean found;
/* TODO: make the dialog insensitive when all the tabs are closed
* and assert here that the view is not NULL */
active_view = xed_window_get_active_view (window);
if (active_view == NULL)
return;
doc = XED_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
match_case = xed_search_dialog_get_match_case (dialog);
entire_word = xed_search_dialog_get_entire_word (dialog);
search_backwards = xed_search_dialog_get_backwards (dialog);
wrap_around = xed_search_dialog_get_wrap_around (dialog);
parse_escapes = xed_search_dialog_get_parse_escapes (dialog);
if (!parse_escapes) {
entry_text = xed_utils_escape_search_text (xed_search_dialog_get_search_text (dialog));
} else {
entry_text = xed_search_dialog_get_search_text (dialog);
}
XED_SEARCH_SET_CASE_SENSITIVE (flags, match_case);
XED_SEARCH_SET_ENTIRE_WORD (flags, entire_word);
search_text = xed_document_get_search_text (doc, &old_flags);
if ((search_text == NULL) ||
(strcmp (search_text, entry_text) != 0) ||
(flags != old_flags))
{
xed_document_set_search_text (doc, entry_text, flags);
}
g_free (search_text);
found = run_search (active_view,
wrap_around,
search_backwards);
if (found)
text_found (window, 0);
else {
if (!parse_escapes) {
text_not_found (window, xed_utils_unescape_search_text (entry_text));
} else {
text_not_found (window, entry_text);
}
}
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
XED_SEARCH_DIALOG_REPLACE_RESPONSE,
found);
}
/* FIXME: move in xed-document.c and share it with xed-view */
static gboolean
get_selected_text (GtkTextBuffer *doc,
gchar **selected_text,
gint *len)
{
GtkTextIter start, end;
g_return_val_if_fail (selected_text != NULL, FALSE);
g_return_val_if_fail (*selected_text == NULL, FALSE);
if (!gtk_text_buffer_get_selection_bounds (doc, &start, &end))
{
if (len != NULL)
len = 0;
return FALSE;
}
*selected_text = gtk_text_buffer_get_slice (doc, &start, &end, TRUE);
if (len != NULL)
*len = g_utf8_strlen (*selected_text, -1);
return TRUE;
}
static void
replace_selected_text (GtkTextBuffer *buffer,
const gchar *replace)
{
g_return_if_fail (gtk_text_buffer_get_selection_bounds (buffer, NULL, NULL));
g_return_if_fail (replace != NULL);
gtk_text_buffer_begin_user_action (buffer);
gtk_text_buffer_delete_selection (buffer, FALSE, TRUE);
gtk_text_buffer_insert_at_cursor (buffer, replace, strlen (replace));
gtk_text_buffer_end_user_action (buffer);
}
static void
do_replace (XedSearchDialog *dialog,
XedWindow *window)
{
XedDocument *doc;
const gchar *search_entry_text;
const gchar *replace_entry_text;
gchar *unescaped_search_text;
gchar *unescaped_replace_text;
gchar *selected_text = NULL;
gboolean match_case;
gboolean parse_escapes;
doc = xed_window_get_active_document (window);
if (doc == NULL)
return;
parse_escapes = xed_search_dialog_get_parse_escapes (dialog);
if (!parse_escapes) {
search_entry_text = xed_utils_escape_search_text (xed_search_dialog_get_search_text (dialog));
} else {
search_entry_text = xed_search_dialog_get_search_text (dialog);
}
g_return_if_fail ((search_entry_text) != NULL);
g_return_if_fail ((*search_entry_text) != '\0');
/* replace text may be "", we just delete */
if (!parse_escapes) {
replace_entry_text = xed_utils_escape_search_text (xed_search_dialog_get_replace_text (dialog));
} else {
replace_entry_text = xed_search_dialog_get_replace_text (dialog);
}
g_return_if_fail ((replace_entry_text) != NULL);
unescaped_search_text = xed_utils_unescape_search_text (search_entry_text);
get_selected_text (GTK_TEXT_BUFFER (doc),
&selected_text,
NULL);
match_case = xed_search_dialog_get_match_case (dialog);
if ((selected_text == NULL) ||
(match_case && (strcmp (selected_text, unescaped_search_text) != 0)) ||
(!match_case && !g_utf8_caselessnmatch (selected_text,
unescaped_search_text,
strlen (selected_text),
strlen (unescaped_search_text)) != 0))
{
do_find (dialog, window);
g_free (unescaped_search_text);
g_free (selected_text);
return;
}
unescaped_replace_text = xed_utils_unescape_search_text (replace_entry_text);
replace_selected_text (GTK_TEXT_BUFFER (doc), unescaped_replace_text);
g_free (unescaped_search_text);
g_free (selected_text);
g_free (unescaped_replace_text);
do_find (dialog, window);
}
static void
do_replace_all (XedSearchDialog *dialog,
XedWindow *window)
{
XedView *active_view;
XedDocument *doc;
const gchar *search_entry_text;
const gchar *replace_entry_text;
gboolean match_case;
gboolean entire_word;
gboolean parse_escapes;
guint flags = 0;
gint count;
active_view = xed_window_get_active_view (window);
if (active_view == NULL)
return;
doc = XED_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
parse_escapes = xed_search_dialog_get_parse_escapes (dialog);
if (!parse_escapes) {
search_entry_text = xed_utils_escape_search_text(xed_search_dialog_get_search_text (dialog));
} else {
search_entry_text = xed_search_dialog_get_search_text (dialog);
}
g_return_if_fail ((search_entry_text) != NULL);
g_return_if_fail ((*search_entry_text) != '\0');
/* replace text may be "", we just delete all occurrencies */
if (!parse_escapes) {
replace_entry_text = xed_utils_escape_search_text (xed_search_dialog_get_replace_text (dialog));
} else {
replace_entry_text = xed_search_dialog_get_replace_text (dialog);
}
g_return_if_fail ((replace_entry_text) != NULL);
match_case = xed_search_dialog_get_match_case (dialog);
entire_word = xed_search_dialog_get_entire_word (dialog);
XED_SEARCH_SET_CASE_SENSITIVE (flags, match_case);
XED_SEARCH_SET_ENTIRE_WORD (flags, entire_word);
count = xed_document_replace_all (doc,
search_entry_text,
replace_entry_text,
flags);
if (count > 0)
{
text_found (window, count);
}
else
{
if (!parse_escapes) {
text_not_found (window, xed_utils_unescape_search_text (search_entry_text));
} else {
text_not_found (window, search_entry_text);
}
}
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
XED_SEARCH_DIALOG_REPLACE_RESPONSE,
FALSE);
}
static void
search_dialog_response_cb (XedSearchDialog *dialog,
gint response_id,
XedWindow *window)
{
xed_debug (DEBUG_COMMANDS);
switch (response_id)
{
case XED_SEARCH_DIALOG_FIND_RESPONSE:
do_find (dialog, window);
break;
case XED_SEARCH_DIALOG_REPLACE_RESPONSE:
do_replace (dialog, window);
break;
case XED_SEARCH_DIALOG_REPLACE_ALL_RESPONSE:
do_replace_all (dialog, window);
break;
default:
last_search_data_store_position (dialog);
gtk_widget_hide (GTK_WIDGET (dialog));
}
}
static gboolean
search_dialog_delete_event_cb (GtkWidget *widget,
GdkEventAny *event,
gpointer user_data)
{
xed_debug (DEBUG_COMMANDS);
/* prevent destruction */
return TRUE;
}
static void
search_dialog_destroyed (XedWindow *window,
XedSearchDialog *dialog)
{
xed_debug (DEBUG_COMMANDS);
g_object_set_data (G_OBJECT (window),
XED_SEARCH_DIALOG_KEY,
NULL);
g_object_set_data (G_OBJECT (dialog),
XED_LAST_SEARCH_DATA_KEY,
NULL);
}
static GtkWidget *
create_dialog (XedWindow *window, gboolean show_replace)
{
GtkWidget *dialog;
dialog = xed_search_dialog_new (GTK_WINDOW (window), show_replace);
g_signal_connect (dialog,
"response",
G_CALLBACK (search_dialog_response_cb),
window);
g_signal_connect (dialog,
"delete-event",
G_CALLBACK (search_dialog_delete_event_cb),
NULL);
g_object_set_data (G_OBJECT (window),
XED_SEARCH_DIALOG_KEY,
dialog);
g_object_weak_ref (G_OBJECT (dialog),
(GWeakNotify) search_dialog_destroyed,
window);
return dialog;
xed_searchbar_show (xed_window_get_searchbar (window), FALSE);
}
void
_xed_cmd_search_find (GtkAction *action,
XedWindow *window)
_xed_cmd_search_replace (GtkAction *action,
XedWindow *window)
{
gpointer data;
GtkWidget *search_dialog;
XedDocument *doc;
gboolean selection_exists;
gboolean parse_escapes;
gchar *find_text = NULL;
const gchar *search_text = NULL;
gint sel_len;
xed_debug (DEBUG_COMMANDS);
data = g_object_get_data (G_OBJECT (window), XED_SEARCH_DIALOG_KEY);
if (data == NULL)
{
search_dialog = create_dialog (window, FALSE);
}
else
{
g_return_if_fail (XED_IS_SEARCH_DIALOG (data));
search_dialog = GTK_WIDGET (data);
/* turn the dialog into a find dialog if needed */
if (xed_search_dialog_get_show_replace (XED_SEARCH_DIALOG (search_dialog)))
xed_search_dialog_set_show_replace (XED_SEARCH_DIALOG (search_dialog),
FALSE);
}
doc = xed_window_get_active_document (window);
g_return_if_fail (doc != NULL);
selection_exists = get_selected_text (GTK_TEXT_BUFFER (doc),
&find_text,
&sel_len);
if (selection_exists && find_text != NULL && sel_len < 80)
{
/*
* Special case: if the currently selected text
* is the same as the unescaped search text and
* escape sequence parsing is activated, use the
* same old search text. (Without this, if you e.g.
* search for '\n' in escaped mode and then open
* the search dialog again, you'll get an unprintable
* single-character literal '\n' in the "search for"
* box).
*/
parse_escapes = xed_search_dialog_get_parse_escapes (XED_SEARCH_DIALOG (search_dialog));
search_text = xed_search_dialog_get_search_text (XED_SEARCH_DIALOG (search_dialog));
if (!(search_text != NULL
&& !strcmp(xed_utils_unescape_search_text(search_text), find_text)
&& parse_escapes)) {
/* General case */
xed_search_dialog_set_search_text (XED_SEARCH_DIALOG (search_dialog),
find_text);
}
g_free (find_text);
}
else
{
g_free (find_text);
}
gtk_widget_show (search_dialog);
last_search_data_restore_position (XED_SEARCH_DIALOG (search_dialog));
xed_search_dialog_present_with_time (XED_SEARCH_DIALOG (search_dialog),
GDK_CURRENT_TIME);
xed_searchbar_show (xed_window_get_searchbar (window), TRUE);
}
void
_xed_cmd_search_replace (GtkAction *action,
XedWindow *window)
_xed_cmd_search_find_next (GtkAction *action,
XedWindow *window)
{
gpointer data;
GtkWidget *replace_dialog;
XedDocument *doc;
gboolean selection_exists;
gboolean parse_escapes;
gchar *find_text = NULL;
const gchar *search_text = NULL;
gint sel_len;
xed_debug (DEBUG_COMMANDS);
data = g_object_get_data (G_OBJECT (window), XED_SEARCH_DIALOG_KEY);
if (data == NULL)
{
replace_dialog = create_dialog (window, TRUE);
}
else
{
g_return_if_fail (XED_IS_SEARCH_DIALOG (data));
replace_dialog = GTK_WIDGET (data);
/* turn the dialog into a find dialog if needed */
if (!xed_search_dialog_get_show_replace (XED_SEARCH_DIALOG (replace_dialog)))
xed_search_dialog_set_show_replace (XED_SEARCH_DIALOG (replace_dialog),
TRUE);
}
doc = xed_window_get_active_document (window);
g_return_if_fail (doc != NULL);
selection_exists = get_selected_text (GTK_TEXT_BUFFER (doc),
&find_text,
&sel_len);
if (selection_exists && find_text != NULL && sel_len < 80)
{
/*
* Special case: if the currently selected text
* is the same as the unescaped search text and
* escape sequence parsing is activated, use the
* same old search text. (Without this, if you e.g.
* search for '\n' in escaped mode and then open
* the search dialog again, you'll get an unprintable
* single-character literal '\n' in the "search for"
* box).
*/
parse_escapes = xed_search_dialog_get_parse_escapes (XED_SEARCH_DIALOG (replace_dialog));
search_text = xed_search_dialog_get_search_text (XED_SEARCH_DIALOG (replace_dialog));
if (!(search_text != NULL
&& !strcmp(xed_utils_unescape_search_text(search_text), find_text)
&& parse_escapes)) {
/* General case */
xed_search_dialog_set_search_text (XED_SEARCH_DIALOG (replace_dialog),
find_text);
}
g_free (find_text);
}
else
{
g_free (find_text);
}
gtk_widget_show (replace_dialog);
last_search_data_restore_position (XED_SEARCH_DIALOG (replace_dialog));
xed_search_dialog_present_with_time (XED_SEARCH_DIALOG (replace_dialog),
GDK_CURRENT_TIME);
}
static void
do_find_again (XedWindow *window,
gboolean backward)
{
XedView *active_view;
gboolean wrap_around = TRUE;
gpointer data;
active_view = xed_window_get_active_view (window);
g_return_if_fail (active_view != NULL);
data = g_object_get_data (G_OBJECT (window), XED_SEARCH_DIALOG_KEY);
if (data != NULL)
wrap_around = xed_search_dialog_get_wrap_around (XED_SEARCH_DIALOG (data));
run_search (active_view,
wrap_around,
backward);
xed_debug (DEBUG_COMMANDS);
xed_searchbar_find_again (xed_window_get_searchbar (window), FALSE);
}
void
_xed_cmd_search_find_next (GtkAction *action,
XedWindow *window)
_xed_cmd_search_find_prev (GtkAction *action,
XedWindow *window)
{
xed_debug (DEBUG_COMMANDS);
do_find_again (window, FALSE);
xed_debug (DEBUG_COMMANDS);
xed_searchbar_find_again (xed_window_get_searchbar (window), TRUE);
}
void
_xed_cmd_search_find_prev (GtkAction *action,
XedWindow *window)
_xed_cmd_search_clear_highlight (XedWindow *window)
{
xed_debug (DEBUG_COMMANDS);
do_find_again (window, TRUE);
XedDocument *doc;
xed_debug (DEBUG_COMMANDS);
doc = xed_window_get_active_document (window);
if (doc != NULL)
{
xed_document_set_search_text (XED_DOCUMENT(doc), "", XED_SEARCH_DONT_SET_FLAGS);
}
}
void
_xed_cmd_search_clear_highlight (GtkAction *action,
XedWindow *window)
_xed_cmd_search_goto_line (GtkAction *action,
XedWindow *window)
{
XedDocument *doc;
XedView *active_view;
xed_debug (DEBUG_COMMANDS);
xed_debug (DEBUG_COMMANDS);
active_view = xed_window_get_active_view (window);
if (active_view == NULL)
{
return;
}
doc = xed_window_get_active_document (window);
xed_document_set_search_text (XED_DOCUMENT (doc),
"",
XED_SEARCH_DONT_SET_FLAGS);
}
void
_xed_cmd_search_goto_line (GtkAction *action,
XedWindow *window)
{
XedView *active_view;
xed_debug (DEBUG_COMMANDS);
active_view = xed_window_get_active_view (window);
if (active_view == NULL)
return;
/* Focus the view if needed: we need to focus the view otherwise
activating the binding for goto line has no effect */
gtk_widget_grab_focus (GTK_WIDGET (active_view));
/* goto line is builtin in XedView, just activate
* the corrisponding binding.
*/
gtk_bindings_activate (G_OBJECT (active_view),
GDK_KEY_i,
GDK_CONTROL_MASK);
}
void
_xed_cmd_search_incremental_search (GtkAction *action,
XedWindow *window)
{
XedView *active_view;
xed_debug (DEBUG_COMMANDS);
active_view = xed_window_get_active_view (window);
if (active_view == NULL)
return;
/* Focus the view if needed: we need to focus the view otherwise
activating the binding for incremental search has no effect */
gtk_widget_grab_focus (GTK_WIDGET (active_view));
/* incremental search is builtin in XedView, just activate
* the corrisponding binding.
*/
gtk_bindings_activate (G_OBJECT (active_view),
GDK_KEY_k,
GDK_CONTROL_MASK);
/* Focus the view if needed: we need to focus the view otherwise
activating the binding for goto line has no effect */
gtk_widget_grab_focus (GTK_WIDGET(active_view));
/* Goto line is builtin in XedView, just activate the corresponding binding. */
gtk_bindings_activate (G_OBJECT(active_view), GDK_KEY_i, GDK_CONTROL_MASK);
}

View File

@@ -1,36 +1,3 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* xed-commands.h
* This file is part of xed
*
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
* Copyright (C) 2002-2005 Paolo Maggi
*
* 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.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Modified by the xed Team, 1998-2005. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
#ifndef __XED_COMMANDS_H__
#define __XED_COMMANDS_H__
@@ -40,120 +7,67 @@
G_BEGIN_DECLS
/* Do nothing if URI does not exist */
void xed_commands_load_uri (XedWindow *window,
const gchar *uri,
const XedEncoding *encoding,
gint line_pos);
void xed_commands_load_uri (XedWindow *window, const gchar *uri, const XedEncoding *encoding, gint line_pos);
/* Ignore non-existing URIs */
gint xed_commands_load_uris (XedWindow *window,
const GSList *uris,
const XedEncoding *encoding,
gint line_pos);
void xed_commands_save_document (XedWindow *window,
XedDocument *document);
void xed_commands_save_all_documents (XedWindow *window);
gint xed_commands_load_uris (XedWindow *window, const GSList *uris, const XedEncoding *encoding, gint line_pos);
void xed_commands_save_document (XedWindow *window, XedDocument *document);
void xed_commands_save_all_documents (XedWindow *window);
/*
* Non-exported functions
*/
/* Create titled documens for non-existing URIs */
gint _xed_cmd_load_files_from_prompt (XedWindow *window,
GSList *files,
const XedEncoding *encoding,
gint line_pos);
gint _xed_cmd_load_files_from_prompt (XedWindow *window, GSList *files, const XedEncoding *encoding, gint line_pos);
void _xed_cmd_file_new (GtkAction *action, XedWindow *window);
void _xed_cmd_file_open (GtkAction *action, XedWindow *window);
void _xed_cmd_file_save (GtkAction *action, XedWindow *window);
void _xed_cmd_file_save_as (GtkAction *action, XedWindow *window);
void _xed_cmd_file_save_all (GtkAction *action, XedWindow *window);
void _xed_cmd_file_revert (GtkAction *action, XedWindow *window);
void _xed_cmd_file_open_uri (GtkAction *action, XedWindow *window);
void _xed_cmd_file_print_preview (GtkAction *action, XedWindow *window);
void _xed_cmd_file_print (GtkAction *action, XedWindow *window);
void _xed_cmd_file_close (GtkAction *action, XedWindow *window);
void _xed_cmd_file_close_all (GtkAction *action, XedWindow *window);
void _xed_cmd_file_quit (GtkAction *action, XedWindow *window);
void _xed_cmd_file_new (GtkAction *action,
XedWindow *window);
void _xed_cmd_file_open (GtkAction *action,
XedWindow *window);
void _xed_cmd_file_save (GtkAction *action,
XedWindow *window);
void _xed_cmd_file_save_as (GtkAction *action,
XedWindow *window);
void _xed_cmd_file_save_all (GtkAction *action,
XedWindow *window);
void _xed_cmd_file_revert (GtkAction *action,
XedWindow *window);
void _xed_cmd_file_open_uri (GtkAction *action,
XedWindow *window);
void _xed_cmd_file_print_preview (GtkAction *action,
XedWindow *window);
void _xed_cmd_file_print (GtkAction *action,
XedWindow *window);
void _xed_cmd_file_close (GtkAction *action,
XedWindow *window);
void _xed_cmd_file_close_all (GtkAction *action,
XedWindow *window);
void _xed_cmd_file_quit (GtkAction *action,
XedWindow *window);
void _xed_cmd_edit_undo (GtkAction *action, XedWindow *window);
void _xed_cmd_edit_redo (GtkAction *action, XedWindow *window);
void _xed_cmd_edit_cut (GtkAction *action, XedWindow *window);
void _xed_cmd_edit_copy (GtkAction *action, XedWindow *window);
void _xed_cmd_edit_paste (GtkAction *action, XedWindow *window);
void _xed_cmd_edit_delete (GtkAction *action, XedWindow *window);
void _xed_cmd_edit_select_all (GtkAction *action, XedWindow *window);
void _xed_cmd_edit_preferences (GtkAction *action, XedWindow *window);
void _xed_cmd_edit_undo (GtkAction *action,
XedWindow *window);
void _xed_cmd_edit_redo (GtkAction *action,
XedWindow *window);
void _xed_cmd_edit_cut (GtkAction *action,
XedWindow *window);
void _xed_cmd_edit_copy (GtkAction *action,
XedWindow *window);
void _xed_cmd_edit_paste (GtkAction *action,
XedWindow *window);
void _xed_cmd_edit_delete (GtkAction *action,
XedWindow *window);
void _xed_cmd_edit_select_all (GtkAction *action,
XedWindow *window);
void _xed_cmd_edit_preferences (GtkAction *action,
XedWindow *window);
void _xed_cmd_view_show_toolbar (GtkAction *action, XedWindow *window);
void _xed_cmd_view_show_statusbar (GtkAction *action, XedWindow *window);
void _xed_cmd_view_show_side_pane (GtkAction *action, XedWindow *window);
void _xed_cmd_view_show_bottom_pane (GtkAction *action, XedWindow *window);
void _xed_cmd_view_toggle_fullscreen_mode (GtkAction *action, XedWindow *window);
void _xed_cmd_view_leave_fullscreen_mode (GtkAction *action, XedWindow *window);
void _xed_cmd_view_show_toolbar (GtkAction *action,
XedWindow *window);
void _xed_cmd_view_show_statusbar (GtkAction *action,
XedWindow *window);
void _xed_cmd_view_show_side_pane (GtkAction *action,
XedWindow *window);
void _xed_cmd_view_show_bottom_pane (GtkAction *action,
XedWindow *window);
void _xed_cmd_view_toggle_fullscreen_mode (GtkAction *action,
XedWindow *window);
void _xed_cmd_view_leave_fullscreen_mode (GtkAction *action,
XedWindow *window);
void _xed_cmd_search_find (GtkAction *action, XedWindow *window);
void _xed_cmd_search_find (GtkAction *action,
XedWindow *window);
void _xed_cmd_search_find_next (GtkAction *action,
XedWindow *window);
void _xed_cmd_search_find_prev (GtkAction *action,
XedWindow *window);
void _xed_cmd_search_replace (GtkAction *action,
XedWindow *window);
void _xed_cmd_search_clear_highlight (GtkAction *action,
XedWindow *window);
void _xed_cmd_search_goto_line (GtkAction *action,
XedWindow *window);
void _xed_cmd_search_incremental_search (GtkAction *action,
XedWindow *window);
void _xed_cmd_documents_previous_document (GtkAction *action,
XedWindow *window);
void _xed_cmd_documents_next_document (GtkAction *action,
XedWindow *window);
void _xed_cmd_documents_move_to_new_window (GtkAction *action,
XedWindow *window);
void _xed_cmd_search_find_next (GtkAction *action, XedWindow *window);
void _xed_cmd_search_find_prev (GtkAction *action, XedWindow *window);
void _xed_cmd_search_replace (GtkAction *action, XedWindow *window);
void _xed_cmd_search_clear_highlight (XedWindow *window);
void _xed_cmd_search_goto_line (GtkAction *action, XedWindow *window);
void _xed_cmd_help_contents (GtkAction *action,
XedWindow *window);
void _xed_cmd_help_about (GtkAction *action,
XedWindow *window);
void _xed_cmd_documents_previous_document (GtkAction *action, XedWindow *window);
void _xed_cmd_documents_next_document (GtkAction *action, XedWindow *window);
void _xed_cmd_documents_move_to_new_window (GtkAction *action, XedWindow *window);
void _xed_cmd_file_close_tab (XedTab *tab,
XedWindow *window);
void _xed_cmd_help_contents (GtkAction *action, XedWindow *window);
void _xed_cmd_help_about (GtkAction *action, XedWindow *window);
void _xed_cmd_file_save_documents_list (XedWindow *window,
GList *docs);
void _xed_cmd_file_close_tab (XedTab *tab, XedWindow *window);
void _xed_cmd_file_save_documents_list (XedWindow *window, GList *docs);
G_END_DECLS
#endif /* __XED_COMMANDS_H__ */
#endif /* __XED_COMMANDS_H__ */

View File

@@ -1316,8 +1316,8 @@ xed_prefs_manager_source_style_scheme_changed (GSettings *settings,
static void
xed_prefs_manager_max_recents_changed (GSettings *settings,
gchar *key,
gpointer user_data)
gchar *key,
gpointer user_data)
{
xed_debug (DEBUG_PREFS);
@@ -1328,21 +1328,11 @@ xed_prefs_manager_max_recents_changed (GSettings *settings,
max = g_settings_get_int (settings, key);
if (max < 0) {
if (max < 0)
{
max = GPM_DEFAULT_MAX_RECENTS;
}
windows = xed_app_get_windows (xed_app_get_default ());
while (windows != NULL)
{
XedWindow *w = windows->data;
gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (w->priv->toolbar_recent_menu),
max);
windows = g_list_next (windows);
}
/* FIXME: we have no way at the moment to trigger the
* update of the inline recents in the File menu */
}

View File

@@ -359,76 +359,6 @@ DEFINE_BOOL_PREF (display_line_numbers,
DEFINE_BOOL_PREF (toolbar_visible,
GPM_TOOLBAR_VISIBLE)
/* Toolbar suttons style */
XedToolbarSetting
xed_prefs_manager_get_toolbar_buttons_style (void)
{
gchar *str;
XedToolbarSetting res;
xed_debug (DEBUG_PREFS);
str = xed_prefs_manager_get_string (GPM_TOOLBAR_BUTTONS_STYLE);
if (strcmp (str, "XED_TOOLBAR_ICONS") == 0)
res = XED_TOOLBAR_ICONS;
else
{
if (strcmp (str, "XED_TOOLBAR_ICONS_AND_TEXT") == 0)
res = XED_TOOLBAR_ICONS_AND_TEXT;
else
{
if (strcmp (str, "XED_TOOLBAR_ICONS_BOTH_HORIZ") == 0)
res = XED_TOOLBAR_ICONS_BOTH_HORIZ;
else
res = XED_TOOLBAR_SYSTEM;
}
}
g_free (str);
return res;
}
void
xed_prefs_manager_set_toolbar_buttons_style (XedToolbarSetting tbs)
{
const gchar * str;
xed_debug (DEBUG_PREFS);
switch (tbs)
{
case XED_TOOLBAR_ICONS:
str = "XED_TOOLBAR_ICONS";
break;
case XED_TOOLBAR_ICONS_AND_TEXT:
str = "XED_TOOLBAR_ICONS_AND_TEXT";
break;
case XED_TOOLBAR_ICONS_BOTH_HORIZ:
str = "XED_TOOLBAR_ICONS_BOTH_HORIZ";
break;
default: /* XED_TOOLBAR_SYSTEM */
str = "XED_TOOLBAR_SYSTEM";
}
xed_prefs_manager_set_string (GPM_TOOLBAR_BUTTONS_STYLE,
str);
}
gboolean
xed_prefs_manager_toolbar_buttons_style_can_set (void)
{
xed_debug (DEBUG_PREFS);
return xed_prefs_manager_key_is_writable (GPM_TOOLBAR_BUTTONS_STYLE);
}
/* Statusbar visiblity */
DEFINE_BOOL_PREF (statusbar_visible,
GPM_STATUSBAR_VISIBLE)

View File

@@ -74,7 +74,6 @@
/* UI */
#define GPM_TOOLBAR_VISIBLE "toolbar-visible"
#define GPM_TOOLBAR_BUTTONS_STYLE "toolbar-buttons-style"
#define GPM_STATUSBAR_VISIBLE "statusbar-visible"
@@ -115,13 +114,6 @@
#define GPM_DEFAULT_AUTO_SAVE_INTERVAL 10 /* minutes */
#define GPM_DEFAULT_MAX_RECENTS 5
typedef enum {
XED_TOOLBAR_SYSTEM = 0,
XED_TOOLBAR_ICONS,
XED_TOOLBAR_ICONS_AND_TEXT,
XED_TOOLBAR_ICONS_BOTH_HORIZ
} XedToolbarSetting;
/** LIFE CYCLE MANAGEMENT FUNCTIONS **/
gboolean xed_prefs_manager_init (void);
@@ -195,11 +187,6 @@ gboolean xed_prefs_manager_get_toolbar_visible (void);
void xed_prefs_manager_set_toolbar_visible (gboolean tv);
gboolean xed_prefs_manager_toolbar_visible_can_set (void);
/* Toolbar buttons style */
XedToolbarSetting xed_prefs_manager_get_toolbar_buttons_style (void);
void xed_prefs_manager_set_toolbar_buttons_style (XedToolbarSetting tbs);
gboolean xed_prefs_manager_toolbar_buttons_style_can_set (void);
/* Statusbar visible */
gboolean xed_prefs_manager_get_statusbar_visible (void);
void xed_prefs_manager_set_statusbar_visible (gboolean sv);

771
xed/xed-searchbar.c Executable file
View File

@@ -0,0 +1,771 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "xed-searchbar.h"
#include "xed-statusbar.h"
#include "xed-history-entry.h"
#include "xed-utils.h"
#include "xed-marshal.h"
#include "xed-dirs.h"
#include "xed-commands.h"
#include "xed-window-private.h"
#define XED_SEARCHBAR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), XED_TYPE_SEARCHBAR, XedSearchbarPrivate))
/* Signals */
enum
{
SHOW_REPLACE, LAST_SIGNAL
};
struct _XedSearchbarPrivate
{
gboolean show_replace;
GtkWidget *revealer;
GtkWidget *grid;
GtkWidget *search_label;
GtkWidget *search_entry;
GtkWidget *search_text_entry;
GtkWidget *replace_label;
GtkWidget *replace_entry;
GtkWidget *replace_text_entry;
GtkWidget *match_case_checkbutton;
GtkWidget *entire_word_checkbutton;
GtkWidget *wrap_around_checkbutton;
GtkWidget *find_button;
GtkWidget *find_prev_button;
GtkWidget *replace_button;
GtkWidget *replace_all_button;
};
G_DEFINE_TYPE(XedSearchbar, xed_searchbar, GTK_TYPE_BOX)
static void
xed_searchbar_class_init (XedSearchbarClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
GtkBindingSet *binding_set;
g_type_class_add_private (object_class, sizeof(XedSearchbarPrivate));
binding_set = gtk_binding_set_by_class (klass);
}
#define XED_SEARCHBAR_KEY "xed-searchbar-key"
#define MAX_MSG_LENGTH 40
/* Use occurrences only for Replace All */
static void
text_found (XedWindow *window,
gint occurrences)
{
if (occurrences > 1)
{
xed_statusbar_flash_message (XED_STATUSBAR(window->priv->statusbar), window->priv->generic_message_cid,
ngettext ("Found and replaced %d occurrence", "Found and replaced %d occurrences", occurrences),
occurrences);
}
else
{
if (occurrences == 1)
{
xed_statusbar_flash_message (XED_STATUSBAR(window->priv->statusbar), window->priv->generic_message_cid,
_("Found and replaced one occurrence"));
}
else
{
xed_statusbar_flash_message (XED_STATUSBAR(window->priv->statusbar), window->priv->generic_message_cid,
" ");
}
}
}
static void
text_not_found (XedWindow *window,
const gchar *text)
{
gchar *searched;
searched = xed_utils_str_end_truncate (text, MAX_MSG_LENGTH);
xed_statusbar_flash_message (XED_STATUSBAR(window->priv->statusbar), window->priv->generic_message_cid,
_("\"%s\" not found"), searched);
g_free (searched);
}
static gboolean
run_search (XedView *view,
gboolean wrap_around,
gboolean search_backwards)
{
XedDocument *doc;
GtkTextIter start_iter;
GtkTextIter match_start;
GtkTextIter match_end;
gboolean found = FALSE;
doc = XED_DOCUMENT(gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
if (!search_backwards)
{
gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER(doc), NULL, &start_iter);
found = xed_document_search_forward (doc, &start_iter, NULL, &match_start, &match_end);
}
else
{
gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER(doc), &start_iter, NULL);
found = xed_document_search_backward (doc, NULL, &start_iter, &match_start, &match_end);
}
if (!found && wrap_around)
{
if (!search_backwards)
{
/* FIXME: set the end_inter */
found = xed_document_search_forward (doc, NULL, NULL, &match_start, &match_end);
}
else
{
/* FIXME: set the start_inter */
found = xed_document_search_backward (doc, NULL, NULL, &match_start, &match_end);
}
}
if (found)
{
gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER(doc), &match_start);
gtk_text_buffer_move_mark_by_name (GTK_TEXT_BUFFER(doc), "selection_bound", &match_end);
xed_view_scroll_to_cursor (view);
}
else
{
gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER(doc), &start_iter);
}
return found;
}
static void
do_find (XedSearchbar *searchbar,
gboolean search_backwards)
{
XedView *active_view;
XedDocument *doc;
gchar *search_text;
const gchar *entry_text;
gboolean match_case;
gboolean entire_word;
gboolean wrap_around;
guint flags = 0;
guint old_flags = 0;
gboolean found;
/* TODO: make the searchbar insensitive when all the tabs are closed
* and assert here that the view is not NULL */
active_view = xed_window_get_active_view (searchbar->window);
if (active_view == NULL)
{
return;
}
doc = XED_DOCUMENT(gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
match_case = xed_searchbar_get_match_case (searchbar);
entire_word = xed_searchbar_get_entire_word (searchbar);
wrap_around = xed_searchbar_get_wrap_around (searchbar);
entry_text = xed_searchbar_get_search_text (searchbar);
XED_SEARCH_SET_CASE_SENSITIVE(flags, match_case);
XED_SEARCH_SET_ENTIRE_WORD(flags, entire_word);
search_text = xed_document_get_search_text (doc, &old_flags);
if ((search_text == NULL) || (strcmp (search_text, entry_text) != 0) || (flags != old_flags))
{
xed_document_set_search_text (doc, entry_text, flags);
}
g_free (search_text);
found = run_search (active_view, wrap_around, search_backwards);
if (found)
{
text_found (searchbar->window, 0);
}
else
{
text_not_found (searchbar->window, entry_text);
}
}
void
xed_searchbar_find_again (XedSearchbar *searchbar,
gboolean backward)
{
XedView *active_view;
gboolean wrap_around = TRUE;
gpointer data;
active_view = xed_window_get_active_view (searchbar->window);
g_return_if_fail(active_view != NULL);
data = g_object_get_data (G_OBJECT(searchbar->window), XED_SEARCHBAR_KEY);
if (data != NULL)
{
wrap_around = xed_searchbar_get_wrap_around (XED_SEARCHBAR(data));
}
run_search (active_view, wrap_around, backward);
}
static void
search_buttons_set_sensitive (XedSearchbar *searchbar,
gboolean sensitive)
{
gtk_widget_set_sensitive (searchbar->priv->find_button, sensitive);
gtk_widget_set_sensitive (searchbar->priv->find_prev_button, sensitive);
gtk_widget_set_sensitive (searchbar->priv->replace_button, sensitive);
gtk_widget_set_sensitive (searchbar->priv->replace_all_button, sensitive);
}
/* FIXME: move in xed-document.c and share it with xed-view */
static gboolean
get_selected_text (GtkTextBuffer *doc,
gchar **selected_text,
gint *len)
{
GtkTextIter start, end;
g_return_val_if_fail(selected_text != NULL, FALSE);
g_return_val_if_fail(*selected_text == NULL, FALSE);
if (!gtk_text_buffer_get_selection_bounds (doc, &start, &end))
{
if (len != NULL)
{
len = 0;
}
return FALSE;
}
*selected_text = gtk_text_buffer_get_slice (doc, &start, &end, TRUE);
if (len != NULL)
{
*len = g_utf8_strlen (*selected_text, -1);
}
return TRUE;
}
static void
replace_selected_text (GtkTextBuffer *buffer,
const gchar *replace)
{
g_return_if_fail(gtk_text_buffer_get_selection_bounds (buffer, NULL, NULL));
g_return_if_fail(replace != NULL);
gtk_text_buffer_begin_user_action (buffer);
gtk_text_buffer_delete_selection (buffer, FALSE, TRUE);
gtk_text_buffer_insert_at_cursor (buffer, replace, strlen (replace));
gtk_text_buffer_end_user_action (buffer);
}
static void
do_replace (XedSearchbar *searchbar)
{
XedDocument *doc;
const gchar *search_entry_text;
const gchar *replace_entry_text;
gchar *unescaped_search_text;
gchar *unescaped_replace_text;
gchar *selected_text = NULL;
gboolean match_case;
doc = xed_window_get_active_document (searchbar->window);
if (doc == NULL)
{
return;
}
search_entry_text = xed_searchbar_get_search_text (searchbar);
g_return_if_fail((search_entry_text) != NULL);
g_return_if_fail((*search_entry_text) != '\0');
/* replace text may be "", we just delete */
replace_entry_text = xed_searchbar_get_replace_text (searchbar);
g_return_if_fail((replace_entry_text) != NULL);
unescaped_search_text = xed_utils_unescape_search_text (search_entry_text);
get_selected_text (GTK_TEXT_BUFFER(doc), &selected_text, NULL);
match_case = xed_searchbar_get_match_case (searchbar);
if ((selected_text == NULL)
|| (match_case && (strcmp (selected_text, unescaped_search_text) != 0))
|| (!match_case && !g_utf8_caselessnmatch (selected_text,
unescaped_search_text,
strlen (selected_text),
strlen (unescaped_search_text)) != 0))
{
do_find (searchbar, FALSE);
g_free (unescaped_search_text);
g_free (selected_text);
return;
}
unescaped_replace_text = xed_utils_unescape_search_text (replace_entry_text);
replace_selected_text (GTK_TEXT_BUFFER(doc), unescaped_replace_text);
g_free (unescaped_search_text);
g_free (selected_text);
g_free (unescaped_replace_text);
do_find (searchbar, FALSE);
}
static void
do_replace_all (XedSearchbar *searchbar)
{
XedView *active_view;
XedDocument *doc;
const gchar *search_entry_text;
const gchar *replace_entry_text;
gboolean match_case;
gboolean entire_word;
guint flags = 0;
gint count;
active_view = xed_window_get_active_view (searchbar->window);
if (active_view == NULL)
{
return;
}
doc = XED_DOCUMENT(gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
search_entry_text = xed_searchbar_get_search_text (searchbar);
g_return_if_fail((search_entry_text) != NULL);
g_return_if_fail((*search_entry_text) != '\0');
/* replace text may be "", we just delete all occurrences */
replace_entry_text = xed_searchbar_get_replace_text (searchbar);
g_return_if_fail((replace_entry_text) != NULL);
match_case = xed_searchbar_get_match_case (searchbar);
entire_word = xed_searchbar_get_entire_word (searchbar);
XED_SEARCH_SET_CASE_SENSITIVE(flags, match_case);
XED_SEARCH_SET_ENTIRE_WORD(flags, entire_word);
count = xed_document_replace_all (doc, search_entry_text, replace_entry_text, flags);
if (count > 0)
{
text_found (searchbar->window, count);
}
else
{
text_not_found (searchbar->window, search_entry_text);
}
}
static void
insert_text_handler (GtkEditable *editable,
const gchar *text,
gint length,
gint *position,
gpointer data)
{
static gboolean insert_text = FALSE;
gchar *escaped_text;
gint new_len;
/* To avoid recursive behavior */
if (insert_text)
{
return;
}
escaped_text = xed_utils_escape_search_text (text);
new_len = strlen (escaped_text);
if (new_len == length)
{
g_free (escaped_text);
return;
}
insert_text = TRUE;
g_signal_stop_emission_by_name (editable, "insert_text");
gtk_editable_insert_text (editable, escaped_text, new_len, position);
insert_text = FALSE;
g_free (escaped_text);
}
static void
search_text_entry_changed (GtkEditable *editable,
XedSearchbar *searchbar)
{
const gchar *search_string;
search_string = gtk_entry_get_text (GTK_ENTRY(editable));
g_return_if_fail(search_string != NULL);
if (*search_string != '\0')
{
search_buttons_set_sensitive (searchbar, TRUE);
do_find (searchbar, FALSE);
}
else
{
search_buttons_set_sensitive (searchbar, FALSE);
}
}
static void
remember_search_entry (XedSearchbar *searchbar)
{
const gchar *str;
str = gtk_entry_get_text (GTK_ENTRY(searchbar->priv->search_text_entry));
if (*str != '\0')
{
gchar *text;
text = xed_utils_unescape_search_text (str);
xed_history_entry_prepend_text (XED_HISTORY_ENTRY(searchbar->priv->search_entry), text);
g_free (text);
}
}
static void
remember_replace_entry (XedSearchbar *searchbar)
{
const gchar *str;
str = gtk_entry_get_text (GTK_ENTRY(searchbar->priv->replace_text_entry));
if (*str != '\0')
{
gchar *text;
text = xed_utils_unescape_search_text (str);
xed_history_entry_prepend_text (XED_HISTORY_ENTRY(searchbar->priv->replace_entry), text);
g_free (text);
}
}
static void
find_button_clicked_callback (GtkWidget *button,
XedSearchbar *searchbar)
{
remember_search_entry (searchbar);
do_find (searchbar, FALSE);
}
static void
find_prev_button_clicked_callback (GtkWidget *button,
XedSearchbar *searchbar)
{
remember_search_entry (searchbar);
do_find (searchbar, TRUE);
}
static void
replace_button_clicked_callback (GtkWidget *button,
XedSearchbar *searchbar)
{
remember_search_entry (searchbar);
remember_replace_entry (searchbar);
do_replace (searchbar);
}
static void
replace_all_button_clicked_callback (GtkWidget *button,
XedSearchbar *searchbar)
{
remember_search_entry (searchbar);
remember_replace_entry (searchbar);
do_replace_all (searchbar);
}
static void
on_search_text_entry_activated (GtkEntry *widget,
XedSearchbar *searchbar)
{
remember_search_entry (searchbar);
do_find (searchbar, FALSE);
}
static void
xed_searchbar_init (XedSearchbar *searchbar)
{
GtkWidget *content;
GtkSizeGroup *size_group;
GtkWidget *error_widget;
gchar *file;
gchar *root_objects[] = { "searchbar_content", NULL };
searchbar->priv = XED_SEARCHBAR_GET_PRIVATE(searchbar);
file = xed_dirs_get_ui_file ("xed-searchbar.ui");
xed_utils_get_ui_objects (file,
root_objects,
&error_widget,
"searchbar_content", &content,
"revealer", &searchbar->priv->revealer,
"grid", &searchbar->priv->grid,
"search_label", &searchbar->priv->search_label,
"replace_with_label", &searchbar->priv->replace_label,
"match_case_checkbutton", &searchbar->priv->match_case_checkbutton,
"entire_word_checkbutton", &searchbar->priv->entire_word_checkbutton,
"wrap_around_checkbutton", &searchbar->priv->wrap_around_checkbutton,
"find_button", &searchbar->priv->find_button,
"find_prev_button", &searchbar->priv->find_prev_button,
"replace_button", &searchbar->priv->replace_button,
"replace_all_button", &searchbar->priv->replace_all_button,
NULL);
g_free (file);
searchbar->priv->search_entry = xed_history_entry_new ("history-search-for", TRUE);
gtk_widget_set_hexpand (searchbar->priv->search_entry, TRUE);
xed_history_entry_set_escape_func (XED_HISTORY_ENTRY(searchbar->priv->search_entry),
(XedHistoryEntryEscapeFunc) xed_utils_escape_search_text);
searchbar->priv->search_text_entry = xed_history_entry_get_entry (XED_HISTORY_ENTRY(searchbar->priv->search_entry));
gtk_entry_set_activates_default (GTK_ENTRY(searchbar->priv->search_text_entry), TRUE);
gtk_widget_show (searchbar->priv->search_entry);
gtk_grid_attach (GTK_GRID(searchbar->priv->grid), searchbar->priv->search_entry, 2, 0, 1, 1);
searchbar->priv->replace_entry = xed_history_entry_new ("history-replace-with", TRUE);
xed_history_entry_set_escape_func (XED_HISTORY_ENTRY(searchbar->priv->replace_entry),
(XedHistoryEntryEscapeFunc) xed_utils_escape_search_text);
searchbar->priv->replace_text_entry = xed_history_entry_get_entry (
XED_HISTORY_ENTRY(searchbar->priv->replace_entry));
gtk_entry_set_activates_default (GTK_ENTRY(searchbar->priv->replace_text_entry), TRUE);
gtk_widget_show (searchbar->priv->replace_entry);
gtk_grid_attach (GTK_GRID(searchbar->priv->grid), searchbar->priv->replace_entry, 2, 1, 1, 1);
gtk_label_set_mnemonic_widget (GTK_LABEL(searchbar->priv->search_label), searchbar->priv->search_entry);
gtk_label_set_mnemonic_widget (GTK_LABEL(searchbar->priv->replace_label), searchbar->priv->replace_entry);
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (size_group, GTK_WIDGET(searchbar->priv->find_button));
gtk_size_group_add_widget (size_group, GTK_WIDGET(searchbar->priv->find_prev_button));
gtk_size_group_add_widget (size_group, GTK_WIDGET(searchbar->priv->replace_button));
gtk_size_group_add_widget (size_group, GTK_WIDGET(searchbar->priv->replace_all_button));
/* insensitive by default */
search_buttons_set_sensitive (searchbar, FALSE);
xed_searchbar_hide (searchbar);
gtk_box_pack_start (GTK_BOX(searchbar), content, TRUE, TRUE, 0);
gtk_widget_show (GTK_WIDGET(searchbar));
g_object_unref (content);
g_signal_connect(searchbar->priv->search_text_entry, "insert_text",
G_CALLBACK (insert_text_handler), NULL);
g_signal_connect(searchbar->priv->replace_text_entry, "insert_text",
G_CALLBACK (insert_text_handler), NULL);
g_signal_connect(searchbar->priv->search_text_entry, "changed",
G_CALLBACK (search_text_entry_changed), searchbar);
g_signal_connect(searchbar->priv->search_text_entry, "activate",
G_CALLBACK (on_search_text_entry_activated), searchbar);
g_signal_connect(searchbar->priv->find_button, "clicked",
G_CALLBACK (find_button_clicked_callback), searchbar);
g_signal_connect(searchbar->priv->find_prev_button, "clicked",
G_CALLBACK (find_prev_button_clicked_callback), searchbar);
g_signal_connect(searchbar->priv->replace_button, "clicked",
G_CALLBACK (replace_button_clicked_callback), searchbar);
g_signal_connect(searchbar->priv->replace_all_button, "clicked",
G_CALLBACK (replace_all_button_clicked_callback), searchbar);
}
GtkWidget *
xed_searchbar_new (GtkWindow *parent,
gboolean show_replace)
{
XedSearchbar *searchbar;
searchbar = g_object_new (XED_TYPE_SEARCHBAR, NULL);
searchbar->window = parent;
return GTK_WIDGET(searchbar);
}
void
xed_searchbar_show (XedSearchbar *searchbar,
gboolean show_replace)
{
XedDocument *doc;
gboolean selection_exists;
gchar *find_text = NULL;
const gchar *search_text = NULL;
gint sel_len;
doc = xed_window_get_active_document (searchbar->window);
g_return_if_fail(doc != NULL);
selection_exists = get_selected_text (GTK_TEXT_BUFFER(doc), &find_text, &sel_len);
if (selection_exists && find_text != NULL && sel_len < 80)
{
/*
* Special case: if the currently selected text
* is the same as the unescaped search text, use the
* same old search text. (Without this, if you e.g.
* search for '\n' and then open the search searchbar again,
* you'll get an unprintable single-character literal '\n' in the "search for" box).
*/
search_text = xed_searchbar_get_search_text (XED_SEARCHBAR(searchbar));
if (!(search_text != NULL && !strcmp (xed_utils_unescape_search_text (search_text), find_text)))
{
/* General case */
xed_searchbar_set_search_text (XED_SEARCHBAR(searchbar), find_text);
}
g_free (find_text);
}
else
{
g_free (find_text);
}
gtk_revealer_set_transition_type (GTK_REVEALER(searchbar->priv->revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
gtk_revealer_set_reveal_child (GTK_REVEALER(searchbar->priv->revealer), TRUE);
if (show_replace)
{
gtk_widget_show (searchbar->priv->replace_label);
gtk_widget_show (searchbar->priv->replace_entry);
gtk_widget_show (searchbar->priv->replace_all_button);
gtk_widget_show (searchbar->priv->replace_button);
gtk_grid_set_row_spacing (GTK_GRID(searchbar->priv->grid), 10);
}
else
{
gtk_widget_hide (searchbar->priv->replace_label);
gtk_widget_hide (searchbar->priv->replace_entry);
gtk_widget_hide (searchbar->priv->replace_all_button);
gtk_widget_hide (searchbar->priv->replace_button);
gtk_grid_set_row_spacing (GTK_GRID(searchbar->priv->grid), 0);
}
gtk_widget_show (searchbar->priv->find_button);
gtk_widget_grab_focus (searchbar->priv->search_text_entry);
}
void
xed_searchbar_hide (XedSearchbar *searchbar)
{
gtk_revealer_set_transition_type (GTK_REVEALER(searchbar->priv->revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
gtk_revealer_set_reveal_child (GTK_REVEALER(searchbar->priv->revealer), FALSE);
// focus document
XedView *active_view = xed_window_get_active_view (searchbar->window);
if (active_view != NULL)
{
gtk_widget_grab_focus (GTK_WIDGET(active_view));
}
// remove highlighting
_xed_cmd_search_clear_highlight (searchbar->window);
}
void
xed_searchbar_set_search_text (XedSearchbar *searchbar,
const gchar *text)
{
g_return_if_fail(XED_IS_SEARCHBAR (searchbar));
g_return_if_fail(text != NULL);
gtk_entry_set_text (GTK_ENTRY(searchbar->priv->search_text_entry), text);
search_buttons_set_sensitive (searchbar, (text != '\0'));
}
/*
* The text must be unescaped before searching.
*/
const gchar *
xed_searchbar_get_search_text (XedSearchbar *searchbar)
{
g_return_val_if_fail(XED_IS_SEARCHBAR (searchbar), NULL);
return gtk_entry_get_text (GTK_ENTRY(searchbar->priv->search_text_entry));
}
void
xed_searchbar_set_replace_text (XedSearchbar *searchbar,
const gchar *text)
{
g_return_if_fail(XED_IS_SEARCHBAR (searchbar));
g_return_if_fail(text != NULL);
gtk_entry_set_text (GTK_ENTRY(searchbar->priv->replace_text_entry), text);
}
const gchar *
xed_searchbar_get_replace_text (XedSearchbar *searchbar)
{
g_return_val_if_fail(XED_IS_SEARCHBAR (searchbar), NULL);
return gtk_entry_get_text (GTK_ENTRY(searchbar->priv->replace_text_entry));
}
void
xed_searchbar_set_match_case (XedSearchbar *searchbar,
gboolean match_case)
{
g_return_if_fail(XED_IS_SEARCHBAR (searchbar));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(searchbar->priv->match_case_checkbutton), match_case);
}
gboolean
xed_searchbar_get_match_case (XedSearchbar *searchbar)
{
g_return_val_if_fail(XED_IS_SEARCHBAR (searchbar), FALSE);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(searchbar->priv->match_case_checkbutton));
}
void
xed_searchbar_set_entire_word (XedSearchbar *searchbar,
gboolean entire_word)
{
g_return_if_fail(XED_IS_SEARCHBAR (searchbar));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(searchbar->priv->entire_word_checkbutton), entire_word);
}
gboolean
xed_searchbar_get_entire_word (XedSearchbar *searchbar)
{
g_return_val_if_fail(XED_IS_SEARCHBAR (searchbar), FALSE);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(searchbar->priv->entire_word_checkbutton));
}
void
xed_searchbar_set_wrap_around (XedSearchbar *searchbar,
gboolean wrap_around)
{
g_return_if_fail(XED_IS_SEARCHBAR (searchbar));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(searchbar->priv->wrap_around_checkbutton), wrap_around);
}
gboolean
xed_searchbar_get_wrap_around (XedSearchbar *searchbar)
{
g_return_val_if_fail(XED_IS_SEARCHBAR (searchbar), FALSE);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(searchbar->priv->wrap_around_checkbutton));
}

92
xed/xed-searchbar.h Executable file
View File

@@ -0,0 +1,92 @@
#ifndef __XED_SEARCHBAR_H__
#define __XED_SEARCHBAR_H__
#include <gtk/gtk.h>
#include "xed-window.h"
G_BEGIN_DECLS
/*
* Type checking and casting macros
*/
#define XED_TYPE_SEARCHBAR (xed_searchbar_get_type())
#define XED_SEARCHBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_SEARCHBAR, XedSearchbar))
#define XED_SEARCHBAR_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_SEARCHBAR, XedSearchbar const))
#define XED_SEARCHBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_SEARCHBAR, XedSearchbarClass))
#define XED_IS_SEARCHBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XED_TYPE_SEARCHBAR))
#define XED_IS_SEARCHBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_SEARCHBAR))
#define XED_SEARCHBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_SEARCHBAR, XedSearchbarClass))
/* Private structure type */
typedef struct _XedSearchbarPrivate XedSearchbarPrivate;
/*
* Main object structure
*/
typedef struct _XedSearchbar XedSearchbar;
struct _XedSearchbar
{
GtkBox parent;
XedWindow *window;
/*< private > */
XedSearchbarPrivate *priv;
};
/*
* Class definition
*/
typedef struct _XedSearchbarClass XedSearchbarClass;
struct _XedSearchbarClass
{
GtkBoxClass parent_class;
/* Key bindings */
gboolean (* show_replace) (XedSearchbar *dlg);
};
enum
{
XED_SEARCHBAR_FIND_RESPONSE = 100,
XED_SEARCHBAR_REPLACE_RESPONSE,
XED_SEARCHBAR_REPLACE_ALL_RESPONSE
};
/*
* Public methods
*/
GType xed_searchbar_get_type (void) G_GNUC_CONST;
GtkWidget *xed_searchbar_new (GtkWindow *parent, gboolean show_replace);
void xed_searchbar_hide (XedSearchbar *searchbar);
void xed_searchbar_show (XedSearchbar *searchbar, gboolean show_replace);
void xed_searchbar_find_again (XedSearchbar *searchbar, gboolean backward);
void xed_searchbar_set_search_text (XedSearchbar *searchbar, const gchar *text);
const gchar *xed_searchbar_get_search_text (XedSearchbar *searchbar);
void xed_searchbar_set_replace_text (XedSearchbar *searchbar, const gchar *text);
const gchar *xed_searchbar_get_replace_text (XedSearchbar *searchbar);
void xed_searchbar_set_match_case (XedSearchbar *searchbar, gboolean match_case);
gboolean xed_searchbar_get_match_case (XedSearchbar *searchbar);
void xed_searchbar_set_entire_word (XedSearchbar *searchbar, gboolean entire_word);
gboolean xed_searchbar_get_entire_word (XedSearchbar *searchbar);
void xed_searchbar_set_backwards (XedSearchbar *searchbar, gboolean backwards);
gboolean xed_searchbar_get_backwards (XedSearchbar *searchbar);
void xed_searchbar_set_wrap_around (XedSearchbar *searchbar, gboolean wrap_around);
gboolean xed_searchbar_get_wrap_around (XedSearchbar *searchbar);
void xed_searchbar_set_parse_escapes (XedSearchbar *searchbar, gboolean parse_escapes);
gboolean xed_searchbar_get_parse_escapes (XedSearchbar *searchbar);
G_END_DECLS
#endif /* __XED_SEARCHBAR_H__ */

208
xed/xed-searchbar.ui Executable file
View File

@@ -0,0 +1,208 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!--*- mode: xml -*-->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<child>
<object class="GtkBox" id="searchbar_content">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkRevealer" id="revealer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition_type">crossfade</property>
<property name="transition_duration">175</property>
<property name="reveal_child">True</property>
<child>
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="border_width">6</property>
<property name="column_spacing">3</property>
<child>
<object class="GtkButton" id="replace_all_button">
<property name="label" translatable="yes">Replace All</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="replace_button">
<property name="label" translatable="yes">Replace</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="search_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="hexpand">False</property>
<property name="vexpand">False</property>
<property name="label" translatable="yes">_Search for: </property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="replace_with_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Replace _with: </property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="find_button">
<property name="label" translatable="yes">Find</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="hexpand">False</property>
<property name="vexpand">False</property>
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="find_prev_button">
<property name="label" translatable="yes">Find Prev</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="valign">center</property>
<property name="hexpand">False</property>
<property name="vexpand">False</property>
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkToggleButton" id="match_case_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Case sensitive</property>
<property name="halign">start</property>
<child>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">xapp-text-case-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="entire_word_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Whole word</property>
<property name="halign">start</property>
<child>
<object class="GtkImage" id="image5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">xapp-search-entire-word-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="wrap_around_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Wrap</property>
<property name="active">True</property>
<child>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">xapp-search-wrap-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<style>
<class name="linked"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@@ -53,23 +53,23 @@ static const GtkActionEntry xed_always_sensitive_menu_entries[] =
{ "Help", NULL, N_("_Help") },
/* File menu */
{ "FileNew", GTK_STOCK_NEW, NULL, "<control>N",
{ "FileNew", "document-new-symbolic", N_("_New"), "<control>N",
N_("Create a new document"), G_CALLBACK (_xed_cmd_file_new) },
{ "FileOpen", GTK_STOCK_OPEN, N_("_Open..."), "<control>O",
{ "FileOpen", "document-open-symbolic", N_("_Open..."), "<control>O",
N_("Open a file"), G_CALLBACK (_xed_cmd_file_open) },
/* Edit menu */
{ "EditPreferences", GTK_STOCK_PREFERENCES, N_("Pr_eferences"), NULL,
{ "EditPreferences", "preferences-other-symbolic", N_("Pr_eferences"), NULL,
N_("Configure the application"), G_CALLBACK (_xed_cmd_edit_preferences) },
/* Help menu */
{"HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1",
{"HelpContents", "help-contents-symbolic", N_("_Contents"), "F1",
N_("Open the xed manual"), G_CALLBACK (_xed_cmd_help_contents) },
{ "HelpAbout", GTK_STOCK_ABOUT, NULL, NULL,
{ "HelpAbout", "help-about-symbolic", N_("About"), NULL,
N_("About this application"), G_CALLBACK (_xed_cmd_help_about) },
/* Fullscreen toolbar */
{ "LeaveFullscreen", GTK_STOCK_LEAVE_FULLSCREEN, NULL,
{ "LeaveFullscreen", "view-restore-symbolic", NULL,
NULL, N_("Leave fullscreen mode"),
G_CALLBACK (_xed_cmd_view_leave_fullscreen_mode) }
};
@@ -77,56 +77,52 @@ static const GtkActionEntry xed_always_sensitive_menu_entries[] =
static const GtkActionEntry xed_menu_entries[] =
{
/* File menu */
{ "FileSave", GTK_STOCK_SAVE, NULL, "<control>S",
{ "FileSave", "document-save-symbolic", N_("_Save"), "<control>S",
N_("Save the current file"), G_CALLBACK (_xed_cmd_file_save) },
{ "FileSaveAs", GTK_STOCK_SAVE_AS, N_("Save _As..."), "<shift><control>S",
{ "FileSaveAs", "document-save-as-symbolic", N_("Save _As..."), "<shift><control>S",
N_("Save the current file with a different name"), G_CALLBACK (_xed_cmd_file_save_as) },
{ "FileRevert", GTK_STOCK_REVERT_TO_SAVED, NULL, NULL,
{ "FileRevert", "document-revert-symbolic", N_("Revert"), NULL,
N_("Revert to a saved version of the file"), G_CALLBACK (_xed_cmd_file_revert) },
{ "FilePrintPreview", GTK_STOCK_PRINT_PREVIEW, N_("Print Previe_w"),"<control><shift>P",
{ "FilePrintPreview", "document-print-preview-symbolic", N_("Print Previe_w"),"<control><shift>P",
N_("Print preview"), G_CALLBACK (_xed_cmd_file_print_preview) },
{ "FilePrint", GTK_STOCK_PRINT, N_("_Print..."), "<control>P",
{ "FilePrint", "document-print-symbolic", N_("_Print..."), "<control>P",
N_("Print the current page"), G_CALLBACK (_xed_cmd_file_print) },
/* Edit menu */
{ "EditUndo", GTK_STOCK_UNDO, NULL, "<control>Z",
{ "EditUndo", "edit-undo-symbolic", N_("Undo"), "<control>Z",
N_("Undo the last action"), G_CALLBACK (_xed_cmd_edit_undo) },
{ "EditRedo", GTK_STOCK_REDO, NULL, "<control>Y",
{ "EditRedo", "edit-redo-symbolic", N_("Redo"), "<control>Y",
N_("Redo the last undone action"), G_CALLBACK (_xed_cmd_edit_redo) },
{ "EditCut", GTK_STOCK_CUT, NULL, "<control>X",
{ "EditCut", "edit-cut-symbolic", N_("Cut"), "<control>X",
N_("Cut the selection"), G_CALLBACK (_xed_cmd_edit_cut) },
{ "EditCopy", GTK_STOCK_COPY, NULL, "<control>C",
{ "EditCopy", "edit-copy-symbolic", N_("Copy"), "<control>C",
N_("Copy the selection"), G_CALLBACK (_xed_cmd_edit_copy) },
{ "EditPaste", GTK_STOCK_PASTE, NULL, "<control>V",
{ "EditPaste", "edit-paste-symbolic", N_("Paste"), "<control>V",
N_("Paste the clipboard"), G_CALLBACK (_xed_cmd_edit_paste) },
{ "EditDelete", GTK_STOCK_DELETE, NULL, NULL,
{ "EditDelete", "edit-delete-symbolic", N_("Delete"), NULL,
N_("Delete the selected text"), G_CALLBACK (_xed_cmd_edit_delete) },
{ "EditSelectAll", GTK_STOCK_SELECT_ALL, N_("Select _All"), "<control>A",
{ "EditSelectAll", "edit-select-all-symbolic", N_("Select _All"), "<control>A",
N_("Select the entire document"), G_CALLBACK (_xed_cmd_edit_select_all) },
/* View menu */
{ "ViewHighlightMode", NULL, N_("_Highlight Mode") },
/* Search menu */
{ "SearchFind", GTK_STOCK_FIND, N_("_Find..."), "<control>F",
{ "SearchFind", "edit-find-symbolic", N_("_Find"), "<control>F",
N_("Search for text"), G_CALLBACK (_xed_cmd_search_find) },
{ "SearchFindNext", NULL, N_("Find Ne_xt"), "<control>G",
N_("Search forwards for the same text"), G_CALLBACK (_xed_cmd_search_find_next) },
{ "SearchFindPrevious", NULL, N_("Find Pre_vious"), "<shift><control>G",
N_("Search backwards for the same text"), G_CALLBACK (_xed_cmd_search_find_prev) },
{ "SearchReplace", GTK_STOCK_FIND_AND_REPLACE, N_("_Replace..."), "<control>H",
{ "SearchReplace", "edit-find-replace-symbolic", N_("_Replace"), "<control>H",
N_("Search for and replace text"), G_CALLBACK (_xed_cmd_search_replace) },
{ "SearchClearHighlight", NULL, N_("_Clear Highlight"), "<shift><control>K",
N_("Clear highlighting of search matches"), G_CALLBACK (_xed_cmd_search_clear_highlight) },
{ "SearchGoToLine", GTK_STOCK_JUMP_TO, N_("Go to _Line..."), "<control>I",
{ "SearchGoToLine", "go-jump-symbolic", N_("Go to _Line..."), "<control>I",
N_("Go to a specific line"), G_CALLBACK (_xed_cmd_search_goto_line) },
{ "SearchIncrementalSearch", GTK_STOCK_FIND, N_("_Incremental Search..."), "<control>K",
N_("Incrementally search for text"), G_CALLBACK (_xed_cmd_search_incremental_search) },
/* Documents menu */
{ "FileSaveAll", GTK_STOCK_SAVE, N_("_Save All"), "<shift><control>L",
{ "FileSaveAll", "document-save-symbolic", N_("_Save All"), "<shift><control>L",
N_("Save all open files"), G_CALLBACK (_xed_cmd_file_save_all) },
{ "FileCloseAll", GTK_STOCK_CLOSE, N_("_Close All"), "<shift><control>W",
{ "FileCloseAll", "window-close-symbolic", N_("_Close All"), "<shift><control>W",
N_("Close all open files"), G_CALLBACK (_xed_cmd_file_close_all) },
{ "DocumentsPreviousDocument", NULL, N_("_Previous Document"), "<alt><control>Page_Up",
N_("Activate previous document"), G_CALLBACK (_xed_cmd_documents_previous_document) },
@@ -139,14 +135,14 @@ static const GtkActionEntry xed_menu_entries[] =
/* separate group, needs to be sensitive on OS X even when there are no tabs */
static const GtkActionEntry xed_close_menu_entries[] =
{
{ "FileClose", GTK_STOCK_CLOSE, NULL, "<control>W",
{ "FileClose", "window-close-symbolic", N_("_Close"), "<control>W",
N_("Close the current file"), G_CALLBACK (_xed_cmd_file_close) }
};
/* separate group, should be sensitive even when there are no tabs */
static const GtkActionEntry xed_quit_menu_entries[] =
{
{ "FileQuit", GTK_STOCK_QUIT, NULL, "<control>Q",
{ "FileQuit", "application-exit-symbolic", N_("_Quit"), "<control>Q",
N_("Quit the program"), G_CALLBACK (_xed_cmd_file_quit) }
};

View File

@@ -1,31 +1,3 @@
<!--
* xed-ui.xml
* This file is part of xed
*
* Copyright (C) 2005 - Paolo Maggi
*
* 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.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* Modified by the xed Team, 2005. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
-->
<ui>
<menubar name="MenuBar">
@@ -60,9 +32,9 @@
<menuitem name="EditCopyMenu" action="EditCopy"/>
<menuitem name="EditPasteMenu" action="EditPaste"/>
<menuitem name="EditDeleteMenu" action="EditDelete"/>
<placeholder name="EditOps_1" />
<placeholder name="EditOps_1" />
<separator/>
<placeholder name="EditOps_2" />
<placeholder name="EditOps_2" />
<menuitem name="EditSelectAllMenu" action="EditSelectAll"/>
<placeholder name="EditOps_3" />
<separator/>
@@ -93,7 +65,6 @@
<menuitem name="SearchFindMenu" action="SearchFind"/>
<menuitem name="SearchFindNextMenu" action="SearchFindNext"/>
<menuitem name="SearchFindPreviousMenu" action="SearchFindPrevious"/>
<menuitem name="SearchIncrementalSearchMenu" action="SearchIncrementalSearch"/>
<placeholder name="SearchOps_1" />
<separator/>
<placeholder name="SearchOps_2" />
@@ -103,12 +74,11 @@
<separator/>
<placeholder name="SearchOps_4" />
<separator/>
<menuitem name="SearchClearHighlight" action="SearchClearHighlight"/>
<placeholder name="SearchOps_5" />
<separator/>
<placeholder name="SearchOps_6" />
<separator/>
<menuitem name="SearchGoToLineMenu" action="SearchGoToLine"/>
<menuitem name="SearchGoToLineMenu" action="SearchGoToLine"/>
<placeholder name="SearchOps_7" />
<separator/>
<placeholder name="SearchOps_8" />
@@ -136,7 +106,7 @@
<placeholder name="DocumentsOps_2" />
<separator/>
<placeholder name="DocumentsOps_3" />
<menuitem action="DocumentsPreviousDocument" />
<menuitem action="DocumentsPreviousDocument" />
<menuitem action="DocumentsNextDocument" />
<separator/>
<menuitem action="DocumentsMoveToNewWindow"/>
@@ -195,7 +165,7 @@
<separator/>
<menuitem action="FilePrint"/>
<separator/>
<placeholder name="NotebookPupupOps_1"/>
<placeholder name="NotebookPupupOps_1"/>
<separator/>
<menuitem name="FileCloseMenu" action="FileClose"/>
</popup>

File diff suppressed because it is too large Load Diff

View File

@@ -1,33 +1,3 @@
/*
* xed-view.h
* This file is part of xed
*
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
* Copyright (C) 2002-2005 Paolo Maggi
*
* 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.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Modified by the xed Team, 1998-2005. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*/
#ifndef __XED_VIEW_H__
#define __XED_VIEW_H__
@@ -41,67 +11,59 @@ G_BEGIN_DECLS
/*
* Type checking and casting macros
*/
#define XED_TYPE_VIEW (xed_view_get_type ())
#define XED_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_VIEW, XedView))
#define XED_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_VIEW, XedViewClass))
#define XED_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XED_TYPE_VIEW))
#define XED_TYPE_VIEW (xed_view_get_type ())
#define XED_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_VIEW, XedView))
#define XED_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_VIEW, XedViewClass))
#define XED_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XED_TYPE_VIEW))
#define XED_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_VIEW))
#define XED_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_VIEW, XedViewClass))
#define XED_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_VIEW, XedViewClass))
/* Private structure type */
typedef struct _XedViewPrivate XedViewPrivate;
typedef struct _XedViewPrivate XedViewPrivate;
/*
* Main object structure
*/
typedef struct _XedView XedView;
typedef struct _XedView XedView;
struct _XedView
{
GtkSourceView view;
GtkSourceView view;
/*< private > */
XedViewPrivate *priv;
/*< private > */
XedViewPrivate *priv;
};
/*
* Class definition
*/
typedef struct _XedViewClass XedViewClass;
typedef struct _XedViewClass XedViewClass;
struct _XedViewClass
{
GtkSourceViewClass parent_class;
GtkSourceViewClass parent_class;
/* FIXME: Do we need placeholders ? */
/* FIXME: Do we need placeholders ? */
/* Key bindings */
gboolean (* start_interactive_search) (XedView *view);
gboolean (* start_interactive_goto_line)(XedView *view);
gboolean (* reset_searched_text) (XedView *view);
void (* drop_uris) (XedView *view,
gchar **uri_list);
/* Key bindings */
gboolean (* start_interactive_search) (XedView *view);
gboolean (* start_interactive_goto_line)(XedView *view);
gboolean (* reset_searched_text) (XedView *view);
void (* drop_uris) (XedView *view, gchar **uri_list);
};
/*
* Public methods
*/
GType xed_view_get_type (void) G_GNUC_CONST;
GtkWidget *xed_view_new (XedDocument *doc);
void xed_view_cut_clipboard (XedView *view);
void xed_view_copy_clipboard (XedView *view);
void xed_view_paste_clipboard (XedView *view);
void xed_view_delete_selection (XedView *view);
void xed_view_select_all (XedView *view);
void xed_view_scroll_to_cursor (XedView *view);
void xed_view_set_font (XedView *view,
gboolean def,
const gchar *font_name);
GType xed_view_get_type (void) G_GNUC_CONST;
GtkWidget *xed_view_new (XedDocument *doc);
void xed_view_cut_clipboard (XedView *view);
void xed_view_copy_clipboard (XedView *view);
void xed_view_paste_clipboard (XedView *view);
void xed_view_delete_selection (XedView *view);
void xed_view_select_all (XedView *view);
void xed_view_scroll_to_cursor (XedView *view);
void xed_view_set_font (XedView *view, gboolean def, const gchar *font_name);
G_END_DECLS

View File

@@ -56,11 +56,13 @@ struct _XedWindowPrivate
/* Widgets for fullscreen mode */
GtkWidget *fullscreen_controls;
GtkWidget *fullscreen_controls_container;
guint fullscreen_animation_timeout_id;
gboolean fullscreen_animation_enter;
/* statusbar and context ids for statusbar messages */
GtkWidget *statusbar;
GtkWidget *searchbar;
guint generic_message_cid;
guint tip_message_cid;
guint tab_width_id;
@@ -78,9 +80,7 @@ struct _XedWindowPrivate
GtkActionGroup *documents_list_action_group;
guint documents_list_menu_ui_id;
GtkWidget *toolbar;
GtkWidget *toolbar_recent_menu;
GtkWidget *menubar;
XedToolbarSetting toolbar_style;
/* recent files */
GtkActionGroup *recents_action_group;

File diff suppressed because it is too large Load Diff

View File

@@ -1,33 +1,3 @@
/*
* xed-window.h
* This file is part of xed
*
* Copyright (C) 2005 - Paolo Maggi
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANWINDOWILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Modified by the xed Team, 2005. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*
* $Id$
*/
#ifndef __XED_WINDOW_H__
#define __XED_WINDOW_H__
@@ -42,23 +12,23 @@ G_BEGIN_DECLS
typedef enum
{
XED_WINDOW_STATE_NORMAL = 0,
XED_WINDOW_STATE_SAVING = 1 << 1,
XED_WINDOW_STATE_PRINTING = 1 << 2,
XED_WINDOW_STATE_LOADING = 1 << 3,
XED_WINDOW_STATE_ERROR = 1 << 4,
XED_WINDOW_STATE_SAVING_SESSION = 1 << 5
XED_WINDOW_STATE_NORMAL = 0,
XED_WINDOW_STATE_SAVING = 1 << 1,
XED_WINDOW_STATE_PRINTING = 1 << 2,
XED_WINDOW_STATE_LOADING = 1 << 3,
XED_WINDOW_STATE_ERROR = 1 << 4,
XED_WINDOW_STATE_SAVING_SESSION = 1 << 5
} XedWindowState;
/*
* Type checking and casting macros
*/
#define XED_TYPE_WINDOW (xed_window_get_type())
#define XED_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_WINDOW, XedWindow))
#define XED_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_WINDOW, XedWindowClass))
#define XED_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XED_TYPE_WINDOW))
#define XED_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_WINDOW))
#define XED_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_WINDOW, XedWindowClass))
#define XED_TYPE_WINDOW (xed_window_get_type())
#define XED_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_WINDOW, XedWindow))
#define XED_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_WINDOW, XedWindowClass))
#define XED_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XED_TYPE_WINDOW))
#define XED_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_WINDOW))
#define XED_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_WINDOW, XedWindowClass))
/* Private structure type */
typedef struct _XedWindowPrivate XedWindowPrivate;
@@ -68,12 +38,12 @@ typedef struct _XedWindowPrivate XedWindowPrivate;
*/
typedef struct _XedWindow XedWindow;
struct _XedWindow
struct _XedWindow
{
GtkWindow window;
GtkWindow window;
/*< private > */
XedWindowPrivate *priv;
/*< private > */
XedWindowPrivate *priv;
};
/*
@@ -81,115 +51,74 @@ struct _XedWindow
*/
typedef struct _XedWindowClass XedWindowClass;
struct _XedWindowClass
struct _XedWindowClass
{
GtkWindowClass parent_class;
/* Signals */
void (* tab_added) (XedWindow *window,
XedTab *tab);
void (* tab_removed) (XedWindow *window,
XedTab *tab);
void (* tabs_reordered) (XedWindow *window);
void (* active_tab_changed) (XedWindow *window,
XedTab *tab);
void (* active_tab_state_changed)
(XedWindow *window);
GtkWindowClass parent_class;
/* Signals */
void (* tab_added) (XedWindow *window, XedTab *tab);
void (* tab_removed) (XedWindow *window, XedTab *tab);
void (* tabs_reordered) (XedWindow *window);
void (* active_tab_changed) (XedWindow *window, XedTab *tab);
void (* active_tab_state_changed) (XedWindow *window);
};
/*
* Public methods
*/
GType xed_window_get_type (void) G_GNUC_CONST;
XedTab *xed_window_create_tab (XedWindow *window,
gboolean jump_to);
XedTab *xed_window_create_tab_from_uri (XedWindow *window,
const gchar *uri,
const XedEncoding *encoding,
gint line_pos,
gboolean create,
gboolean jump_to);
void xed_window_close_tab (XedWindow *window,
XedTab *tab);
void xed_window_close_all_tabs (XedWindow *window);
void xed_window_close_tabs (XedWindow *window,
const GList *tabs);
XedTab *xed_window_get_active_tab (XedWindow *window);
void xed_window_set_active_tab (XedWindow *window,
XedTab *tab);
GType xed_window_get_type (void) G_GNUC_CONST;
XedTab *xed_window_create_tab (XedWindow *window, gboolean jump_to);
XedTab *xed_window_create_tab_from_uri (XedWindow *window, const gchar *uri, const XedEncoding *encoding,
gint line_pos, gboolean create, gboolean jump_to);
void xed_window_close_tab (XedWindow *window, XedTab *tab);
void xed_window_close_all_tabs (XedWindow *window);
void xed_window_close_tabs (XedWindow *window, const GList *tabs);
XedTab *xed_window_get_active_tab (XedWindow *window);
void xed_window_set_active_tab (XedWindow *window, XedTab *tab);
/* Helper functions */
XedView *xed_window_get_active_view (XedWindow *window);
XedDocument *xed_window_get_active_document (XedWindow *window);
XedView *xed_window_get_active_view (XedWindow *window);
XedDocument *xed_window_get_active_document (XedWindow *window);
/* Returns a newly allocated list with all the documents in the window */
GList *xed_window_get_documents (XedWindow *window);
GList *xed_window_get_documents (XedWindow *window);
/* Returns a newly allocated list with all the documents that need to be
saved before closing the window */
GList *xed_window_get_unsaved_documents (XedWindow *window);
/* Returns a newly allocated list with all the documents that need to be
saved before closing the window */
GList *xed_window_get_unsaved_documents (XedWindow *window);
/* Returns a newly allocated list with all the views in the window */
GList *xed_window_get_views (XedWindow *window);
GtkWindowGroup *xed_window_get_group (XedWindow *window);
XedPanel *xed_window_get_side_panel (XedWindow *window);
XedPanel *xed_window_get_bottom_panel (XedWindow *window);
GtkWidget *xed_window_get_statusbar (XedWindow *window);
GtkUIManager *xed_window_get_ui_manager (XedWindow *window);
XedWindowState xed_window_get_state (XedWindow *window);
XedTab *xed_window_get_tab_from_location (XedWindow *window,
GFile *location);
XedTab *xed_window_get_tab_from_uri (XedWindow *window,
const gchar *uri);
GList *xed_window_get_views (XedWindow *window);
GtkWindowGroup *xed_window_get_group (XedWindow *window);
XedPanel *xed_window_get_side_panel (XedWindow *window);
XedPanel *xed_window_get_bottom_panel (XedWindow *window);
GtkWidget *xed_window_get_statusbar (XedWindow *window);
GtkWidget *xed_window_get_searchbar (XedWindow *window);
GtkUIManager *xed_window_get_ui_manager (XedWindow *window);
XedWindowState xed_window_get_state (XedWindow *window);
XedTab *xed_window_get_tab_from_location (XedWindow *window, GFile *location);
XedTab *xed_window_get_tab_from_uri (XedWindow *window, const gchar *uri);
/* Message bus */
XedMessageBus *xed_window_get_message_bus (XedWindow *window);
XedMessageBus *xed_window_get_message_bus (XedWindow *window);
/*
* Non exported functions
*/
GtkWidget *_xed_window_get_notebook (XedWindow *window);
XedWindow *_xed_window_move_tab_to_new_window (XedWindow *window,
XedTab *tab);
gboolean _xed_window_is_removing_tabs (XedWindow *window);
GFile *_xed_window_get_default_location (XedWindow *window);
void _xed_window_set_default_location (XedWindow *window,
GFile *location);
void _xed_window_set_saving_session_state (XedWindow *window,
gboolean saving_session);
void _xed_window_fullscreen (XedWindow *window);
void _xed_window_unfullscreen (XedWindow *window);
gboolean _xed_window_is_fullscreen (XedWindow *window);
GtkWidget *_xed_window_get_notebook (XedWindow *window);
XedWindow *_xed_window_move_tab_to_new_window (XedWindow *window, XedTab *tab);
gboolean _xed_window_is_removing_tabs (XedWindow *window);
GFile *_xed_window_get_default_location (XedWindow *window);
void _xed_window_set_default_location (XedWindow *window, GFile *location);
void _xed_window_set_saving_session_state (XedWindow *window, gboolean saving_session);
void _xed_window_fullscreen (XedWindow *window);
void _xed_window_unfullscreen (XedWindow *window);
gboolean _xed_window_is_fullscreen (XedWindow *window);
/* these are in xed-window because of screen safety */
void _xed_recent_add (XedWindow *window,
const gchar *uri,
const gchar *mime);
void _xed_recent_remove (XedWindow *window,
const gchar *uri);
void _xed_recent_add (XedWindow *window, const gchar *uri, const gchar *mime);
void _xed_recent_remove (XedWindow *window, const gchar *uri);
G_END_DECLS
#endif /* __XED_WINDOW_H__ */
#endif /* __XED_WINDOW_H__ */