Display the dialogs near the mouse for ease of use.
authorRoy Marples <roy@marples.name>
Wed, 19 Nov 2014 21:39:10 +0000 (21:39 +0000)
committerRoy Marples <roy@marples.name>
Wed, 19 Nov 2014 21:39:10 +0000 (21:39 +0000)
src/dhcpcd-gtk/menu.c
src/dhcpcd-gtk/prefs.c
src/dhcpcd-qt/dhcpcd-about.cpp
src/dhcpcd-qt/dhcpcd-preferences.cpp

index 5ec3d14f84c6ca17e4285d81176c5b2147eb2a79..33c6114200f35da87697cfe550148821cce586fb 100644 (file)
@@ -32,6 +32,7 @@ static const char *authors[] = { "Roy Marples <roy@marples.name>", NULL };
 
 static GtkStatusIcon *sicon;
 static GtkWidget *menu;
+static GtkAboutDialog *about;
 static bool ifmenu;
 
 static void
@@ -49,34 +50,6 @@ on_quit(void)
        gtk_main_quit();
 }
 
-#if GTK_MAJOR_VERSION == 2
-static void
-url_show(GtkAboutDialog *dialog, const char *url)
-{
-       GdkScreen *screen;
-
-       screen = gtk_widget_get_screen(GTK_WIDGET(dialog));
-       gtk_show_uri(screen, url, GDK_CURRENT_TIME, NULL);
-}
-
-static void
-email_hook(GtkAboutDialog *dialog, const char *url, _unused gpointer data)
-{
-       char *address;
-
-       address = g_strdup_printf("mailto:%s", url);
-       url_show(dialog, address);
-       g_free(address);
-}
-
-
-static void
-url_hook(GtkAboutDialog *dialog, const char *url, _unused gpointer data)
-{
-       url_show(dialog, url);
-}
-#endif
-
 static void
 ssid_hook(GtkMenuItem *item, _unused gpointer data)
 {
@@ -103,20 +76,23 @@ static void
 on_about(_unused GtkMenuItem *item)
 {
 
-       gtk_window_set_default_icon_name("network-transmit-receive");
-#if GTK_MAJOR_VERSION == 2
-       gtk_about_dialog_set_email_hook(email_hook, NULL, NULL);
-       gtk_about_dialog_set_url_hook(url_hook, NULL, NULL);
-#endif
-       gtk_show_about_dialog(NULL,
-           "version", VERSION,
-           "copyright", copyright,
-           "website-label", "dhcpcd Website",
-           "website", "http://roy.marples.name/projects/dhcpcd",
-           "authors", authors,
-           "logo-icon-name", "network-transmit-receive",
-           "comments", "Part of the dhcpcd project",
-           NULL);
+       if (about == NULL) {
+               about = GTK_ABOUT_DIALOG(gtk_about_dialog_new());
+               gtk_about_dialog_set_version(about, VERSION);
+               gtk_about_dialog_set_copyright(about, copyright);
+               gtk_about_dialog_set_website_label(about, "dhcpcd Website");
+               gtk_about_dialog_set_website(about,
+                   "http://roy.marples.name/projects/dhcpcd");
+               gtk_about_dialog_set_authors(about, authors);
+               gtk_about_dialog_set_logo_icon_name(about,
+                   "network-transmit-receive");
+               gtk_about_dialog_set_comments(about,
+                   "Part of the dhcpcd project");
+       }
+       gtk_window_set_position(GTK_WINDOW(about), GTK_WIN_POS_MOUSE);
+       gtk_window_present(GTK_WINDOW(about));
+       gtk_dialog_run(GTK_DIALOG(about));
+       gtk_widget_hide(GTK_WIDGET(about));
 }
 
 static const char *
index 603521c89e029dff41327e4d1f5cace70aad39d8..4023cd0d04827541f2d6d4ff4cce88ffcfb5c15e 100644 (file)
@@ -528,7 +528,7 @@ prefs_show(DHCPCD_CONNECTION *con)
        gtk_window_set_resizable(GTK_WINDOW(dialog), false);
        gtk_window_set_icon_name(GTK_WINDOW(dialog),
            "preferences-system-network");
-       gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+       gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
        gtk_window_set_type_hint(GTK_WINDOW(dialog),
            GDK_WINDOW_TYPE_HINT_DIALOG);
 
index a25d4c34a36c4eb4964039ee9268f2655753f4f3..cc12e8990bab5c12483461bbd724bf80c3dff001 100644 (file)
 DhcpcdAbout::DhcpcdAbout(DhcpcdQt *parent)
     : QDialog(parent)
 {
-       QVBoxLayout *layout;
-
        this->parent = parent;
+       QVBoxLayout *layout;
        resize(300, 200);
        setWindowIcon(DhcpcdQt::getIcon("status", "network-transmit-receive"));
        setWindowTitle(tr("About Network Configurator"));
+       QPoint p = QCursor::pos();
+       move(p.x(), p.y());
+
        layout = new QVBoxLayout(this);
 
        QIcon icon = DhcpcdQt::getIcon("status", "network-transmit-receive");
index 3d8b6dff3a42197a8f6b74312c72c8d789a8bd6d..032f10b379c1bcd23adedd6ec8bca568098d77e6 100644 (file)
@@ -55,6 +55,8 @@ DhcpcdPreferences::DhcpcdPreferences(DhcpcdQt *parent)
        resize(400, 200);
        setWindowIcon(DhcpcdQt::getIcon("status", "network-transmit-receive"));
        setWindowTitle(tr("Network Preferences"));
+       QPoint p = QCursor::pos();
+       move(p.x(), p.y());
 
        name = NULL;
        config = NULL;