void on_iface_properties_clicked (GtkWidget *widget, gpointer data) { GstConnectionDialog *dialog; GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeIter iter; OobsIface *iface; selection = gtk_tree_view_get_selection (GST_NETWORK_TOOL (tool)->interfaces_list); if (gtk_tree_selection_get_selected (selection, &model, &iter)) { gtk_tree_model_get (model, &iter, COL_OBJECT, &iface, -1); dialog = GST_NETWORK_TOOL (tool)->dialog; connection_dialog_prepare (dialog, iface); gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), GTK_WINDOW (tool->main_dialog)); gst_dialog_add_edit_dialog (tool->main_dialog, dialog->dialog); gtk_widget_show (dialog->dialog); } }
static void accept_connection_dialog (GstTool *tool) { GstConnectionDialog *dialog; GtkTreeSelection *selection; GtkTreeIter iter; dialog = GST_NETWORK_TOOL (tool)->dialog; connection_dialog_hide (dialog); if (dialog->changed) { connection_save (dialog); selection = gtk_tree_view_get_selection (GST_NETWORK_TOOL (tool)->interfaces_list); if (gtk_tree_selection_get_selected (selection, NULL, &iter)) { ifaces_model_modify_interface_at_iter (&iter); g_signal_emit_by_name (G_OBJECT (selection), "changed"); } gst_tool_commit_async (tool, OOBS_OBJECT (GST_NETWORK_TOOL (tool)->ifaces_config), _("Changing interface configuration"), on_configuration_changed, tool); } g_object_unref (dialog->iface); if (dialog->standalone) gtk_main_quit (); }
static void host_aliases_dialog_save (GtkTreeIter *iter) { GtkTreeView *list; GtkTreeModel *model; GtkWidget *address, *aliases; GtkTextBuffer *buffer; OobsStaticHost *host; GList *aliases_list; address = gst_dialog_get_widget (tool->main_dialog, "host_alias_address"); aliases = gst_dialog_get_widget (tool->main_dialog, "host_alias_list"); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (aliases)); aliases_list = split_buffer_content (buffer); if (iter) { OobsListIter *list_iter; list = GST_NETWORK_TOOL (tool)->host_aliases_list; model = gtk_tree_view_get_model (list); gtk_tree_model_get (model, iter, COL_HOST_OBJECT, &host, COL_HOST_ITER, &list_iter, -1); oobs_static_host_set_ip_address (host, gtk_entry_get_text (GTK_ENTRY (address))); oobs_static_host_set_aliases (host, aliases_list); host_aliases_modify_at_iter (iter, host, list_iter); oobs_list_iter_free (list_iter); g_object_unref (host); } else { OobsList *list; OobsListIter list_iter; list = oobs_hosts_config_get_static_hosts (GST_NETWORK_TOOL (tool)->hosts_config); host = oobs_static_host_new (gtk_entry_get_text (GTK_ENTRY (address)), aliases_list); oobs_list_append (list, &list_iter); oobs_list_set (list, &list_iter, host); host_aliases_add (host, &list_iter); } gst_tool_commit (tool, OOBS_OBJECT (GST_NETWORK_TOOL (tool)->hosts_config)); }
void on_host_aliases_properties_clicked (GtkWidget *widget, gpointer data) { GtkTreeSelection *selection; GtkTreeView *list; GtkTreeModel *model; GtkTreeIter iter; list = GST_NETWORK_TOOL (tool)->host_aliases_list; selection = gtk_tree_view_get_selection (list); if (gtk_tree_selection_get_selected (selection, &model, &iter)) host_aliases_run_dialog (GST_NETWORK_TOOL (tool), &iter); }
void ifaces_model_modify_interface_at_iter (GtkTreeIter *iter) { GtkTreeModel *model; OobsIface *iface; gchar *desc; gboolean show_name, configured; GdkPixbuf *pixbuf; model = GST_NETWORK_TOOL (tool)->interfaces_model; gtk_tree_model_get (model, iter, COL_OBJECT, &iface, COL_SHOW_IFACE_NAME, &show_name, -1); desc = get_iface_desc (OOBS_IFACE (iface), show_name); pixbuf = get_iface_pixbuf (OOBS_IFACE (iface)); configured = oobs_iface_get_configured (OOBS_IFACE (iface)); gtk_list_store_set (GTK_LIST_STORE (model), iter, COL_ACTIVE, oobs_iface_get_active (OOBS_IFACE (iface)), COL_IMAGE, pixbuf, COL_DESC, desc, COL_DEV, oobs_iface_get_device_name (OOBS_IFACE (iface)), COL_INCONSISTENT, !configured, COL_NOT_INCONSISTENT, configured, -1); if (pixbuf) g_object_unref (pixbuf); g_object_unref (iface); g_free (desc); }
static void iface_state_changed (OobsIface *iface, gpointer user_data) { GtkTreeModel *model; GtkTreeIter iter; OobsIface *model_iface; gboolean valid, found; found = FALSE; model = GST_NETWORK_TOOL (tool)->interfaces_model; valid = gtk_tree_model_get_iter_first (model, &iter); while (valid && !found) { gtk_tree_model_get (model, &iter, COL_OBJECT, &model_iface, -1); if (iface == model_iface) { ifaces_model_modify_interface_at_iter (&iter); found = TRUE; } g_object_unref (iface); valid = gtk_tree_model_iter_next (model, &iter); } }
static void host_aliases_modify_at_iter (GtkTreeIter *iter, OobsStaticHost *host, OobsListIter *list_iter) { GtkTreeView *list; GtkTreeModel *model; gchar *aliases_str; GList *aliases; list = GST_NETWORK_TOOL (tool)->host_aliases_list; model = gtk_tree_view_get_model (list); aliases = oobs_static_host_get_aliases (host); aliases_str = concatenate_aliases (aliases, " "); g_list_free (aliases); gtk_list_store_set (GTK_LIST_STORE (model), iter, COL_HOST_IP, oobs_static_host_get_ip_address (host), COL_HOST_ALIASES, aliases_str, COL_HOST_OBJECT, host, COL_HOST_ITER, list_iter, -1); g_free (aliases_str); }
GtkTreeView* ifaces_list_create (GstTool *tool) { GtkWidget *table = gst_dialog_get_widget (tool->main_dialog, "interfaces_list"); GstTablePopup *table_popup; GtkTreeSelection *selection; GtkTreeModel *model; model = GST_NETWORK_TOOL (tool)->interfaces_model; gtk_tree_view_set_model (GTK_TREE_VIEW (table), model); gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (GTK_LIST_STORE (model)), ifaces_list_sort, NULL, NULL); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (GTK_LIST_STORE (model)), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_DESCENDING); add_list_columns (GTK_TREE_VIEW (table), model); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (table)); g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (on_table_selection_changed), NULL); table_popup = g_new0 (GstTablePopup, 1); table_popup->properties = on_iface_properties_clicked; table_popup->popup = popup_menu_create (table); g_signal_connect (G_OBJECT (table), "button-press-event", G_CALLBACK (on_table_button_press), (gpointer) table_popup); g_signal_connect (G_OBJECT (table), "popup_menu", G_CALLBACK (on_table_popup_menu), (gpointer) table_popup); return GTK_TREE_VIEW (table); }
void ifaces_model_clear (void) { GtkTreeModel *model; model = GST_NETWORK_TOOL (tool)->interfaces_model; gtk_list_store_clear (GTK_LIST_STORE (model)); }
void on_dialog_changed (GtkWidget *widget, gpointer data) { GstNetworkTool *network_tool = GST_NETWORK_TOOL (tool); network_tool->dialog->changed = TRUE; connection_check_fields (network_tool->dialog); }
gboolean on_ip_address_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) { GstConnectionDialog *dialog = GST_NETWORK_TOOL (tool)->dialog; connection_check_netmask (dialog->address, dialog->netmask); return FALSE; }
void connection_dialog_update (GstConnectionDialog *gcd) { populate_combo (GTK_COMBO_BOX (gcd->bootproto_combo), oobs_ifaces_config_get_available_configuration_methods (GST_NETWORK_TOOL (tool)->ifaces_config), method_descriptions, G_N_ELEMENTS (method_descriptions)); populate_combo (GTK_COMBO_BOX (gcd->key_type_combo), oobs_ifaces_config_get_available_key_types (GST_NETWORK_TOOL (tool)->ifaces_config), key_type_descriptions, G_N_ELEMENTS (key_type_descriptions)); populate_combo (GTK_COMBO_BOX (gcd->ppp_type_combo), oobs_ifaces_config_get_available_ppp_types (GST_NETWORK_TOOL (tool)->ifaces_config), ppp_type_descriptions, G_N_ELEMENTS (ppp_type_descriptions)); populate_ethernet_interfaces (gcd, GST_NETWORK_TOOL (tool)); }
void host_aliases_clear (void) { GtkTreeView *list; GtkTreeModel *model; list = GST_NETWORK_TOOL (tool)->host_aliases_list; model = gtk_tree_view_get_model (list); gtk_list_store_clear (GTK_LIST_STORE (model)); }
static void cancel_connection_dialog (GstTool *tool) { GstConnectionDialog *dialog; dialog = GST_NETWORK_TOOL (tool)->dialog; g_object_unref (dialog->iface); connection_dialog_hide (dialog); if (dialog->standalone) gtk_main_quit (); }
void host_aliases_add (OobsStaticHost *host, OobsListIter *list_iter) { GtkTreeView *list; GtkTreeModel *model; GtkTreeIter iter; list = GST_NETWORK_TOOL (tool)->host_aliases_list; model = gtk_tree_view_get_model (list); gtk_list_store_append (GTK_LIST_STORE (model), &iter); host_aliases_modify_at_iter (&iter, host, list_iter); }
gboolean on_hostname_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) { GstNetworkTool *tool; gboolean changed; const gchar *hostname; tool = GST_NETWORK_TOOL (gst_dialog_get_tool (GST_DIALOG (data))); changed = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "content-changed")); hostname = gtk_entry_get_text (GTK_ENTRY (widget)); if (changed && hostname && *hostname) { GtkWidget *dialog; gint res; dialog = gtk_message_dialog_new (GTK_WINDOW (GST_TOOL (tool)->main_dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE, _("The host name has changed"), NULL); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), _("This will prevent you " "from launching new applications, and so you will " "have to log in again. Continue anyway?"), NULL); gtk_dialog_add_buttons (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("Change _Host name"), GTK_RESPONSE_ACCEPT, NULL); res = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); if (res == GTK_RESPONSE_ACCEPT) { oobs_hosts_config_set_hostname (tool->hosts_config, hostname); oobs_object_commit (OOBS_OBJECT (tool->hosts_config)); } else { gtk_entry_set_text (GTK_ENTRY (widget), oobs_hosts_config_get_hostname (tool->hosts_config)); } } g_object_set_data (G_OBJECT (widget), "content-changed", GINT_TO_POINTER (FALSE)); return FALSE; }
void ifaces_model_add_interface (OobsIface *iface, gboolean show_name) { GtkTreeModel *model; GtkTreeIter it; model = GST_NETWORK_TOOL (tool)->interfaces_model; gtk_list_store_append (GTK_LIST_STORE (model), &it); ifaces_model_set_interface_at_iter (iface, &it, show_name); g_signal_connect (iface, "state-changed", G_CALLBACK (iface_state_changed), tool); }
static void ifaces_model_set_interface_at_iter (OobsIface *iface, GtkTreeIter *iter, gboolean show_name) { GtkTreeModel *model; g_return_if_fail (iface != NULL); model = GST_NETWORK_TOOL (tool)->interfaces_model; gtk_list_store_set (GTK_LIST_STORE (model), iter, COL_OBJECT, iface, COL_SHOW_IFACE_NAME, show_name, -1); ifaces_model_modify_interface_at_iter (iter); }
void on_host_aliases_delete_clicked (GtkWidget *widget, gpointer data) { GtkTreeSelection *selection; GtkTreeView *list; GtkTreeModel *model; GtkTreeIter iter; OobsList *hosts_list; OobsListIter *list_iter; list = GST_NETWORK_TOOL (tool)->host_aliases_list; selection = gtk_tree_view_get_selection (list); if (gtk_tree_selection_get_selected (selection, &model, &iter)) { gtk_tree_model_get (model, &iter, COL_HOST_ITER, &list_iter, -1); hosts_list = oobs_hosts_config_get_static_hosts (GST_NETWORK_TOOL (tool)->hosts_config); oobs_list_remove (hosts_list, list_iter); gtk_list_store_remove (GTK_LIST_STORE (model), &iter); oobs_list_iter_free (list_iter); oobs_object_commit (OOBS_OBJECT (GST_NETWORK_TOOL (tool)->hosts_config)); } }
void on_ppp_type_changed (GtkWidget *widget, gpointer data) { GstConnectionDialog *dialog; gchar *type; dialog = GST_NETWORK_TOOL (tool)->dialog; type = connection_combo_get_value (GTK_COMBO_BOX (dialog->ppp_type_combo)); on_dialog_changed (widget, data); if (!type) return; if (strcmp (type, "modem") == 0) { gtk_widget_show (dialog->modem_page); gtk_widget_show (dialog->isp_frame); gtk_widget_show (dialog->modem_settings_table); gtk_widget_show (dialog->modem_isp_table); gtk_widget_hide (dialog->pppoe_settings_table); gtk_widget_hide (dialog->gprs_isp_table); } else if (strcmp (type, "isdn") == 0) { gtk_widget_show (dialog->isp_frame); gtk_widget_show (dialog->modem_isp_table); gtk_widget_hide (dialog->modem_page); gtk_widget_hide (dialog->gprs_isp_table); } else if (strcmp (type, "pppoe") == 0) { gtk_widget_show (dialog->modem_page); gtk_widget_show (dialog->pppoe_settings_table); gtk_widget_show (dialog->modem_isp_table); gtk_widget_hide (dialog->isp_frame); gtk_widget_hide (dialog->modem_settings_table); } else if (strcmp (type, "gprs") == 0) { gtk_widget_show (dialog->modem_page); gtk_widget_show (dialog->isp_frame); gtk_widget_show (dialog->modem_settings_table); gtk_widget_show (dialog->gprs_isp_table); gtk_widget_hide (dialog->modem_isp_table); gtk_widget_hide (dialog->pppoe_settings_table); } }
void on_detect_modem_clicked (GtkWidget *widget, gpointer data) { GstNetworkTool *network_tool; GstConnectionDialog *dialog; GtkWidget *d; GdkCursor *cursor; gchar *dev = NULL; network_tool = GST_NETWORK_TOOL (tool); dialog = network_tool->dialog; /* give some feedback to let know the user that the tool is busy */ gtk_entry_set_text (GTK_ENTRY (GTK_BIN (GTK_COMBO_BOX (dialog->serial_port))->child), ""); gtk_widget_set_sensitive (dialog->serial_port, FALSE); gtk_widget_set_sensitive (dialog->detect_modem, FALSE); cursor = gdk_cursor_new (GDK_WATCH); gdk_window_set_cursor (GTK_WIDGET (dialog->dialog)->window, cursor); gdk_cursor_unref (cursor); dev = connection_detect_modem (); /* remove the user feedback */ gtk_widget_set_sensitive (dialog->detect_modem, TRUE); gtk_widget_set_sensitive (dialog->serial_port, TRUE); gdk_window_set_cursor (GTK_WIDGET (dialog->dialog)->window, NULL); if (!dev || !*dev) { d = gtk_message_dialog_new (GTK_WINDOW (dialog->dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, _("Could not autodetect modem device"), NULL); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (d), _("Check that the device is not busy and " "that is correctly attached to the computer."), NULL); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (d); } else gtk_entry_set_text (GTK_ENTRY (GTK_BIN (GTK_COMBO_BOX (dialog->serial_port))->child), dev); g_free (dev); }
void on_connection_response (GtkWidget *widget, gint response, gpointer data) { GstConnectionDialog *connection_dialog; GstDialog *dialog = GST_DIALOG (data); GstTool *tool = gst_dialog_get_tool (dialog); if (response == GTK_RESPONSE_OK) accept_connection_dialog (tool); else cancel_connection_dialog (tool); connection_dialog = GST_NETWORK_TOOL (tool)->dialog; gst_dialog_remove_edit_dialog (tool->main_dialog, connection_dialog->dialog); }
void on_iface_active_changed (GtkWidget *widget, gpointer data) { GstConnectionDialog *dialog; GtkWidget *roaming_active; gboolean active; dialog = GST_NETWORK_TOOL (tool)->dialog; active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); connection_dialog_set_sensitive (dialog, active); roaming_active = gst_dialog_get_widget (tool->main_dialog, "connection_device_roaming"); g_signal_handlers_block_by_func (roaming_active, on_iface_roaming_changed, data); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (roaming_active), !active); g_signal_handlers_unblock_by_func (roaming_active, on_iface_roaming_changed, data); }
void on_bootproto_changed (GtkWidget *widget, gpointer data) { GstConnectionDialog *dialog; gchar *method; gboolean enabled; dialog = GST_NETWORK_TOOL (tool)->dialog; method = connection_combo_get_value (GTK_COMBO_BOX (dialog->bootproto_combo)); enabled = (method && strcmp (method, "static") == 0); gtk_widget_set_sensitive (dialog->address, enabled); gtk_widget_set_sensitive (dialog->netmask, enabled); gtk_widget_set_sensitive (dialog->gateway, enabled); g_free (method); }
void general_prepare (GstConnectionDialog *dialog, OobsIface *iface) { NMState state; state = nm_integration_get_state (GST_NETWORK_TOOL (tool)); if (nm_integration_iface_supported (iface) && state != NM_STATE_UNKNOWN) { gtk_widget_show (dialog->roaming_configured); gtk_widget_hide (dialog->connection_configured); } else { gtk_widget_hide (dialog->roaming_configured); gtk_widget_show (dialog->connection_configured); } }
static gboolean toggle_nm (gpointer data) { GstNetworkTool *tool = GST_NETWORK_TOOL (data); NMState state; state = nm_integration_get_state (tool); if (state == NM_STATE_DISCONNECTED || state == NM_STATE_CONNECTING || state == NM_STATE_CONNECTED) { /* "reboot" NM */ nm_integration_sleep (tool); nm_integration_wake (tool); } return FALSE; }
gboolean on_domain_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) { GstNetworkTool *tool; gboolean changed; const gchar *domain; tool = GST_NETWORK_TOOL (gst_dialog_get_tool (GST_DIALOG (data))); changed = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "content-changed")); domain = gtk_entry_get_text (GTK_ENTRY (widget)); if (changed) { oobs_hosts_config_set_domainname (tool->hosts_config, domain); oobs_object_commit (OOBS_OBJECT (tool->hosts_config)); } g_object_set_data (G_OBJECT (widget), "content-changed", GINT_TO_POINTER (FALSE)); return FALSE; }
OobsIface* ifaces_model_search_iface (IfaceSearchTerm search_term, const gchar *term) { GtkTreeModel *model; GtkTreeIter iter; gboolean valid; gchar *dev, *item; OobsIface *iface = NULL; g_return_val_if_fail (term != NULL, NULL); model = GST_NETWORK_TOOL (tool)->interfaces_model; valid = gtk_tree_model_get_iter_first (model, &iter); while (valid) { gtk_tree_model_get (model, &iter, COL_OBJECT, &iface, COL_DEV, &dev, -1); if (search_term == SEARCH_DEV) item = dev; else item = (gchar *) iface_to_type (iface); if (strcmp (term, item) == 0) valid = FALSE; else { valid = gtk_tree_model_iter_next (model, &iter); g_object_unref (iface); iface = NULL; } g_free (dev); } return iface; }
void on_iface_toggled (GtkCellRendererToggle *renderer, gchar *path_str, gpointer data) { GtkTreePath *path; GtkTreeModel *model = GTK_TREE_MODEL (data); GtkTreeIter iter; gboolean active, inconsistent; OobsIface *iface; path = gtk_tree_path_new_from_string (path_str); if (gtk_tree_model_get_iter (model, &iter, path)) { gtk_tree_model_get (model, &iter, COL_ACTIVE, &active, COL_INCONSISTENT, &inconsistent, COL_OBJECT, &iface, -1); if (!inconsistent) { active ^= 1; oobs_iface_set_active (iface, active); oobs_iface_set_auto (iface, active); ifaces_model_modify_interface_at_iter (&iter); gst_tool_commit_async (tool, OOBS_OBJECT (GST_NETWORK_TOOL (tool)->ifaces_config), _("Changing interface configuration"), on_configuration_changed, tool); } g_object_unref (iface); } gtk_tree_path_free (path); }
static void init_standalone_dialog (GstTool *tool, IfaceSearchTerm search_term, const gchar *term) { GstNetworkTool *network_tool; OobsIface *iface; GtkWidget *d; network_tool = GST_NETWORK_TOOL (tool); gst_tool_update_gui (tool); iface = ifaces_model_search_iface (search_term, term); if (iface) { connection_dialog_prepare (network_tool->dialog, iface); network_tool->dialog->standalone = TRUE; g_object_unref (iface); gtk_widget_show (network_tool->dialog->dialog); } else { d = gtk_message_dialog_new (GTK_WINDOW (tool->main_dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, _("The interface does not exist")); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (d), _("Check that it is correctly typed " "and that it is correctly supported " "by your system."), NULL); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (d); exit (-1); } }