summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-20 16:47:13 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-20 16:47:13 +0000
commit0ba5c5e634c8e0282169fd94e119d9e4070b1e6d (patch)
treeacbc48190a9dc739c120f62e97d67a9be9beab4a /chrome/browser/gtk
parent797cf0cc490f960fec4bfd3de5a19d23e42c6b84 (diff)
downloadchromium_src-0ba5c5e634c8e0282169fd94e119d9e4070b1e6d.zip
chromium_src-0ba5c5e634c8e0282169fd94e119d9e4070b1e6d.tar.gz
chromium_src-0ba5c5e634c8e0282169fd94e119d9e4070b1e6d.tar.bz2
Add (incomplete) UI for creating application shortcuts on Linux
TEST=none http://crbug.com/17251 Review URL: http://codereview.chromium.org/171082 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23827 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/create_application_shortcuts_dialog_gtk.cc69
-rw-r--r--chrome/browser/gtk/create_application_shortcuts_dialog_gtk.h46
2 files changed, 115 insertions, 0 deletions
diff --git a/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.cc b/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.cc
new file mode 100644
index 0000000..6997651
--- /dev/null
+++ b/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.cc
@@ -0,0 +1,69 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/gtk/create_application_shortcuts_dialog_gtk.h"
+
+#include "app/l10n_util.h"
+#include "chrome/browser/shell_integration.h"
+#include "chrome/common/gtk_util.h"
+#include "grit/generated_resources.h"
+
+// static
+void CreateApplicationShortcutsDialogGtk::Show(GtkWindow* parent,
+ const GURL& url,
+ const string16& title) {
+ new CreateApplicationShortcutsDialogGtk(parent, url, title);
+}
+
+CreateApplicationShortcutsDialogGtk::CreateApplicationShortcutsDialogGtk(
+ GtkWindow* parent, const GURL& url, const string16& title)
+ : url_(url),
+ title_(title) {
+ // Build the dialog.
+ GtkWidget* dialog = gtk_dialog_new_with_buttons(
+ l10n_util::GetStringUTF8(IDS_CREATE_SHORTCUTS_TITLE).c_str(),
+ parent,
+ (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_REJECT,
+ NULL);
+ gtk_util::AddButtonToDialog(dialog,
+ l10n_util::GetStringUTF8(IDS_CREATE_SHORTCUTS_COMMIT).c_str(),
+ GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT);
+
+ GtkWidget* content_area = GTK_DIALOG(dialog)->vbox;
+ gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing);
+
+ GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
+ gtk_container_add(GTK_CONTAINER(content_area), vbox);
+
+ // Label on top of the checkboxes.
+ GtkWidget* description = gtk_label_new(
+ l10n_util::GetStringUTF8(IDS_CREATE_SHORTCUTS_LABEL).c_str());
+ gtk_misc_set_alignment(GTK_MISC(description), 0, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), description, FALSE, FALSE, 0);
+
+ // Desktop checkbox.
+ desktop_checkbox_ = gtk_check_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_CREATE_SHORTCUTS_DESKTOP_CHKBOX).c_str());
+ gtk_box_pack_start(GTK_BOX(vbox), desktop_checkbox_, FALSE, FALSE, 0);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(desktop_checkbox_), true);
+
+ g_signal_connect(dialog, "response",
+ G_CALLBACK(HandleOnResponseDialog), this);
+ gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+ gtk_widget_show_all(dialog);
+}
+
+void CreateApplicationShortcutsDialogGtk::OnDialogResponse(GtkWidget* widget,
+ int response) {
+ if (response == GTK_RESPONSE_ACCEPT) {
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(desktop_checkbox_)))
+ ShellIntegration::CreateDesktopShortcut(url_, title_);
+ }
+
+ delete this;
+ gtk_widget_destroy(GTK_WIDGET(widget));
+}
+
diff --git a/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.h b/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.h
new file mode 100644
index 0000000..79b54306
--- /dev/null
+++ b/chrome/browser/gtk/create_application_shortcuts_dialog_gtk.h
@@ -0,0 +1,46 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_
+#define CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_
+
+#include "base/basictypes.h"
+#include "base/string16.h"
+#include "googleurl/src/gurl.h"
+
+typedef struct _GtkWidget GtkWidget;
+typedef struct _GtkWindow GtkWindow;
+
+class CreateApplicationShortcutsDialogGtk {
+ public:
+ // Displays the dialog box to create application shortcuts for |url| with
+ // |title|.
+ static void Show(GtkWindow* parent, const GURL& url, const string16& title);
+
+ private:
+ CreateApplicationShortcutsDialogGtk(GtkWindow* parent, const GURL& url,
+ const string16& title);
+ ~CreateApplicationShortcutsDialogGtk() { }
+
+ // Handler to respond to Ok and Cancel responses from the dialog.
+ static void HandleOnResponseDialog(GtkWidget* widget,
+ int response, CreateApplicationShortcutsDialogGtk* user_data) {
+ user_data->OnDialogResponse(widget, response);
+ }
+
+ void OnDialogResponse(GtkWidget* widget, int response);
+
+ // UI elements.
+ GtkWidget* desktop_checkbox_;
+
+ // Target URL of the shortcut.
+ GURL url_;
+
+ // Visible title of the shortcut.
+ string16 title_;
+
+ DISALLOW_COPY_AND_ASSIGN(CreateApplicationShortcutsDialogGtk);
+};
+
+#endif // CHROME_BROWSER_GTK_CREATE_APPLICATION_SHORTCUTS_DIALOG_GTK_H_