commit 62378e9ab6ea75336df5fccaed4c361af51f5b54
Author: Vitaly Minko <vitaly.minko@gmail.com>
Date:   Fri Nov 5 23:59:29 2010 +0300

    Base the search bar on GtkToolbar instead of GtkHBox in order not to resize the chat window when we activate it (#614319).

diff --git a/libempathy-gtk/empathy-search-bar.c b/libempathy-gtk/empathy-search-bar.c
index 9a27795..a8da9a0 100644
--- a/libempathy-gtk/empathy-search-bar.c
+++ b/libempathy-gtk/empathy-search-bar.c
@@ -17,8 +17,11 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include "config.h"
+
 #include <glib.h>
 #include <glib-object.h>
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
 
@@ -41,6 +44,8 @@ struct _EmpathySearchBarPriv
 
   GtkWidget *search_match_case;
 
+  GtkWidget *search_match_case_toolitem;
+
   GtkWidget *search_close;
   GtkWidget *search_previous;
   GtkWidget *search_next;
@@ -239,6 +244,42 @@ empathy_search_bar_match_case_toggled (GtkButton *button,
 }
 
 static void
+empathy_search_bar_match_case_menu_toggled (GtkWidget *check,
+    gpointer user_data)
+{
+  EmpathySearchBarPriv* priv = GET_PRIV ( EMPATHY_SEARCH_BAR (user_data));
+  gboolean match_case;
+
+  match_case = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (check));
+
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->search_match_case),
+      match_case);
+}
+
+static gboolean
+empathy_searchbar_create_menu_proxy_cb (GtkToolItem *toolitem,
+    gpointer user_data)
+{
+  EmpathySearchBarPriv* priv = GET_PRIV ( EMPATHY_SEARCH_BAR (user_data));
+  GtkWidget *checkbox_menu;
+  gboolean match_case;
+
+  checkbox_menu = gtk_check_menu_item_new_with_mnemonic (_("_Match case"));
+  match_case = gtk_toggle_button_get_active (
+      GTK_TOGGLE_BUTTON (priv->search_match_case));
+  gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (checkbox_menu),
+      match_case);
+
+  g_signal_connect (checkbox_menu, "toggled",
+      G_CALLBACK (empathy_search_bar_match_case_menu_toggled), user_data);
+
+  gtk_tool_item_set_proxy_menu_item (toolitem, "menu-proxy",
+      checkbox_menu);
+
+  return TRUE;
+}
+
+static void
 empathy_search_bar_init (EmpathySearchBar * self)
 {
   gchar *filename;
@@ -270,6 +311,7 @@ empathy_search_bar_init (EmpathySearchBar * self)
       "search_previous", "clicked", empathy_search_bar_previous_cb,
       "search_next", "clicked", empathy_search_bar_next_cb,
       "search_match_case", "toggled", empathy_search_bar_match_case_toggled,
+      "search_match_case_toolitem", "create-menu-proxy", empathy_searchbar_create_menu_proxy_cb,
       NULL);
 
   g_signal_connect (G_OBJECT (self), "key-press-event",
diff --git a/libempathy-gtk/empathy-search-bar.ui b/libempathy-gtk/empathy-search-bar.ui
index b07bda3..1c03a15 100644
--- a/libempathy-gtk/empathy-search-bar.ui
+++ b/libempathy-gtk/empathy-search-bar.ui
@@ -2,120 +2,121 @@
 <interface>
   <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy project-wide -->
-  <object class="GtkHBox" id="search_widget">
+  <object class="GtkToolbar" id="search_widget">
     <property name="visible">True</property>
-    <property name="spacing">6</property>
+    <property name="icon_size">2</property>
     <child>
-      <object class="GtkButton" id="search_close">
+      <object class="GtkToolButton" id="search_close">
         <property name="visible">True</property>
-        <property name="can_focus">True</property>
+        <property name="is_important">True</property>
         <property name="receives_default">True</property>
-        <property name="image">image1</property>
+        <property name="icon_name">gtk-close</property>
       </object>
       <packing>
         <property name="expand">False</property>
-        <property name="fill">False</property>
-        <property name="position">0</property>
+        <property name="homogeneous">True</property>
       </packing>
     </child>
     <child>
-      <object class="GtkLabel" id="search_label">
+      <object class="GtkToolItem" id="search_entry_toolitem">
         <property name="visible">True</property>
-        <property name="label" translatable="yes">Find:</property>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">False</property>
-        <property name="position">1</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkEntry" id="search_entry">
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
+        <child>
+          <object class="GtkAlignment" id="alignment1">
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkHBox" id="hbox1">
+                <property name="visible">True</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkLabel" id="search_label">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Find:</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="search_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
       </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="position">2</property>
-      </packing>
     </child>
     <child>
-      <object class="GtkButton" id="search_previous">
+      <object class="GtkToolButton" id="search_previous">
         <property name="label" translatable="yes">Find Previous</property>
         <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="receives_default">True</property>
-        <property name="image">image3</property>
+        <property name="is_important">True</property>
+        <property name="icon_name">gtk-go-back-ltr</property>
       </object>
       <packing>
-        <property name="expand">False</property>
-        <property name="position">3</property>
+        <property name="homogeneous">True</property>
       </packing>
     </child>
     <child>
-      <object class="GtkButton" id="search_next">
+      <object class="GtkToolButton" id="search_next">
         <property name="label" translatable="yes">Find Next</property>
         <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="receives_default">True</property>
-        <property name="image">image4</property>
+        <property name="is_important">True</property>
+        <property name="icon_name">gtk-go-forward-ltr</property>
       </object>
       <packing>
-        <property name="expand">False</property>
-        <property name="position">4</property>
+        <property name="homogeneous">True</property>
       </packing>
     </child>
     <child>
-      <object class="GtkCheckButton" id="search_match_case">
-        <property name="label" translatable="yes">Match case</property>
+      <object class="GtkToolItem" id="search_match_case_toolitem">
         <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="receives_default">False</property>
-        <property name="draw_indicator">True</property>
+        <property name="is_important">True</property>
+        <child>
+          <object class="GtkCheckButton" id="search_match_case">
+            <property name="label" translatable="yes">Match case</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="draw_indicator">True</property>
+          </object>
+        </child>
       </object>
       <packing>
-        <property name="position">6</property>
+        <property name="homogeneous">True</property>
       </packing>
     </child>
     <child>
-      <object class="GtkHBox" id="search_not_found">
-        <property name="spacing">6</property>
-        <child>
-          <object class="GtkImage" id="image2">
-            <property name="visible">True</property>
-            <property name="stock">gtk-dialog-error</property>
-          </object>
-          <packing>
-            <property name="position">0</property>
-          </packing>
-        </child>
+      <object class="GtkToolItem" id="search_not_found_toolitem">
+        <property name="visible">True</property>
         <child>
-          <object class="GtkLabel" id="label1">
+          <object class="GtkAlignment" id="alignment2">
             <property name="visible">True</property>
-            <property name="label" translatable="yes">Phrase not found</property>
+            <property name="left_padding">6</property>
+            <child>
+              <object class="GtkHBox" id="search_not_found">
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkImage" id="image1">
+                    <property name="visible">True</property>
+                    <property name="stock">gtk-dialog-error</property>
+                  </object>
+                  <packing>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="not_found_label">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Phrase not found</property>
+                  </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
           </object>
-          <packing>
-            <property name="position">1</property>
-          </packing>
         </child>
       </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="pack_type">end</property>
-        <property name="position">5</property>
-      </packing>
     </child>
   </object>
-  <object class="GtkImage" id="image1">
-    <property name="visible">True</property>
-    <property name="stock">gtk-close</property>
-  </object>
-  <object class="GtkImage" id="image3">
-    <property name="visible">True</property>
-    <property name="stock">gtk-go-back</property>
-  </object>
-  <object class="GtkImage" id="image4">
-    <property name="visible">True</property>
-    <property name="stock">gtk-go-forward</property>
-  </object>
 </interface>
