Back to index

im-sdk  12.3.91
Defines | Functions | Variables
preference.c File Reference
#include <config.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkcheckbutton.h>
#include <gtk/gtksignal.h>
#include <panel-applet.h>
#include <panel-applet-gconf.h>
#include <gnome.h>
#include "gnome-im-switcher.h"
#include "language.h"
#include "preference.h"
#include "status-placement.h"
#include "utils.h"
#include "widgets.h"
#include <gconf/gconf-client.h>

Go to the source code of this file.

Defines

#define IM_KEY_DIR   "/desktop/gnome/input_methods"
#define ENABLE_IM_KEY   IM_KEY_DIR "/support"
#define ENABLE_STATUS_KEY   IM_KEY_DIR "/status"
#define ENABLE_LOOKUP_KEY   IM_KEY_DIR "/lookup"
#define STATUS_PLACEMENT_KEY   IM_KEY_DIR "/status_placement"

Functions

static void input_language_policy_update (GimletWindow *gimlet)
static void on_follow_application_toggled (GtkWidget *button, GimletWindow *gimlet)
static void on_follow_quick_access_menu_toggled (GtkWidget *button, GimletWindow *gimlet)
static void init_im_settings (GimletWindow *gimlet)
static void im_setting_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, GimletWindow *gimlet)
void gimlet_preference_init (GimletWindow *gimlet)
static void response_callback (GtkWidget *window, int id, void *data)
static void conversion_on_start_checkbutton_toggled (GtkToggleButton *button, GtkWidget *dialog)
GtkWidget * gimlet_preference_dialog_new (GtkWindow *transient_parent, GimletWindow *gimlet)

Variables

static GConfClient * default_client = NULL
static const char * disabled = "disabled"

Define Documentation

#define ENABLE_IM_KEY   IM_KEY_DIR "/support"

Definition at line 108 of file preference.c.

#define ENABLE_LOOKUP_KEY   IM_KEY_DIR "/lookup"

Definition at line 110 of file preference.c.

#define ENABLE_STATUS_KEY   IM_KEY_DIR "/status"

Definition at line 109 of file preference.c.

#define IM_KEY_DIR   "/desktop/gnome/input_methods"

Definition at line 107 of file preference.c.

#define STATUS_PLACEMENT_KEY   IM_KEY_DIR "/status_placement"

Definition at line 111 of file preference.c.


Function Documentation

static void conversion_on_start_checkbutton_toggled ( GtkToggleButton *  button,
GtkWidget *  dialog 
) [static]

Definition at line 252 of file preference.c.

{
  GimletWindow *gimlet = g_object_get_data (G_OBJECT (dialog), "gimlet");

  if (gtk_toggle_button_get_active (button))
    gimlet->conversion_on_start = TRUE;
  else
    gimlet->conversion_on_start = FALSE;

  panel_applet_gconf_set_bool (PANEL_APPLET (gimlet->applet),
                            "conversion_on_start",
                            gimlet->conversion_on_start,
                            NULL);
  return;
}

Here is the caller graph for this function:

GtkWidget* gimlet_preference_dialog_new ( GtkWindow *  transient_parent,
GimletWindow *  gimlet 
)

Definition at line 342 of file preference.c.

{
  GladeXML *xml;
  GtkWidget *w;
  GtkWidget *dialog;

  xml = gimlet_util_load_glade_file (GIMLET_GLADE_FILE,
                                 "preference-dialog",
                                 transient_parent);
  if (xml == NULL)
    return NULL;

  /* The dialog itself */
  dialog = glade_xml_get_widget (xml, "preference-dialog");
  g_object_set_data (G_OBJECT (dialog), "gimlet", gimlet);

  gimlet_util_set_unique_role (GTK_WINDOW (dialog), "gimlet-preferences");

  g_signal_connect (G_OBJECT (dialog), "response",
                    G_CALLBACK (response_callback),
                    NULL);

  /* Input Language */

#ifdef MEANINGLESS_OPTION_PERHAPS
  w = glade_xml_get_widget (xml, "default-input-language-option");
  gimlet->input_language_option_menu = w;
  gtk_widget_set_sensitive (gimlet->input_language_option_menu, FALSE);

  add_languages_in_option_menu (gimlet);

  w = glade_xml_get_widget (xml, "follow-current-locale");
  g_signal_connect (G_OBJECT (w), "toggled",
                  G_CALLBACK (on_follow_current_locale_toggled), gimlet);
  if (gimlet->input_lang_policy == FOLLOW_CURRENT_LOCALE)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);

  w = glade_xml_get_widget (xml, "follow-option-menu");
  g_signal_connect (G_OBJECT (w), "toggled",
                  G_CALLBACK (on_follow_option_menu_toggled), gimlet);
  if (gimlet->input_lang_policy == FOLLOW_OPTION_MENU)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);

#endif

  w = glade_xml_get_widget (xml, "follow-application");
  g_signal_connect (G_OBJECT (w), "toggled",
                  G_CALLBACK (on_follow_application_toggled), gimlet);
  if (gimlet->input_lang_policy == FOLLOW_APPLICATION)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);

  w = glade_xml_get_widget (xml, "follow-quick-access-menu");
  g_signal_connect (G_OBJECT (w), "toggled",
                  G_CALLBACK (on_follow_quick_access_menu_toggled), gimlet);
  if (gimlet->input_lang_policy == FOLLOW_QUICK_ACCESS_MENU)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);

  w = glade_xml_get_widget (xml, "conversion_on_start_checkbutton");
  g_object_set_data (G_OBJECT (dialog),
                     "conversion-on-start-checkbutton",
                     w);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
                            gimlet->conversion_on_start);

  conversion_on_start_checkbutton_toggled (GTK_TOGGLE_BUTTON (w), dialog);
       
  g_signal_connect (G_OBJECT (w), "toggled", 
                  G_CALLBACK (conversion_on_start_checkbutton_toggled), 
                  dialog);
  return dialog;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gimlet_preference_init ( GimletWindow *  gimlet)

Definition at line 203 of file preference.c.

{
  int int_value;

  panel_applet_add_preferences (gimlet->applet,
                            "/schemas/apps/gimlet/preference",
                            NULL);
  if (default_client == NULL)
    {
      default_client = gconf_client_get_default ();
      g_object_ref (G_OBJECT (default_client));
    }

  /* Input Language */
  int_value = panel_applet_gconf_get_int (gimlet->applet,
                                     "input_language_policy", NULL);
  gimlet->input_lang_policy = int_value;

  gimlet->conversion_on_start = panel_applet_gconf_get_bool (gimlet->applet,
                                                      "conversion_on_start", NULL);

  /* input method settings */
  init_im_settings (gimlet);
  gconf_client_notify_add (default_client, ENABLE_IM_KEY,
                        (GConfClientNotifyFunc)im_setting_changed,
                        gimlet, NULL, NULL);
  gconf_client_notify_add (default_client, ENABLE_STATUS_KEY,
                        (GConfClientNotifyFunc)im_setting_changed,
                        gimlet, NULL, NULL);
  gconf_client_notify_add (default_client, STATUS_PLACEMENT_KEY,
                        (GConfClientNotifyFunc)im_setting_changed,
                        gimlet, NULL, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void im_setting_changed ( GConfClient *  client,
guint  cnxn_id,
GConfEntry *  entry,
GimletWindow *  gimlet 
) [static]

Definition at line 158 of file preference.c.

{
  gchar *str = NULL;

  if (!entry->value || entry->value->type != GCONF_VALUE_STRING)
    return;

  if (strcmp (entry->key, ENABLE_IM_KEY) == 0)
    {
      str = g_strdup (gconf_value_get_string (entry->value));
      if (strcmp (str, disabled) == 0)
       gimlet->im_enabled = FALSE;
      else
       gimlet->im_enabled = TRUE;
    }
  else if (strcmp (entry->key, ENABLE_STATUS_KEY) == 0)
    {
      str = g_strdup (gconf_value_get_string (entry->value));
      if (strcmp (str, disabled) == 0)
       gimlet->status_enabled = FALSE;
      else
       gimlet->status_enabled = TRUE;
    }
  else if (strcmp (entry->key, ENABLE_LOOKUP_KEY) == 0)
    {
      str = g_strdup (gconf_value_get_string (entry->value));
      if (strcmp (str, disabled) == 0)
       gimlet->lookup_enabled = FALSE;
      else
       gimlet->lookup_enabled = TRUE;
    }
  else if (strcmp (entry->key, STATUS_PLACEMENT_KEY) == 0)
    {
      str = g_strdup (gconf_value_get_string (entry->value));
      gimlet->status_placement = gimlet_status_placement (str);
    }
  gimlet_update_lang (gimlet);
  gimlet_status_show_or_hide (gimlet);
  g_free (str);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void init_im_settings ( GimletWindow *  gimlet) [static]

Definition at line 117 of file preference.c.

{
  gchar *str;

  str = NULL;
  str = gconf_client_get_string (default_client,
                             ENABLE_IM_KEY, NULL);
  if (str && strcmp (str, disabled) == 0)
    gimlet->im_enabled = FALSE;
  else
    gimlet->im_enabled = TRUE;
  g_free (str);

  str = NULL;
  str = gconf_client_get_string (default_client,
                             ENABLE_STATUS_KEY, NULL);
  if (str && strcmp (str, disabled) == 0)
    gimlet->status_enabled = FALSE;
  else
    gimlet->status_enabled = TRUE;
  g_free (str);

  str = NULL;
  str = gconf_client_get_string (default_client,
                             ENABLE_LOOKUP_KEY, NULL);
  if (str && strcmp (str, disabled) == 0)
    gimlet->lookup_enabled = FALSE;
  else
    gimlet->lookup_enabled = TRUE;
  g_free (str);

  str = NULL;
  str = gconf_client_get_string (default_client,
                             STATUS_PLACEMENT_KEY, NULL);
  gimlet->status_placement = gimlet_status_placement (str);

  g_free (str);

}

Here is the call graph for this function:

Here is the caller graph for this function:

static void input_language_policy_update ( GimletWindow *  gimlet) [static]

Definition at line 41 of file preference.c.

{
  panel_applet_gconf_set_int (PANEL_APPLET (gimlet->applet),
                           "input_language_policy",
                           gimlet->input_lang_policy,
                           NULL);
}

Here is the caller graph for this function:

static void on_follow_application_toggled ( GtkWidget *  button,
GimletWindow *  gimlet 
) [static]

Definition at line 50 of file preference.c.

{
  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
    {
      gimlet->input_lang_policy = FOLLOW_APPLICATION;
#ifdef MEANINGLESS_OPTION_PERHAPS
      gtk_widget_set_sensitive (gimlet->input_language_option_menu, FALSE);
#endif
    }

  input_language_policy_update (gimlet);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void on_follow_quick_access_menu_toggled ( GtkWidget *  button,
GimletWindow *  gimlet 
) [static]

Definition at line 65 of file preference.c.

{
  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
    {
      gimlet->input_lang_policy = FOLLOW_QUICK_ACCESS_MENU;
#ifdef MEANINGLESS_OPTION_PERHAPS
      gtk_widget_set_sensitive (gimlet->input_language_option_menu, FALSE);
#endif
    }

  input_language_policy_update (gimlet);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void response_callback ( GtkWidget *  window,
int  id,
void *  data 
) [static]

Definition at line 238 of file preference.c.

{
  if (id == GTK_RESPONSE_HELP)
    gimlet_util_show_help ("imswitcher-prefs-inputlanguage",
                        GTK_WINDOW (window));
  else
    {
      gtk_widget_destroy (GTK_WIDGET (window));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

GConfClient* default_client = NULL [static]

Definition at line 38 of file preference.c.

const char* disabled = "disabled" [static]

Definition at line 114 of file preference.c.