Ejemplo n.º 1
0
/* DESCRIPTION  :  Generic notifiers for string-based option_menus.
 *                 This callback is called when a specific key of
 *                 the config database associated with an option menu changes,
 *                 this only updates the menu.
 * BEHAVIOR     :  It only updates the widget.
 * PRE          :  The config key triggering that notifier on modifiction
 *                 should be of type string.
 */
void
string_option_menu_changed_nt (G_GNUC_UNUSED gpointer cid,
			       GmConfEntry *entry,
			       gpointer data)
{
  int cpt = 0;
  int count = 0;

  GtkTreeModel *model = NULL;
  GtkTreeIter iter;

  GtkWidget *e = NULL;

  gchar *text = NULL;
  gchar* txt = NULL;

  if (gm_conf_entry_get_type (entry) == GM_CONF_STRING) {

    e = GTK_WIDGET (data);

    model = gtk_combo_box_get_model (GTK_COMBO_BOX (e));
    count = gtk_tree_model_iter_n_children (model, NULL);
    gtk_tree_model_get_iter_first (model, &iter);

    for (cpt = 0 ; cpt < count ; cpt++) {

      gtk_tree_model_get (model, &iter, 0, &text, -1);
      txt = gm_conf_entry_get_string (entry);
      if (text && !g_strcmp0 (text, txt)) {

        g_free (text);
        g_free (txt);
        break;
      }
      g_free (txt);
      gtk_tree_model_iter_next (model, &iter);

      g_free (text);
    }

    g_signal_handlers_block_matched (G_OBJECT (e),
				     G_SIGNAL_MATCH_FUNC,
				     0, 0, NULL,
				     (gpointer) string_option_menu_changed,
				     NULL);
    if (cpt != count && gtk_combo_box_get_active (GTK_COMBO_BOX (data)) != cpt)
      gtk_combo_box_set_active (GTK_COMBO_BOX (data), cpt);
    g_signal_handlers_unblock_matched (G_OBJECT (e),
				       G_SIGNAL_MATCH_FUNC,
				       0, 0, NULL,
				       (gpointer) string_option_menu_changed,
				       NULL);
  }
}
Ejemplo n.º 2
0
/* DESCRIPTION  :  Generic notifiers for entries.
 *                 This callback is called when a specific key of
 *                 the config database associated with an entry changes.
 * BEHAVIOR     :  It updates the widget.
 * PRE          :  The config key triggering that notifier on modification
 *                 should be of type string.
 */
void
entry_changed_nt (G_GNUC_UNUSED gpointer cid, 
		  GmConfEntry *entry,
		  gpointer data)
{
  GtkWidget *e = NULL;
  gchar *current_value = NULL;
  
  if (gm_conf_entry_get_type(entry) == GM_CONF_STRING) {

    gdk_threads_enter ();
  
    e = GTK_WIDGET (data);
    current_value = (gchar *) gm_conf_entry_get_string (entry);

    if (current_value
	&& strcmp (current_value, gtk_entry_get_text (GTK_ENTRY (e)))) {

      g_signal_handlers_block_matched (G_OBJECT (e),
				       G_SIGNAL_MATCH_FUNC,
				       0, 0, NULL,
				       (gpointer) entry_focus_changed,
				       NULL);
      g_signal_handlers_block_matched (G_OBJECT (e),
				       G_SIGNAL_MATCH_FUNC,
				       0, 0, NULL,
				       (gpointer) entry_activate_changed,
				       NULL);
      gtk_entry_set_text (GTK_ENTRY (e), current_value);
      g_signal_handlers_unblock_matched (G_OBJECT (e),
					 G_SIGNAL_MATCH_FUNC,
					 0, 0, NULL,
					 (gpointer) entry_activate_changed,
					 NULL);
      g_signal_handlers_unblock_matched (G_OBJECT (e),
					 G_SIGNAL_MATCH_FUNC,
					 0, 0, NULL,
					 (gpointer) entry_focus_changed,
					 NULL);
    }

    gdk_threads_leave (); 
  }
}