Rename Pluma to Xedit
This commit is contained in:
31
xedit/dialogs/Makefile.am
Executable file
31
xedit/dialogs/Makefile.am
Executable file
@@ -0,0 +1,31 @@
|
||||
uidir = $(datadir)/xedit/ui/
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_srcdir)/xedit \
|
||||
-I$(top_builddir)/xedit \
|
||||
$(XEDIT_CFLAGS) \
|
||||
$(WARN_CFLAGS) \
|
||||
$(DISABLE_DEPRECATED_CFLAGS)
|
||||
|
||||
noinst_LTLIBRARIES = libdialogs.la
|
||||
|
||||
libdialogs_la_SOURCES = \
|
||||
xedit-preferences-dialog.h \
|
||||
xedit-preferences-dialog.c \
|
||||
xedit-close-confirmation-dialog.c \
|
||||
xedit-close-confirmation-dialog.h \
|
||||
xedit-encodings-dialog.c \
|
||||
xedit-encodings-dialog.h \
|
||||
xedit-search-dialog.h \
|
||||
xedit-search-dialog.c
|
||||
|
||||
ui_DATA = \
|
||||
xedit-encodings-dialog.ui \
|
||||
xedit-preferences-dialog.ui \
|
||||
xedit-search-dialog.ui
|
||||
|
||||
EXTRA_DIST = $(ui_DATA)
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
836
xedit/dialogs/xedit-close-confirmation-dialog.c
Executable file
836
xedit/dialogs/xedit-close-confirmation-dialog.c
Executable file
@@ -0,0 +1,836 @@
|
||||
/*
|
||||
* xedit-close-confirmation-dialog.c
|
||||
* This file is part of xedit
|
||||
*
|
||||
* Copyright (C) 2004-2005 GNOME Foundation
|
||||
*
|
||||
* 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 xedit Team, 2004-2005. See the AUTHORS file for a
|
||||
* list of people on the xedit Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "xedit-close-confirmation-dialog.h"
|
||||
#include <xedit/xedit-app.h>
|
||||
#include <xedit/xedit-utils.h>
|
||||
#include <xedit/xedit-window.h>
|
||||
|
||||
|
||||
/* Properties */
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_UNSAVED_DOCUMENTS,
|
||||
PROP_LOGOUT_MODE
|
||||
};
|
||||
|
||||
/* Mode */
|
||||
enum
|
||||
{
|
||||
SINGLE_DOC_MODE,
|
||||
MULTIPLE_DOCS_MODE
|
||||
};
|
||||
|
||||
/* Columns */
|
||||
enum
|
||||
{
|
||||
SAVE_COLUMN,
|
||||
NAME_COLUMN,
|
||||
DOC_COLUMN, /* a handy pointer to the document */
|
||||
N_COLUMNS
|
||||
};
|
||||
|
||||
struct _XeditCloseConfirmationDialogPrivate
|
||||
{
|
||||
gboolean logout_mode;
|
||||
|
||||
GList *unsaved_documents;
|
||||
|
||||
GList *selected_documents;
|
||||
|
||||
GtkTreeModel *list_store;
|
||||
|
||||
gboolean disable_save_to_disk;
|
||||
};
|
||||
|
||||
#define XEDIT_CLOSE_CONFIRMATION_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
|
||||
XEDIT_TYPE_CLOSE_CONFIRMATION_DIALOG, \
|
||||
XeditCloseConfirmationDialogPrivate))
|
||||
|
||||
#define GET_MODE(priv) (((priv->unsaved_documents != NULL) && \
|
||||
(priv->unsaved_documents->next == NULL)) ? \
|
||||
SINGLE_DOC_MODE : MULTIPLE_DOCS_MODE)
|
||||
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
#define gtk_hbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_HORIZONTAL,Y)
|
||||
#define gtk_vbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_VERTICAL,Y)
|
||||
#endif
|
||||
|
||||
G_DEFINE_TYPE(XeditCloseConfirmationDialog, xedit_close_confirmation_dialog, GTK_TYPE_DIALOG)
|
||||
|
||||
static void set_unsaved_document (XeditCloseConfirmationDialog *dlg,
|
||||
const GList *list);
|
||||
|
||||
static GList *get_selected_docs (GtkTreeModel *store);
|
||||
|
||||
/* Since we connect in the costructor we are sure this handler will be called
|
||||
* before the user ones
|
||||
*/
|
||||
static void
|
||||
response_cb (XeditCloseConfirmationDialog *dlg,
|
||||
gint response_id,
|
||||
gpointer data)
|
||||
{
|
||||
XeditCloseConfirmationDialogPrivate *priv;
|
||||
|
||||
g_return_if_fail (XEDIT_IS_CLOSE_CONFIRMATION_DIALOG (dlg));
|
||||
|
||||
priv = dlg->priv;
|
||||
|
||||
if (priv->selected_documents != NULL)
|
||||
g_list_free (priv->selected_documents);
|
||||
|
||||
if (response_id == GTK_RESPONSE_YES)
|
||||
{
|
||||
if (GET_MODE (priv) == SINGLE_DOC_MODE)
|
||||
{
|
||||
priv->selected_documents =
|
||||
g_list_copy (priv->unsaved_documents);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_return_if_fail (priv->list_store);
|
||||
|
||||
priv->selected_documents =
|
||||
get_selected_docs (priv->list_store);
|
||||
}
|
||||
}
|
||||
else
|
||||
priv->selected_documents = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
set_logout_mode (XeditCloseConfirmationDialog *dlg,
|
||||
gboolean logout_mode)
|
||||
{
|
||||
dlg->priv->logout_mode = logout_mode;
|
||||
|
||||
if (logout_mode)
|
||||
{
|
||||
gtk_dialog_add_button (GTK_DIALOG (dlg),
|
||||
_("Log Out _without Saving"),
|
||||
GTK_RESPONSE_NO);
|
||||
|
||||
xedit_dialog_add_button (GTK_DIALOG (dlg),
|
||||
_("_Cancel Logout"),
|
||||
GTK_STOCK_CANCEL,
|
||||
GTK_RESPONSE_CANCEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_dialog_add_button (GTK_DIALOG (dlg),
|
||||
_("Close _without Saving"),
|
||||
GTK_RESPONSE_NO);
|
||||
|
||||
gtk_dialog_add_button (GTK_DIALOG (dlg),
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
|
||||
}
|
||||
|
||||
if (dlg->priv->disable_save_to_disk)
|
||||
{
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dlg),
|
||||
GTK_RESPONSE_NO);
|
||||
}
|
||||
else
|
||||
{
|
||||
const gchar *stock_id = GTK_STOCK_SAVE;
|
||||
|
||||
if (GET_MODE (dlg->priv) == SINGLE_DOC_MODE)
|
||||
{
|
||||
XeditDocument *doc;
|
||||
|
||||
doc = XEDIT_DOCUMENT (dlg->priv->unsaved_documents->data);
|
||||
|
||||
if (xedit_document_get_readonly (doc) ||
|
||||
xedit_document_is_untitled (doc))
|
||||
stock_id = GTK_STOCK_SAVE_AS;
|
||||
}
|
||||
|
||||
gtk_dialog_add_button (GTK_DIALOG (dlg),
|
||||
stock_id,
|
||||
GTK_RESPONSE_YES);
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dlg),
|
||||
GTK_RESPONSE_YES);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xedit_close_confirmation_dialog_init (XeditCloseConfirmationDialog *dlg)
|
||||
{
|
||||
AtkObject *atk_obj;
|
||||
|
||||
dlg->priv = XEDIT_CLOSE_CONFIRMATION_DIALOG_GET_PRIVATE (dlg);
|
||||
|
||||
dlg->priv->disable_save_to_disk =
|
||||
xedit_app_get_lockdown (xedit_app_get_default ())
|
||||
& XEDIT_LOCKDOWN_SAVE_TO_DISK;
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
|
||||
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
|
||||
14);
|
||||
gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
|
||||
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dlg), TRUE);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (dlg), "");
|
||||
|
||||
gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
|
||||
gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
|
||||
|
||||
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (dlg));
|
||||
atk_object_set_role (atk_obj, ATK_ROLE_ALERT);
|
||||
atk_object_set_name (atk_obj, _("Question"));
|
||||
|
||||
g_signal_connect (dlg,
|
||||
"response",
|
||||
G_CALLBACK (response_cb),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
xedit_close_confirmation_dialog_finalize (GObject *object)
|
||||
{
|
||||
XeditCloseConfirmationDialogPrivate *priv;
|
||||
|
||||
priv = XEDIT_CLOSE_CONFIRMATION_DIALOG (object)->priv;
|
||||
|
||||
if (priv->unsaved_documents != NULL)
|
||||
g_list_free (priv->unsaved_documents);
|
||||
|
||||
if (priv->selected_documents != NULL)
|
||||
g_list_free (priv->selected_documents);
|
||||
|
||||
/* Call the parent's destructor */
|
||||
G_OBJECT_CLASS (xedit_close_confirmation_dialog_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xedit_close_confirmation_dialog_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
XeditCloseConfirmationDialog *dlg;
|
||||
|
||||
dlg = XEDIT_CLOSE_CONFIRMATION_DIALOG (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_UNSAVED_DOCUMENTS:
|
||||
set_unsaved_document (dlg, g_value_get_pointer (value));
|
||||
break;
|
||||
|
||||
case PROP_LOGOUT_MODE:
|
||||
set_logout_mode (dlg, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xedit_close_confirmation_dialog_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
XeditCloseConfirmationDialogPrivate *priv;
|
||||
|
||||
priv = XEDIT_CLOSE_CONFIRMATION_DIALOG (object)->priv;
|
||||
|
||||
switch( prop_id )
|
||||
{
|
||||
case PROP_UNSAVED_DOCUMENTS:
|
||||
g_value_set_pointer (value, priv->unsaved_documents);
|
||||
break;
|
||||
|
||||
case PROP_LOGOUT_MODE:
|
||||
g_value_set_boolean (value, priv->logout_mode);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xedit_close_confirmation_dialog_class_init (XeditCloseConfirmationDialogClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->set_property = xedit_close_confirmation_dialog_set_property;
|
||||
gobject_class->get_property = xedit_close_confirmation_dialog_get_property;
|
||||
gobject_class->finalize = xedit_close_confirmation_dialog_finalize;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (XeditCloseConfirmationDialogPrivate));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_UNSAVED_DOCUMENTS,
|
||||
g_param_spec_pointer ("unsaved_documents",
|
||||
"Unsaved Documents",
|
||||
"List of Unsaved Documents",
|
||||
(G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY)));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_LOGOUT_MODE,
|
||||
g_param_spec_boolean ("logout_mode",
|
||||
"Logout Mode",
|
||||
"Whether the dialog is in logout mode",
|
||||
FALSE,
|
||||
(G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY)));
|
||||
}
|
||||
|
||||
static GList *
|
||||
get_selected_docs (GtkTreeModel *store)
|
||||
{
|
||||
GList *list;
|
||||
gboolean valid;
|
||||
GtkTreeIter iter;
|
||||
|
||||
list = NULL;
|
||||
valid = gtk_tree_model_get_iter_first (store, &iter);
|
||||
|
||||
while (valid)
|
||||
{
|
||||
gboolean to_save;
|
||||
XeditDocument *doc;
|
||||
|
||||
gtk_tree_model_get (store, &iter,
|
||||
SAVE_COLUMN, &to_save,
|
||||
DOC_COLUMN, &doc,
|
||||
-1);
|
||||
if (to_save)
|
||||
list = g_list_prepend (list, doc);
|
||||
|
||||
valid = gtk_tree_model_iter_next (store, &iter);
|
||||
}
|
||||
|
||||
list = g_list_reverse (list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
GList *
|
||||
xedit_close_confirmation_dialog_get_selected_documents (XeditCloseConfirmationDialog *dlg)
|
||||
{
|
||||
g_return_val_if_fail (XEDIT_IS_CLOSE_CONFIRMATION_DIALOG (dlg), NULL);
|
||||
|
||||
return g_list_copy (dlg->priv->selected_documents);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
xedit_close_confirmation_dialog_new (GtkWindow *parent,
|
||||
GList *unsaved_documents,
|
||||
gboolean logout_mode)
|
||||
{
|
||||
GtkWidget *dlg;
|
||||
g_return_val_if_fail (unsaved_documents != NULL, NULL);
|
||||
|
||||
dlg = GTK_WIDGET (g_object_new (XEDIT_TYPE_CLOSE_CONFIRMATION_DIALOG,
|
||||
"unsaved_documents", unsaved_documents,
|
||||
"logout_mode", logout_mode,
|
||||
NULL));
|
||||
g_return_val_if_fail (dlg != NULL, NULL);
|
||||
|
||||
if (parent != NULL)
|
||||
{
|
||||
gtk_window_group_add_window (xedit_window_get_group (XEDIT_WINDOW (parent)),
|
||||
GTK_WINDOW (dlg));
|
||||
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dlg), parent);
|
||||
}
|
||||
|
||||
return dlg;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
xedit_close_confirmation_dialog_new_single (GtkWindow *parent,
|
||||
XeditDocument *doc,
|
||||
gboolean logout_mode)
|
||||
{
|
||||
GtkWidget *dlg;
|
||||
GList *unsaved_documents;
|
||||
g_return_val_if_fail (doc != NULL, NULL);
|
||||
|
||||
unsaved_documents = g_list_prepend (NULL, doc);
|
||||
|
||||
dlg = xedit_close_confirmation_dialog_new (parent,
|
||||
unsaved_documents,
|
||||
logout_mode);
|
||||
|
||||
g_list_free (unsaved_documents);
|
||||
|
||||
return dlg;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
get_text_secondary_label (XeditDocument *doc)
|
||||
{
|
||||
glong seconds;
|
||||
gchar *secondary_msg;
|
||||
|
||||
seconds = MAX (1, _xedit_document_get_seconds_since_last_save_or_load (doc));
|
||||
|
||||
if (seconds < 55)
|
||||
{
|
||||
secondary_msg = g_strdup_printf (
|
||||
ngettext ("If you don't save, changes from the last %ld second "
|
||||
"will be permanently lost.",
|
||||
"If you don't save, changes from the last %ld seconds "
|
||||
"will be permanently lost.",
|
||||
seconds),
|
||||
seconds);
|
||||
}
|
||||
else if (seconds < 75) /* 55 <= seconds < 75 */
|
||||
{
|
||||
secondary_msg = g_strdup (_("If you don't save, changes from the last minute "
|
||||
"will be permanently lost."));
|
||||
}
|
||||
else if (seconds < 110) /* 75 <= seconds < 110 */
|
||||
{
|
||||
secondary_msg = g_strdup_printf (
|
||||
ngettext ("If you don't save, changes from the last minute and %ld "
|
||||
"second will be permanently lost.",
|
||||
"If you don't save, changes from the last minute and %ld "
|
||||
"seconds will be permanently lost.",
|
||||
seconds - 60 ),
|
||||
seconds - 60);
|
||||
}
|
||||
else if (seconds < 3600)
|
||||
{
|
||||
secondary_msg = g_strdup_printf (
|
||||
ngettext ("If you don't save, changes from the last %ld minute "
|
||||
"will be permanently lost.",
|
||||
"If you don't save, changes from the last %ld minutes "
|
||||
"will be permanently lost.",
|
||||
seconds / 60),
|
||||
seconds / 60);
|
||||
}
|
||||
else if (seconds < 7200)
|
||||
{
|
||||
gint minutes;
|
||||
seconds -= 3600;
|
||||
|
||||
minutes = seconds / 60;
|
||||
if (minutes < 5)
|
||||
{
|
||||
secondary_msg = g_strdup (_("If you don't save, changes from the last hour "
|
||||
"will be permanently lost."));
|
||||
}
|
||||
else
|
||||
{
|
||||
secondary_msg = g_strdup_printf (
|
||||
ngettext ("If you don't save, changes from the last hour and %d "
|
||||
"minute will be permanently lost.",
|
||||
"If you don't save, changes from the last hour and %d "
|
||||
"minutes will be permanently lost.",
|
||||
minutes),
|
||||
minutes);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gint hours;
|
||||
|
||||
hours = seconds / 3600;
|
||||
|
||||
secondary_msg = g_strdup_printf (
|
||||
ngettext ("If you don't save, changes from the last %d hour "
|
||||
"will be permanently lost.",
|
||||
"If you don't save, changes from the last %d hours "
|
||||
"will be permanently lost.",
|
||||
hours),
|
||||
hours);
|
||||
}
|
||||
|
||||
return secondary_msg;
|
||||
}
|
||||
|
||||
static void
|
||||
build_single_doc_dialog (XeditCloseConfirmationDialog *dlg)
|
||||
{
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *primary_label;
|
||||
GtkWidget *secondary_label;
|
||||
GtkWidget *image;
|
||||
XeditDocument *doc;
|
||||
gchar *doc_name;
|
||||
gchar *str;
|
||||
gchar *markup_str;
|
||||
|
||||
g_return_if_fail (dlg->priv->unsaved_documents->data != NULL);
|
||||
doc = XEDIT_DOCUMENT (dlg->priv->unsaved_documents->data);
|
||||
|
||||
/* Image */
|
||||
#if GTK_CHECK_VERSION (3, 10, 0)
|
||||
image = gtk_image_new_from_icon_name ("dialog-warning",
|
||||
GTK_ICON_SIZE_DIALOG);
|
||||
#else
|
||||
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
|
||||
GTK_ICON_SIZE_DIALOG);
|
||||
#endif
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
gtk_widget_set_halign (image, GTK_ALIGN_START);
|
||||
gtk_widget_set_valign (image, GTK_ALIGN_END);
|
||||
#else
|
||||
gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
|
||||
#endif
|
||||
|
||||
/* Primary label */
|
||||
primary_label = gtk_label_new (NULL);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
|
||||
gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
|
||||
#if GTK_CHECK_VERSION (3, 16, 0)
|
||||
gtk_label_set_xalign (GTK_LABEL (primary_label), 0.0);
|
||||
#else
|
||||
gtk_misc_set_alignment (GTK_MISC (primary_label), 0.0, 0.5);
|
||||
#endif
|
||||
gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
|
||||
gtk_widget_set_can_focus (GTK_WIDGET (primary_label), FALSE);
|
||||
|
||||
doc_name = xedit_document_get_short_name_for_display (doc);
|
||||
|
||||
if (dlg->priv->disable_save_to_disk)
|
||||
{
|
||||
str = g_markup_printf_escaped (_("Changes to document \"%s\" will be permanently lost."),
|
||||
doc_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
str = g_markup_printf_escaped (_("Save changes to document \"%s\" before closing?"),
|
||||
doc_name);
|
||||
}
|
||||
|
||||
g_free (doc_name);
|
||||
|
||||
markup_str = g_strconcat ("<span weight=\"bold\" size=\"larger\">", str, "</span>", NULL);
|
||||
g_free (str);
|
||||
|
||||
gtk_label_set_markup (GTK_LABEL (primary_label), markup_str);
|
||||
g_free (markup_str);
|
||||
|
||||
/* Secondary label */
|
||||
if (dlg->priv->disable_save_to_disk)
|
||||
str = g_strdup (_("Saving has been disabled by the system administrator."));
|
||||
else
|
||||
str = get_text_secondary_label (doc);
|
||||
secondary_label = gtk_label_new (str);
|
||||
g_free (str);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
|
||||
#if GTK_CHECK_VERSION (3, 16, 0)
|
||||
gtk_label_set_xalign (GTK_LABEL (secondary_label), 0.0);
|
||||
#else
|
||||
gtk_misc_set_alignment (GTK_MISC (secondary_label), 0.0, 0.5);
|
||||
#endif
|
||||
gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
|
||||
gtk_widget_set_can_focus (GTK_WIDGET (secondary_label), FALSE);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 12);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 12);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), primary_label, FALSE, FALSE, 0);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), secondary_label, FALSE, FALSE, 0);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
|
||||
hbox,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0);
|
||||
|
||||
gtk_widget_show_all (hbox);
|
||||
}
|
||||
|
||||
static void
|
||||
populate_model (GtkTreeModel *store, GList *docs)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
|
||||
while (docs != NULL)
|
||||
{
|
||||
XeditDocument *doc;
|
||||
gchar *name;
|
||||
|
||||
doc = XEDIT_DOCUMENT (docs->data);
|
||||
|
||||
name = xedit_document_get_short_name_for_display (doc);
|
||||
|
||||
gtk_list_store_append (GTK_LIST_STORE (store), &iter);
|
||||
gtk_list_store_set (GTK_LIST_STORE (store), &iter,
|
||||
SAVE_COLUMN, TRUE,
|
||||
NAME_COLUMN, name,
|
||||
DOC_COLUMN, doc,
|
||||
-1);
|
||||
|
||||
g_free (name);
|
||||
|
||||
docs = g_list_next (docs);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
save_toggled (GtkCellRendererToggle *renderer, gchar *path_str, GtkTreeModel *store)
|
||||
{
|
||||
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
|
||||
GtkTreeIter iter;
|
||||
gboolean active;
|
||||
|
||||
gtk_tree_model_get_iter (store, &iter, path);
|
||||
gtk_tree_model_get (store, &iter, SAVE_COLUMN, &active, -1);
|
||||
|
||||
active ^= 1;
|
||||
|
||||
gtk_list_store_set (GTK_LIST_STORE (store), &iter,
|
||||
SAVE_COLUMN, active, -1);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_treeview (XeditCloseConfirmationDialogPrivate *priv)
|
||||
{
|
||||
GtkListStore *store;
|
||||
GtkWidget *treeview;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
|
||||
treeview = gtk_tree_view_new ();
|
||||
gtk_widget_set_size_request (treeview, 260, 120);
|
||||
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
|
||||
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeview), FALSE);
|
||||
|
||||
/* Create and populate the model */
|
||||
store = gtk_list_store_new (N_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER);
|
||||
populate_model (GTK_TREE_MODEL (store), priv->unsaved_documents);
|
||||
|
||||
/* Set model to the treeview */
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store));
|
||||
g_object_unref (store);
|
||||
|
||||
priv->list_store = GTK_TREE_MODEL (store);
|
||||
|
||||
/* Add columns */
|
||||
if (!priv->disable_save_to_disk)
|
||||
{
|
||||
renderer = gtk_cell_renderer_toggle_new ();
|
||||
g_signal_connect (renderer, "toggled",
|
||||
G_CALLBACK (save_toggled), store);
|
||||
|
||||
column = gtk_tree_view_column_new_with_attributes ("Save?",
|
||||
renderer,
|
||||
"active",
|
||||
SAVE_COLUMN,
|
||||
NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
|
||||
}
|
||||
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes ("Name",
|
||||
renderer,
|
||||
"text",
|
||||
NAME_COLUMN,
|
||||
NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
|
||||
|
||||
return treeview;
|
||||
}
|
||||
|
||||
static void
|
||||
build_multiple_docs_dialog (XeditCloseConfirmationDialog *dlg)
|
||||
{
|
||||
XeditCloseConfirmationDialogPrivate *priv;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *image;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *primary_label;
|
||||
GtkWidget *vbox2;
|
||||
GtkWidget *select_label;
|
||||
GtkWidget *scrolledwindow;
|
||||
GtkWidget *treeview;
|
||||
GtkWidget *secondary_label;
|
||||
gchar *str;
|
||||
gchar *markup_str;
|
||||
|
||||
priv = dlg->priv;
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 12);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
|
||||
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
|
||||
hbox, TRUE, TRUE, 0);
|
||||
|
||||
/* Image */
|
||||
#if GTK_CHECK_VERSION (3, 10, 0)
|
||||
image = gtk_image_new_from_icon_name ("dialog-warning",
|
||||
GTK_ICON_SIZE_DIALOG);
|
||||
#else
|
||||
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
|
||||
GTK_ICON_SIZE_DIALOG);
|
||||
#endif
|
||||
#if GTK_CHECK_VERSION (3, 0, 0)
|
||||
gtk_widget_set_halign (image, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (image, GTK_ALIGN_START);
|
||||
#else
|
||||
gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
|
||||
#endif
|
||||
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 12);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
|
||||
|
||||
/* Primary label */
|
||||
primary_label = gtk_label_new (NULL);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE);
|
||||
gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
|
||||
#if GTK_CHECK_VERSION (3, 16, 0)
|
||||
gtk_label_set_xalign (GTK_LABEL (primary_label), 0.0);
|
||||
#else
|
||||
gtk_misc_set_alignment (GTK_MISC (primary_label), 0.0, 0.5);
|
||||
#endif
|
||||
gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
|
||||
|
||||
if (priv->disable_save_to_disk)
|
||||
str = g_strdup_printf (
|
||||
ngettext ("Changes to %d document will be permanently lost.",
|
||||
"Changes to %d documents will be permanently lost.",
|
||||
g_list_length (priv->unsaved_documents)),
|
||||
g_list_length (priv->unsaved_documents));
|
||||
else
|
||||
str = g_strdup_printf (
|
||||
ngettext ("There is %d document with unsaved changes. "
|
||||
"Save changes before closing?",
|
||||
"There are %d documents with unsaved changes. "
|
||||
"Save changes before closing?",
|
||||
g_list_length (priv->unsaved_documents)),
|
||||
g_list_length (priv->unsaved_documents));
|
||||
|
||||
markup_str = g_strconcat ("<span weight=\"bold\" size=\"larger\">", str, "</span>", NULL);
|
||||
g_free (str);
|
||||
|
||||
gtk_label_set_markup (GTK_LABEL (primary_label), markup_str);
|
||||
g_free (markup_str);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), primary_label, FALSE, FALSE, 0);
|
||||
|
||||
vbox2 = gtk_vbox_new (FALSE, 8);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
|
||||
|
||||
if (priv->disable_save_to_disk)
|
||||
select_label = gtk_label_new_with_mnemonic (_("Docum_ents with unsaved changes:"));
|
||||
else
|
||||
select_label = gtk_label_new_with_mnemonic (_("S_elect the documents you want to save:"));
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), select_label, FALSE, FALSE, 0);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (select_label), TRUE);
|
||||
#if GTK_CHECK_VERSION (3, 16, 0)
|
||||
gtk_label_set_xalign (GTK_LABEL (select_label), 0.0);
|
||||
#else
|
||||
gtk_misc_set_alignment (GTK_MISC (select_label), 0.0, 0.5);
|
||||
#endif
|
||||
|
||||
scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), scrolledwindow, TRUE, TRUE, 0);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow),
|
||||
GTK_SHADOW_IN);
|
||||
|
||||
treeview = create_treeview (priv);
|
||||
gtk_container_add (GTK_CONTAINER (scrolledwindow), treeview);
|
||||
|
||||
/* Secondary label */
|
||||
if (priv->disable_save_to_disk)
|
||||
secondary_label = gtk_label_new (_("Saving has been disabled by the system administrator."));
|
||||
else
|
||||
secondary_label = gtk_label_new (_("If you don't save, "
|
||||
"all your changes will be permanently lost."));
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), secondary_label, FALSE, FALSE, 0);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
|
||||
#if GTK_CHECK_VERSION (3, 16, 0)
|
||||
gtk_label_set_xalign (GTK_LABEL (secondary_label), 0.0);
|
||||
#else
|
||||
gtk_misc_set_alignment (GTK_MISC (secondary_label), 0.0, 0.5);
|
||||
#endif
|
||||
gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
|
||||
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (select_label), treeview);
|
||||
|
||||
gtk_widget_show_all (hbox);
|
||||
}
|
||||
|
||||
static void
|
||||
set_unsaved_document (XeditCloseConfirmationDialog *dlg,
|
||||
const GList *list)
|
||||
{
|
||||
XeditCloseConfirmationDialogPrivate *priv;
|
||||
|
||||
g_return_if_fail (list != NULL);
|
||||
|
||||
priv = dlg->priv;
|
||||
g_return_if_fail (priv->unsaved_documents == NULL);
|
||||
|
||||
priv->unsaved_documents = g_list_copy ((GList *)list);
|
||||
|
||||
if (GET_MODE (priv) == SINGLE_DOC_MODE)
|
||||
{
|
||||
build_single_doc_dialog (dlg);
|
||||
}
|
||||
else
|
||||
{
|
||||
build_multiple_docs_dialog (dlg);
|
||||
}
|
||||
}
|
||||
|
||||
const GList *
|
||||
xedit_close_confirmation_dialog_get_unsaved_documents (XeditCloseConfirmationDialog *dlg)
|
||||
{
|
||||
g_return_val_if_fail (XEDIT_IS_CLOSE_CONFIRMATION_DIALOG (dlg), NULL);
|
||||
|
||||
return dlg->priv->unsaved_documents;
|
||||
}
|
75
xedit/dialogs/xedit-close-confirmation-dialog.h
Executable file
75
xedit/dialogs/xedit-close-confirmation-dialog.h
Executable file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* xedit-close-confirmation-dialog.h
|
||||
* This file is part of xedit
|
||||
*
|
||||
* Copyright (C) 2004-2005 GNOME Foundation
|
||||
*
|
||||
* 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 xedit Team, 2004-2005. See the AUTHORS file for a
|
||||
* list of people on the xedit Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*/
|
||||
|
||||
#ifndef __XEDIT_CLOSE_CONFIRMATION_DIALOG_H__
|
||||
#define __XEDIT_CLOSE_CONFIRMATION_DIALOG_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <xedit/xedit-document.h>
|
||||
|
||||
#define XEDIT_TYPE_CLOSE_CONFIRMATION_DIALOG (xedit_close_confirmation_dialog_get_type ())
|
||||
#define XEDIT_CLOSE_CONFIRMATION_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XEDIT_TYPE_CLOSE_CONFIRMATION_DIALOG, XeditCloseConfirmationDialog))
|
||||
#define XEDIT_CLOSE_CONFIRMATION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XEDIT_TYPE_CLOSE_CONFIRMATION_DIALOG, XeditCloseConfirmationDialogClass))
|
||||
#define XEDIT_IS_CLOSE_CONFIRMATION_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XEDIT_TYPE_CLOSE_CONFIRMATION_DIALOG))
|
||||
#define XEDIT_IS_CLOSE_CONFIRMATION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XEDIT_TYPE_CLOSE_CONFIRMATION_DIALOG))
|
||||
#define XEDIT_CLOSE_CONFIRMATION_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),XEDIT_TYPE_CLOSE_CONFIRMATION_DIALOG, XeditCloseConfirmationDialogClass))
|
||||
|
||||
typedef struct _XeditCloseConfirmationDialog XeditCloseConfirmationDialog;
|
||||
typedef struct _XeditCloseConfirmationDialogClass XeditCloseConfirmationDialogClass;
|
||||
typedef struct _XeditCloseConfirmationDialogPrivate XeditCloseConfirmationDialogPrivate;
|
||||
|
||||
struct _XeditCloseConfirmationDialog
|
||||
{
|
||||
GtkDialog parent;
|
||||
|
||||
/*< private > */
|
||||
XeditCloseConfirmationDialogPrivate *priv;
|
||||
};
|
||||
|
||||
struct _XeditCloseConfirmationDialogClass
|
||||
{
|
||||
GtkDialogClass parent_class;
|
||||
};
|
||||
|
||||
GType xedit_close_confirmation_dialog_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget *xedit_close_confirmation_dialog_new (GtkWindow *parent,
|
||||
GList *unsaved_documents,
|
||||
gboolean logout_mode);
|
||||
GtkWidget *xedit_close_confirmation_dialog_new_single (GtkWindow *parent,
|
||||
XeditDocument *doc,
|
||||
gboolean logout_mode);
|
||||
|
||||
const GList *xedit_close_confirmation_dialog_get_unsaved_documents (XeditCloseConfirmationDialog *dlg);
|
||||
|
||||
GList *xedit_close_confirmation_dialog_get_selected_documents (XeditCloseConfirmationDialog *dlg);
|
||||
|
||||
#endif /* __XEDIT_CLOSE_CONFIRMATION_DIALOG_H__ */
|
||||
|
498
xedit/dialogs/xedit-encodings-dialog.c
Executable file
498
xedit/dialogs/xedit-encodings-dialog.c
Executable file
@@ -0,0 +1,498 @@
|
||||
/*
|
||||
* xedit-encodings-dialog.c
|
||||
* This file is part of xedit
|
||||
*
|
||||
* 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 xedit Team, 2002-2005. See the AUTHORS file for a
|
||||
* list of people on the xedit Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "xedit-encodings-dialog.h"
|
||||
#include "xedit-encodings.h"
|
||||
#include "xedit-prefs-manager.h"
|
||||
#include "xedit-utils.h"
|
||||
#include "xedit-debug.h"
|
||||
#include "xedit-help.h"
|
||||
#include "xedit-dirs.h"
|
||||
|
||||
#define XEDIT_ENCODINGS_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
||||
XEDIT_TYPE_ENCODINGS_DIALOG, \
|
||||
XeditEncodingsDialogPrivate))
|
||||
|
||||
struct _XeditEncodingsDialogPrivate
|
||||
{
|
||||
GtkListStore *available_liststore;
|
||||
GtkListStore *displayed_liststore;
|
||||
GtkWidget *available_treeview;
|
||||
GtkWidget *displayed_treeview;
|
||||
GtkWidget *add_button;
|
||||
GtkWidget *remove_button;
|
||||
|
||||
GSList *show_in_menu_list;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(XeditEncodingsDialog, xedit_encodings_dialog, GTK_TYPE_DIALOG)
|
||||
|
||||
static void
|
||||
xedit_encodings_dialog_finalize (GObject *object)
|
||||
{
|
||||
XeditEncodingsDialogPrivate *priv = XEDIT_ENCODINGS_DIALOG (object)->priv;
|
||||
|
||||
g_slist_free (priv->show_in_menu_list);
|
||||
|
||||
G_OBJECT_CLASS (xedit_encodings_dialog_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xedit_encodings_dialog_class_init (XeditEncodingsDialogClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = xedit_encodings_dialog_finalize;
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (XeditEncodingsDialogPrivate));
|
||||
}
|
||||
|
||||
enum {
|
||||
COLUMN_NAME,
|
||||
COLUMN_CHARSET,
|
||||
N_COLUMNS
|
||||
};
|
||||
|
||||
static void
|
||||
count_selected_items_func (GtkTreeModel *model,
|
||||
GtkTreePath *path,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
int *count = data;
|
||||
|
||||
*count += 1;
|
||||
}
|
||||
|
||||
static void
|
||||
available_selection_changed_callback (GtkTreeSelection *selection,
|
||||
XeditEncodingsDialog *dialogs)
|
||||
{
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
gtk_tree_selection_selected_foreach (selection,
|
||||
count_selected_items_func,
|
||||
&count);
|
||||
|
||||
gtk_widget_set_sensitive (dialogs->priv->add_button, count > 0);
|
||||
}
|
||||
|
||||
static void
|
||||
displayed_selection_changed_callback (GtkTreeSelection *selection,
|
||||
XeditEncodingsDialog *dialogs)
|
||||
{
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
gtk_tree_selection_selected_foreach (selection,
|
||||
count_selected_items_func,
|
||||
&count);
|
||||
|
||||
gtk_widget_set_sensitive (dialogs->priv->remove_button, count > 0);
|
||||
}
|
||||
|
||||
static void
|
||||
get_selected_encodings_func (GtkTreeModel *model,
|
||||
GtkTreePath *path,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
GSList **list = data;
|
||||
gchar *charset;
|
||||
const XeditEncoding *enc;
|
||||
|
||||
charset = NULL;
|
||||
gtk_tree_model_get (model, iter, COLUMN_CHARSET, &charset, -1);
|
||||
|
||||
enc = xedit_encoding_get_from_charset (charset);
|
||||
g_free (charset);
|
||||
|
||||
*list = g_slist_prepend (*list, (gpointer)enc);
|
||||
}
|
||||
|
||||
static void
|
||||
update_shown_in_menu_tree_model (GtkListStore *store,
|
||||
GSList *list)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
|
||||
gtk_list_store_clear (store);
|
||||
|
||||
while (list != NULL)
|
||||
{
|
||||
const XeditEncoding *enc;
|
||||
|
||||
enc = (const XeditEncoding*) list->data;
|
||||
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
COLUMN_CHARSET,
|
||||
xedit_encoding_get_charset (enc),
|
||||
COLUMN_NAME,
|
||||
xedit_encoding_get_name (enc), -1);
|
||||
|
||||
list = g_slist_next (list);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_button_clicked_callback (GtkWidget *button,
|
||||
XeditEncodingsDialog *dialog)
|
||||
{
|
||||
GtkTreeSelection *selection;
|
||||
GSList *encodings;
|
||||
GSList *tmp;
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->priv->available_treeview));
|
||||
|
||||
encodings = NULL;
|
||||
gtk_tree_selection_selected_foreach (selection,
|
||||
get_selected_encodings_func,
|
||||
&encodings);
|
||||
|
||||
tmp = encodings;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
if (g_slist_find (dialog->priv->show_in_menu_list, tmp->data) == NULL)
|
||||
dialog->priv->show_in_menu_list = g_slist_prepend (dialog->priv->show_in_menu_list,
|
||||
tmp->data);
|
||||
|
||||
tmp = g_slist_next (tmp);
|
||||
}
|
||||
|
||||
g_slist_free (encodings);
|
||||
|
||||
update_shown_in_menu_tree_model (GTK_LIST_STORE (dialog->priv->displayed_liststore),
|
||||
dialog->priv->show_in_menu_list);
|
||||
}
|
||||
|
||||
static void
|
||||
remove_button_clicked_callback (GtkWidget *button,
|
||||
XeditEncodingsDialog *dialog)
|
||||
{
|
||||
GtkTreeSelection *selection;
|
||||
GSList *encodings;
|
||||
GSList *tmp;
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->priv->displayed_treeview));
|
||||
|
||||
encodings = NULL;
|
||||
gtk_tree_selection_selected_foreach (selection,
|
||||
get_selected_encodings_func,
|
||||
&encodings);
|
||||
|
||||
tmp = encodings;
|
||||
while (tmp != NULL)
|
||||
{
|
||||
dialog->priv->show_in_menu_list = g_slist_remove (dialog->priv->show_in_menu_list,
|
||||
tmp->data);
|
||||
|
||||
tmp = g_slist_next (tmp);
|
||||
}
|
||||
|
||||
g_slist_free (encodings);
|
||||
|
||||
update_shown_in_menu_tree_model (GTK_LIST_STORE (dialog->priv->displayed_liststore),
|
||||
dialog->priv->show_in_menu_list);
|
||||
}
|
||||
|
||||
static void
|
||||
init_shown_in_menu_tree_model (XeditEncodingsDialog *dialog)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GSList *list, *tmp;
|
||||
|
||||
/* add data to the list store */
|
||||
list = xedit_prefs_manager_get_shown_in_menu_encodings ();
|
||||
|
||||
tmp = list;
|
||||
|
||||
while (tmp != NULL)
|
||||
{
|
||||
const XeditEncoding *enc;
|
||||
|
||||
enc = (const XeditEncoding *) tmp->data;
|
||||
|
||||
dialog->priv->show_in_menu_list = g_slist_prepend (dialog->priv->show_in_menu_list,
|
||||
tmp->data);
|
||||
|
||||
gtk_list_store_append (dialog->priv->displayed_liststore,
|
||||
&iter);
|
||||
gtk_list_store_set (dialog->priv->displayed_liststore,
|
||||
&iter,
|
||||
COLUMN_CHARSET,
|
||||
xedit_encoding_get_charset (enc),
|
||||
COLUMN_NAME,
|
||||
xedit_encoding_get_name (enc), -1);
|
||||
|
||||
tmp = g_slist_next (tmp);
|
||||
}
|
||||
|
||||
g_slist_free (list);
|
||||
}
|
||||
|
||||
static void
|
||||
response_handler (GtkDialog *dialog,
|
||||
gint response_id,
|
||||
XeditEncodingsDialog *dlg)
|
||||
{
|
||||
if (response_id == GTK_RESPONSE_HELP)
|
||||
{
|
||||
xedit_help_display (GTK_WINDOW (dialog), "xedit", NULL);
|
||||
g_signal_stop_emission_by_name (dialog, "response");
|
||||
return;
|
||||
}
|
||||
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
{
|
||||
g_return_if_fail (xedit_prefs_manager_shown_in_menu_encodings_can_set ());
|
||||
xedit_prefs_manager_set_shown_in_menu_encodings (dlg->priv->show_in_menu_list);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xedit_encodings_dialog_init (XeditEncodingsDialog *dlg)
|
||||
{
|
||||
GtkWidget *content;
|
||||
GtkCellRenderer *cell_renderer;
|
||||
GtkTreeModel *sort_model;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeIter parent_iter;
|
||||
GtkTreeSelection *selection;
|
||||
const XeditEncoding *enc;
|
||||
GtkWidget *error_widget;
|
||||
int i;
|
||||
gboolean ret;
|
||||
gchar *file;
|
||||
gchar *root_objects[] = {
|
||||
"encodings-dialog-contents",
|
||||
NULL
|
||||
};
|
||||
|
||||
dlg->priv = XEDIT_ENCODINGS_DIALOG_GET_PRIVATE (dlg);
|
||||
|
||||
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
|
||||
GTK_STOCK_CANCEL,
|
||||
GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OK,
|
||||
GTK_RESPONSE_OK,
|
||||
GTK_STOCK_HELP,
|
||||
GTK_RESPONSE_HELP,
|
||||
NULL);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (dlg), _("Character Encodings"));
|
||||
gtk_window_set_default_size (GTK_WINDOW (dlg), 650, 400);
|
||||
|
||||
/* 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);
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dlg),
|
||||
GTK_RESPONSE_OK);
|
||||
|
||||
g_signal_connect (dlg,
|
||||
"response",
|
||||
G_CALLBACK (response_handler),
|
||||
dlg);
|
||||
|
||||
file = xedit_dirs_get_ui_file ("xedit-encodings-dialog.ui");
|
||||
ret = xedit_utils_get_ui_objects (file,
|
||||
root_objects,
|
||||
&error_widget,
|
||||
"encodings-dialog-contents", &content,
|
||||
"add-button", &dlg->priv->add_button,
|
||||
"remove-button", &dlg->priv->remove_button,
|
||||
"available-treeview", &dlg->priv->available_treeview,
|
||||
"displayed-treeview", &dlg->priv->displayed_treeview,
|
||||
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);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
|
||||
content, TRUE, TRUE, 0);
|
||||
g_object_unref (content);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (content), 5);
|
||||
|
||||
g_signal_connect (dlg->priv->add_button,
|
||||
"clicked",
|
||||
G_CALLBACK (add_button_clicked_callback),
|
||||
dlg);
|
||||
g_signal_connect (dlg->priv->remove_button,
|
||||
"clicked",
|
||||
G_CALLBACK (remove_button_clicked_callback),
|
||||
dlg);
|
||||
|
||||
/* Tree view of available encodings */
|
||||
dlg->priv->available_liststore = gtk_list_store_new (N_COLUMNS,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING);
|
||||
|
||||
cell_renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes (_("_Description"),
|
||||
cell_renderer,
|
||||
"text", COLUMN_NAME,
|
||||
NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->available_treeview),
|
||||
column);
|
||||
gtk_tree_view_column_set_sort_column_id (column, COLUMN_NAME);
|
||||
|
||||
cell_renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes (_("_Encoding"),
|
||||
cell_renderer,
|
||||
"text",
|
||||
COLUMN_CHARSET,
|
||||
NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->available_treeview),
|
||||
column);
|
||||
gtk_tree_view_column_set_sort_column_id (column, COLUMN_CHARSET);
|
||||
|
||||
/* Add the data */
|
||||
i = 0;
|
||||
while ((enc = xedit_encoding_get_from_index (i)) != NULL)
|
||||
{
|
||||
gtk_list_store_append (dlg->priv->available_liststore,
|
||||
&parent_iter);
|
||||
gtk_list_store_set (dlg->priv->available_liststore,
|
||||
&parent_iter,
|
||||
COLUMN_CHARSET,
|
||||
xedit_encoding_get_charset (enc),
|
||||
COLUMN_NAME,
|
||||
xedit_encoding_get_name (enc), -1);
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
/* Sort model */
|
||||
sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (dlg->priv->available_liststore));
|
||||
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model),
|
||||
COLUMN_NAME,
|
||||
GTK_SORT_ASCENDING);
|
||||
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (dlg->priv->available_treeview),
|
||||
sort_model);
|
||||
g_object_unref (G_OBJECT (dlg->priv->available_liststore));
|
||||
g_object_unref (G_OBJECT (sort_model));
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->available_treeview));
|
||||
gtk_tree_selection_set_mode (GTK_TREE_SELECTION (selection),
|
||||
GTK_SELECTION_MULTIPLE);
|
||||
|
||||
available_selection_changed_callback (selection, dlg);
|
||||
g_signal_connect (selection,
|
||||
"changed",
|
||||
G_CALLBACK (available_selection_changed_callback),
|
||||
dlg);
|
||||
|
||||
/* Tree view of selected encodings */
|
||||
dlg->priv->displayed_liststore = gtk_list_store_new (N_COLUMNS,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING);
|
||||
|
||||
cell_renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes (_("_Description"),
|
||||
cell_renderer,
|
||||
"text", COLUMN_NAME,
|
||||
NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->displayed_treeview),
|
||||
column);
|
||||
gtk_tree_view_column_set_sort_column_id (column, COLUMN_NAME);
|
||||
|
||||
cell_renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes (_("_Encoding"),
|
||||
cell_renderer,
|
||||
"text",
|
||||
COLUMN_CHARSET,
|
||||
NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->priv->displayed_treeview),
|
||||
column);
|
||||
gtk_tree_view_column_set_sort_column_id (column, COLUMN_CHARSET);
|
||||
|
||||
/* Add the data */
|
||||
init_shown_in_menu_tree_model (dlg);
|
||||
|
||||
/* Sort model */
|
||||
sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (dlg->priv->displayed_liststore));
|
||||
|
||||
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE
|
||||
(sort_model), COLUMN_NAME,
|
||||
GTK_SORT_ASCENDING);
|
||||
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (dlg->priv->displayed_treeview),
|
||||
sort_model);
|
||||
g_object_unref (G_OBJECT (sort_model));
|
||||
g_object_unref (G_OBJECT (dlg->priv->displayed_liststore));
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->displayed_treeview));
|
||||
gtk_tree_selection_set_mode (GTK_TREE_SELECTION (selection),
|
||||
GTK_SELECTION_MULTIPLE);
|
||||
|
||||
displayed_selection_changed_callback (selection, dlg);
|
||||
g_signal_connect (selection,
|
||||
"changed",
|
||||
G_CALLBACK (displayed_selection_changed_callback),
|
||||
dlg);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
xedit_encodings_dialog_new (void)
|
||||
{
|
||||
GtkWidget *dlg;
|
||||
|
||||
dlg = GTK_WIDGET (g_object_new (XEDIT_TYPE_ENCODINGS_DIALOG, NULL));
|
||||
|
||||
return dlg;
|
||||
}
|
||||
|
86
xedit/dialogs/xedit-encodings-dialog.h
Executable file
86
xedit/dialogs/xedit-encodings-dialog.h
Executable file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* xedit-encodings-dialog.h
|
||||
* This file is part of xedit
|
||||
*
|
||||
* Copyright (C) 2003-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 xedit Team, 2003-2005. See the AUTHORS file for a
|
||||
* list of people on the xedit Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __XEDIT_ENCODINGS_DIALOG_H__
|
||||
#define __XEDIT_ENCODINGS_DIALOG_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Type checking and casting macros
|
||||
*/
|
||||
#define XEDIT_TYPE_ENCODINGS_DIALOG (xedit_encodings_dialog_get_type())
|
||||
#define XEDIT_ENCODINGS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XEDIT_TYPE_ENCODINGS_DIALOG, XeditEncodingsDialog))
|
||||
#define XEDIT_ENCODINGS_DIALOG_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XEDIT_TYPE_ENCODINGS_DIALOG, XeditEncodingsDialog const))
|
||||
#define XEDIT_ENCODINGS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XEDIT_TYPE_ENCODINGS_DIALOG, XeditEncodingsDialogClass))
|
||||
#define XEDIT_IS_ENCODINGS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XEDIT_TYPE_ENCODINGS_DIALOG))
|
||||
#define XEDIT_IS_ENCODINGS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XEDIT_TYPE_ENCODINGS_DIALOG))
|
||||
#define XEDIT_ENCODINGS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XEDIT_TYPE_ENCODINGS_DIALOG, XeditEncodingsDialogClass))
|
||||
|
||||
|
||||
/* Private structure type */
|
||||
typedef struct _XeditEncodingsDialogPrivate XeditEncodingsDialogPrivate;
|
||||
|
||||
/*
|
||||
* Main object structure
|
||||
*/
|
||||
typedef struct _XeditEncodingsDialog XeditEncodingsDialog;
|
||||
|
||||
struct _XeditEncodingsDialog
|
||||
{
|
||||
GtkDialog dialog;
|
||||
|
||||
/*< private > */
|
||||
XeditEncodingsDialogPrivate *priv;
|
||||
};
|
||||
|
||||
/*
|
||||
* Class definition
|
||||
*/
|
||||
typedef struct _XeditEncodingsDialogClass XeditEncodingsDialogClass;
|
||||
|
||||
struct _XeditEncodingsDialogClass
|
||||
{
|
||||
GtkDialogClass parent_class;
|
||||
};
|
||||
|
||||
/*
|
||||
* Public methods
|
||||
*/
|
||||
GType xedit_encodings_dialog_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget *xedit_encodings_dialog_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XEDIT_ENCODINGS_DIALOG_H__ */
|
||||
|
255
xedit/dialogs/xedit-encodings-dialog.ui
Executable file
255
xedit/dialogs/xedit-encodings-dialog.ui
Executable file
@@ -0,0 +1,255 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--*- mode: xml -*-->
|
||||
<interface>
|
||||
<object class="GtkDialog" id="encodings-dialog">
|
||||
<property name="width_request">650</property>
|
||||
<property name="height_request">400</property>
|
||||
<property name="title" translatable="yes">Character encodings</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">True</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkVBox" id="dialog-vbox3">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkHButtonBox" id="dialog-action_area3">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="helpbutton1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-help</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="closebutton1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkHBox" id="encodings-dialog-contents">
|
||||
<property name="border_width">6</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox6">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="available-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">A_vailable encodings:</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="mnemonic_widget">available-treeview</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="available-treeview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">True</property>
|
||||
<property name="rules_hint">True</property>
|
||||
<property name="reorderable">False</property>
|
||||
<property name="enable_search">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkHBox" id="hbox6">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="add-button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-add</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</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>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox7">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="displayed-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">E_ncodings shown in menu:</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="mnemonic_widget">displayed-treeview</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="displayed-treeview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">True</property>
|
||||
<property name="rules_hint">True</property>
|
||||
<property name="reorderable">False</property>
|
||||
<property name="enable_search">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkHBox" id="hbox8">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="remove-button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-remove</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</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="-11">helpbutton1</action-widget>
|
||||
<action-widget response="-6">closebutton1</action-widget>
|
||||
<action-widget response="-5">button1</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
</interface>
|
1191
xedit/dialogs/xedit-preferences-dialog.c
Executable file
1191
xedit/dialogs/xedit-preferences-dialog.c
Executable file
File diff suppressed because it is too large
Load Diff
87
xedit/dialogs/xedit-preferences-dialog.h
Executable file
87
xedit/dialogs/xedit-preferences-dialog.h
Executable file
@@ -0,0 +1,87 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* xedit-preferences-dialog.c
|
||||
* This file is part of xedit
|
||||
*
|
||||
* Copyright (C) 2001-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 xedit Team, 2003. See the AUTHORS file for a
|
||||
* list of people on the xedit Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __XEDIT_PREFERENCES_DIALOG_H__
|
||||
#define __XEDIT_PREFERENCES_DIALOG_H__
|
||||
|
||||
#include "xedit-window.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Type checking and casting macros
|
||||
*/
|
||||
#define XEDIT_TYPE_PREFERENCES_DIALOG (xedit_preferences_dialog_get_type())
|
||||
#define XEDIT_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XEDIT_TYPE_PREFERENCES_DIALOG, XeditPreferencesDialog))
|
||||
#define XEDIT_PREFERENCES_DIALOG_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XEDIT_TYPE_PREFERENCES_DIALOG, XeditPreferencesDialog const))
|
||||
#define XEDIT_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XEDIT_TYPE_PREFERENCES_DIALOG, XeditPreferencesDialogClass))
|
||||
#define XEDIT_IS_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XEDIT_TYPE_PREFERENCES_DIALOG))
|
||||
#define XEDIT_IS_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XEDIT_TYPE_PREFERENCES_DIALOG))
|
||||
#define XEDIT_PREFERENCES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XEDIT_TYPE_PREFERENCES_DIALOG, XeditPreferencesDialogClass))
|
||||
|
||||
|
||||
/* Private structure type */
|
||||
typedef struct _XeditPreferencesDialogPrivate XeditPreferencesDialogPrivate;
|
||||
|
||||
/*
|
||||
* Main object structure
|
||||
*/
|
||||
typedef struct _XeditPreferencesDialog XeditPreferencesDialog;
|
||||
|
||||
struct _XeditPreferencesDialog
|
||||
{
|
||||
GtkDialog dialog;
|
||||
|
||||
/*< private > */
|
||||
XeditPreferencesDialogPrivate *priv;
|
||||
};
|
||||
|
||||
/*
|
||||
* Class definition
|
||||
*/
|
||||
typedef struct _XeditPreferencesDialogClass XeditPreferencesDialogClass;
|
||||
|
||||
struct _XeditPreferencesDialogClass
|
||||
{
|
||||
GtkDialogClass parent_class;
|
||||
};
|
||||
|
||||
/*
|
||||
* Public methods
|
||||
*/
|
||||
GType xedit_preferences_dialog_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void xedit_show_preferences_dialog (XeditWindow *parent);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XEDIT_PREFERENCES_DIALOG_H__ */
|
||||
|
1106
xedit/dialogs/xedit-preferences-dialog.ui
Executable file
1106
xedit/dialogs/xedit-preferences-dialog.ui
Executable file
File diff suppressed because it is too large
Load Diff
654
xedit/dialogs/xedit-search-dialog.c
Executable file
654
xedit/dialogs/xedit-search-dialog.c
Executable file
@@ -0,0 +1,654 @@
|
||||
/*
|
||||
* xedit-search-dialog.c
|
||||
* This file is part of xedit
|
||||
*
|
||||
* 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 xedit Team, 2005. See the AUTHORS file for a
|
||||
* list of people on the xedit 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 "xedit-search-dialog.h"
|
||||
#include "xedit-history-entry.h"
|
||||
#include "xedit-utils.h"
|
||||
#include "xedit-marshal.h"
|
||||
#include "xedit-dirs.h"
|
||||
|
||||
#define XEDIT_SEARCH_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
||||
XEDIT_TYPE_SEARCH_DIALOG, \
|
||||
XeditSearchDialogPrivate))
|
||||
|
||||
/* Signals */
|
||||
enum
|
||||
{
|
||||
SHOW_REPLACE,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint dialog_signals [LAST_SIGNAL] = { 0 };
|
||||
|
||||
struct _XeditSearchDialogPrivate
|
||||
{
|
||||
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(XeditSearchDialog, xedit_search_dialog, GTK_TYPE_DIALOG)
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_SHOW_REPLACE
|
||||
};
|
||||
|
||||
static void
|
||||
xedit_search_dialog_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
XeditSearchDialog *dlg = XEDIT_SEARCH_DIALOG (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SHOW_REPLACE:
|
||||
xedit_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
|
||||
xedit_search_dialog_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
XeditSearchDialog *dlg = XEDIT_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
|
||||
xedit_search_dialog_present_with_time (XeditSearchDialog *dialog,
|
||||
guint32 timestamp)
|
||||
{
|
||||
g_return_if_fail (XEDIT_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 (XeditSearchDialog *dlg)
|
||||
{
|
||||
xedit_search_dialog_set_show_replace (dlg, TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
xedit_search_dialog_class_init (XeditSearchDialogClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
object_class->set_property = xedit_search_dialog_set_property;
|
||||
object_class->get_property = xedit_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 (XeditSearchDialogClass, show_replace),
|
||||
NULL, NULL,
|
||||
xedit_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 (XeditSearchDialogPrivate));
|
||||
|
||||
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 = xedit_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,
|
||||
XeditSearchDialog *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),
|
||||
XEDIT_SEARCH_DIALOG_FIND_RESPONSE, TRUE);
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
||||
XEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
||||
XEDIT_SEARCH_DIALOG_FIND_RESPONSE, FALSE);
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
||||
XEDIT_SEARCH_DIALOG_REPLACE_RESPONSE, FALSE);
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
||||
XEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
response_handler (XeditSearchDialog *dialog,
|
||||
gint response_id,
|
||||
gpointer data)
|
||||
{
|
||||
const gchar *str;
|
||||
|
||||
switch (response_id)
|
||||
{
|
||||
case XEDIT_SEARCH_DIALOG_REPLACE_RESPONSE:
|
||||
case XEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE:
|
||||
str = gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_text_entry));
|
||||
if (*str != '\0')
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
text = xedit_utils_unescape_search_text (str);
|
||||
xedit_history_entry_prepend_text
|
||||
(XEDIT_HISTORY_ENTRY (dialog->priv->replace_entry),
|
||||
text);
|
||||
|
||||
g_free (text);
|
||||
}
|
||||
/* fall through, so that we also save the find entry */
|
||||
case XEDIT_SEARCH_DIALOG_FIND_RESPONSE:
|
||||
str = gtk_entry_get_text (GTK_ENTRY (dialog->priv->search_text_entry));
|
||||
if (*str != '\0')
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
text = xedit_utils_unescape_search_text (str);
|
||||
xedit_history_entry_prepend_text
|
||||
(XEDIT_HISTORY_ENTRY (dialog->priv->search_entry),
|
||||
text);
|
||||
|
||||
g_free (text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
show_replace_widgets (XeditSearchDialog *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
|
||||
xedit_search_dialog_init (XeditSearchDialog *dlg)
|
||||
{
|
||||
GtkWidget *content;
|
||||
GtkWidget *error_widget;
|
||||
gboolean ret;
|
||||
gchar *file;
|
||||
gchar *root_objects[] = {
|
||||
"search_dialog_content",
|
||||
NULL
|
||||
};
|
||||
|
||||
dlg->priv = XEDIT_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 = xedit_dirs_get_ui_file ("xedit-search-dialog.ui");
|
||||
ret = xedit_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 = xedit_history_entry_new ("history-search-for",
|
||||
TRUE);
|
||||
gtk_widget_set_size_request (dlg->priv->search_entry, 300, -1);
|
||||
xedit_history_entry_set_escape_func
|
||||
(XEDIT_HISTORY_ENTRY (dlg->priv->search_entry),
|
||||
(XeditHistoryEntryEscapeFunc) xedit_utils_escape_search_text);
|
||||
|
||||
dlg->priv->search_text_entry = xedit_history_entry_get_entry
|
||||
(XEDIT_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 = xedit_history_entry_new ("history-replace-with",
|
||||
TRUE);
|
||||
xedit_history_entry_set_escape_func
|
||||
(XEDIT_HISTORY_ENTRY (dlg->priv->replace_entry),
|
||||
(XeditHistoryEntryEscapeFunc) xedit_utils_escape_search_text);
|
||||
|
||||
dlg->priv->replace_text_entry = xedit_history_entry_get_entry
|
||||
(XEDIT_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 = xedit_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,
|
||||
XEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE);
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
|
||||
dlg->priv->replace_button,
|
||||
XEDIT_SEARCH_DIALOG_REPLACE_RESPONSE);
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (dlg),
|
||||
dlg->priv->find_button,
|
||||
XEDIT_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),
|
||||
XEDIT_SEARCH_DIALOG_FIND_RESPONSE);
|
||||
|
||||
/* insensitive by default */
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
|
||||
XEDIT_SEARCH_DIALOG_FIND_RESPONSE,
|
||||
FALSE);
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
|
||||
XEDIT_SEARCH_DIALOG_REPLACE_RESPONSE,
|
||||
FALSE);
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg),
|
||||
XEDIT_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 *
|
||||
xedit_search_dialog_new (GtkWindow *parent,
|
||||
gboolean show_replace)
|
||||
{
|
||||
XeditSearchDialog *dlg;
|
||||
|
||||
dlg = g_object_new (XEDIT_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
|
||||
xedit_search_dialog_get_show_replace (XeditSearchDialog *dialog)
|
||||
{
|
||||
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
|
||||
|
||||
return dialog->priv->show_replace;
|
||||
}
|
||||
|
||||
void
|
||||
xedit_search_dialog_set_show_replace (XeditSearchDialog *dialog,
|
||||
gboolean show_replace)
|
||||
{
|
||||
g_return_if_fail (XEDIT_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
|
||||
xedit_search_dialog_set_search_text (XeditSearchDialog *dialog,
|
||||
const gchar *text)
|
||||
{
|
||||
g_return_if_fail (XEDIT_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),
|
||||
XEDIT_SEARCH_DIALOG_FIND_RESPONSE,
|
||||
(text != '\0'));
|
||||
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
|
||||
XEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE,
|
||||
(text != '\0'));
|
||||
}
|
||||
|
||||
/*
|
||||
* The text must be unescaped before searching.
|
||||
*/
|
||||
const gchar *
|
||||
xedit_search_dialog_get_search_text (XeditSearchDialog *dialog)
|
||||
{
|
||||
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), NULL);
|
||||
|
||||
return gtk_entry_get_text (GTK_ENTRY (dialog->priv->search_text_entry));
|
||||
}
|
||||
|
||||
void
|
||||
xedit_search_dialog_set_replace_text (XeditSearchDialog *dialog,
|
||||
const gchar *text)
|
||||
{
|
||||
g_return_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog));
|
||||
g_return_if_fail (text != NULL);
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (dialog->priv->replace_text_entry),
|
||||
text);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
xedit_search_dialog_get_replace_text (XeditSearchDialog *dialog)
|
||||
{
|
||||
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), NULL);
|
||||
|
||||
return gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_text_entry));
|
||||
}
|
||||
|
||||
void
|
||||
xedit_search_dialog_set_match_case (XeditSearchDialog *dialog,
|
||||
gboolean match_case)
|
||||
{
|
||||
g_return_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog));
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->match_case_checkbutton),
|
||||
match_case);
|
||||
}
|
||||
|
||||
gboolean
|
||||
xedit_search_dialog_get_match_case (XeditSearchDialog *dialog)
|
||||
{
|
||||
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
|
||||
|
||||
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->match_case_checkbutton));
|
||||
}
|
||||
|
||||
void
|
||||
xedit_search_dialog_set_entire_word (XeditSearchDialog *dialog,
|
||||
gboolean entire_word)
|
||||
{
|
||||
g_return_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog));
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->entire_word_checkbutton),
|
||||
entire_word);
|
||||
}
|
||||
|
||||
gboolean
|
||||
xedit_search_dialog_get_entire_word (XeditSearchDialog *dialog)
|
||||
{
|
||||
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
|
||||
|
||||
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->entire_word_checkbutton));
|
||||
}
|
||||
|
||||
void
|
||||
xedit_search_dialog_set_backwards (XeditSearchDialog *dialog,
|
||||
gboolean backwards)
|
||||
{
|
||||
g_return_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog));
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->backwards_checkbutton),
|
||||
backwards);
|
||||
}
|
||||
|
||||
gboolean
|
||||
xedit_search_dialog_get_backwards (XeditSearchDialog *dialog)
|
||||
{
|
||||
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
|
||||
|
||||
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->backwards_checkbutton));
|
||||
}
|
||||
|
||||
void
|
||||
xedit_search_dialog_set_wrap_around (XeditSearchDialog *dialog,
|
||||
gboolean wrap_around)
|
||||
{
|
||||
g_return_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog));
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->wrap_around_checkbutton),
|
||||
wrap_around);
|
||||
}
|
||||
|
||||
gboolean
|
||||
xedit_search_dialog_get_wrap_around (XeditSearchDialog *dialog)
|
||||
{
|
||||
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
|
||||
|
||||
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->wrap_around_checkbutton));
|
||||
}
|
||||
|
||||
void
|
||||
xedit_search_dialog_set_parse_escapes (XeditSearchDialog *dialog,
|
||||
gboolean parse_escapes)
|
||||
{
|
||||
g_return_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog));
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->parse_escapes_checkbutton),
|
||||
parse_escapes);
|
||||
}
|
||||
|
||||
gboolean
|
||||
xedit_search_dialog_get_parse_escapes (XeditSearchDialog *dialog)
|
||||
{
|
||||
g_return_val_if_fail (XEDIT_IS_SEARCH_DIALOG (dialog), FALSE);
|
||||
|
||||
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->parse_escapes_checkbutton));
|
||||
}
|
133
xedit/dialogs/xedit-search-dialog.h
Executable file
133
xedit/dialogs/xedit-search-dialog.h
Executable file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* xedit-search-dialog.h
|
||||
* This file is part of xedit
|
||||
*
|
||||
* 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 xedit Team, 2005. See the AUTHORS file for a
|
||||
* list of people on the xedit Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __XEDIT_SEARCH_DIALOG_H__
|
||||
#define __XEDIT_SEARCH_DIALOG_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Type checking and casting macros
|
||||
*/
|
||||
#define XEDIT_TYPE_SEARCH_DIALOG (xedit_search_dialog_get_type())
|
||||
#define XEDIT_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XEDIT_TYPE_SEARCH_DIALOG, XeditSearchDialog))
|
||||
#define XEDIT_SEARCH_DIALOG_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XEDIT_TYPE_SEARCH_DIALOG, XeditSearchDialog const))
|
||||
#define XEDIT_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XEDIT_TYPE_SEARCH_DIALOG, XeditSearchDialogClass))
|
||||
#define XEDIT_IS_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XEDIT_TYPE_SEARCH_DIALOG))
|
||||
#define XEDIT_IS_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XEDIT_TYPE_SEARCH_DIALOG))
|
||||
#define XEDIT_SEARCH_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XEDIT_TYPE_SEARCH_DIALOG, XeditSearchDialogClass))
|
||||
|
||||
/* Private structure type */
|
||||
typedef struct _XeditSearchDialogPrivate XeditSearchDialogPrivate;
|
||||
|
||||
/*
|
||||
* Main object structure
|
||||
*/
|
||||
typedef struct _XeditSearchDialog XeditSearchDialog;
|
||||
|
||||
struct _XeditSearchDialog
|
||||
{
|
||||
GtkDialog dialog;
|
||||
|
||||
/*< private > */
|
||||
XeditSearchDialogPrivate *priv;
|
||||
};
|
||||
|
||||
/*
|
||||
* Class definition
|
||||
*/
|
||||
typedef struct _XeditSearchDialogClass XeditSearchDialogClass;
|
||||
|
||||
struct _XeditSearchDialogClass
|
||||
{
|
||||
GtkDialogClass parent_class;
|
||||
|
||||
/* Key bindings */
|
||||
gboolean (* show_replace) (XeditSearchDialog *dlg);
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
XEDIT_SEARCH_DIALOG_FIND_RESPONSE = 100,
|
||||
XEDIT_SEARCH_DIALOG_REPLACE_RESPONSE,
|
||||
XEDIT_SEARCH_DIALOG_REPLACE_ALL_RESPONSE
|
||||
};
|
||||
|
||||
/*
|
||||
* Public methods
|
||||
*/
|
||||
GType xedit_search_dialog_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget *xedit_search_dialog_new (GtkWindow *parent,
|
||||
gboolean show_replace);
|
||||
|
||||
void xedit_search_dialog_present_with_time (XeditSearchDialog *dialog,
|
||||
guint32 timestamp);
|
||||
|
||||
gboolean xedit_search_dialog_get_show_replace (XeditSearchDialog *dialog);
|
||||
|
||||
void xedit_search_dialog_set_show_replace (XeditSearchDialog *dialog,
|
||||
gboolean show_replace);
|
||||
|
||||
|
||||
void xedit_search_dialog_set_search_text (XeditSearchDialog *dialog,
|
||||
const gchar *text);
|
||||
const gchar *xedit_search_dialog_get_search_text (XeditSearchDialog *dialog);
|
||||
|
||||
void xedit_search_dialog_set_replace_text (XeditSearchDialog *dialog,
|
||||
const gchar *text);
|
||||
const gchar *xedit_search_dialog_get_replace_text (XeditSearchDialog *dialog);
|
||||
|
||||
void xedit_search_dialog_set_match_case (XeditSearchDialog *dialog,
|
||||
gboolean match_case);
|
||||
gboolean xedit_search_dialog_get_match_case (XeditSearchDialog *dialog);
|
||||
|
||||
void xedit_search_dialog_set_entire_word (XeditSearchDialog *dialog,
|
||||
gboolean entire_word);
|
||||
gboolean xedit_search_dialog_get_entire_word (XeditSearchDialog *dialog);
|
||||
|
||||
void xedit_search_dialog_set_backwards (XeditSearchDialog *dialog,
|
||||
gboolean backwards);
|
||||
gboolean xedit_search_dialog_get_backwards (XeditSearchDialog *dialog);
|
||||
|
||||
void xedit_search_dialog_set_wrap_around (XeditSearchDialog *dialog,
|
||||
gboolean wrap_around);
|
||||
gboolean xedit_search_dialog_get_wrap_around (XeditSearchDialog *dialog);
|
||||
|
||||
|
||||
void xedit_search_dialog_set_parse_escapes (XeditSearchDialog *dialog,
|
||||
gboolean parse_escapes);
|
||||
gboolean xedit_search_dialog_get_parse_escapes (XeditSearchDialog *dialog);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XEDIT_SEARCH_DIALOG_H__ */
|
272
xedit/dialogs/xedit-search-dialog.ui
Executable file
272
xedit/dialogs/xedit-search-dialog.ui
Executable file
@@ -0,0 +1,272 @@
|
||||
<?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>
|
Reference in New Issue
Block a user