]> Pileus Git - ~andy/gtk/blobdiff - modules/input/gtkimcontextime.c
Don't rotate pdf landscape output
[~andy/gtk] / modules / input / gtkimcontextime.c
index ad560925cdb6d48c58d7f1c20f5cfa5a97fb63a5..009af3febe08f1b495deea2f908dffbf30fedfac 100644 (file)
@@ -14,9 +14,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  *
  */
 
  *  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/appendix/hh/appendix/imeimes2_35ph.asp
  */
 
+#ifdef GTK_DISABLE_DEPRECATED
+#undef GTK_DISABLE_DEPRECATED
+#endif
+
 #include "gtkimcontextime.h"
 
 #include "imm-extra.h"
 
 #include "gdk/win32/gdkwin32.h"
 #include "gdk/gdkkeysyms.h"
-#include "gtk/gtkwidget.h"
 
-#include <pango/pango-utils.h>
+#include <pango/pango.h>
 
 /* avoid warning */
 #ifdef STRICT
@@ -125,7 +126,7 @@ static GObjectClass *parent_class;
 void
 gtk_im_context_ime_register_type (GTypeModule *type_module)
 {
-  static const GTypeInfo im_context_ime_info = {
+  const GTypeInfo im_context_ime_info = {
     sizeof (GtkIMContextIMEClass),
     (GBaseInitFunc) NULL,
     (GBaseFinalizeFunc) NULL,
@@ -312,6 +313,9 @@ gtk_im_context_ime_filter_keypress (GtkIMContext *context,
   if (event->type == GDK_KEY_RELEASE)
     return FALSE;
 
+  if (event->state & GDK_CONTROL_MASK)
+    return FALSE;
+
   context_ime = GTK_IM_CONTEXT_IME (context);
 
   if (!context_ime->focus)
@@ -327,7 +331,7 @@ gtk_im_context_ime_filter_keypress (GtkIMContext *context,
       int len = g_unichar_to_utf8 (c, utf8);
       utf8[len] = 0;
 
-      g_signal_emit_by_name (G_OBJECT (context_ime), "commit", utf8);
+      g_signal_emit_by_name (context_ime, "commit", utf8);
       retval = TRUE;
     }
 
@@ -342,6 +346,9 @@ gtk_im_context_ime_reset (GtkIMContext *context)
   HWND hwnd;
   HIMC himc;
 
+  if (!context_ime->client_window)
+    return;
+
   hwnd = GDK_WINDOW_HWND (context_ime->client_window);
   himc = ImmGetContext (hwnd);
   if (!himc)
@@ -351,7 +358,7 @@ gtk_im_context_ime_reset (GtkIMContext *context)
     ImmNotifyIME (himc, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
 
   context_ime->preediting = FALSE;
-  g_signal_emit_by_name (context, "preedit_changed");
+  g_signal_emit_by_name (context, "preedit-changed");
 
   ImmReleaseContext (hwnd, himc);
 }
@@ -368,6 +375,8 @@ get_utf8_preedit_string (GtkIMContextIME *context_ime, gint *pos_ret)
   if (pos_ret)
     *pos_ret = 0;
 
+  if (!context_ime->client_window)
+    return g_strdup ("");
   hwnd = GDK_WINDOW_HWND (context_ime->client_window);
   himc = ImmGetContext (hwnd);
   if (!himc)
@@ -427,6 +436,8 @@ get_pango_attr_list (GtkIMContextIME *context_ime, const gchar *utf8str)
   HWND hwnd;
   HIMC himc;
 
+  if (!context_ime->client_window)
+    return attrs;
   hwnd = GDK_WINDOW_HWND (context_ime->client_window);
   himc = ImmGetContext (hwnd);
   if (!himc)
@@ -443,9 +454,9 @@ get_pango_attr_list (GtkIMContextIME *context_ime, const gchar *utf8str)
       /*
        *  get attributes list of IME.
        */
-      len = ImmGetCompositionStringA (himc, GCS_COMPATTR, NULL, 0);
+      len = ImmGetCompositionStringW (himc, GCS_COMPATTR, NULL, 0);
       buf = g_alloca (len);
-      ImmGetCompositionStringA (himc, GCS_COMPATTR, buf, len);
+      ImmGetCompositionStringW (himc, GCS_COMPATTR, buf, len);
 
       /*
        *  schr and echr are pointer in utf8str.
@@ -590,7 +601,7 @@ gtk_im_context_ime_focus_in (GtkIMContext *context)
   gdk_window_get_user_data (context_ime->client_window, (gpointer) & widget);
   if (GTK_IS_WIDGET (widget))
     {
-      g_signal_connect (G_OBJECT (widget), "hierarchy-changed",
+      g_signal_connect (widget, "hierarchy-changed",
                         G_CALLBACK (cb_client_widget_hierarchy_changed),
                         context_ime);
     }
@@ -849,7 +860,7 @@ gtk_im_context_ime_set_preedit_font (GtkIMContext *context)
       PangoLanguage *pango_lang = pango_language_from_string (lang);
       PangoFontset *fontset =
        pango_context_load_fontset (pango_context,
-                                   widget->style->font_desc,
+                                   gtk_widget_get_style (widget)->font_desc,
                                    pango_lang);
       gunichar *sample =
        g_utf8_to_ucs4 (pango_language_get_sample_string (pango_lang),
@@ -871,7 +882,7 @@ gtk_im_context_ime_set_preedit_font (GtkIMContext *context)
       g_object_unref (fontset);
     }
   else
-    font = pango_context_load_font (pango_context, widget->style->font_desc);
+    font = pango_context_load_font (pango_context, gtk_widget_get_style (widget)->font_desc);
 
   if (!font)
     goto ERROR_OUT;
@@ -944,7 +955,7 @@ gtk_im_context_ime_message_filter (GdkXEvent *xevent,
         ImmSetCandidateWindow (himc, &cf);
 
         if ((msg->lParam & GCS_COMPSTR))
-          g_signal_emit_by_name (context, "preedit_changed");
+          g_signal_emit_by_name (context, "preedit-changed");
 
         if (msg->lParam & GCS_RESULTSTR)
           {
@@ -969,8 +980,9 @@ gtk_im_context_ime_message_filter (GdkXEvent *xevent,
 
             if (utf8str)
               {
-                g_signal_emit_by_name (G_OBJECT (context), "commit", utf8str);
+                g_signal_emit_by_name (context, "commit", utf8str);
                 g_free (utf8str);
+               retval = TRUE;
               }
           }
 
@@ -982,15 +994,15 @@ gtk_im_context_ime_message_filter (GdkXEvent *xevent,
     case WM_IME_STARTCOMPOSITION:
       context_ime->preediting = TRUE;
       gtk_im_context_ime_set_cursor_location (context, NULL);
-      g_signal_emit_by_name (context, "preedit_start");
+      g_signal_emit_by_name (context, "preedit-start");
       if (context_ime->use_preedit)
         retval = TRUE;
       break;
 
     case WM_IME_ENDCOMPOSITION:
       context_ime->preediting = FALSE;
-      g_signal_emit_by_name (context, "preedit_changed");
-      g_signal_emit_by_name (context, "preedit_end");
+      g_signal_emit_by_name (context, "preedit-changed");
+      g_signal_emit_by_name (context, "preedit-end");
       if (context_ime->use_preedit)
         retval = TRUE;
       break;