Commit 3cd54380 authored by Priyanka Saggu's avatar Priyanka Saggu

add updated file

parent b94982ff
#include "example-document-view.h"
struct _ExampleDocumentView
{
GtkBin parent_instance;
......@@ -19,6 +20,8 @@ G_DEFINE_TYPE (ExampleDocumentView, example_document_view, GTK_TYPE_BIN)
static GParamSpec *properties [N_PROPS];
static void
example_document_view_set_document (ExampleDocumentView *self,
ExampleDocument *document)
......@@ -111,6 +114,7 @@ example_document_view_class_init (ExampleDocumentViewClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/example/ui/example-document-view.ui");
gtk_widget_class_bind_template_child (widget_class, ExampleDocumentView, text_view);
}
static void
......
#include "example-document.h"
#include "example-editor-search-bar.h"
struct _ExampleDocument
{
GtkTextBuffer parent_instance;
gchar *title;
GtkOverlay *overlay;
GtkRevealer *search_revealer;
ExampleEditorSearchBar *search_bar;
GtkSourceView *source_view;
GtkSearchEntry *search;
};
enum {
PROP_0,
PROP_TITLE,
PROP_SEARCH,
N_PROPS
};
......@@ -17,6 +24,41 @@ G_DEFINE_TYPE (ExampleDocument, example_document, GTK_TYPE_TEXT_BUFFER)
static guint last_untitled;
static GParamSpec *properties [N_PROPS];
static void
example_editor_page_stop_search (ExampleDocument *self,
ExampleEditorSearchBar *search_bar)
{
g_assert (EXAMPLE_IS_DOCUMENT (self));
g_assert (EXAMPLE_IS_EDITOR_SEARCH_BAR (search_bar));
gtk_revealer_set_reveal_child (self->search_revealer, FALSE);
gtk_widget_grab_focus (GTK_WIDGET (self->source_view));
}
static void
example_editor_page_notify_child_revealed (ExampleDocument *self,
GParamSpec *pspec,
GtkRevealer *revealer)
{
g_assert (EXAMPLE_IS_DOCUMENT (self));
g_assert (GTK_IS_REVEALER (revealer));
if (gtk_revealer_get_child_revealed (revealer))
{
GtkWidget *toplevel = gtk_widget_get_ancestor (GTK_WIDGET (revealer), GTK_TYPE_WINDOW);
GtkWidget *focus = gtk_window_get_focus (GTK_WINDOW (toplevel));
/* Only focus the search bar if it doesn't already have focus,
* as it can reselect the search text.
*/
if (focus == NULL || !gtk_widget_is_ancestor (focus, GTK_WIDGET (revealer)))
gtk_widget_grab_focus (GTK_WIDGET (self->search_bar));
}
}
static void
example_document_constructed (GObject *object)
{
......@@ -81,6 +123,7 @@ static void
example_document_class_init (ExampleDocumentClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = example_document_finalize;
object_class->constructed = example_document_constructed;
......@@ -95,15 +138,28 @@ example_document_class_init (ExampleDocumentClass *klass)
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/example/ui/example-document.ui");
gtk_widget_class_bind_template_child (widget_class, ExampleDocument, overlay);
gtk_widget_class_bind_template_child (widget_class, ExampleDocument, search_bar);
gtk_widget_class_bind_template_child (widget_class, ExampleDocument, search_revealer);
gtk_widget_class_bind_template_callback (widget_class, example_editor_page_notify_child_revealed);
gtk_widget_class_bind_template_callback (widget_class, example_editor_page_stop_search);
g_type_ensure (EXAMPLE_TYPE_EDITOR_SEARCH_BAR);
}
static void
example_document_init (ExampleDocument *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
ExampleDocument *
example_document_new (void)
example_document_new (GObject *object)
{
ExampleDocument *self = (ExampleDocument *)object;
example_editor_search_bar_set_search (self->search_bar, self->search);
return g_object_new (EXAMPLE_TYPE_DOCUMENT, NULL);
}
......@@ -8,6 +8,6 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (ExampleDocument, example_document, EXAMPLE, DOCUMENT, GtkTextBuffer)
ExampleDocument *example_document_new (void);
ExampleDocument *example_document_new (GObject *object);
G_END_DECLS
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ExampleDocument" parent="GtkBin">
<child>
<object class="GtkOverlay" id="overlay">
<property name="visible">true</property>
<child type="overlay">
<object class="GtkRevealer" id="search_revealer">
<property name="width-request">525</property>
<property name="halign">end</property>
<property name="valign">start</property>
<property name="margin-right">12</property>
<property name="reveal-child">true</property>
<property name="visible">true</property>
<child>
<object class="ExampleEditorSearchBar" id="search_bar">
<property name="visible">true</property>
<signal name="stop-search" handler="example_editor_page_stop_search" swapped="true" object="IdeEditorPage"/>
</object>
</child>
</object>
<packing>
<property name="index">1</property>
</packing>
</child>
</object>
</child>
</template>
</interface>
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ExampleSearchBar" parent="DzlBin">
<template class="ExampleEditorSearchBar" parent="DzlBin">
<style>
<class name="search-frame"/>
</style>
......@@ -16,7 +16,7 @@
<property name="row_spacing">8</property>
<property name="column_spacing">8</property>
<child>
<object class="ExampleTaggedEntry" id="search_entry">
<object class="GtkEntry" id="search_entry">
<property name="visible">true</property>
<property name="tag-close-visible">false</property>
<property name="can-focus">true</property>
......@@ -150,7 +150,7 @@
<property name="spacing">8</property>
<child>
<object class="GtkToggleButton">
<property name="active" bind-source="ExampleSearchBar" bind-property="replace-mode" bind-flags="sync-create|bidirectional"/>
<property name="active" bind-source="ExampleEditorSearchBar" bind-property="replace-mode" bind-flags="sync-create|bidirectional"/>
<property name="tooltip-text" translatable="yes">Switch between Search and Search-and-Replace</property>
<property name="visible">true</property>
<property name="can-focus">true</property>
......@@ -175,7 +175,7 @@
<property name="focus-on-click">false</property>
<property name="visible">true</property>
<property name="can-focus">true</property>
<property name="active" bind-source="ExampleSearchBar" bind-property="show-options" bind-flags="sync-create|bidirectional"/>
<property name="active" bind-source="ExampleEditorSearchBar" bind-property="show-options" bind-flags="sync-create|bidirectional"/>
<child>
<object class="GtkImage">
<property name="visible">true</property>
......
#include "example-editor-search-bar.h"
#include "example-document.h"
G_BEGIN_DECLS
void _example_search_bar_init_shortcuts (ExampleSearchBar *self);
struct _ExampleEditorPage
{
ExamplePage parent_instance;
ExampleExtensionSetAdapter *addins;
GSettings *editor_settings;
GSettings *insight_settings;
ExampleBuffer *buffer;
DzlBindingGroup *buffer_bindings;
DzlSignalGroup *buffer_signals;
ExampleSearch *search;
GCancellable *destroy_cancellable;
GtkSourceMap *map;
GtkRevealer *map_revealer;
GtkOverlay *overlay;
GtkProgressBar *progress_bar;
ExampleSourceView *source_view;
GtkScrolledWindow *scroller;
GtkBox *scroller_box;
ExampleSearchBar *search_bar;
GtkRevealer *search_revealer;
GtkRevealer *modified_revealer;
GtkButton *modified_cancel_button;
/* Raw pointer used to determine when frame changes */
ExampleFrame *last_frame_ptr;
guint toggle_map_source;
guint auto_hide_map : 1;
guint show_map : 1;
};
G_END_DECLS
......@@ -10,6 +10,7 @@ struct _ExampleWindow
GtkNotebook *notebook;
DzlEmptyState *empty_state;
GtkStack *stack;
DzlSimplePopover *popover;
};
G_DEFINE_TYPE (ExampleWindow, example_window, DZL_TYPE_APPLICATION_WINDOW)
......@@ -18,7 +19,6 @@ static const DzlShortcutEntry shortcuts[] = {
{ "com.example.window.NewDoc", 0, NULL, N_("Editing"), N_("Documents"), N_("New Document"), N_("Create a new document") },
{ "com.example.window.CloseDoc", 0, NULL, N_("Editing"), N_("Documents"), N_("Close Document"), N_("Close the current document") },
{ "com.example.window.Fullscreen", 0, "F11", N_("Editing"), N_("General"), N_("Fullscreen"), N_("Toggle window fullscreen") },
{ "com.example.window.Search", 0, NULL, N_("Editing"), N_("General"), N_("Search & Replace"), N_("Open search and replace bar") },
};
ExampleDocumentView *
......@@ -79,10 +79,11 @@ new_document_cb (GSimpleAction *action,
GtkWidget *view;
GtkWidget *label;
gint page;
GObject *object;
g_assert (EXAMPLE_IS_WINDOW (self));
document = example_document_new ();
document = example_document_new (object);
view = g_object_new (EXAMPLE_TYPE_DOCUMENT_VIEW,
"visible", TRUE,
"document", document,
......@@ -177,8 +178,6 @@ example_window_init (ExampleWindow *self)
dzl_shortcut_controller_add_command_action (controller, "com.example.window.NewDoc", NULL, 0, "win.new-document");
dzl_shortcut_controller_add_command_action (controller, "com.example.window.CloseDoc", NULL, 0, "win.close-document");
dzl_shortcut_controller_add_command_action (controller, "com.example.window.Fullscreen", NULL, 0, "win.fullscreen");
dzl_shortcut_controller_add_command_action (controller, "com.example.window.Search", NULL, 0, "win.search");
g_signal_connect_swapped (self,
"key-press-event",
......
......@@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/org/gnome/example/ui">
<file>example-document-view.ui</file>
<file>example-document.ui</file>
<file>example-window.ui</file>
<file>example-editor-search-bar.ui</file>
</gresource>
......
......@@ -7,7 +7,6 @@ example_resources = gnome.compile_resources(
example_application_sources = [
'example-editor-search-bar.c',
'example-editor-search-bar.h',
'example-private.h',
'example-application.c',
'example-application.h',
'example-document.c',
......
......@@ -5,7 +5,6 @@
<shortcut accelerator="<primary>n" command="com.example.window.NewDoc"/>
<shortcut accelerator="<primary>w" command="com.example.window.CloseDoc"/>
<shortcut accelerator="<primary><shift>question" action="app.shortcuts"/>
<shortcut accelerator="<primary>f" command="com.example.window.Search"/>
<shortcut accelerator="<primary>q" action="app.quit"/>
</keytheme>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment