summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-29 02:40:54 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-29 02:40:54 +0000
commitb5f9d24188969c4f42663077394957399e34e229 (patch)
tree8e0ed477caacea14455834f54d8415a09eabf136 /chrome
parent5b7680926ee4ffd9213346ff0c9aaf764265585f (diff)
downloadchromium_src-b5f9d24188969c4f42663077394957399e34e229.zip
chromium_src-b5f9d24188969c4f42663077394957399e34e229.tar.gz
chromium_src-b5f9d24188969c4f42663077394957399e34e229.tar.bz2
gtk: Gray out uneditable search URLs.
Change the appearence of the url entry to be like disable, so the user doesn't begin confused. BUG=34476 TEST=see bug Review URL: http://codereview.chromium.org/2823030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51093 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/gtk/edit_search_engine_dialog.cc27
1 files changed, 26 insertions, 1 deletions
diff --git a/chrome/browser/gtk/edit_search_engine_dialog.cc b/chrome/browser/gtk/edit_search_engine_dialog.cc
index aa64b73..ec7590b 100644
--- a/chrome/browser/gtk/edit_search_engine_dialog.cc
+++ b/chrome/browser/gtk/edit_search_engine_dialog.cc
@@ -29,7 +29,6 @@ std::string GetDisplayURL(const TemplateURL& turl) {
return turl.url() ? WideToUTF8(turl.url()->DisplayURL()) : std::string();
}
-
// Forces text to lowercase when connected to an editable's "insert-text"
// signal. (Like views Textfield::STYLE_LOWERCASE.)
void LowercaseInsertTextHandler(GtkEditable *editable, const gchar *text,
@@ -50,6 +49,22 @@ void LowercaseInsertTextHandler(GtkEditable *editable, const gchar *text,
}
}
+void SetWidgetStyle(GtkWidget* entry, GtkStyle* label_style,
+ GtkStyle* dialog_style) {
+ gtk_widget_modify_fg(entry, GTK_STATE_NORMAL,
+ &label_style->fg[GTK_STATE_NORMAL]);
+ gtk_widget_modify_fg(entry, GTK_STATE_INSENSITIVE,
+ &label_style->fg[GTK_STATE_INSENSITIVE]);
+ // GTK_NO_WINDOW widgets like GtkLabel don't draw their own background, so we
+ // combine the normal or insensitive foreground of the label style with the
+ // normal background of the window style to achieve the "normal label" and
+ // "insensitive label" colors.
+ gtk_widget_modify_base(entry, GTK_STATE_NORMAL,
+ &dialog_style->bg[GTK_STATE_NORMAL]);
+ gtk_widget_modify_base(entry, GTK_STATE_INSENSITIVE,
+ &dialog_style->bg[GTK_STATE_NORMAL]);
+}
+
} // namespace
EditSearchEngineDialog::EditSearchEngineDialog(
@@ -152,6 +167,16 @@ void EditSearchEngineDialog::Init(GtkWindow* parent_window, Profile* profile) {
gtk_editable_set_editable(
GTK_EDITABLE(url_entry_),
controller_->template_url()->prepopulate_id() == 0);
+
+ if (controller_->template_url()->prepopulate_id() != 0) {
+ GtkWidget* fake_label = gtk_label_new("Fake label");
+ gtk_widget_set_sensitive(fake_label,
+ controller_->template_url()->prepopulate_id() == 0);
+ GtkStyle* label_style = gtk_widget_get_style(fake_label);
+ GtkStyle* dialog_style = gtk_widget_get_style(dialog_);
+ SetWidgetStyle(url_entry_, label_style, dialog_style);
+ gtk_widget_destroy(fake_label);
+ }
}
GtkWidget* controls = gtk_util::CreateLabeledControlsGroup(NULL,