Skip to content
Newer
Older
100644 98 lines (81 sloc) 2.89 KB
df4a395 @gregkh usbview 0.8.0 release
authored
1 /*************************************************************************
35903be @gregkh usbview 0.9.0
authored
2 ** configure-dialog.c for USBView - a USB device viewer
3 ** Copyright (c) 1999, 2000 by Greg Kroah-Hartman, <greg@kroah.com>
df4a395 @gregkh usbview 0.8.0 release
authored
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
e372c42 @gregkh update the FSF address by removing it in all files.
authored
7 ** the Free Software Foundation; version 2 of the License.
df4a395 @gregkh usbview 0.8.0 release
authored
8 **
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ** GNU General Public License for more details.
13 **
14 ** (See the included file COPYING)
15 *************************************************************************/
16
17
18 #ifdef HAVE_CONFIG_H
c7b6b1e @gregkh usbview 0.8.1
authored
19 #include <config.h>
df4a395 @gregkh usbview 0.8.0 release
authored
20 #endif
21
22 #include <gtk/gtk.h>
23 #include <string.h>
24 #include "usbtree.h"
25 #include "usbparse.h"
26
27 static GtkWidget *fileEntry;
28
29 static void fileSelectButtonClick (GtkWidget *widget, gpointer data)
30 {
6f14355 @jwrdegoede port usbview to use gtk3
jwrdegoede authored
31 GtkWidget *dialog;
32 gchar *filename;
33
34 dialog = gtk_file_chooser_dialog_new (
35 "locate usbdevfs devices file",
36 GTK_WINDOW (windowMain),
37 GTK_FILE_CHOOSER_ACTION_OPEN,
38 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
39 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
40 NULL);
41
42 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
43 {
44 filename = gtk_file_chooser_get_filename(
45 GTK_FILE_CHOOSER (dialog));
46 gtk_entry_set_text (GTK_ENTRY (fileEntry), filename);
47 g_free (filename);
df4a395 @gregkh usbview 0.8.0 release
authored
48 }
6f14355 @jwrdegoede port usbview to use gtk3
jwrdegoede authored
49
50 gtk_widget_destroy (dialog);
df4a395 @gregkh usbview 0.8.0 release
authored
51 }
52
53 void configure_dialog (void)
54 {
6f14355 @jwrdegoede port usbview to use gtk3
jwrdegoede authored
55 GtkWidget *dialog, *content_area;
df4a395 @gregkh usbview 0.8.0 release
authored
56 GtkWidget *hbox1;
57 GtkWidget *label1;
58 GtkWidget *fileSelectButton;
6f14355 @jwrdegoede port usbview to use gtk3
jwrdegoede authored
59 gchar *editString;
60 gint result;
df4a395 @gregkh usbview 0.8.0 release
authored
61
6f14355 @jwrdegoede port usbview to use gtk3
jwrdegoede authored
62 dialog = gtk_dialog_new_with_buttons (
63 "USB View Configuration",
64 GTK_WINDOW (windowMain),
65 GTK_DIALOG_DESTROY_WITH_PARENT,
66 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
67 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
68 NULL);
df4a395 @gregkh usbview 0.8.0 release
authored
69
6f14355 @jwrdegoede port usbview to use gtk3
jwrdegoede authored
70 content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
df4a395 @gregkh usbview 0.8.0 release
authored
71
6f14355 @jwrdegoede port usbview to use gtk3
jwrdegoede authored
72 hbox1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
73 gtk_container_add (GTK_CONTAINER (content_area), hbox1);
91a5830 @gregkh usbview 1.0
authored
74
6f14355 @jwrdegoede port usbview to use gtk3
jwrdegoede authored
75 label1 = gtk_label_new ("Location of usbdevfs devices file");
df4a395 @gregkh usbview 0.8.0 release
authored
76 gtk_box_pack_start (GTK_BOX (hbox1), label1, FALSE, FALSE, 5);
c7b6b1e @gregkh usbview 0.8.1
authored
77
df4a395 @gregkh usbview 0.8.0 release
authored
78 fileEntry = gtk_entry_new ();
79 gtk_entry_set_text (GTK_ENTRY (fileEntry), devicesFile);
80 gtk_box_pack_start (GTK_BOX (hbox1), fileEntry, TRUE, TRUE, 0);
c7b6b1e @gregkh usbview 0.8.1
authored
81
df4a395 @gregkh usbview 0.8.0 release
authored
82 fileSelectButton = gtk_button_new_with_label ("...");
6f14355 @jwrdegoede port usbview to use gtk3
jwrdegoede authored
83 g_signal_connect (G_OBJECT (fileSelectButton), "clicked",
84 G_CALLBACK (fileSelectButtonClick), NULL);
91a5830 @gregkh usbview 1.0
authored
85 gtk_box_pack_start (GTK_BOX (hbox1), fileSelectButton, TRUE, FALSE, 1);
c7b6b1e @gregkh usbview 0.8.1
authored
86
6f14355 @jwrdegoede port usbview to use gtk3
jwrdegoede authored
87 gtk_widget_show_all (dialog);
88 result = gtk_dialog_run(GTK_DIALOG (dialog));
89 if (result == GTK_RESPONSE_ACCEPT) {
90 editString = gtk_editable_get_chars (
91 GTK_EDITABLE (fileEntry), 0, -1);
92 strcpy (devicesFile, editString);
93 g_free (editString);
94 LoadUSBTree (0);
95 }
96 gtk_widget_destroy (dialog);
df4a395 @gregkh usbview 0.8.0 release
authored
97 }
Something went wrong with that request. Please try again.