]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-ui-utils.c
empathy_window_present: use _NET_WM_USER_TIME only has a fallback
[empathy.git] / libempathy-gtk / empathy-ui-utils.c
index a2865bc55d7b883c74759dc2c0f766f167500556..4503a39cc22f67f12cb613e3d1be4f55df183d46 100644 (file)
 #include <libempathy/empathy-idle.h>
 #include <libempathy/empathy-ft-factory.h>
 
-#define SCHEMES           "([a-zA-Z\\+]+)"
-#define INVALID_CHARS     "\\s\"'"
-#define INVALID_CHARS_EXT INVALID_CHARS "\\[\\]<>(){},;:?"
-#define BODY              "([^"INVALID_CHARS"]+)"
-#define BODY_END          "([^"INVALID_CHARS"]*)[^"INVALID_CHARS_EXT".]"
-#define BODY_STRICT       "([^"INVALID_CHARS_EXT"]+)"
-#define URI_REGEX         "("SCHEMES"://"BODY_END")" \
-                         "|((www|ftp)\\."BODY_END")" \
-                         "|((mailto:)?"BODY_STRICT"@"BODY"\\."BODY_END")"
-
 void
 empathy_gtk_init (void)
 {
@@ -75,19 +65,6 @@ empathy_gtk_init (void)
        initialized = TRUE;
 }
 
-GRegex *
-empathy_uri_regex_dup_singleton (void)
-{
-       static GRegex *uri_regex = NULL;
-
-       /* We intentionally leak the regex so it's not recomputed */
-       if (!uri_regex) {
-               uri_regex = g_regex_new (URI_REGEX, 0, 0, NULL);
-       }
-
-       return g_regex_ref (uri_regex);
-}
-
 static GtkBuilder *
 builder_get_file_valist (const gchar *filename,
                         const gchar *first_object,
@@ -1396,7 +1373,8 @@ empathy_window_iconify (GtkWindow *window, GtkStatusIcon *status_icon)
 
        XChangeProperty (dpy,
                         GDK_WINDOW_XID (gdk_window),
-                        gdk_x11_get_xatom_by_name_for_display (gdk_drawable_get_display (gdk_window),
+                        gdk_x11_get_xatom_by_name_for_display (
+                               gdk_drawable_get_display (gdk_window),
                         "_NET_WM_ICON_GEOMETRY"),
                         XA_CARDINAL, 32, PropModeReplace,
                         (guchar *)&data, 4);
@@ -1407,11 +1385,10 @@ empathy_window_iconify (GtkWindow *window, GtkStatusIcon *status_icon)
 
 /* Takes care of moving the window to the current workspace. */
 void
-empathy_window_present (GtkWindow *window,
-                       gboolean   steal_focus)
+empathy_window_present (GtkWindow *window)
 {
-       guint32 timestamp;
        GdkWindow *gdk_window;
+       guint32 timestamp;
 
        g_return_if_fail (GTK_IS_WINDOW (window));
 
@@ -1434,6 +1411,10 @@ empathy_window_present (GtkWindow *window,
        }
 
        timestamp = gtk_get_current_event_time ();
+       if (timestamp == 0)
+               /* No event, fallback to _NET_WM_USER_TIME */
+               timestamp = gdk_x11_display_get_user_time (gdk_display_get_default ());
+
        gtk_window_present_with_time (window, timestamp);
        gtk_window_set_skip_taskbar_hint (window, FALSE);
        gtk_window_deiconify (window);
@@ -1554,19 +1535,6 @@ empathy_link_button_new (const gchar *url,
        return gtk_link_button_new_with_label (url, title);
 }
 
-void
-empathy_toggle_button_set_state_quietly (GtkWidget *widget,
-                                       GCallback  callback,
-                                       gpointer   user_data,
-                                       gboolean   active)
-{
-       g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget));
-
-       g_signal_handlers_block_by_func (widget, callback, user_data);
-       g_object_set (widget, "active", active, NULL);
-       g_signal_handlers_unblock_by_func (widget, callback, user_data);
-}
-
 void
 empathy_send_file (EmpathyContact *contact, GFile *file)
 {
@@ -1668,6 +1636,9 @@ empathy_send_file_with_file_chooser (EmpathyContact *contact)
 
        gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (widget), FALSE);
 
+       gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget),
+               g_get_home_dir ());
+
        g_signal_connect (widget, "response",
                          G_CALLBACK (file_manager_send_file_response_cb),
                          contact);
@@ -1706,6 +1677,7 @@ void
 empathy_receive_file_with_file_chooser (EmpathyFTHandler *handler)
 {
        GtkWidget *widget;
+       const gchar *dir;
 
        widget = gtk_file_chooser_dialog_new (_("Select a destination"),
                                              NULL,
@@ -1720,6 +1692,13 @@ empathy_receive_file_with_file_chooser (EmpathyFTHandler *handler)
        gtk_file_chooser_set_do_overwrite_confirmation
                (GTK_FILE_CHOOSER (widget), TRUE);
 
+       dir = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD);
+       if (dir == NULL)
+               /* Fallback to $HOME if $XDG_DOWNLOAD_DIR is not set */
+               dir = g_get_home_dir ();
+
+       gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget), dir);
+
        g_signal_connect (widget, "response",
                G_CALLBACK (file_manager_receive_file_response_cb), handler);