empathy r2867 - trunk/src



Author: xclaesse
Date: Thu Apr 16 12:29:18 2009
New Revision: 2867
URL: http://svn.gnome.org/viewvc/empathy?rev=2867&view=rev

Log:
Make use of GtkUIManager in EmpathyCallWindow

From: Xavier Claessens <xclaesse gmail com>

Modified:
   trunk/src/empathy-call-window.c
   trunk/src/empathy-call-window.ui

Modified: trunk/src/empathy-call-window.c
==============================================================================
--- trunk/src/empathy-call-window.c	(original)
+++ trunk/src/empathy-call-window.c	Thu Apr 16 12:29:18 2009
@@ -69,6 +69,7 @@
 
   gboolean connected;
 
+  GtkUIManager *ui_manager;
   GtkWidget *video_output;
   GtkWidget *video_preview;
   GtkWidget *sidebar;
@@ -78,8 +79,8 @@
   GtkWidget *mic_button;
   GtkWidget *camera_button;
   GtkWidget *toolbar;
-  GtkWidget *hangup;
   GtkWidget *pane;
+  GtkAction *send_video;
 
   gdouble volume;
   GtkAdjustment *audio_input_adj;
@@ -124,13 +125,20 @@
 static void empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
   EmpathyCallWindow *window);
 
+static void empathy_call_window_send_video_toggled_cb (GtkToggleAction *toggle,
+  EmpathyCallWindow *window);
+
+static void empathy_call_window_show_preview_toggled_cb (GtkToggleAction *toggle,
+  EmpathyCallWindow *window);
+
 static void empathy_call_window_mic_toggled_cb (
   GtkToggleToolButton *toggle, EmpathyCallWindow *window);
 
 static void empathy_call_window_sidebar_hidden_cb (EmpathySidebar *sidebar,
   EmpathyCallWindow *window);
 
-static void empathy_call_window_hangup (EmpathyCallWindow *window);
+static void empathy_call_window_hangup_cb (gpointer object,
+  EmpathyCallWindow *window);
 
 static void empathy_call_window_status_message (EmpathyCallWindow *window,
   gchar *message);
@@ -143,29 +151,11 @@
   gdouble value, EmpathyCallWindow *window);
 
 static void
-empathy_call_window_setup_menubar (EmpathyCallWindow *self)
-{
-  EmpathyCallWindowPriv *priv = GET_PRIV (self);
-
-  g_signal_connect_swapped (priv->hangup, "activate",
-    G_CALLBACK (empathy_call_window_hangup), self);
-}
-
-static void
 empathy_call_window_setup_toolbar (EmpathyCallWindow *self)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
   GtkToolItem *tool_item;
 
-  g_signal_connect_swapped (priv->hangup, "clicked",
-    G_CALLBACK (empathy_call_window_hangup), self);
-
-  gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->mic_button),
-      TRUE);
-
-  g_signal_connect (G_OBJECT (priv->mic_button), "toggled",
-    G_CALLBACK (empathy_call_window_mic_toggled_cb), self);
-
   /* Add an empty expanded GtkToolItem so the volume button is at the end of
    * the toolbar. */
   tool_item = gtk_tool_item_new ();
@@ -185,13 +175,6 @@
   gtk_container_add (GTK_CONTAINER (tool_item), priv->volume_button);
   gtk_widget_show_all (GTK_WIDGET (tool_item));
   gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), tool_item, -1);
-
-  gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->camera_button),
-      FALSE);
-  gtk_widget_set_sensitive (priv->camera_button, FALSE);
-
-  g_signal_connect (priv->camera_button, "toggled",
-    G_CALLBACK (empathy_call_window_camera_toggled_cb), self);
 }
 
 static void
@@ -489,14 +472,23 @@
     "microphone", &priv->mic_button,
     "camera", &priv->camera_button,
     "toolbar", &priv->toolbar,
-    "hangup", &priv->hangup,
+    "send_video", &priv->send_video,
+    "ui_manager", &priv->ui_manager,
+    NULL);
+
+  empathy_builder_connect (gui, self,
+    "menuhangup", "activate", empathy_call_window_hangup_cb,
+    "hangup", "clicked", empathy_call_window_hangup_cb,
+    "microphone", "toggled", empathy_call_window_mic_toggled_cb,
+    "camera", "toggled", empathy_call_window_camera_toggled_cb,
+    "send_video", "toggled", empathy_call_window_send_video_toggled_cb,
+    "show_preview", "toggled", empathy_call_window_show_preview_toggled_cb,
     NULL);
 
   priv->lock = g_mutex_new ();
 
   gtk_container_add (GTK_CONTAINER (self), top_vbox);
 
-  empathy_call_window_setup_menubar (self);
   empathy_call_window_setup_toolbar (self);
 
   priv->pipeline = gst_pipeline_new (NULL);
@@ -582,6 +574,7 @@
 
   priv->timer = g_timer_new ();
 
+  g_object_ref (priv->ui_manager);
   g_object_unref (gui);
 }
 
@@ -685,6 +678,10 @@
     g_source_remove (priv->timer_id);
   priv->timer_id = 0;
 
+  if (priv->ui_manager != NULL)
+    g_object_unref (priv->ui_manager);
+  priv->ui_manager = NULL;
+
   /* release any references held by the object here */
   if (G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose)
     G_OBJECT_CLASS (empathy_call_window_parent_class)->dispose (object);
@@ -759,6 +756,7 @@
   empathy_call_window_status_message (self, _("Disconnected"));
 
   gtk_widget_set_sensitive (priv->camera_button, FALSE);
+  gtk_action_set_sensitive (priv->send_video, FALSE);
 }
 
 
@@ -857,7 +855,10 @@
     gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
 
   if (priv->video_input != NULL)
-    gtk_widget_set_sensitive (priv->camera_button, TRUE);
+    {
+      gtk_widget_set_sensitive (priv->camera_button, TRUE);
+      gtk_action_set_sensitive (priv->send_video, TRUE);
+    }
 
   g_object_unref (call);
 
@@ -1141,20 +1142,42 @@
 }
 
 static void
+empathy_call_window_set_send_video (EmpathyCallWindow *window,
+  gboolean send)
+{
+  EmpathyCallWindowPriv *priv = GET_PRIV (window);
+  EmpathyTpCall *call;
+
+  g_object_get (priv->handler, "tp-call", &call, NULL);
+  empathy_tp_call_request_video_stream_direction (call, send);
+  g_object_unref (call);
+}
+
+static void
 empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
   EmpathyCallWindow *window)
 {
-  EmpathyCallWindowPriv *priv = GET_PRIV (window);
   gboolean active;
-  EmpathyTpCall *call;
 
   active = (gtk_toggle_tool_button_get_active (toggle));
+  empathy_call_window_set_send_video (window, active);
+}
 
-  g_object_get (priv->handler, "tp-call", &call, NULL);
+static void
+empathy_call_window_send_video_toggled_cb (GtkToggleAction *toggle,
+  EmpathyCallWindow *window)
+{
+  gboolean active;
 
-  empathy_tp_call_request_video_stream_direction (call, active);
+  active = (gtk_toggle_action_get_active (toggle));
+  empathy_call_window_set_send_video (window, active);
+}
 
-  g_object_unref (call);
+static void
+empathy_call_window_show_preview_toggled_cb (GtkToggleAction *toggle,
+  EmpathyCallWindow *window)
+{
+  /* FIXME: Not implemented */
 }
 
 static void
@@ -1196,7 +1219,8 @@
 }
 
 static void
-empathy_call_window_hangup (EmpathyCallWindow *window)
+empathy_call_window_hangup_cb (gpointer object,
+                               EmpathyCallWindow *window)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (window);
 

Modified: trunk/src/empathy-call-window.ui
==============================================================================
--- trunk/src/empathy-call-window.ui	(original)
+++ trunk/src/empathy-call-window.ui	Thu Apr 16 12:29:18 2009
@@ -1,93 +1,138 @@
 <?xml version="1.0"?>
+<!--Generated with glade3 3.4.5 on Mon Feb 16 12:31:56 2009 -->
 <interface>
-  <requires lib="gtk+" version="2.16"/>
-  <!-- interface-naming-policy toplevel-contextual -->
-  <object class="GtkUIManager" id="uimanager1"/>
-  <object class="GtkVBox" id="call_window_vbox">
-    <property name="visible">True</property>
-    <property name="orientation">vertical</property>
+  <object class="GtkUIManager" id="ui_manager">
     <child>
-      <object class="GtkHPaned" id="pane">
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
+      <object class="GtkActionGroup" id="actiongroup1">
         <child>
-          <placeholder/>
+          <object class="GtkAction" id="call">
+            <property name="name">call</property>
+            <property name="label" translatable="yes">_Call</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkToggleAction" id="send_video">
+            <property name="name">send_video</property>
+            <property name="label" translatable="yes">Send video</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkAction" id="menuhangup">
+            <property name="stock_id">gtk-cancel</property>
+            <property name="name">menuhangup</property>
+            <property name="label" translatable="yes">Hang up</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkAction" id="view">
+            <property name="name">view</property>
+            <property name="label" translatable="yes">_View</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkToggleAction" id="show_preview">
+            <property name="name">show_preview</property>
+            <property name="label" translatable="yes">Video preview</property>
+          </object>
         </child>
       </object>
-      <packing>
-        <property name="position">0</property>
-      </packing>
     </child>
-    <child>
-      <object class="GtkToolbar" id="toolbar">
+    <ui>
+      <menubar name="menubar1">
+        <menu action="call">
+          <menuitem action="send_video"/>
+          <menuitem action="menuhangup"/>
+        </menu>
+        <menu action="view">
+          <menuitem action="show_preview"/>
+        </menu>
+      </menubar>
+    </ui>
+  </object>
+      <object class="GtkVBox" id="call_window_vbox">
         <property name="visible">True</property>
         <child>
-          <object class="GtkToolButton" id="hangup">
+          <object class="GtkMenuBar" constructor="ui_manager" id="menubar1">
             <property name="visible">True</property>
-            <property name="is_important">True</property>
-            <property name="label" translatable="yes">Hang up</property>
-            <property name="stock_id">gtk-cancel</property>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="homogeneous">True</property>
           </packing>
         </child>
         <child>
-          <object class="GtkSeparatorToolItem" id="toolbutton1">
+          <object class="GtkToolbar" id="toolbar">
             <property name="visible">True</property>
+            <child>
+              <object class="GtkToolButton" id="hangup">
+                <property name="visible">True</property>
+                <property name="is_important">True</property>
+                <property name="label" translatable="yes">Hang up</property>
+                <property name="stock_id">gtk-cancel</property>
+              </object>
+              <packing>
+                <property name="homogeneous">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparatorToolItem" id="toolbutton1">
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="homogeneous">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToggleToolButton" id="microphone">
+                <property name="visible">True</property>
+                <property name="active">True</property>
+                <property name="label" translatable="yes">Send Audio</property>
+                <property name="icon_name">gnome-stock-mic</property>
+              </object>
+              <packing>
+                <property name="homogeneous">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToggleToolButton" id="camera">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Send video</property>
+                <property name="icon_name">camera-web</property>
+                <property name="sensitive">False</property>
+              </object>
+              <packing>
+                <property name="homogeneous">True</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="homogeneous">True</property>
+            <property name="position">1</property>
           </packing>
         </child>
         <child>
-          <object class="GtkToggleToolButton" id="microphone">
+          <object class="GtkHPaned" id="pane">
             <property name="visible">True</property>
-            <property name="label" translatable="yes">Send Audio</property>
-            <property name="icon_name">gnome-stock-mic</property>
+            <property name="can_focus">True</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="homogeneous">True</property>
+            <property name="position">2</property>
           </packing>
         </child>
         <child>
-          <object class="GtkToggleToolButton" id="camera">
+          <object class="GtkStatusbar" id="statusbar">
             <property name="visible">True</property>
-            <property name="label" translatable="yes">Send video</property>
-            <property name="icon_name">camera-web</property>
+            <property name="spacing">2</property>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="homogeneous">True</property>
+            <property name="position">3</property>
           </packing>
         </child>
       </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="position">1</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkMenuBar" id="menubar1">
-        <property name="visible">True</property>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="position">0</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkStatusbar" id="statusbar">
-        <property name="visible">True</property>
-        <property name="spacing">2</property>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="position">3</property>
-      </packing>
-    </child>
-  </object>
 </interface>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]