inspector: add im-module
This adds a new row to the Global/Information section which displays the GTK im-module that is likely to be in use unless changed by an application. It responds to updates of GtkSettings:gtk-im-module unless the GTK_IM_MODULE environment variable is set. Fixes #4512 (cherry picked from commit 6be352f4468b4dbbb1d71f427948dda154b9a658)
This commit is contained in:
		 Christian Hergert
					Christian Hergert
				
			
				
					committed by
					
						 Jan Tojnar
						Jan Tojnar
					
				
			
			
				
	
			
			
			 Jan Tojnar
						Jan Tojnar
					
				
			
						parent
						
							22dd7189bb
						
					
				
				
					commit
					c26a209283
				
			| @ -26,10 +26,12 @@ | ||||
| #include "gtkswitch.h" | ||||
| #include "gtklistbox.h" | ||||
| #include "gtkprivate.h" | ||||
| #include "gtksettings.h" | ||||
| #include "gtksizegroup.h" | ||||
| #include "gtkimage.h" | ||||
| #include "gtkadjustment.h" | ||||
| #include "gtkbox.h" | ||||
| #include "gtkimmoduleprivate.h" | ||||
|  | ||||
| #ifdef GDK_WINDOWING_X11 | ||||
| #include "x11/gdkx.h" | ||||
| @ -66,6 +68,7 @@ struct _GtkInspectorGeneralPrivate | ||||
|   GtkWidget *app_id_frame; | ||||
|   GtkWidget *app_id; | ||||
|   GtkWidget *resource_path; | ||||
|   GtkWidget *im_module; | ||||
|   GtkWidget *gl_version; | ||||
|   GtkWidget *gl_vendor; | ||||
|   GtkWidget *prefix; | ||||
| @ -522,6 +525,39 @@ init_pango (GtkInspectorGeneral *gen) | ||||
|   gtk_label_set_label (GTK_LABEL (gen->priv->pango_fontmap), name); | ||||
| } | ||||
|  | ||||
| static void | ||||
| im_module_changed (GtkSettings         *settings, | ||||
|                    GParamSpec          *pspec, | ||||
|                    GtkInspectorGeneral *gen) | ||||
| { | ||||
|   gtk_label_set_label (GTK_LABEL (gen->priv->im_module), | ||||
|                        _gtk_im_module_get_default_context_id ()); | ||||
| } | ||||
|  | ||||
| static void | ||||
| init_im_module (GtkInspectorGeneral *gen) | ||||
| { | ||||
|   GdkScreen *screen = gdk_screen_get_default (); | ||||
|   GtkSettings *settings = gtk_settings_get_for_screen (screen); | ||||
|   const char *default_context_id = _gtk_im_module_get_default_context_id (); | ||||
|  | ||||
|   gtk_label_set_label (GTK_LABEL (gen->priv->im_module), default_context_id); | ||||
|  | ||||
|   if (g_getenv ("GTK_IM_MODULE") != NULL) | ||||
|     { | ||||
|       /* This can't update if GTK_IM_MODULE envvar is set */ | ||||
|       gtk_widget_set_tooltip_text (gen->priv->im_module, | ||||
|                                    _("IM Context is hardcoded by GTK_IM_MODULE")); | ||||
|       gtk_widget_set_sensitive (gen->priv->im_module, FALSE); | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|   g_signal_connect_object (settings, | ||||
|                            "notify::gtk-im-module", | ||||
|                            G_CALLBACK (im_module_changed), | ||||
|                            gen, 0); | ||||
| } | ||||
|  | ||||
| static void populate_seats (GtkInspectorGeneral *gen); | ||||
|  | ||||
| static void | ||||
| @ -693,6 +729,7 @@ gtk_inspector_general_init (GtkInspectorGeneral *gen) | ||||
|   init_env (gen); | ||||
|   init_display (gen); | ||||
|   init_pango (gen); | ||||
|   init_im_module (gen); | ||||
|   init_gl (gen); | ||||
|   init_device (gen); | ||||
| } | ||||
| @ -781,6 +818,7 @@ gtk_inspector_general_class_init (GtkInspectorGeneralClass *klass) | ||||
|   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, gtk_version); | ||||
|   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, gdk_backend); | ||||
|   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, pango_fontmap); | ||||
|   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, im_module); | ||||
|   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, app_id_frame); | ||||
|   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, app_id); | ||||
|   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, resource_path); | ||||
|  | ||||
| @ -120,6 +120,40 @@ | ||||
|                     </child> | ||||
|                   </object> | ||||
|                 </child> | ||||
|                 <child> | ||||
|                   <object class="GtkListBoxRow"> | ||||
|                     <property name="visible">True</property> | ||||
|                     <property name="activatable">False</property> | ||||
|                     <child> | ||||
|                       <object class="GtkBox"> | ||||
|                         <property name="visible">True</property> | ||||
|                         <property name="orientation">horizontal</property> | ||||
|                         <property name="margin">10</property> | ||||
|                         <property name="spacing">40</property> | ||||
|                         <child> | ||||
|                           <object class="GtkLabel" id="input_method_label"> | ||||
|                             <property name="visible">True</property> | ||||
|                             <property name="label" translatable="yes">Input Method</property> | ||||
|                             <property name="halign">start</property> | ||||
|                             <property name="valign">baseline</property> | ||||
|                             <property name="xalign">0.0</property> | ||||
|                           </object> | ||||
|                         </child> | ||||
|                         <child> | ||||
|                           <object class="GtkLabel" id="im_module"> | ||||
|                             <property name="visible">True</property> | ||||
|                             <property name="selectable">True</property> | ||||
|                             <property name="halign">end</property> | ||||
|                             <property name="valign">baseline</property> | ||||
|                           </object> | ||||
|                           <packing> | ||||
|                             <property name="expand">True</property> | ||||
|                           </packing> | ||||
|                         </child> | ||||
|                       </object> | ||||
|                     </child> | ||||
|                   </object> | ||||
|                 </child> | ||||
|               </object> | ||||
|             </child> | ||||
|           </object> | ||||
| @ -685,6 +719,7 @@ | ||||
|       <widget name="gtk_version_label"/> | ||||
|       <widget name="gdk_backend_label"/> | ||||
|       <widget name="pango_fontmap_label"/> | ||||
|       <widget name="input_method_label"/> | ||||
|       <widget name="app_id_label"/> | ||||
|       <widget name="resource_path_label"/> | ||||
|       <widget name="gl_version_label"/> | ||||
|  | ||||
		Reference in New Issue
	
	Block a user