| 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ |
|---|
| 2 | |
|---|
| 3 | /* |
|---|
| 4 | * Copyright (C) 2000 Eazel, Inc |
|---|
| 5 | * |
|---|
| 6 | * This program is free software; you can redistribute it and/or |
|---|
| 7 | * modify it under the terms of the GNU General Public License as |
|---|
| 8 | * published by the Free Software Foundation; either version 2 of the |
|---|
| 9 | * License, or (at your option) any later version. |
|---|
| 10 | * |
|---|
| 11 | * This program is distributed in the hope that it will be useful, |
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 14 | * General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU General Public |
|---|
| 17 | * License along with this program; if not, write to the |
|---|
| 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|---|
| 19 | * Boston, MA 02111-1307, USA. |
|---|
| 20 | * |
|---|
| 21 | * Author: Maciej Stachowiak <mjs@eazel.com> |
|---|
| 22 | */ |
|---|
| 23 | |
|---|
| 24 | /* nautilus-inventory-config-page.h - |
|---|
| 25 | */ |
|---|
| 26 | |
|---|
| 27 | #include <config.h> |
|---|
| 28 | #include "nautilus-inventory-config-page.h" |
|---|
| 29 | #include <gtk/gtklabel.h> |
|---|
| 30 | #include <gtk/gtkhbox.h> |
|---|
| 31 | #include <gtk/gtkbutton.h> |
|---|
| 32 | #include <gtk/gtkentry.h> |
|---|
| 33 | #include <gtk/gtksignal.h> |
|---|
| 34 | #include <gtk/gtkcheckbutton.h> |
|---|
| 35 | #include <libnautilus-extensions/nautilus-gtk-macros.h> |
|---|
| 36 | #include <libnautilus/nautilus-view.h> |
|---|
| 37 | #include <eazel-inventory-service-interface.h> |
|---|
| 38 | |
|---|
| 39 | #define SERVICE_IID "OAFIID:trilobite_inventory_service:eaae1152-1551-43d5-a764-52274131a9d5" |
|---|
| 40 | |
|---|
| 41 | struct NautilusInventoryConfigPageDetails { |
|---|
| 42 | GtkWidget *machine_entry; |
|---|
| 43 | GtkWidget *warn_check_button; |
|---|
| 44 | NautilusView *view; |
|---|
| 45 | Trilobite_Eazel_Inventory inventory_service; |
|---|
| 46 | }; |
|---|
| 47 | |
|---|
| 48 | static void nautilus_inventory_config_page_initialize_class (NautilusInventoryConfigPageClass *klass); |
|---|
| 49 | static void nautilus_inventory_config_page_initialize (NautilusInventoryConfigPage *file); |
|---|
| 50 | static void nautilus_inventory_config_page_destroy (GtkObject *object); |
|---|
| 51 | |
|---|
| 52 | NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusInventoryConfigPage, nautilus_inventory_config_page, GTK_TYPE_VBOX) |
|---|
| 53 | |
|---|
| 54 | static void |
|---|
| 55 | nautilus_inventory_config_page_initialize_class (NautilusInventoryConfigPageClass *klass) |
|---|
| 56 | { |
|---|
| 57 | GtkObjectClass *object_class; |
|---|
| 58 | |
|---|
| 59 | object_class = GTK_OBJECT_CLASS (klass); |
|---|
| 60 | |
|---|
| 61 | object_class->destroy = nautilus_inventory_config_page_destroy; |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | static void |
|---|
| 65 | next_button_callback (GtkWidget *button, |
|---|
| 66 | NautilusInventoryConfigPage *config_page) |
|---|
| 67 | { |
|---|
| 68 | CORBA_Environment ev; |
|---|
| 69 | g_print ("clicked next.\n"); |
|---|
| 70 | |
|---|
| 71 | CORBA_exception_init (&ev); |
|---|
| 72 | |
|---|
| 73 | Trilobite_Eazel_Inventory__set_machine_name (config_page->details->inventory_service, |
|---|
| 74 | gtk_entry_get_text |
|---|
| 75 | (GTK_ENTRY (config_page->details->machine_entry)), &ev); |
|---|
| 76 | |
|---|
| 77 | Trilobite_Eazel_Inventory__set_warn_before_upload (config_page->details->inventory_service, |
|---|
| 78 | gtk_toggle_button_get_active |
|---|
| 79 | (GTK_TOGGLE_BUTTON (config_page->details->warn_check_button)), &ev); |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | Trilobite_Eazel_Inventory__set_enabled (config_page->details->inventory_service, |
|---|
| 83 | CORBA_TRUE, &ev); |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | Trilobite_Eazel_Inventory_upload (config_page->details->inventory_service, &ev); |
|---|
| 87 | |
|---|
| 88 | CORBA_exception_free (&ev); |
|---|
| 89 | |
|---|
| 90 | nautilus_view_open_location_in_this_window (config_page->details->view, "eazel-services:/inventory"); |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | static void |
|---|
| 94 | nautilus_inventory_config_page_initialize (NautilusInventoryConfigPage *config_page) |
|---|
| 95 | { |
|---|
| 96 | GtkWidget *label; |
|---|
| 97 | GtkWidget *button; |
|---|
| 98 | GtkWidget *hbox; |
|---|
| 99 | BonoboObjectClient *object; |
|---|
| 100 | char *initial_machine_name; |
|---|
| 101 | gboolean initial_warn; |
|---|
| 102 | |
|---|
| 103 | CORBA_Environment ev; |
|---|
| 104 | |
|---|
| 105 | CORBA_exception_init (&ev); |
|---|
| 106 | |
|---|
| 107 | config_page->details = g_new0 (NautilusInventoryConfigPageDetails, 1); |
|---|
| 108 | |
|---|
| 109 | object = bonobo_object_activate (SERVICE_IID, 0); |
|---|
| 110 | |
|---|
| 111 | config_page->details->inventory_service = bonobo_object_query_interface |
|---|
| 112 | (BONOBO_OBJECT (object), "IDL:Trilobite/Eazel/Inventory:1.0"); |
|---|
| 113 | |
|---|
| 114 | bonobo_object_unref (BONOBO_OBJECT (object)); |
|---|
| 115 | |
|---|
| 116 | label = gtk_label_new ("Eazel Inventory Configuration"); |
|---|
| 117 | gtk_widget_show (label); |
|---|
| 118 | gtk_box_pack_start (GTK_BOX (config_page), label, FALSE, FALSE, 0); |
|---|
| 119 | |
|---|
| 120 | label = gtk_label_new ("blah blah blah"); |
|---|
| 121 | gtk_widget_show (label); |
|---|
| 122 | gtk_box_pack_start (GTK_BOX (config_page), label, FALSE, FALSE, 0); |
|---|
| 123 | |
|---|
| 124 | hbox = gtk_hbox_new (FALSE, 0); |
|---|
| 125 | gtk_widget_show (hbox); |
|---|
| 126 | gtk_box_pack_start (GTK_BOX (config_page), hbox, FALSE, FALSE, 0); |
|---|
| 127 | |
|---|
| 128 | label = gtk_label_new ("Machine Name:"); |
|---|
| 129 | gtk_widget_show (label); |
|---|
| 130 | gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); |
|---|
| 131 | |
|---|
| 132 | config_page->details->machine_entry = gtk_entry_new (); |
|---|
| 133 | initial_machine_name = Trilobite_Eazel_Inventory__get_machine_name |
|---|
| 134 | (config_page->details->inventory_service, &ev); |
|---|
| 135 | |
|---|
| 136 | g_print ("initial machine name = `%s'\n", initial_machine_name); |
|---|
| 137 | |
|---|
| 138 | if ( (initial_machine_name == NULL) || (initial_machine_name[0] == '\n') ) { |
|---|
| 139 | /* the user has never specified a name for this machine */ |
|---|
| 140 | g_print ("no name selected yet\n"); |
|---|
| 141 | |
|---|
| 142 | /* TODO: perhaps guess an intial machine name based on host |
|---|
| 143 | * name... |
|---|
| 144 | */ |
|---|
| 145 | |
|---|
| 146 | } else { |
|---|
| 147 | gtk_entry_set_text (GTK_ENTRY(config_page->details->machine_entry), |
|---|
| 148 | initial_machine_name); |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | gtk_widget_show (config_page->details->machine_entry); |
|---|
| 152 | gtk_box_pack_start (GTK_BOX (hbox), config_page->details->machine_entry, FALSE, FALSE, 0); |
|---|
| 153 | |
|---|
| 154 | config_page->details->warn_check_button = gtk_check_button_new_with_label ("Warn me before upload"); |
|---|
| 155 | initial_warn = Trilobite_Eazel_Inventory__get_warn_before_upload |
|---|
| 156 | (config_page->details->inventory_service, &ev); |
|---|
| 157 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_page->details->warn_check_button), initial_warn); |
|---|
| 158 | gtk_widget_show (config_page->details->warn_check_button); |
|---|
| 159 | gtk_box_pack_start (GTK_BOX (config_page), config_page->details->warn_check_button, FALSE, FALSE, 0); |
|---|
| 160 | |
|---|
| 161 | button = gtk_button_new_with_label ("Next"); |
|---|
| 162 | gtk_widget_show (button); |
|---|
| 163 | gtk_box_pack_start (GTK_BOX (config_page), button, FALSE, FALSE, 0); |
|---|
| 164 | gtk_signal_connect (GTK_OBJECT (button), "clicked", next_button_callback, config_page); |
|---|
| 165 | |
|---|
| 166 | } |
|---|
| 167 | |
|---|
| 168 | |
|---|
| 169 | GtkWidget * |
|---|
| 170 | nautilus_inventory_config_page_new (NautilusView *view) |
|---|
| 171 | { |
|---|
| 172 | NautilusInventoryConfigPage *config_page; |
|---|
| 173 | |
|---|
| 174 | config_page = NAUTILUS_INVENTORY_CONFIG_PAGE (gtk_widget_new (nautilus_inventory_config_page_get_type (), NULL)); |
|---|
| 175 | |
|---|
| 176 | config_page->details->view = view; |
|---|
| 177 | |
|---|
| 178 | return GTK_WIDGET (config_page); |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | static void |
|---|
| 183 | nautilus_inventory_config_page_destroy (GtkObject *object) |
|---|
| 184 | { |
|---|
| 185 | NautilusInventoryConfigPage *page = NAUTILUS_INVENTORY_CONFIG_PAGE (object); |
|---|
| 186 | |
|---|
| 187 | g_free (page->details); |
|---|
| 188 | |
|---|
| 189 | NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); |
|---|
| 190 | } |
|---|
| 191 | |
|---|
| 192 | |
|---|
| 193 | |
|---|
| 194 | |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | |
|---|