]> git.0d.be Git - empathy.git/commitdiff
Merge commit 'ksz/fix-bug-583558'
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 22 May 2009 15:47:31 +0000 (16:47 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 22 May 2009 15:47:31 +0000 (16:47 +0100)
libempathy/empathy-tp-roomlist.c
src/empathy-new-chatroom-dialog.c
src/empathy-new-chatroom-dialog.ui

index 417a287d35ed0f758537a474af4574cdec4d468f..1b2e393d10fbe94b7dd5a4700e94c15afc2dd62b 100644 (file)
@@ -48,6 +48,7 @@ typedef struct {
 enum {
        NEW_ROOM,
        DESTROY,
+       ERROR,
        LAST_SIGNAL
 };
 
@@ -239,22 +240,24 @@ tp_roomlist_invalidated_cb (TpChannel         *channel,
 static void
 call_list_rooms_cb (TpChannel *proxy,
                    const GError *error,
-                   gpointer user_data,
+                   gpointer list,
                    GObject *weak_object)
 {
        if (error != NULL) {
                DEBUG ("Error listing rooms: %s", error->message);
+               g_signal_emit_by_name (list, "error::start", error);
        }
 }
 
 static void
 stop_listing_cb (TpChannel *proxy,
                 const GError *error,
-                gpointer user_data,
+                gpointer list,
                 GObject *weak_object)
 {
        if (error != NULL) {
                DEBUG ("Error on stop listing: %s", error->message);
+               g_signal_emit_by_name (list, "error::stop", error);
        }
 }
 
@@ -294,7 +297,7 @@ channel_ready_cb (TpChannel *channel,
 
        if (priv->start_requested == TRUE) {
                tp_cli_channel_type_room_list_call_list_rooms (priv->channel, -1,
-                       call_list_rooms_cb, NULL, NULL, NULL);
+                       call_list_rooms_cb, list, NULL, NULL);
                priv->start_requested = FALSE;
        }
 }
@@ -452,6 +455,16 @@ empathy_tp_roomlist_class_init (EmpathyTpRoomlistClass *klass)
                              G_TYPE_NONE,
                              0);
 
+       signals[ERROR] =
+               g_signal_new ("error",
+                             G_TYPE_FROM_CLASS (klass),
+                             G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+                             0,
+                             NULL, NULL,
+                             g_cclosure_marshal_VOID__POINTER,
+                             G_TYPE_NONE,
+                             1, G_TYPE_POINTER);
+
        g_type_class_add_private (object_class, sizeof (EmpathyTpRoomlistPriv));
 }
 
@@ -506,7 +519,7 @@ empathy_tp_roomlist_start (EmpathyTpRoomlist *list)
        g_return_if_fail (EMPATHY_IS_TP_ROOMLIST (list));
        if (priv->channel != NULL) {
                tp_cli_channel_type_room_list_call_list_rooms (priv->channel, -1,
-                       call_list_rooms_cb, NULL, NULL, NULL);
+                       call_list_rooms_cb, list, NULL, NULL);
        } else {
                priv->start_requested = TRUE;
        }
@@ -521,6 +534,6 @@ empathy_tp_roomlist_stop (EmpathyTpRoomlist *list)
        g_return_if_fail (TP_IS_CHANNEL (priv->channel));
 
        tp_cli_channel_type_room_list_call_stop_listing (priv->channel, -1,
-                                                        stop_listing_cb, NULL, NULL, NULL);
+                                                        stop_listing_cb, list, NULL, NULL);
 }
 
index 5f8d19b3ccc4c6202c6c631b4dee677030d8f3d9..5636659323e60440a70a1af04103c56653b81839 100644 (file)
@@ -30,6 +30,7 @@
 #include <gtk/gtk.h>
 #include <glib.h>
 #include <glib/gi18n.h>
+#include <glib/gprintf.h>
 
 #include <libmissioncontrol/mission-control.h>
 #include <libmissioncontrol/mc-account.h>
@@ -66,7 +67,8 @@ typedef struct {
        GtkWidget         *treeview;
        GtkTreeModel      *model;
        GtkWidget         *button_join;
-       GtkWidget         *button_close;
+       GtkWidget         *label_error_message;
+       GtkWidget         *viewport_error;
 } EmpathyNewChatroomDialog;
 
 enum {
@@ -98,6 +100,12 @@ static void     new_chatroom_dialog_new_room_cb                     (EmpathyTpRo
 static void     new_chatroom_dialog_listing_cb                      (EmpathyTpRoomlist        *room_list,
                                                                     gpointer                  unused,
                                                                     EmpathyNewChatroomDialog *dialog);
+static void     start_listing_error_cb                              (EmpathyTpRoomlist        *room_list,
+                                                                    GError                   *error,
+                                                                    EmpathyNewChatroomDialog *dialog);
+static void     stop_listing_error_cb                               (EmpathyTpRoomlist        *room_list,
+                                                                    GError                   *error,
+                                                                    EmpathyNewChatroomDialog *dialog);
 static void     new_chatroom_dialog_model_clear                     (EmpathyNewChatroomDialog *dialog);
 static void     new_chatroom_dialog_model_row_activated_cb          (GtkTreeView             *tree_view,
                                                                     GtkTreePath             *path,
@@ -117,6 +125,8 @@ static void     new_chatroom_dialog_expander_browse_activate_cb     (GtkWidget
 static gboolean new_chatroom_dialog_entry_server_focus_out_cb       (GtkWidget               *widget,
                                                                     GdkEventFocus           *event,
                                                                     EmpathyNewChatroomDialog *dialog);
+static void    new_chatroom_dialog_button_close_error_clicked_cb   (GtkButton                *button,
+                                                                    EmpathyNewChatroomDialog *dialog);
 
 static EmpathyNewChatroomDialog *dialog_p = NULL;
 
@@ -147,6 +157,8 @@ empathy_new_chatroom_dialog_show (GtkWindow *parent)
                                       "treeview", &dialog->treeview,
                                       "button_join", &dialog->button_join,
                                       "expander_browse", &dialog->expander_browse,
+                                      "label_error_message", &dialog->label_error_message,
+                                      "viewport_error", &dialog->viewport_error,
                                       NULL);
        g_free (filename);
 
@@ -158,6 +170,7 @@ empathy_new_chatroom_dialog_show (GtkWindow *parent)
                              "entry_server", "focus-out-event", new_chatroom_dialog_entry_server_focus_out_cb,
                              "entry_room", "changed", new_chatroom_dialog_entry_changed_cb,
                              "expander_browse", "activate", new_chatroom_dialog_expander_browse_activate_cb,
+                             "button_close_error", "clicked", new_chatroom_dialog_button_close_error_clicked_cb,
                              NULL);
 
        g_object_unref (gui);
@@ -411,9 +424,17 @@ new_chatroom_dialog_account_changed_cb (GtkComboBox             *combobox,
                g_signal_connect (dialog->room_list, "notify::is-listing",
                                  G_CALLBACK (new_chatroom_dialog_listing_cb),
                                  dialog);
+               g_signal_connect (dialog->room_list, "error::start",
+                                 G_CALLBACK (start_listing_error_cb),
+                                 dialog);
+               g_signal_connect (dialog->room_list, "error::stop",
+                                 G_CALLBACK (stop_listing_error_cb),
+                                 dialog);
 
                expanded = gtk_expander_get_expanded (GTK_EXPANDER (dialog->expander_browse));
                if (expanded) {
+                       gtk_widget_hide (dialog->viewport_error);
+                       gtk_widget_set_sensitive (dialog->treeview, TRUE);
                        new_chatroom_dialog_browse_start (dialog);
                }
 
@@ -428,6 +449,13 @@ new_chatroom_dialog_account_changed_cb (GtkComboBox             *combobox,
        g_object_unref (account);
 }
 
+static void
+new_chatroom_dialog_button_close_error_clicked_cb   (GtkButton                *button,
+                                                    EmpathyNewChatroomDialog *dialog)
+{
+       gtk_widget_hide (dialog->viewport_error);
+}
+
 static void
 new_chatroom_dialog_roomlist_destroy_cb (EmpathyTpRoomlist        *room_list,
                                         EmpathyNewChatroomDialog *dialog)
@@ -486,6 +514,26 @@ new_chatroom_dialog_new_room_cb (EmpathyTpRoomlist        *room_list,
        g_free (tooltip);
 }
 
+static void
+start_listing_error_cb (EmpathyTpRoomlist        *room_list,
+                       GError                   *error,
+                       EmpathyNewChatroomDialog *dialog)
+{
+       gtk_label_set_text (GTK_LABEL (dialog->label_error_message), _("Could not start room listing"));
+       gtk_widget_show_all (dialog->viewport_error);
+       gtk_widget_set_sensitive (dialog->treeview, FALSE);
+}
+
+static void
+stop_listing_error_cb (EmpathyTpRoomlist        *room_list,
+                      GError                   *error,
+                      EmpathyNewChatroomDialog *dialog)
+{
+       gtk_label_set_text (GTK_LABEL (dialog->label_error_message), _("Could not stop room listing"));
+       gtk_widget_show_all (dialog->viewport_error);
+       gtk_widget_set_sensitive (dialog->treeview, FALSE);
+}
+
 static void
 new_chatroom_dialog_listing_cb (EmpathyTpRoomlist        *room_list,
                                gpointer                  unused,
@@ -622,6 +670,8 @@ new_chatroom_dialog_expander_browse_activate_cb (GtkWidget               *widget
                new_chatroom_dialog_browse_stop (dialog);
                gtk_window_set_resizable (GTK_WINDOW (dialog->window), FALSE);
        } else {
+               gtk_widget_hide (dialog->viewport_error);
+               gtk_widget_set_sensitive (dialog->treeview, TRUE);
                new_chatroom_dialog_browse_start (dialog);
                gtk_window_set_resizable (GTK_WINDOW (dialog->window), TRUE);
        }
index ba7a326efb56d5b758071a9bab366833cfdd858b..a8fccf4a01e5735673fdfc0971c036bf1997bf64 100644 (file)
@@ -1,13 +1,14 @@
 <?xml version="1.0"?>
-<!--*- mode: xml -*-->
 <interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-naming-policy toplevel-contextual -->
   <object class="GtkDialog" id="new_chatroom_dialog">
     <property name="visible">True</property>
     <property name="border_width">5</property>
     <property name="title" translatable="yes">Join Room</property>
     <property name="role">join_new_chatroom</property>
     <property name="default_width">350</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="type_hint">dialog</property>
     <property name="has_separator">False</property>
     <child internal-child="vbox">
       <object class="GtkVBox" id="dialog-vbox4">
                 <property name="n_columns">3</property>
                 <property name="column_spacing">5</property>
                 <property name="row_spacing">5</property>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
                 <child>
                   <object class="GtkEntry" id="entry_room">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="tooltip-text" translatable="yes">Enter the room name to join here or click on one or more rooms in the list.</property>
+                    <property name="tooltip_text" translatable="yes">Enter the room name to join here or click on one or more rooms in the list.</property>
                     <property name="activates_default">True</property>
                     <property name="width_chars">25</property>
                   </object>
@@ -64,7 +59,7 @@
                   <object class="GtkEntry" id="entry_server">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="tooltip-text" translatable="yes">Enter the server which hosts the room, or leave it empty if the room is on the current account's server</property>
+                    <property name="tooltip_text" translatable="yes">Enter the server which hosts the room, or leave it empty if the room is on the current account's server</property>
                     <property name="width_chars">25</property>
                   </object>
                   <packing>
@@ -73,7 +68,7 @@
                     <property name="top_attach">1</property>
                     <property name="bottom_attach">2</property>
                     <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"/>
+                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
@@ -88,7 +83,7 @@
                     <property name="top_attach">1</property>
                     <property name="bottom_attach">2</property>
                     <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"/>
+                    <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
                   </object>
                   <packing>
                     <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"/>
+                    <property name="y_options"></property>
                   </packing>
                 </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
               </object>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <child>
-                  <object class="GtkScrolledWindow" id="scrolledwindow2">
-                    <property name="width_request">350</property>
-                    <property name="height_request">150</property>
+                  <object class="GtkVBox" id="vbox1">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
-                    <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-                    <property name="shadow_type">GTK_SHADOW_IN</property>
+                    <property name="orientation">vertical</property>
+                    <property name="spacing">2</property>
+                    <child>
+                      <object class="GtkViewport" id="viewport_error">
+                        <property name="resize_mode">queue</property>
+                        <child>
+                          <object class="GtkHBox" id="hbox1">
+                            <property name="visible">True</property>
+                            <child>
+                              <object class="GtkImage" id="image1">
+                                <property name="visible">True</property>
+                                <property name="stock">gtk-dialog-error</property>
+                                <property name="icon-size">1</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="padding">5</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label_error_message">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="xpad">10</property>
+                                <property name="label" translatable="yes">Couldn't load room list</property>
+                              </object>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkButton" id="button_close_error">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="relief">none</property>
+                                <child>
+                                  <object class="GtkImage" id="image2">
+                                    <property name="visible">True</property>
+                                    <property name="stock">gtk-close</property>
+                                    <property name="icon-size">1</property>
+                                  </object>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
                     <child>
-                      <object class="GtkTreeView" id="treeview">
+                      <object class="GtkScrolledWindow" id="scrolledwindow2">
+                        <property name="width_request">350</property>
+                        <property name="height_request">150</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="search_column">0</property>
-                        <property name="show_expanders">False</property>
+                        <property name="hscrollbar_policy">never</property>
+                        <property name="vscrollbar_policy">automatic</property>
+                        <property name="shadow_type">in</property>
+                        <child>
+                          <object class="GtkTreeView" id="treeview">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="search_column">0</property>
+                            <property name="show_expanders">False</property>
+                          </object>
+                        </child>
                       </object>
+                      <packing>
+                        <property name="position">1</property>
+                      </packing>
                     </child>
                   </object>
                 </child>
         <child internal-child="action_area">
           <object class="GtkHButtonBox" id="dialog-action_area4">
             <property name="visible">True</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="button_cancel">
+                <property name="label">gtk-cancel</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
-                <property name="label">gtk-cancel</property>
+                <property name="receives_default">False</property>
                 <property name="use_stock">True</property>
               </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
             </child>
             <child>
               <object class="GtkButton" id="button_join">
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="has_default">True</property>
+                <property name="receives_default">False</property>
                 <child>
                   <object class="GtkAlignment" id="alignment4">
                     <property name="visible">True</property>
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">False</property>
+                            <property name="position">0</property>
                           </packing>
                         </child>
                         <child>
                 </child>
               </object>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">1</property>
               </packing>
             </child>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
           </packing>
         </child>
       </object>