summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@gnome.org>2016-10-31 16:57:20 -0500
committerMichael Catanzaro <mcatanzaro@gnome.org>2016-12-12 12:41:01 -0600
commit0040e0434f978266c4a62fea9b6137627b09b890 (patch)
tree5d66ca226b6307e0f4732a521152f193819c80e7
parent574ccd7a290c5ce6613dac110650a8bd1c229caa (diff)
downloadepiphany-wip/search-engine-dialog.tar.gz
This is really WIP. Seriously, it looks awful. I did warn you!
-rw-r--r--src/Makefile.am3
-rw-r--r--src/ephy-search-engine-dialog.c78
-rw-r--r--src/ephy-search-engine-dialog.h35
-rw-r--r--src/prefs-dialog.c16
-rw-r--r--src/resources/epiphany.gresource.xml1
-rw-r--r--src/resources/prefs-dialog.ui31
-rw-r--r--src/resources/search-engine-dialog.ui85
7 files changed, 242 insertions, 7 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index ea316e7a4..417bc187e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -58,6 +58,9 @@ libephymain_la_SOURCES = \
ephy-lockdown.h \
ephy-notebook.c \
ephy-notebook.h \
+ ephy-private.h \
+ ephy-search-engine-dialog.c \
+ ephy-search-engine-dialog.h \
ephy-session.c \
ephy-session.h \
ephy-shell.c \
diff --git a/src/ephy-search-engine-dialog.c b/src/ephy-search-engine-dialog.c
new file mode 100644
index 000000000..ffc23d3a6
--- /dev/null
+++ b/src/ephy-search-engine-dialog.c
@@ -0,0 +1,78 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright © 2016 Igalia S.L
+ *
+ * This file is part of Epiphany.
+ *
+ * Epiphany 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Epiphany 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 Epiphany. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "ephy-search-engine-dialog.h"
+
+#include "ephy-bookmarks-manager.h"
+#include "ephy-shell.h"
+
+struct _EphySearchEngineDialog {
+ GtkDialog parent_instance;
+
+ EphyBookmarksManager *bookmarks_manager;
+
+ GtkEntry *name_entry;
+};
+
+G_DEFINE_TYPE (EphySearchEngineDialog, ephy_search_engine_dialog, GTK_TYPE_DIALOG)
+
+static void
+ephy_search_engine_dialog_response_cb (GtkDialog *widget,
+ int response,
+ EphySearchEngineDialog *dialog)
+{
+ if (response == GTK_RESPONSE_OK) {
+ // TODO: Add smart bookmark
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static void
+ephy_search_engine_dialog_class_init (EphySearchEngineDialogClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/epiphany/search-engine-dialog.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, EphySearchEngineDialog, name_entry);
+
+ gtk_widget_class_bind_template_callback (widget_class, ephy_search_engine_dialog_response_cb);
+}
+
+static void
+ephy_search_engine_dialog_init (EphySearchEngineDialog *dialog)
+{
+ EphyShell *shell = ephy_shell_get_default ();
+
+ dialog->bookmarks_manager = ephy_shell_get_bookmarks_manager (shell);
+
+ gtk_widget_init_template (GTK_WIDGET (dialog));
+}
+
+GtkWidget *
+ephy_search_engine_dialog_new (void)
+{
+ return GTK_WIDGET (g_object_new (EPHY_TYPE_SEARCH_ENGINE_DIALOG,
+ "use-header-bar", TRUE,
+ NULL));
+}
diff --git a/src/ephy-search-engine-dialog.h b/src/ephy-search-engine-dialog.h
new file mode 100644
index 000000000..ffb1e5846
--- /dev/null
+++ b/src/ephy-search-engine-dialog.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright © 2016 Igalia S.L.
+ *
+ * This file is part of Epiphany.
+ *
+ * Epiphany 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Epiphany 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 Epiphany. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "ephy-bookmarks-manager.h"
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_SEARCH_ENGINE_DIALOG (ephy_search_engine_dialog_get_type ())
+
+G_DECLARE_FINAL_TYPE (EphySearchEngineDialog, ephy_search_engine_dialog, EPHY, SEARCH_ENGINE_DIALOG, GtkDialog)
+
+GtkWidget *ephy_search_engine_dialog_new (void);
+
+G_END_DECLS
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index b49dff1b3..862856aa3 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -33,6 +33,7 @@
#include "ephy-gui.h"
#include "ephy-langs.h"
#include "ephy-prefs.h"
+#include "ephy-search-engine-dialog.h"
#include "ephy-session.h"
#include "ephy-settings.h"
#include "ephy-shell.h"
@@ -532,6 +533,19 @@ on_sync_sign_out_button_clicked (GtkWidget *button,
#endif
static void
+on_search_engine_dialog_button_clicked (GtkWidget *button,
+ PrefsDialog *dialog)
+{
+ GtkWidget *search_engine_dialog;
+
+ search_engine_dialog = ephy_search_engine_dialog_new ();
+
+ gtk_window_set_transient_for (GTK_WINDOW (search_engine_dialog), GTK_WINDOW (dialog));
+ gtk_window_set_modal (GTK_WINDOW (search_engine_dialog), TRUE);
+ gtk_window_present (GTK_WINDOW (search_engine_dialog));
+}
+
+static void
on_manage_cookies_button_clicked (GtkWidget *button,
PrefsDialog *dialog)
{
@@ -581,6 +595,8 @@ prefs_dialog_class_init (PrefsDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, download_button_hbox);
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, download_button_label);
+ gtk_widget_class_bind_template_callback (widget_class, on_search_engine_dialog_button_clicked);
+
/* fonts */
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, use_gnome_fonts_checkbutton);
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, custom_fonts_table);
diff --git a/src/resources/epiphany.gresource.xml b/src/resources/epiphany.gresource.xml
index 8edcf2b40..72a7f7a4a 100644
--- a/src/resources/epiphany.gresource.xml
+++ b/src/resources/epiphany.gresource.xml
@@ -28,6 +28,7 @@
<file preprocess="xml-stripblanks" compressed="true">passwords-dialog.ui</file>
<file preprocess="xml-stripblanks" compressed="true">prefs-dialog.ui</file>
<file preprocess="xml-stripblanks" compressed="true">prefs-lang-dialog.ui</file>
+ <file preprocess="xml-stripblanks" compressed="true">search-engine-dialog.ui</file>
<file preprocess="xml-stripblanks" compressed="true">shortcuts-dialog.ui</file>
</gresource>
<gresource prefix="/org/gnome/Epiphany/icons">
diff --git a/src/resources/prefs-dialog.ui b/src/resources/prefs-dialog.ui
index ad4f4281c..1635cfca7 100644
--- a/src/resources/prefs-dialog.ui
+++ b/src/resources/prefs-dialog.ui
@@ -169,13 +169,30 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
- <object class="GtkLabel">
+ <object class="GtkBox">
<property name="visible">True</property>
- <property name="halign">start</property>
- <property name="label" translatable="yes">Search</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Search</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="search_engine_dialog_button">
+ <property name="label" translatable="yes">_Manage Engines</property>
+ <property name="visible">True</property>
+ <property name="use-underline">True</property>
+ <signal name="clicked" handler="on_search_engine_dialog_button_clicked"/>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
</object>
</child>
<child>
@@ -191,7 +208,7 @@
<child>
<object class="GtkLabel">
<property name="visible">True</property>
- <property name="label" translatable="yes">_Engine:</property>
+ <property name="label" translatable="yes">_Default Engine:</property>
<property name="use-underline">True</property>
<property name="mnemonic-widget">search_engine_combo</property>
</object>
diff --git a/src/resources/search-engine-dialog.ui b/src/resources/search-engine-dialog.ui
new file mode 100644
index 000000000..73d4dd2ce
--- /dev/null
+++ b/src/resources/search-engine-dialog.ui
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="EphySearchEngineDialog" parent="GtkDialog">
+ <property name="border_width">15</property>
+ <property name="modal">True</property>
+ <property name="window_position">center</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="type_hint">dialog</property>
+ <property name="resizable">False</property>
+ <signal name="response" handler="ephy_search_engine_dialog_response_cb"/>
+ <child internal-child="headerbar">
+ <object class="GtkHeaderBar">
+ <property name="title" translatable="yes">New Search Engine</property>
+ <property name="show-close-button">False</property>
+ <child>
+ <object class="GtkButton" id="apply_button">
+ <property name="label" translatable="yes">_Add</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="can_default">True</property>
+ <property name="valign">center</property>
+ <style>
+ <class name="suggested-action"/>
+ <class name="text-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancel_button">
+ <property name="label" translatable="yes">_Cancel</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="valign">center</property>
+ <style>
+ <class name="text-button"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">_Name:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">name_entry</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkEntry" id="name_entry">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">To determine the search URL, perform a search using the search engine that you want to add and check the resulting URL. Remove the search term from the resulting URL and replace it with “%s” (without the quotes).</property>
+ <property name="wrap">True</property>
+ <property name="max_width_chars">50</property>
+ <property name="margin_start">12</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="cancel">cancel_button</action-widget>
+ <action-widget response="apply" default="true">apply_button</action-widget>
+ </action-widgets>
+ </template>
+</interface>