]> git.0d.be Git - empathy.git/commitdiff
Make use of GtkUIManager in EmpathyCallWindow
authorXavier Claessens <xclaesse@gmail.com>
Thu, 16 Apr 2009 12:29:18 +0000 (12:29 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Thu, 16 Apr 2009 12:29:18 +0000 (12:29 +0000)
From: Xavier Claessens <xclaesse@gmail.com>

svn path=/trunk/; revision=2867

src/empathy-call-window.c
src/empathy-call-window.ui

index 48b6b664705f42e9cb8e98fdf05bf9e65516fed5..d7d79df90ff40da5861538d015b169e0cf9bbb00 100644 (file)
@@ -69,6 +69,7 @@ struct _EmpathyCallWindowPriv
 
   gboolean connected;
 
 
   gboolean connected;
 
+  GtkUIManager *ui_manager;
   GtkWidget *video_output;
   GtkWidget *video_preview;
   GtkWidget *sidebar;
   GtkWidget *video_output;
   GtkWidget *video_preview;
   GtkWidget *sidebar;
@@ -78,8 +79,8 @@ struct _EmpathyCallWindowPriv
   GtkWidget *mic_button;
   GtkWidget *camera_button;
   GtkWidget *toolbar;
   GtkWidget *mic_button;
   GtkWidget *camera_button;
   GtkWidget *toolbar;
-  GtkWidget *hangup;
   GtkWidget *pane;
   GtkWidget *pane;
+  GtkAction *send_video;
 
   gdouble volume;
   GtkAdjustment *audio_input_adj;
 
   gdouble volume;
   GtkAdjustment *audio_input_adj;
@@ -124,13 +125,20 @@ static void empathy_call_window_sidebar_toggled_cb (GtkToggleButton *toggle,
 static void empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
   EmpathyCallWindow *window);
 
 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_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);
 
 static void empathy_call_window_status_message (EmpathyCallWindow *window,
   gchar *message);
@@ -142,30 +150,12 @@ static void
 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
   gdouble value, EmpathyCallWindow *window);
 
 empathy_call_window_volume_changed_cb (GtkScaleButton *button,
   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;
 
 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 ();
   /* 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 @@ empathy_call_window_setup_toolbar (EmpathyCallWindow *self)
   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_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
 }
 
 static void
@@ -489,14 +472,23 @@ empathy_call_window_init (EmpathyCallWindow *self)
     "microphone", &priv->mic_button,
     "camera", &priv->camera_button,
     "toolbar", &priv->toolbar,
     "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);
 
     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);
   empathy_call_window_setup_toolbar (self);
 
   priv->pipeline = gst_pipeline_new (NULL);
@@ -582,6 +574,7 @@ empathy_call_window_init (EmpathyCallWindow *self)
 
   priv->timer = g_timer_new ();
 
 
   priv->timer = g_timer_new ();
 
+  g_object_ref (priv->ui_manager);
   g_object_unref (gui);
 }
 
   g_object_unref (gui);
 }
 
@@ -685,6 +678,10 @@ empathy_call_window_dispose (GObject *object)
     g_source_remove (priv->timer_id);
   priv->timer_id = 0;
 
     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);
   /* 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_disconnected (EmpathyCallWindow *self)
   empathy_call_window_status_message (self, _("Disconnected"));
 
   gtk_widget_set_sensitive (priv->camera_button, FALSE);
   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 @@ empathy_call_window_connected (gpointer user_data)
     gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
 
   if (priv->video_input != NULL)
     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);
 
 
   g_object_unref (call);
 
@@ -1140,21 +1141,43 @@ empathy_call_window_sidebar_toggled_cb (GtkToggleButton *toggle,
     gtk_window_resize (GTK_WINDOW (window), w, h);
 }
 
     gtk_window_resize (GTK_WINDOW (window), w, h);
 }
 
+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)
 {
 static void
 empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle,
   EmpathyCallWindow *window)
 {
-  EmpathyCallWindowPriv *priv = GET_PRIV (window);
   gboolean active;
   gboolean active;
-  EmpathyTpCall *call;
 
   active = (gtk_toggle_tool_button_get_active (toggle));
 
   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
 }
 
 static void
@@ -1196,7 +1219,8 @@ empathy_call_window_sidebar_hidden_cb (EmpathySidebar *sidebar,
 }
 
 static void
 }
 
 static void
-empathy_call_window_hangup (EmpathyCallWindow *window)
+empathy_call_window_hangup_cb (gpointer object,
+                               EmpathyCallWindow *window)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (window);
 
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (window);
 
index 8ac599989637424daea6a002c5b3141a2ea210c3..00b8ffa886868e907d17b90cfaaef0611e42275e 100644 (file)
 <?xml version="1.0"?>
 <?xml version="1.0"?>
+<!--Generated with glade3 3.4.5 on Mon Feb 16 12:31:56 2009 -->
 <interface>
 <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>
     <child>
-      <object class="GtkHPaned" id="pane">
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
+      <object class="GtkActionGroup" id="actiongroup1">
         <child>
         <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>
         </child>
       </object>
-      <packing>
-        <property name="position">0</property>
-      </packing>
     </child>
     </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>
         <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="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>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="homogeneous">True</property>
           </packing>
         </child>
         <child>
           </packing>
         </child>
         <child>
-          <object class="GtkSeparatorToolItem" id="toolbutton1">
+          <object class="GtkToolbar" id="toolbar">
             <property name="visible">True</property>
             <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>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="homogeneous">True</property>
+            <property name="position">1</property>
           </packing>
         </child>
         <child>
           </packing>
         </child>
         <child>
-          <object class="GtkToggleToolButton" id="microphone">
+          <object class="GtkHPaned" id="pane">
             <property name="visible">True</property>
             <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>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="homogeneous">True</property>
+            <property name="position">2</property>
           </packing>
         </child>
         <child>
           </packing>
         </child>
         <child>
-          <object class="GtkToggleToolButton" id="camera">
+          <object class="GtkStatusbar" id="statusbar">
             <property name="visible">True</property>
             <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>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="homogeneous">True</property>
+            <property name="position">3</property>
           </packing>
         </child>
       </object>
           </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>
 </interface>