]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-ui-utils.c
Updatre python binding
[empathy.git] / libempathy-gtk / empathy-ui-utils.c
index 6f1b5a857716db32ade22564657bd381eb38ce54..80dcd42275f98a8c581f53add638813116cc1466 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  * Copyright (C) 2002-2007 Imendio AB
- * Copyright (C) 2007 Collabora Ltd.
+ * Copyright (C) 2007-2008 Collabora Ltd.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -28,6 +28,8 @@
  *          Jeroen Zwartepoorte
  */
 
+#include <config.h>
+
 #include <string.h>
 #include <X11/Xatom.h>
 #include <gdk/gdkx.h>
@@ -58,18 +60,24 @@ get_glade_file (const gchar *filename,
                const gchar *first_required_widget,
                va_list      args)
 {
-       gchar      *path;
        GladeXML   *gui;
+       gchar      *path;
        const char *name;
        GtkWidget **widget_ptr;
 
-       path = g_build_filename (DATADIR, "empathy", filename, NULL);
+       path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "libempathy-gtk",
+                                filename, NULL);
+       if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
+               g_free (path);
+               path = g_build_filename (DATADIR, "empathy", filename, NULL);
+       }
+       empathy_debug (DEBUG_DOMAIN, "Loading glade file %s", path);
+
        gui = glade_xml_new (path, root, domain);
        g_free (path);
 
        if (!gui) {
                g_warning ("Couldn't find necessary glade file '%s'", filename);
-               return NULL;
        }
 
        for (name = first_required_widget; name; name = va_arg (args, char *)) {
@@ -106,11 +114,9 @@ empathy_glade_get_file_simple (const gchar *filename,
 
        va_end (args);
 
-       if (!gui) {
-               return;
+       if (gui) {
+               g_object_unref (gui);
        }
-
-       g_object_unref (gui);
 }
 
 GladeXML *
@@ -212,9 +218,9 @@ empathy_icon_name_from_account (McAccount *account)
 }
 
 const gchar *
-empathy_icon_name_for_presence_state (McPresence state)
+empathy_icon_name_for_presence (McPresence presence)
 {
-       switch (state) {
+       switch (presence) {
        case MC_PRESENCE_AVAILABLE:
                return EMPATHY_IMAGE_AVAILABLE;
        case MC_PRESENCE_DO_NOT_DISTURB:
@@ -235,33 +241,16 @@ empathy_icon_name_for_presence_state (McPresence state)
        return NULL;
 }
 
-const gchar *
-empathy_icon_name_for_presence (EmpathyPresence *presence)
-{
-       McPresence state;
-
-       g_return_val_if_fail (EMPATHY_IS_PRESENCE (presence),
-                             EMPATHY_IMAGE_OFFLINE);
-
-       state = empathy_presence_get_state (presence);
-
-       return empathy_icon_name_for_presence_state (state);
-}
-
 const gchar *
 empathy_icon_name_for_contact (EmpathyContact *contact)
 {
-       EmpathyPresence *presence;
+       McPresence presence;
 
        g_return_val_if_fail (EMPATHY_IS_CONTACT (contact),
                              EMPATHY_IMAGE_OFFLINE);
 
        presence = empathy_contact_get_presence (contact);
-       if (presence) {
-               return empathy_icon_name_for_presence (presence);
-       }
-
-       return EMPATHY_IMAGE_UNKNOWN;
+       return empathy_icon_name_for_presence (presence);
 }
 
 GdkPixbuf *
@@ -1285,6 +1274,9 @@ empathy_window_present (GtkWindow *window,
        timestamp = gtk_get_current_event_time ();
        gtk_window_set_skip_taskbar_hint (window, FALSE);
        gtk_window_present_with_time (window, timestamp);
+       /* FIXME: This shouldn't be required as gtk_window_present's doc says
+        *        it deiconify automatically. */
+       gtk_window_deiconify (window);
 }
 
 GtkWindow *
@@ -1376,3 +1368,51 @@ empathy_toggle_button_set_state_quietly (GtkWidget *widget,
        g_signal_handlers_unblock_by_func (widget, callback, user_data);
 }
 
+GtkTextTag *
+empathy_text_buffer_tag_set (GtkTextBuffer *buffer,
+                            const gchar   *tag_name,
+                            const gchar   *first_property_name,
+                            ...)
+{
+       GtkTextTagTable *table;
+       GtkTextTag      *tag;
+
+       g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), NULL);
+       g_return_val_if_fail (tag_name != NULL, NULL);
+
+       table = gtk_text_buffer_get_tag_table (buffer);
+       tag = gtk_text_tag_table_lookup (table, tag_name);
+
+       if (!tag) {
+               tag = gtk_text_tag_new (tag_name);
+               gtk_text_tag_table_add (table, tag);
+               g_object_unref (tag);
+       } else {
+               /* Clear the old values so that we don't affect the new theme. */
+               g_object_set (tag,
+                             "background-set", FALSE,
+                             "foreground-set", FALSE,
+                             "invisible-set", FALSE,
+                             "justification-set", FALSE,
+                             "paragraph-background-set", FALSE,
+                             "pixels-above-lines-set", FALSE,
+                             "pixels-below-lines-set", FALSE,
+                             "rise-set", FALSE,
+                             "scale-set", FALSE,
+                             "size-set", FALSE,
+                             "style-set", FALSE,
+                             "weight-set", FALSE,
+                             NULL);
+       }
+
+       if (first_property_name) {
+               va_list list;
+
+               va_start (list, first_property_name);
+               g_object_set_valist (G_OBJECT (tag), first_property_name, list);
+               va_end (list);
+       }
+
+       return tag;
+}
+