[epiphany/wip/search-engine-dialog: 152/152] WIP



commit 0040e0434f978266c4a62fea9b6137627b09b890
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Mon Oct 31 16:57:20 2016 -0500

    WIP
    
    This is really WIP. Seriously, it looks awful. I did warn you!

 src/Makefile.am                       |    3 +
 src/ephy-search-engine-dialog.c       |   78 ++++++++++++++++++++++++++++++
 src/ephy-search-engine-dialog.h       |   35 +++++++++++++
 src/prefs-dialog.c                    |   16 ++++++
 src/resources/epiphany.gresource.xml  |    1 +
 src/resources/prefs-dialog.ui         |   31 +++++++++---
 src/resources/search-engine-dialog.ui |   85 +++++++++++++++++++++++++++++++++
 7 files changed, 242 insertions(+), 7 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index ea316e7..417bc18 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 0000000..ffc23d3
--- /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 0000000..ffb1e58
--- /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 b49dff1..862856a 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 8edcf2b..72a7f7a 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 ad4f428..1635cfc 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 0000000..73d4dd2
--- /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>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]