]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-ui-utils.c
Updated Basque language
[empathy.git] / libempathy-gtk / empathy-ui-utils.c
index 3c8c52746c3e522305983dcb7e57850c09501811..1b02195d2db4c498a071645f52950c1f97786c66 100644 (file)
@@ -38,8 +38,6 @@
 #include <gtk/gtk.h>
 #include <gio/gio.h>
 
-#include <libmissioncontrol/mc-profile.h>
-
 #include "empathy-ui-utils.h"
 #include "empathy-images.h"
 #include "empathy-conf.h"
@@ -101,9 +99,19 @@ builder_get_file_valist (const gchar *filename,
 
        gui = gtk_builder_new ();
        if (!gtk_builder_add_from_file (gui, filename, &error)) {
-               g_critical ("GtkBuilder Error: %s", error->message);
+               g_critical ("GtkBuilder Error (%s): %s",
+                               filename, error->message);
                g_clear_error (&error);
                g_object_unref (gui);
+
+               /* we need to iterate and set all of the pointers to NULL */
+               for (name = first_object; name;
+                    name = va_arg (args, const gchar *)) {
+                       object_ptr = va_arg (args, GObject**);
+
+                       *object_ptr = NULL;
+               }
+
                return NULL;
        }
 
@@ -182,16 +190,6 @@ empathy_builder_unref_and_keep_widget (GtkBuilder *gui,
        return widget;
 }
 
-const gchar *
-empathy_icon_name_from_account (EmpathyAccount *account)
-{
-       McProfile *profile;
-
-       profile = empathy_account_get_profile (account);
-
-       return mc_profile_get_icon_name (profile);
-}
-
 const gchar *
 empathy_icon_name_for_presence (TpConnectionPresenceType presence)
 {
@@ -1250,7 +1248,7 @@ empathy_window_get_is_visible (GtkWindow *window)
 
        g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
 
-       gdk_window = GTK_WIDGET (window)->window;
+       gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
        if (!gdk_window) {
                return FALSE;
        }
@@ -1272,7 +1270,7 @@ empathy_window_iconify (GtkWindow *window, GtkStatusIcon *status_icon)
        GdkWindow    *gdk_window;
 
        gtk_status_icon_get_geometry (status_icon, NULL, &icon_location, NULL);
-       gdk_window = GTK_WIDGET (window)->window;
+       gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
        dpy = gdk_x11_drawable_get_xdisplay (gdk_window);
 
        data[0] = icon_location.x;
@@ -1333,25 +1331,46 @@ empathy_get_toplevel_window (GtkWidget *widget)
        return NULL;
 }
 
-/* The URL opening code can't handle schemeless strings, so we try to be
- * smart and add http if there is no scheme or doesn't look like a mail
- * address. This should work in most cases, and let us click on strings
- * like "www.gnome.org".
+/** empathy_make_absolute_url_len:
+ * @url: an url
+ * @len: a length
+ *
+ * Same as #empathy_make_absolute_url but for a limited string length
  */
-static gchar *
-fixup_url (const gchar *url)
+gchar *
+empathy_make_absolute_url_len (const gchar *url,
+                              guint len)
 {
+       g_return_val_if_fail (url != NULL, NULL);
+
        if (g_str_has_prefix (url, "ghelp:") ||
            g_str_has_prefix (url, "mailto:") ||
            strstr (url, ":/")) {
-               return NULL;
+               return g_strndup (url, len);
        }
 
        if (strstr (url, "@")) {
-               return g_strdup_printf ("mailto:%s", url);
+               return g_strdup_printf ("mailto:%.*s", len, url);
        }
 
-       return g_strdup_printf ("http://%s", url);
+       return g_strdup_printf ("http://%.*s", len, url);
+}
+
+/** empathy_make_absolute_url:
+ * @url: an url
+ *
+ * The URL opening code can't handle schemeless strings, so we try to be
+ * smart and add http if there is no scheme or doesn't look like a mail
+ * address. This should work in most cases, and let us click on strings
+ * like "www.gnome.org".
+ *
+ * Returns: a newly allocated url with proper mailto: or http:// prefix, use
+ * g_free when your are done with it
+ */
+gchar *
+empathy_make_absolute_url (const gchar *url)
+{
+       return empathy_make_absolute_url_len (url, strlen (url));
 }
 
 void
@@ -1361,12 +1380,12 @@ empathy_url_show (GtkWidget *parent,
        gchar  *real_url;
        GError *error = NULL;
 
-       real_url = fixup_url (url);
-       if (real_url) {
-               url = real_url;
-       }
+       g_return_if_fail (parent == NULL || GTK_IS_WIDGET (parent));
+       g_return_if_fail (url != NULL);
+
+       real_url = empathy_make_absolute_url (url);
 
-       gtk_show_uri (gtk_widget_get_screen (parent), url,
+       gtk_show_uri (parent ? gtk_widget_get_screen (parent) : NULL, real_url,
                      gtk_get_current_event_time (), &error);
 
        if (error) {
@@ -1483,6 +1502,8 @@ empathy_send_file_with_file_chooser (EmpathyContact *contact)
        gtk_dialog_set_default_response (GTK_DIALOG (widget),
                                         GTK_RESPONSE_OK);
 
+       gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (widget), FALSE);
+
        g_signal_connect (widget, "response",
                          G_CALLBACK (file_manager_send_file_response_cb),
                          contact);