udapted vi.po
[rhythmbox.git] / widgets / rb-dialog.c
blobfbf62b05f5aeddefc2e5a5ecb57cb5ae58885faa
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * arch-tag: Implementation of Rhythmbox dialog wrapper functions
5 * Copyright (C) 2002 Jorn Baayen
6 * Copyright (C) 2004 Colin Walters <walters@redhat.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include <config.h>
26 #include <glib/gi18n.h>
28 #include <gtk/gtk.h>
29 #include <glib.h>
30 #include <glib/gprintf.h>
31 #include <stdio.h>
32 #include <string.h>
33 #include <stdarg.h>
35 #include "rb-dialog.h"
36 #include "rb-stock-icons.h"
38 void
39 rb_error_dialog (GtkWindow *parent,
40 const char *primary,
41 const char *secondary,
42 ...)
44 char *text = "";
45 va_list args;
46 GtkWidget *dialog;
48 va_start (args, secondary);
49 g_vasprintf (&text, secondary, args);
50 va_end (args);
52 dialog = gtk_message_dialog_new (parent,
53 GTK_DIALOG_DESTROY_WITH_PARENT,
54 GTK_MESSAGE_ERROR,
55 GTK_BUTTONS_CLOSE,
56 "%s", primary);
58 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
59 "%s", text);
61 gtk_window_set_title (GTK_WINDOW (dialog), "");
63 gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
65 g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
67 gtk_widget_show (dialog);
69 g_free (text);
72 GtkWidget *
73 rb_file_chooser_new (const char *title,
74 GtkWindow *parent,
75 GtkFileChooserAction action,
76 gboolean local_only)
78 GtkWidget *dialog;
80 if (action == GTK_FILE_CHOOSER_ACTION_OPEN ||
81 action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
82 action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER) {
83 dialog = gtk_file_chooser_dialog_new (title, parent,
84 action,
85 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
86 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
87 NULL);
88 gtk_dialog_set_default_response (GTK_DIALOG (dialog),
89 GTK_RESPONSE_ACCEPT);
90 } else if (action == GTK_FILE_CHOOSER_ACTION_SAVE) {
91 dialog = gtk_file_chooser_dialog_new (title, parent,
92 action,
93 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
94 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
95 NULL);
96 gtk_dialog_set_default_response (GTK_DIALOG (dialog),
97 GTK_RESPONSE_ACCEPT);
98 #if GTK_MINOR_VERSION >= 8
99 gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
100 #endif
101 } else {
102 g_assert_not_reached ();
103 return NULL;
106 gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), local_only);
108 if (parent != NULL) {
109 gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
110 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
113 gtk_widget_show_all (dialog);
115 return dialog;