Esempio n. 1
0
void ok_cb (GtkWidget *w, void *v)
{  
   gboolean edit=TRUE;
   GtkWidget *widget;
   GtkType type;
   GSList *current = widgets;
   
   while (current) {
      edit=TRUE;
      widget = (GtkWidget *)current->data;
      current = current->next;
      
      type = GTK_OBJECT_TYPE(widget);
      if (type == gtk_entry_get_type())
	output_entry(widget);
      if (type == gtk_text_get_type())
	output_text(widget,&edit);
      if (type == gtk_combo_get_type())
	output_combo(widget);
      if (type == gtk_check_button_get_type())
	output_check_button(widget);
      if (type == gtk_option_menu_get_type())
	output_option_menu(widget);
      
      /* if there are more widgets with output values, separate them */
      if (current && edit) {
	putchar ('\v');
      }
   }
   quit(RETURN_OK);
}
void gtk_module_init(gint *argc, gchar ***argv[]) {
  GError *error = NULL;
  STORE_PATH = g_build_filename(g_get_home_dir(), ".password-store", NULL);
  gchar *gpgid_path = g_build_filename(STORE_PATH, ".gpg-id", NULL);
  g_file_get_contents(gpgid_path, &GPG_ID, NULL, &error);
  if (error) {
    g_warning("Failed to load GPG id.");
    return;
  }
  // remove newline
  if (g_str_has_suffix(GPG_ID, "\n")) {
    GPG_ID[strlen(GPG_ID) - 1] = '\0';
  }

  GType entry_type = gtk_entry_get_type();
  // The type class must be instantiated to attach a handler.
  gpointer entry_type_class = g_type_class_ref(entry_type);
  g_signal_override_class_handler("populate-popup", entry_type,
                                  G_CALLBACK(populate_popup_cb));
  g_type_class_unref(entry_type_class);
}