Пример #1
0
void
feed_list_node_remove (nodePtr node)
{
	GtkWidget	*dialog;
	GtkWindow	*mainwindow;
	gchar		*text;
	
	g_assert (node == feedlist_get_selected ());

	liferea_shell_set_status_bar ("%s \"%s\"", _("Deleting entry"), node_get_title (node));
	text = g_strdup_printf (IS_FOLDER (node)?_("Are you sure that you want to delete \"%s\" and its contents?"):_("Are you sure that you want to delete \"%s\"?"), node_get_title (node));

	mainwindow = GTK_WINDOW (liferea_shell_get_window ());
	dialog = gtk_message_dialog_new (mainwindow,
	                                 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
	                                 GTK_MESSAGE_QUESTION,
	                                 GTK_BUTTONS_NONE,
	                                 "%s", text);
	gtk_dialog_add_buttons (GTK_DIALOG (dialog),
	                        "_Cancel", GTK_RESPONSE_CANCEL,
	                        "_Delete", GTK_RESPONSE_ACCEPT,
	                        NULL);
	gtk_window_set_title (GTK_WINDOW (dialog), _("Deletion Confirmation"));
	gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
	gtk_window_set_transient_for (GTK_WINDOW (dialog), mainwindow);

	g_free (text);
	
	gtk_widget_show_all (dialog);

	g_signal_connect (G_OBJECT (dialog), "response",
	                  G_CALLBACK (feed_list_node_remove_cb), node);
}
Пример #2
0
/* typically called when filling the item tree view */
void 
item_list_view_prefocus (ItemListView *ilv)
{
	GtkWidget		*focus_widget;
	GtkTreeSelection	*itemselection;
	
	/* the following is important to prevent setting the unread
	   flag for the first item in the item list when the user does
	   the first click into the treeview, if we don't do a focus and
	   unselect, GTK would always (exception: clicking on first item)
	   generate two selection-change events (one for the clicked and
	   one for the selected item)!!! */

	/* we need to restore the focus after we temporarily select the itemlist */
	focus_widget = gtk_window_get_focus (GTK_WINDOW (liferea_shell_get_window ()));

	/* prevent marking as unread before focussing, which leads to a selection */
	gtk_widget_grab_focus (GTK_WIDGET (ilv->priv->treeview));

	itemselection = gtk_tree_view_get_selection (ilv->priv->treeview);
	if (itemselection)
		gtk_tree_selection_unselect_all (itemselection);
	
	if (focus_widget)
		gtk_widget_grab_focus (focus_widget);
}
Пример #3
0
void
feed_list_view_add_duplicate_url_subscription (subscriptionPtr tempSubscription, nodePtr exNode)
{
	GtkWidget	*dialog;
	GtkWindow	*mainwindow;
	gchar		*text;

	text = g_strdup_printf (
			_("Are you sure that you want to add a new subscription with URL \"%s\"? Another subscription with the same URL already exists (\"%s\")."),
			tempSubscription->source,
			node_get_title (exNode)
	);

	mainwindow = GTK_WINDOW (liferea_shell_get_window ());
	dialog = gtk_message_dialog_new (mainwindow,
									 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
									 GTK_MESSAGE_QUESTION,
									 GTK_BUTTONS_NONE,
									 "%s", text);
	gtk_dialog_add_buttons (GTK_DIALOG (dialog),
							_("_Cancel"), GTK_RESPONSE_CANCEL,
							_("_Add"), GTK_RESPONSE_ACCEPT,
							NULL);
	gtk_window_set_title (GTK_WINDOW (dialog), _("Adding Duplicate Subscription Confirmation"));
	gtk_window_set_transient_for (GTK_WINDOW (dialog), mainwindow);

	g_free (text);

	gtk_widget_show_all (dialog);

	g_signal_connect (G_OBJECT (dialog), "response",
					  G_CALLBACK (feed_list_view_add_duplicate_url_cb), tempSubscription);
}
Пример #4
0
GtkWidget *
liferea_dialog_new (const gchar *name) 
{
	LifereaDialog	*ld;
	gchar 		*path;
	GError          *error = NULL;

	ld = LIFEREA_DIALOG (g_object_new (LIFEREA_DIALOG_TYPE, NULL));
	path = g_strdup_printf ("%s%s.ui", PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S, name);
	ld->priv->xml = gtk_builder_new_from_file (path);
	g_free (path);

	g_return_val_if_fail (ld->priv->xml != NULL, NULL);

	ld->priv->dialog = GTK_WIDGET (gtk_builder_get_object (ld->priv->xml, name));
	gtk_window_set_transient_for (GTK_WINDOW (ld->priv->dialog), GTK_WINDOW (liferea_shell_get_window()));
	gtk_builder_connect_signals (ld->priv->xml, NULL);
	g_return_val_if_fail (ld->priv->dialog != NULL, NULL);

	g_object_set_data (G_OBJECT (ld->priv->dialog), "LifereaDialog", ld);

	g_signal_connect_object (ld->priv->dialog, "destroy", G_CALLBACK (liferea_dialog_destroy_cb), ld, 0);

	return ld->priv->dialog;
}
Пример #5
0
void
ui_indicator_update ()
{
	guint index;

	/* Do not update indicators if the user is interacting with the main window */
	if (!indicator_priv || gtk_window_is_active (GTK_WINDOW (liferea_shell_get_window ())))
		return;

	/* Remove all previous indicators from the menu */
	remove_all_indicators ();
	/* ...then walk the tree and add an indicator for each unread feed */
	feedlist_foreach (add_node_indicator);

	/* revert order of items */
	for (index = indicator_priv->indicators->len; index > 0; index--)
		indicate_indicator_show (g_ptr_array_index (indicator_priv->indicators, index - 1));	
}
Пример #6
0
void
ui_show_error_box (const char *format, ...)
{
    GtkWidget	*dialog;
    va_list		args;
    gchar		*msg;

    g_return_if_fail (format != NULL);

    va_start (args, format);
    msg = g_strdup_vprintf (format, args);
    va_end (args);

    dialog = gtk_message_dialog_new (GTK_WINDOW (liferea_shell_get_window ()),
                                     GTK_DIALOG_DESTROY_WITH_PARENT,
                                     GTK_MESSAGE_ERROR,
                                     GTK_BUTTONS_CLOSE,
                                     "%s", msg);
    (void)gtk_dialog_run (GTK_DIALOG (dialog));
    gtk_widget_destroy (dialog);
    g_free (msg);
}
Пример #7
0
static void
ui_choose_file_or_dir(gchar *title, const gchar *buttonName, gboolean saving, gboolean directory, fileChoosenCallback callback, const gchar *currentPath, const gchar *defaultFilename, const char *filterstring, const char *filtername, gpointer user_data)
{
    GtkWidget			*dialog;
    struct file_chooser_tuple	*tuple;
    GtkWidget			*button;
    gchar				*path = NULL;

    g_assert (!(saving & directory));
    g_assert (!(defaultFilename && !saving));

    if (!currentPath)
        path = g_strdup (g_get_home_dir ());
    else
        path = g_strdup (currentPath);

    dialog = gtk_file_chooser_dialog_new (title, GTK_WINDOW (liferea_shell_get_window ()),
                                          (directory?GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:
                                           (saving ? GTK_FILE_CHOOSER_ACTION_SAVE : GTK_FILE_CHOOSER_ACTION_OPEN)),
                                          _("_Cancel"), GTK_RESPONSE_CANCEL,
                                          NULL);
    if (saving)
        gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
    gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);

    tuple = g_new0 (struct file_chooser_tuple, 1);
    tuple->dialog = dialog;
    tuple->func = callback;
    tuple->user_data = user_data;

    button = gtk_dialog_add_button (GTK_DIALOG (dialog), buttonName, GTK_RESPONSE_ACCEPT);
    gtk_widget_set_can_default (button, TRUE);
    gtk_widget_grab_default (button);

    g_signal_connect (G_OBJECT (dialog), "response",
                      G_CALLBACK (ui_choose_file_save_cb), tuple);

    if (path && g_file_test (path, G_FILE_TEST_EXISTS)) {
        if (directory || defaultFilename)
            gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), path);
        else
            gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), path);
    }
    if (defaultFilename)
        gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), defaultFilename);

    if (filterstring && filtername) {
        GtkFileFilter *filter, *allfiles;
        gchar **filterstrings, **f;

        filter = gtk_file_filter_new ();

        filterstrings = g_strsplit (filterstring, "|", 0);
        for (f = filterstrings; *f != NULL; f++)
            gtk_file_filter_add_pattern (filter, *f);
        g_strfreev (filterstrings);

        gtk_file_filter_set_name (filter, filtername);
        gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);

        allfiles = gtk_file_filter_new ();
        gtk_file_filter_add_pattern (allfiles, "*");
        gtk_file_filter_set_name (allfiles, _("All Files"));
        gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), allfiles);
    }

    gtk_widget_show_all (dialog);
    g_free (path);
}