summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-07 19:16:06 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-07 19:16:06 +0000
commit03082a6536bb152e8391b66a692c092d5d1bd07d (patch)
treea63164bc50ae3a952262bbb3b1bf2d88b85bfe26 /chrome/browser/gtk
parentd76cbd651f0880d9edb5e497f71717f47b5482d7 (diff)
downloadchromium_src-03082a6536bb152e8391b66a692c092d5d1bd07d.zip
chromium_src-03082a6536bb152e8391b66a692c092d5d1bd07d.tar.gz
chromium_src-03082a6536bb152e8391b66a692c092d5d1bd07d.tar.bz2
gtk: Avoid duplicating functions in anonymous namespaces by moving them to gtk_util.h
BUG=None TEST=compiles Patch from Thiago Farina <thiago.farina@gmail.com> Review URL: http://codereview.chromium.org/1610003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43862 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/edit_search_engine_dialog.cc12
-rw-r--r--chrome/browser/gtk/gtk_util.cc19
-rw-r--r--chrome/browser/gtk/gtk_util.h5
-rw-r--r--chrome/browser/gtk/options/content_exception_editor.cc9
-rw-r--r--chrome/browser/gtk/options/content_exceptions_window_gtk.cc35
-rw-r--r--chrome/browser/gtk/options/geolocation_content_exceptions_window.cc27
6 files changed, 49 insertions, 58 deletions
diff --git a/chrome/browser/gtk/edit_search_engine_dialog.cc b/chrome/browser/gtk/edit_search_engine_dialog.cc
index 1978862..45898ea 100644
--- a/chrome/browser/gtk/edit_search_engine_dialog.cc
+++ b/chrome/browser/gtk/edit_search_engine_dialog.cc
@@ -29,12 +29,6 @@ std::string GetDisplayURL(const TemplateURL& turl) {
return turl.url() ? WideToUTF8(turl.url()->DisplayURL()) : std::string();
}
-GtkWidget* CreateEntryImageHBox(GtkWidget* entry, GtkWidget* image) {
- GtkWidget* hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing);
- gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
- return hbox;
-}
// Forces text to lowercase when connected to an editable's "insert-text"
// signal. (Like views Textfield::STYLE_LOWERCASE.)
@@ -163,11 +157,11 @@ void EditSearchEngineDialog::Init(GtkWindow* parent_window, Profile* profile) {
GtkWidget* controls = gtk_util::CreateLabeledControlsGroup(NULL,
l10n_util::GetStringUTF8(
IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_LABEL).c_str(),
- CreateEntryImageHBox(title_entry_, title_image_),
+ gtk_util::CreateEntryImageHBox(title_entry_, title_image_),
l10n_util::GetStringUTF8(IDS_SEARCH_ENGINES_EDITOR_KEYWORD_LABEL).c_str(),
- CreateEntryImageHBox(keyword_entry_, keyword_image_),
+ gtk_util::CreateEntryImageHBox(keyword_entry_, keyword_image_),
l10n_util::GetStringUTF8(IDS_SEARCH_ENGINES_EDITOR_URL_LABEL).c_str(),
- CreateEntryImageHBox(url_entry_, url_image_),
+ gtk_util::CreateEntryImageHBox(url_entry_, url_image_),
NULL);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_)->vbox), controls,
FALSE, FALSE, 0);
diff --git a/chrome/browser/gtk/gtk_util.cc b/chrome/browser/gtk/gtk_util.cc
index 6157bda..72f392e 100644
--- a/chrome/browser/gtk/gtk_util.cc
+++ b/chrome/browser/gtk/gtk_util.cc
@@ -11,6 +11,7 @@
#include <map>
#include "app/gtk_util.h"
+#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "app/x11_util.h"
#include "base/i18n/rtl.h"
@@ -551,6 +552,24 @@ GtkWidget* AddButtonToDialog(GtkWidget* dialog, const gchar* text,
return button;
}
+GtkWidget* BuildDialogButton(GtkWidget* dialog, int ids_id,
+ const gchar* stock_id) {
+ GtkWidget* button = gtk_button_new_with_mnemonic(
+ gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ l10n_util::GetStringUTF8(ids_id)).c_str());
+ gtk_button_set_image(GTK_BUTTON(button),
+ gtk_image_new_from_stock(stock_id,
+ GTK_ICON_SIZE_BUTTON));
+ return button;
+}
+
+GtkWidget* CreateEntryImageHBox(GtkWidget* entry, GtkWidget* image) {
+ GtkWidget* hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing);
+ gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
+ return hbox;
+}
+
void SetLabelColor(GtkWidget* label, const GdkColor* color) {
gtk_widget_modify_fg(label, GTK_STATE_NORMAL, color);
gtk_widget_modify_fg(label, GTK_STATE_ACTIVE, color);
diff --git a/chrome/browser/gtk/gtk_util.h b/chrome/browser/gtk/gtk_util.h
index 92164ad..9a65193 100644
--- a/chrome/browser/gtk/gtk_util.h
+++ b/chrome/browser/gtk/gtk_util.h
@@ -177,6 +177,11 @@ void SetDefaultWindowIcon();
GtkWidget* AddButtonToDialog(GtkWidget* dialog, const gchar* text,
const gchar* stock_id, gint response_id);
+GtkWidget* BuildDialogButton(GtkWidget* dialog, int ids_id,
+ const gchar* stock_id);
+
+GtkWidget* CreateEntryImageHBox(GtkWidget* entry, GtkWidget* image);
+
// Sets all the foreground color states of |label| to |color|.
void SetLabelColor(GtkWidget* label, const GdkColor* color);
diff --git a/chrome/browser/gtk/options/content_exception_editor.cc b/chrome/browser/gtk/options/content_exception_editor.cc
index 74d29e3..9e73704 100644
--- a/chrome/browser/gtk/options/content_exception_editor.cc
+++ b/chrome/browser/gtk/options/content_exception_editor.cc
@@ -28,13 +28,6 @@ bool ValidHost(const std::string& host) {
return !net::CanonicalizeHost(host, &host_info).empty();
}
-GtkWidget* CreateEntryImageHBox(GtkWidget* entry, GtkWidget* image) {
- GtkWidget* hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing);
- gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
- return hbox;
-}
-
} // namespace
ContentExceptionEditor::ContentExceptionEditor(
@@ -82,7 +75,7 @@ ContentExceptionEditor::ContentExceptionEditor(
GtkWidget* table = gtk_util::CreateLabeledControlsGroup(
NULL,
l10n_util::GetStringUTF8(IDS_EXCEPTION_EDITOR_HOST_TITLE).c_str(),
- CreateEntryImageHBox(entry_, host_image_),
+ gtk_util::CreateEntryImageHBox(entry_, host_image_),
l10n_util::GetStringUTF8(IDS_EXCEPTION_EDITOR_ACTION_TITLE).c_str(),
action_combo_,
NULL);
diff --git a/chrome/browser/gtk/options/content_exceptions_window_gtk.cc b/chrome/browser/gtk/options/content_exceptions_window_gtk.cc
index 9ee01bb..4106be2 100644
--- a/chrome/browser/gtk/options/content_exceptions_window_gtk.cc
+++ b/chrome/browser/gtk/options/content_exceptions_window_gtk.cc
@@ -20,19 +20,6 @@ namespace {
// Singletons for each possible exception window.
ContentExceptionsWindowGtk* instances[CONTENT_SETTINGS_NUM_TYPES] = { NULL };
-GtkWidget* BuildDialogButton(GtkWidget* dialog, int ids_id,
- const gchar* stock_id) {
- GtkWidget* button = gtk_button_new_with_label(
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
- l10n_util::GetStringUTF8(ids_id)).c_str());
- gtk_button_set_image(GTK_BUTTON(button),
- gtk_image_new_from_stock(stock_id,
- GTK_ICON_SIZE_BUTTON));
- gtk_button_set_use_underline(GTK_BUTTON(button), TRUE);
-
- return button;
-}
-
} // namespace
// static
@@ -123,24 +110,28 @@ ContentExceptionsWindowGtk::ContentExceptionsWindowGtk(
GtkWidget* button_box = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
- GtkWidget* add_button = BuildDialogButton(dialog_, IDS_EXCEPTIONS_ADD_BUTTON,
- GTK_STOCK_ADD);
+ GtkWidget* add_button = gtk_util::BuildDialogButton(dialog_,
+ IDS_EXCEPTIONS_ADD_BUTTON,
+ GTK_STOCK_ADD);
g_signal_connect(add_button, "clicked", G_CALLBACK(AddThunk), this);
gtk_box_pack_start(GTK_BOX(button_box), add_button, FALSE, FALSE, 0);
- edit_button_ = BuildDialogButton(dialog_, IDS_EXCEPTIONS_EDIT_BUTTON,
- GTK_STOCK_EDIT);
+ edit_button_ = gtk_util::BuildDialogButton(dialog_,
+ IDS_EXCEPTIONS_EDIT_BUTTON,
+ GTK_STOCK_EDIT);
g_signal_connect(edit_button_, "clicked", G_CALLBACK(EditThunk), this);
gtk_box_pack_start(GTK_BOX(button_box), edit_button_, FALSE, FALSE, 0);
- remove_button_ = BuildDialogButton(dialog_, IDS_EXCEPTIONS_REMOVE_BUTTON,
- GTK_STOCK_REMOVE);
+ remove_button_ = gtk_util::BuildDialogButton(dialog_,
+ IDS_EXCEPTIONS_REMOVE_BUTTON,
+ GTK_STOCK_REMOVE);
g_signal_connect(remove_button_, "clicked", G_CALLBACK(RemoveThunk), this);
gtk_box_pack_start(GTK_BOX(button_box), remove_button_, FALSE, FALSE, 0);
- remove_all_button_ = BuildDialogButton(dialog_,
- IDS_EXCEPTIONS_REMOVEALL_BUTTON,
- GTK_STOCK_CLEAR);
+ remove_all_button_ = gtk_util::BuildDialogButton(
+ dialog_,
+ IDS_EXCEPTIONS_REMOVEALL_BUTTON,
+ GTK_STOCK_CLEAR);
g_signal_connect(remove_all_button_, "clicked", G_CALLBACK(RemoveAllThunk),
this);
gtk_box_pack_start(GTK_BOX(button_box), remove_all_button_, FALSE, FALSE, 0);
diff --git a/chrome/browser/gtk/options/geolocation_content_exceptions_window.cc b/chrome/browser/gtk/options/geolocation_content_exceptions_window.cc
index 106d721..0274faf 100644
--- a/chrome/browser/gtk/options/geolocation_content_exceptions_window.cc
+++ b/chrome/browser/gtk/options/geolocation_content_exceptions_window.cc
@@ -17,20 +17,6 @@ namespace {
// Singleton for exception window.
GeolocationContentExceptionsWindow* instance = NULL;
-// TODO(mattm): de-dupe?
-GtkWidget* BuildDialogButton(GtkWidget* dialog, int ids_id,
- const gchar* stock_id) {
- GtkWidget* button = gtk_button_new_with_label(
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
- l10n_util::GetStringUTF8(ids_id)).c_str());
- gtk_button_set_image(GTK_BUTTON(button),
- gtk_image_new_from_stock(stock_id,
- GTK_ICON_SIZE_BUTTON));
- gtk_button_set_use_underline(GTK_BUTTON(button), TRUE);
-
- return button;
-}
-
} // namespace
// static
@@ -106,14 +92,17 @@ GeolocationContentExceptionsWindow::GeolocationContentExceptionsWindow(
GtkWidget* button_box = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
- remove_button_ = BuildDialogButton(dialog_, IDS_EXCEPTIONS_REMOVE_BUTTON,
- GTK_STOCK_REMOVE);
+ remove_button_ = gtk_util::BuildDialogButton(dialog_,
+ IDS_EXCEPTIONS_REMOVE_BUTTON,
+ GTK_STOCK_REMOVE);
+
g_signal_connect(remove_button_, "clicked", G_CALLBACK(RemoveThunk), this);
gtk_box_pack_start(GTK_BOX(button_box), remove_button_, FALSE, FALSE, 0);
- remove_all_button_ = BuildDialogButton(dialog_,
- IDS_EXCEPTIONS_REMOVEALL_BUTTON,
- GTK_STOCK_CLEAR);
+ remove_all_button_ = gtk_util::BuildDialogButton(
+ dialog_,
+ IDS_EXCEPTIONS_REMOVEALL_BUTTON,
+ GTK_STOCK_CLEAR);
g_signal_connect(remove_all_button_, "clicked", G_CALLBACK(RemoveAllThunk),
this);
gtk_box_pack_start(GTK_BOX(button_box), remove_all_button_, FALSE, FALSE, 0);