Exemplo n.º 1
0
void
dlg_password (GtkWidget *widget,
	      gpointer   callback_data)
{
	FrWindow   *window = callback_data;
	DialogData *data;

	data = g_new0 (DialogData, 1);

	data->builder = _gtk_builder_new_from_file ("password.ui");
	if (data->builder == NULL) {
		g_free (data);
		return;
	}

	data->window = window;

	/* Get the widgets. */

	data->dialog = _gtk_builder_get_widget (data->builder, "password_dialog");
	data->pw_password_entry = _gtk_builder_get_widget (data->builder, "pw_password_entry");
	data->pw_encrypt_header_checkbutton = _gtk_builder_get_widget (data->builder, "pw_encrypt_header_checkbutton");

	/* Set widgets data. */

	_gtk_entry_set_locale_text (GTK_ENTRY (data->pw_password_entry), fr_window_get_password (window));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (data->pw_encrypt_header_checkbutton), fr_window_get_encrypt_header (window));

	/* Set the signals handlers. */

	g_signal_connect (G_OBJECT (data->dialog),
			  "destroy",
			  G_CALLBACK (destroy_cb),
			  data);

	g_signal_connect (G_OBJECT (data->dialog),
			  "response",
			  G_CALLBACK (response_cb),
			  data);

	/* Run dialog. */

	gtk_widget_grab_focus (data->pw_password_entry);
	if (gtk_widget_get_realized (GTK_WIDGET (window)))
		gtk_window_set_transient_for (GTK_WINDOW (data->dialog),
					      GTK_WINDOW (window));
	gtk_window_set_modal (GTK_WINDOW (data->dialog), TRUE);

	gtk_widget_show (data->dialog);
}
Exemplo n.º 2
0
static void
recent_activated_cb (GtkTreeView       *tree_view,
		     GtkTreePath       *path,
		     GtkTreeViewColumn *column,
		     gpointer           callback_data)
{
	DialogData   *data = callback_data;
	GtkTreeIter   iter;
	char         *editor;

	if (! gtk_tree_model_get_iter (data->recent_model, &iter, path))
		return;

	gtk_tree_model_get (data->recent_model, &iter,
			    0, &editor,
			    -1);
	_gtk_entry_set_locale_text (GTK_ENTRY (data->o_app_entry), editor);
	g_free (editor);

	open_cb (NULL, data);
}
Exemplo n.º 3
0
static void
app_activated_cb (GtkTreeView       *tree_view,
		  GtkTreePath       *path,
		  GtkTreeViewColumn *column,
		  gpointer           callback_data)
{
	DialogData   *data = callback_data;
	GtkTreeIter   iter;
	GAppInfo     *app;

	if (! gtk_tree_model_get_iter (data->app_model, &iter, path))
		return;

	gtk_tree_model_get (data->app_model, &iter,
			    DATA_COLUMN, &app,
			    -1);

	_gtk_entry_set_locale_text (GTK_ENTRY (data->o_app_entry), g_app_info_get_executable (app));

	open_cb (NULL, data);
}
Exemplo n.º 4
0
static void
app_list_selection_changed_cb (GtkTreeSelection *selection,
			       gpointer          p)
{
	DialogData  *data = p;
	GtkTreeIter  iter;
	GAppInfo    *app;

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->o_app_tree_view));
	if (selection == NULL)
		return;

	if (! gtk_tree_selection_get_selected (selection, NULL, &iter))
		return;

	gtk_tree_model_get (data->app_model, &iter,
			    DATA_COLUMN, &app,
			    -1);
	_gtk_entry_set_locale_text (GTK_ENTRY (data->o_app_entry), g_app_info_get_executable (app));
	data->last_clicked_list = data->o_app_tree_view;
}
Exemplo n.º 5
0
static void
recent_list_selection_changed_cb (GtkTreeSelection *selection,
				  gpointer          p)
{
	DialogData   *data = p;
	GtkTreeIter   iter;
	char         *editor;

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->o_recent_tree_view));
	if (selection == NULL)
		return;

	if (! gtk_tree_selection_get_selected (selection, NULL, &iter))
		return;

	gtk_tree_model_get (data->recent_model, &iter,
			    0, &editor,
			    -1);
	_gtk_entry_set_locale_text (GTK_ENTRY (data->o_app_entry), editor);
	g_free (editor);
	data->last_clicked_list = data->o_recent_tree_view;
}
Exemplo n.º 6
0
void
dlg_password (GtkWidget *widget,
	      gpointer   callback_data)
{
	FrWindow   *window = callback_data;
	DialogData *data;
	GtkWidget  *content_area;
	char       *basename;
	char       *title;

	data = g_new0 (DialogData, 1);
	data->window = window;
	data->builder = _gtk_builder_new_from_resource ("password.ui");
	if (data->builder == NULL) {
		g_free (data);
		return;
	}

	/* Set widgets data. */

	data->dialog = g_object_new (GTK_TYPE_DIALOG,
				     "transient-for", GTK_WINDOW (window),
				     "modal", TRUE,
				     "use-header-bar", _gtk_settings_get_dialogs_use_header (),
				     NULL);
	content_area = gtk_dialog_get_content_area (GTK_DIALOG (data->dialog));
	gtk_container_add (GTK_CONTAINER (content_area),
			   GET_WIDGET ("password_vbox"));
	gtk_dialog_add_buttons (GTK_DIALOG (data->dialog),
				_GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL,
				_GTK_LABEL_SAVE, GTK_RESPONSE_OK,
				NULL);
	gtk_dialog_set_default_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK);
	gtk_style_context_add_class (gtk_widget_get_style_context (gtk_dialog_get_widget_for_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK)),
				     GTK_STYLE_CLASS_SUGGESTED_ACTION);

	basename = _g_file_get_display_basename (fr_archive_get_file (window->archive));
	title = g_strdup_printf (_("Enter a password for “%s”"), basename);
	gtk_label_set_text (GTK_LABEL (GET_WIDGET ("title_label")), title);

	g_free (title);
	g_free (basename);

	_gtk_entry_use_as_password_entry (GTK_ENTRY (GET_WIDGET ("password_entry")));
	_gtk_entry_set_locale_text (GTK_ENTRY (GET_WIDGET ("password_entry")),
				    fr_window_get_password (window));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("encrypt_header_checkbutton")),
				      fr_window_get_encrypt_header (window));

	if (! fr_archive_is_capable_of (window->archive, FR_ARCHIVE_CAN_ENCRYPT_HEADER)) {
		gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (GET_WIDGET ("encrypt_header_checkbutton")), TRUE);
		gtk_widget_set_sensitive (GET_WIDGET ("encrypt_header_checkbutton"), FALSE);
	}

	/* Set the signals handlers. */

	g_signal_connect ((data->dialog),
			  "destroy",
			  G_CALLBACK (destroy_cb),
			  data);
	g_signal_connect ((data->dialog),
			  "response",
			  G_CALLBACK (response_cb),
			  data);

	/* Run dialog. */

	gtk_widget_grab_focus (GET_WIDGET ("password_entry"));
	gtk_widget_show (data->dialog);
}
Exemplo n.º 7
0
static void
dlg_ask_password__common (FrWindow       *window,
			  FrPasswordType  pwd_type)
{
	DialogData *data;
	GtkWidget  *label;
	char       *text;
	char       *name = NULL;

	data = g_new0 (DialogData, 1);

	data->builder = _gtk_builder_new_from_file ("batch-password.ui");
	if (data->builder == NULL) {
		g_free (data);
		return;
	}

	data->window = window;
	data->pwd_type = pwd_type;

	/* Get the widgets. */

	data->dialog = _gtk_builder_get_widget (data->builder, "password_dialog");
	data->pw_password_entry = _gtk_builder_get_widget (data->builder, "pw_password_entry");

	label = _gtk_builder_get_widget (data->builder, "pw_password_label");

	/* Set widgets data. */

	if (data->pwd_type == FR_PASSWORD_TYPE_MAIN)
		name = g_uri_display_basename (fr_window_get_archive_uri (window));
	else if (data->pwd_type == FR_PASSWORD_TYPE_PASTE_FROM)
		name = g_uri_display_basename (fr_window_get_paste_archive_uri (window));
        g_assert (name != NULL);
	text = g_strdup_printf (_("Enter the password for the archive '%s'."), name);
	gtk_label_set_label (GTK_LABEL (label), text);
	g_free (text);
	
	if (fr_window_get_password (window) != NULL)
		_gtk_entry_set_locale_text (GTK_ENTRY (data->pw_password_entry),
					    fr_window_get_password (window));

	/* Set the signals handlers. */

	g_signal_connect (G_OBJECT (data->dialog),
			  "destroy",
			  G_CALLBACK (destroy_cb),
			  data);

	g_signal_connect (G_OBJECT (data->dialog),
			  "response",
			  G_CALLBACK (ask_password__response_cb),
			  data);

	/* Run dialog. */

	gtk_widget_grab_focus (data->pw_password_entry);
	if (gtk_widget_get_realized (GTK_WIDGET (window))) {
		gtk_window_set_transient_for (GTK_WINDOW (data->dialog),
					      GTK_WINDOW (window));
		gtk_window_set_modal (GTK_WINDOW (data->dialog), TRUE);
	}
	else 
		gtk_window_set_title (GTK_WINDOW (data->dialog), name);
	g_free (name);
	
	gtk_widget_show (data->dialog);
}