Home | History | Annotate | Download | only in gtk
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_UI_GTK_EDIT_SEARCH_ENGINE_DIALOG_H_
      6 #define CHROME_BROWSER_UI_GTK_EDIT_SEARCH_ENGINE_DIALOG_H_
      7 #pragma once
      8 
      9 #include <gtk/gtk.h>
     10 #include <string>
     11 
     12 #include "base/basictypes.h"
     13 #include "base/memory/scoped_ptr.h"
     14 #include "base/string16.h"
     15 #include "ui/base/gtk/gtk_signal.h"
     16 
     17 class EditSearchEngineController;
     18 class EditSearchEngineControllerDelegate;
     19 class Profile;
     20 class TemplateURL;
     21 
     22 class EditSearchEngineDialog {
     23  public:
     24   EditSearchEngineDialog(GtkWindow* parent_window,
     25                          const TemplateURL* template_url,
     26                          EditSearchEngineControllerDelegate* delegate,
     27                          Profile* profile);
     28   virtual ~EditSearchEngineDialog();
     29 
     30  private:
     31   // Create and show the window.
     32   void Init(GtkWindow* parent_window, Profile* profile);
     33 
     34   // Retrieve the user input in the various fields.
     35   string16 GetTitleInput() const;
     36   string16 GetKeywordInput() const;
     37   std::string GetURLInput() const;
     38 
     39   // Set sensitivity of buttons based on entry state.
     40   void EnableControls();
     41 
     42   // Updates the tooltip and image of the image view based on is_valid. If
     43   // is_valid is false the tooltip of the image view is set to the message with
     44   // id invalid_message_id, otherwise the tooltip is set to the empty text.
     45   void UpdateImage(GtkWidget* image, bool is_valid, int invalid_message_id);
     46 
     47   // Callback for entry changes.
     48   CHROMEG_CALLBACK_0(EditSearchEngineDialog, void, OnEntryChanged,
     49                      GtkEditable*);
     50 
     51   // Callback for dialog buttons.
     52   CHROMEGTK_CALLBACK_1(EditSearchEngineDialog, void, OnResponse, int);
     53 
     54   // Callback for window destruction.
     55   CHROMEGTK_CALLBACK_0(EditSearchEngineDialog, void, OnWindowDestroy);
     56 
     57   // The dialog window.
     58   GtkWidget* dialog_;
     59 
     60   // Text entries for each field.
     61   GtkWidget* title_entry_;
     62   GtkWidget* keyword_entry_;
     63   GtkWidget* url_entry_;
     64 
     65   // Images showing whether each entry is okay or has errors.
     66   GtkWidget* title_image_;
     67   GtkWidget* keyword_image_;
     68   GtkWidget* url_image_;
     69 
     70   // The ok button (we need a reference to it so we can de-activate it when the
     71   // entries are not all filled in.)
     72   GtkWidget* ok_button_;
     73 
     74   scoped_ptr<EditSearchEngineController> controller_;
     75 
     76   DISALLOW_COPY_AND_ASSIGN(EditSearchEngineDialog);
     77 };
     78 
     79 #endif  // CHROME_BROWSER_UI_GTK_EDIT_SEARCH_ENGINE_DIALOG_H_
     80