static void show_dialog ( TpSimpleApprover *self, TpChannelDispatchOperation *cdo, TpContact *target) { GFile *avatar_file = tp_contact_get_avatar_file (target); GtkWidget *dialog = gtk_message_dialog_new_with_markup (NULL, 0, /* flags */ GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "<b>%s</b> (<i>%s</i>) would like to edit a spreadsheet in LibreOffice " "with you.", tp_contact_get_alias (target), tp_contact_get_identifier (target)); if (avatar_file != NULL) { GtkWidget *avatar = gtk_image_new_from_file (g_file_get_path (avatar_file)); gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), avatar); } gtk_dialog_add_buttons (GTK_DIALOG (dialog), "_Reject", GTK_RESPONSE_REJECT, "_Accept", GTK_RESPONSE_ACCEPT, NULL); g_object_set_data_full (G_OBJECT (dialog), "client", g_object_ref (self), g_object_unref); g_signal_connect (dialog, "response", G_CALLBACK (dialog_response_cb), g_object_ref (cdo)); gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), FALSE); gtk_widget_show_all (dialog); }
JNIEXPORT void JNICALL Java_org_gnome_gtk_GtkMessageDialog_gtk_1message_1dialog_1set_1image ( JNIEnv* env, jclass cls, jlong _self, jlong _image ) { GtkMessageDialog* self; GtkWidget* image; // convert parameter self self = (GtkMessageDialog*) _self; // convert parameter image image = (GtkWidget*) _image; // call function gtk_message_dialog_set_image(self, image); // cleanup parameter self // cleanup parameter image }
static void _panel_helper_shutdown_dialog(Panel * panel) { #ifdef EMBEDDED const char message[] = N_("This will shutdown your device," " therefore closing any application currently opened" " and losing any unsaved data.\n" "Do you really want to proceed?"); #else const char message[] = N_("This will shutdown your computer," " therefore closing any application currently opened" " and losing any unsaved data.\n" "Do you really want to proceed?"); #endif GtkWidget * widget; if(panel->sh_window != NULL) { gtk_window_present(GTK_WINDOW(panel->sh_window)); return; } panel->sh_window = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", #if GTK_CHECK_VERSION(2, 6, 0) _("Shutdown")); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG( panel->sh_window), #endif "%s", _(message)); #if GTK_CHECK_VERSION(2, 10, 0) gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(panel->sh_window), gtk_image_new_from_icon_name("gnome-shutdown", GTK_ICON_SIZE_DIALOG)); #endif gtk_dialog_add_buttons(GTK_DIALOG(panel->sh_window), GTK_STOCK_CANCEL, RES_CANCEL, _("Restart"), RES_REBOOT, NULL); widget = gtk_button_new_with_label(_("Shutdown")); gtk_button_set_image(GTK_BUTTON(widget), gtk_image_new_from_icon_name( "gnome-shutdown", GTK_ICON_SIZE_BUTTON)); gtk_widget_show_all(widget); gtk_dialog_add_action_widget(GTK_DIALOG(panel->sh_window), widget, RES_SHUTDOWN); gtk_window_set_keep_above(GTK_WINDOW(panel->sh_window), TRUE); gtk_window_set_position(GTK_WINDOW(panel->sh_window), GTK_WIN_POS_CENTER); gtk_window_set_title(GTK_WINDOW(panel->sh_window), _("Shutdown")); g_signal_connect(panel->sh_window, "delete-event", G_CALLBACK( _shutdown_dialog_on_closex), panel); g_signal_connect(panel->sh_window, "response", G_CALLBACK( _shutdown_dialog_on_response), panel); gtk_widget_show_all(panel->sh_window); }
void mixer_properties(Mixer * mixer) { GtkSizeGroup * group; GtkWidget * vbox; GtkWidget * hbox; MixerProperties mp; if(mixer->properties != NULL) { gtk_widget_show(mixer->properties); return; } if(mixer_get_properties(mixer, &mp) != 0) return; mixer->properties = gtk_message_dialog_new(GTK_WINDOW(mixer->window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, #if GTK_CHECK_VERSION(2, 6, 0) "%s", _("Properties")); gtk_message_dialog_format_secondary_text( GTK_MESSAGE_DIALOG(mixer->properties), #endif ""); #if GTK_CHECK_VERSION(2, 10, 0) gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(mixer->properties), gtk_image_new_from_icon_name("gtk-properties", GTK_ICON_SIZE_DIALOG)); #endif gtk_window_set_title(GTK_WINDOW(mixer->properties), _("Properties")); g_signal_connect(mixer->properties, "delete-event", G_CALLBACK( _properties_on_closex), NULL); g_signal_connect(mixer->properties, "response", G_CALLBACK( gtk_widget_hide), NULL); #if GTK_CHECK_VERSION(2, 14, 0) vbox = gtk_dialog_get_content_area(GTK_DIALOG(mixer->properties)); #else vbox = GTK_DIALOG(mixer->properties)->vbox; #endif group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); hbox = _properties_label(mixer, group, _("Name: "), mp.name); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 2); hbox = _properties_label(mixer, group, _("Version: "), mp.version); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); hbox = _properties_label(mixer, group, _("Device: "), mp.device); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 2); gtk_widget_show_all(vbox); gtk_widget_show(mixer->properties); }
static void _panel_helper_lock_dialog(Panel * panel) { #ifdef EMBEDDED const char message[] = N_("This will lock your device.\n" "Do you really want to proceed?"); #else const char message[] = N_("This will lock your session.\n" "Do you really want to proceed?"); #endif GtkWidget * widget; if(panel->lk_window != NULL) { gtk_window_present(GTK_WINDOW(panel->lk_window)); return; } panel->lk_window = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", #if GTK_CHECK_VERSION(2, 6, 0) _("Shutdown")); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG( panel->lk_window), #endif "%s", _(message)); #if GTK_CHECK_VERSION(2, 10, 0) gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(panel->lk_window), gtk_image_new_from_icon_name("gnome-lockscreen", GTK_ICON_SIZE_DIALOG)); #endif gtk_dialog_add_buttons(GTK_DIALOG(panel->lk_window), GTK_STOCK_CANCEL, FALSE, NULL); widget = gtk_button_new_with_label(_("Lock")); gtk_button_set_image(GTK_BUTTON(widget), gtk_image_new_from_icon_name( "gnome-lockscreen", GTK_ICON_SIZE_BUTTON)); gtk_widget_show_all(widget); gtk_dialog_add_action_widget(GTK_DIALOG(panel->lk_window), widget, TRUE); gtk_window_set_keep_above(GTK_WINDOW(panel->lk_window), TRUE); gtk_window_set_position(GTK_WINDOW(panel->lk_window), GTK_WIN_POS_CENTER); gtk_window_set_title(GTK_WINDOW(panel->lk_window), _("Lock")); g_signal_connect(panel->lk_window, "delete-event", G_CALLBACK( _lock_dialog_on_closex), panel); g_signal_connect(panel->lk_window, "response", G_CALLBACK( _lock_dialog_on_response), panel); gtk_widget_show_all(panel->lk_window); }
static void _panel_helper_logout_dialog(Panel * panel) { const char message[] = N_("This will log you out of the current session" ", therefore closing any application currently opened" " and losing any unsaved data.\n" "Do you really want to proceed?"); GtkWidget * widget; if(panel->lo_window != NULL) { gtk_window_present(GTK_WINDOW(panel->lo_window)); return; } panel->lo_window = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, #if GTK_CHECK_VERSION(2, 6, 0) "%s", _("Logout")); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG( panel->lo_window), #endif "%s", _(message)); #if GTK_CHECK_VERSION(2, 10, 0) gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(panel->lo_window), gtk_image_new_from_icon_name("gnome-logout", GTK_ICON_SIZE_DIALOG)); #endif gtk_dialog_add_buttons(GTK_DIALOG(panel->lo_window), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); widget = gtk_button_new_with_label(_("Logout")); gtk_button_set_image(GTK_BUTTON(widget), gtk_image_new_from_icon_name( "gnome-logout", GTK_ICON_SIZE_BUTTON)); gtk_widget_show_all(widget); gtk_dialog_add_action_widget(GTK_DIALOG(panel->lo_window), widget, GTK_RESPONSE_ACCEPT); gtk_window_set_keep_above(GTK_WINDOW(panel->lo_window), TRUE); gtk_window_set_position(GTK_WINDOW(panel->lo_window), GTK_WIN_POS_CENTER); gtk_window_set_title(GTK_WINDOW(panel->lo_window), _("Logout")); g_signal_connect_swapped(panel->lo_window, "delete-event", G_CALLBACK( _logout_dialog_on_closex), panel); g_signal_connect(panel->lo_window, "response", G_CALLBACK( _logout_dialog_on_response), panel); gtk_widget_show_all(panel->lo_window); }
static void power_action(const PowerActionData* action) { g_return_if_fail(config.power.enabled && action->get_allow()); if(*action->show_prompt_ptr) { GtkWidget* dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", _(action->prompt)); gtk_dialog_add_buttons(GTK_DIALOG(dialog), _("Return to Login"), GTK_RESPONSE_CANCEL, _(action->name), GTK_RESPONSE_OK, NULL); gtk_widget_set_name(dialog, "power_dialog"); gtk_window_set_title(GTK_WINDOW(dialog), action->name); setup_window(GTK_WINDOW(dialog)); if(action->icon && gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), action->icon)) { GtkWidget* image = gtk_image_new_from_icon_name(action->icon, GTK_ICON_SIZE_DIALOG); gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(dialog), image); } gtk_widget_hide(greeter.ui.login_window); gtk_widget_set_sensitive(greeter.ui.power.widget, FALSE); gtk_widget_show_all(dialog); set_window_position(dialog, &WINDOW_POSITION_CENTER); gboolean result = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK; gtk_widget_destroy(dialog); gtk_widget_show(greeter.ui.login_window); update_windows_layout(); gtk_widget_set_sensitive(greeter.ui.power.widget, TRUE); if(!result) return; } GError* error = NULL; if(!action->do_action(&error) && error) { g_warning("Action \"%s\" failed with error: %s.", action->name, error->message); show_error(_(action->name), _("Action \"%s\" failed with error: %s."), _(action->name), error->message); g_clear_error(&error); } }
static void show_message_dialog1a (GtkWindow *parent) { GtkWidget *dialog; GtkWidget *image; dialog = GTK_WIDGET (gtk_message_dialog_new (parent, GTK_DIALOG_MODAL| GTK_DIALOG_DESTROY_WITH_PARENT| GTK_DIALOG_USE_HEADER_BAR, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "The system network services are not compatible with this version.")); image = gtk_image_new_from_icon_name ("computer-fail", GTK_ICON_SIZE_DIALOG); gtk_widget_show (image); gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); }
static void empathy_password_dialog_constructed (GObject *object) { EmpathyPasswordDialog *dialog; EmpathyPasswordDialogPriv *priv; TpAccount *account; GtkWidget *icon; GtkBox *box; gchar *text; dialog = EMPATHY_PASSWORD_DIALOG (object); priv = dialog->priv; g_assert (priv->handler != NULL); priv->grabbing = FALSE; account = empathy_server_sasl_handler_get_account (priv->handler); tp_g_signal_connect_object (priv->handler, "invalidated", G_CALLBACK (password_dialog_handler_invalidated_cb), object, 0); /* dialog */ gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); priv->ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_OK); gtk_widget_set_sensitive (priv->ok_button, FALSE); text = g_strdup_printf (_("Enter your password for account\n<b>%s</b>"), tp_account_get_display_name (account)); gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), text); g_free (text); gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_DIALOG_AUTHENTICATION); box = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))); /* dialog icon */ icon = gtk_image_new_from_icon_name (tp_account_get_icon_name (account), GTK_ICON_SIZE_DIALOG); gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), icon); gtk_widget_show (icon); /* entry */ priv->entry = gtk_entry_new (); gtk_entry_set_visibility (GTK_ENTRY (priv->entry), FALSE); /* entry clear icon */ gtk_entry_set_icon_from_stock (GTK_ENTRY (priv->entry), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR); gtk_entry_set_icon_sensitive (GTK_ENTRY (priv->entry), GTK_ENTRY_ICON_SECONDARY, FALSE); g_signal_connect (priv->entry, "icon-release", G_CALLBACK (clear_icon_released_cb), NULL); g_signal_connect (priv->entry, "changed", G_CALLBACK (password_entry_changed_cb), dialog); g_signal_connect (priv->entry, "activate", G_CALLBACK (password_entry_activate_cb), dialog); gtk_box_pack_start (box, priv->entry, FALSE, FALSE, 0); gtk_widget_show (priv->entry); /* remember password ticky box */ priv->ticky = gtk_check_button_new_with_label (_("Remember password")); gtk_box_pack_start (box, priv->ticky, FALSE, FALSE, 0); /* only show it if we actually support it */ if (empathy_server_sasl_handler_can_save_response_somewhere (priv->handler)) gtk_widget_show (priv->ticky); g_signal_connect (dialog, "response", G_CALLBACK (password_dialog_response_cb), dialog); g_signal_connect (dialog, "window-state-event", G_CALLBACK (password_dialog_window_state_changed), dialog); g_signal_connect (dialog, "map-event", G_CALLBACK (password_dialog_grab_keyboard), dialog); g_signal_connect (dialog, "unmap-event", G_CALLBACK (password_dialog_ungrab_keyboard), dialog); gtk_widget_grab_focus (priv->entry); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS); }
/* * Block contact dialog */ gboolean empathy_block_individual_dialog_show (GtkWindow *parent, FolksIndividual *individual, GdkPixbuf *avatar, gboolean *abusive) { GtkWidget *dialog; GtkWidget *abusive_check = NULL; GeeSet *personas; GeeIterator *iter; GString *text = g_string_new (""); GString *blocked_str = g_string_new (""); GString *notblocked_str = g_string_new (""); guint npersonas_blocked = 0, npersonas_notblocked = 0; gboolean can_report_abuse = FALSE; int res; dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, _("Block %s?"), folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual))); if (avatar != NULL) { GtkWidget *image = gtk_image_new_from_pixbuf (avatar); gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image); gtk_widget_show (image); } /* build a list of personas that support blocking */ personas = folks_individual_get_personas (individual); iter = gee_iterable_iterator (GEE_ITERABLE (personas)); while (gee_iterator_next (iter)) { TpfPersona *persona = gee_iterator_get (iter); TpContact *contact; GString *s; char *str; TpConnection *conn; if (!TPF_IS_PERSONA (persona)) goto while_finish; contact = tpf_persona_get_contact (persona); if (contact == NULL) goto while_finish; conn = tp_contact_get_connection (contact); if (tp_proxy_has_interface_by_id (conn, TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING)) { s = blocked_str; npersonas_blocked++; } else { s = notblocked_str; npersonas_notblocked++; } if (tp_connection_can_report_abusive (conn)) can_report_abuse = TRUE; str = contact_pretty_name (contact); g_string_append_printf (s, "\n " BULLET_POINT " %s", str); g_free (str); while_finish: g_clear_object (&persona); } g_clear_object (&iter); g_string_append_printf (text, _("Are you sure you want to block '%s' from contacting you again?"), folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual))); if (npersonas_blocked > 0) g_string_append_printf (text, "\n\n%s\n%s", ngettext ("The following identity will be blocked:", "The following identities will be blocked:", npersonas_blocked), blocked_str->str); if (npersonas_notblocked > 0) g_string_append_printf (text, "\n\n%s\n%s", ngettext ("The following identity can not be blocked:", "The following identities can not be blocked:", npersonas_notblocked), notblocked_str->str); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", text->str); gtk_dialog_add_buttons (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("_Block"), GTK_RESPONSE_REJECT, NULL); if (can_report_abuse) { GtkWidget *vbox; vbox = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog)); abusive_check = gtk_check_button_new_with_mnemonic ( ngettext ("_Report this contact as abusive", "_Report these contacts as abusive", npersonas_blocked)); gtk_box_pack_start (GTK_BOX (vbox), abusive_check, FALSE, TRUE, 0); gtk_widget_show (abusive_check); } g_string_free (text, TRUE); g_string_free (blocked_str, TRUE); g_string_free (notblocked_str, TRUE); res = gtk_dialog_run (GTK_DIALOG (dialog)); if (abusive != NULL) { if (abusive_check != NULL) *abusive = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON (abusive_check)); else *abusive = FALSE; } gtk_widget_destroy (dialog); return res == GTK_RESPONSE_REJECT; }
/** * main: **/ int main (int argc, char **argv) { CdClient *client = NULL; CdProfile *profile_tmp = NULL; const gchar *copyright; const gchar *description; const gchar *title; const gchar *lang; gboolean ret; gchar **files = NULL; CdIcc *icc = NULL; GError *error = NULL; GFile *destination = NULL; GFile *file = NULL; GOptionContext *context; GString *string = NULL; GtkResponseType response; GtkWidget *image = NULL; GtkWidget *dialog; guint retval = 1; const GOptionEntry options[] = { { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &files, /* TRANSLATORS: command line option: a list of catalogs to install */ _("ICC profile to install"), NULL }, { NULL} }; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); gtk_init (&argc, &argv); context = g_option_context_new ("gnome-color-manager import program"); g_option_context_add_main_entries (context, options, NULL); g_option_context_add_group (context, gcm_debug_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_parse (context, &argc, &argv, NULL); g_option_context_free (context); /* nothing sent */ if (files == NULL) { /* TRANSLATORS: nothing was specified on the command line */ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("No filename specified")); gtk_window_set_icon_name (GTK_WINDOW (dialog), GCM_STOCK_ICON); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); goto out; } /* load profile */ icc = cd_icc_new (); file = g_file_new_for_path (files[0]); ret = cd_icc_load_file (icc, file, CD_ICC_LOAD_FLAGS_FALLBACK_MD5, NULL, &error); if (!ret) { /* TRANSLATORS: could not read file */ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Failed to open ICC profile")); gtk_window_set_icon_name (GTK_WINDOW (dialog), GCM_STOCK_ICON); /* TRANSLATORS: parsing error */ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), _("Failed to parse file: %s"), error->message); gtk_dialog_run (GTK_DIALOG (dialog)); g_error_free (error); gtk_widget_destroy (dialog); goto out; } /* get data */ lang = g_getenv ("LANG"); description = cd_icc_get_description (icc, lang, NULL); copyright = cd_icc_get_copyright (icc, lang, NULL); /* use the same icon as the color control panel */ image = gtk_image_new_from_icon_name ("preferences-color", GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); gtk_widget_show (image); /* create message */ string = g_string_new (""); /* TRANSLATORS: message text */ g_string_append_printf (string, _("Profile description: %s"), description != NULL ? description : files[0]); /* add copyright */ if (copyright != NULL) { if (g_str_has_prefix (copyright, "Copyright ")) copyright += 10; if (g_str_has_prefix (copyright, "Copyright, ")) copyright += 11; /* TRANSLATORS: message text */ g_string_append_printf (string, "\n%s %s", _("Profile copyright:"), copyright); } /* check file does't already exist as system-wide */ client = cd_client_new (); ret = cd_client_connect_sync (client, NULL, &error); if (!ret) { g_warning ("failed to connect to colord: %s", error->message); g_error_free (error); goto out; } profile_tmp = cd_client_find_profile_by_property_sync (client, CD_PROFILE_METADATA_FILE_CHECKSUM, cd_icc_get_checksum (icc), NULL, NULL); if (profile_tmp != NULL) { ret = cd_profile_connect_sync (profile_tmp, NULL, &error); if (!ret) { g_warning ("failed to connect to profile %s: %s", cd_profile_get_object_path (profile_tmp), error->message); g_error_free (error); goto out; } /* TRANSLATORS: color profile already been installed */ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, _("Color profile is already imported")); gtk_window_set_icon_name (GTK_WINDOW (dialog), GCM_STOCK_ICON); gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", string->str); gtk_dialog_add_button (GTK_DIALOG (dialog), _("Show Details"), GTK_RESPONSE_HELP); response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response == GTK_RESPONSE_HELP) { gcm_import_show_details (GTK_WINDOW (dialog), TRUE, cd_profile_get_id (profile_tmp)); goto try_harder; } gtk_widget_destroy (dialog); goto out; } /* get correct title */ switch (cd_icc_get_kind (icc)) { case CD_PROFILE_KIND_DISPLAY_DEVICE: /* TRANSLATORS: the profile type */ title = _("Import display color profile?"); break; case CD_PROFILE_KIND_OUTPUT_DEVICE: /* TRANSLATORS: the profile type */ title = _("Import device color profile?"); break; case CD_PROFILE_KIND_NAMED_COLOR: /* TRANSLATORS: the profile type */ title = _("Import named color profile?"); break; default: /* TRANSLATORS: the profile type */ title = _("Import color profile?"); break; } /* ask confirmation */ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_CANCEL, "%s", title); gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image); gtk_window_set_icon_name (GTK_WINDOW (dialog), GCM_STOCK_ICON); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", string->str); /* TRANSLATORS: button text */ gtk_dialog_add_button (GTK_DIALOG (dialog), _("Import"), GTK_RESPONSE_OK); gtk_dialog_add_button (GTK_DIALOG (dialog), _("Show Details"), GTK_RESPONSE_HELP); try_harder: response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response == GTK_RESPONSE_HELP) { gcm_import_show_details (GTK_WINDOW (dialog), FALSE, files[0]); goto try_harder; } gtk_widget_destroy (dialog); /* not the correct response */ if (response != GTK_RESPONSE_OK) goto out; /* copy icc file to users profile path */ profile_tmp = cd_client_import_profile_sync (client, file, NULL, &error); if (profile_tmp == NULL) { /* TRANSLATORS: could not read file */ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Failed to import file")); gtk_window_set_icon_name (GTK_WINDOW (dialog), GCM_STOCK_ICON); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message); gtk_dialog_run (GTK_DIALOG (dialog)); g_error_free (error); gtk_widget_destroy (dialog); goto out; } out: if (file != NULL) g_object_unref (file); if (string != NULL) g_string_free (string, TRUE); if (icc != NULL) g_object_unref (icc); if (client != NULL) g_object_unref (client); if (profile_tmp != NULL) g_object_unref (profile_tmp); if (destination != NULL) g_object_unref (destination); g_strfreev (files); return retval; }
static gboolean handle_access_dialog (XdpImplAccess *object, GDBusMethodInvocation *invocation, const char *arg_handle, const char *arg_app_id, const char *arg_parent_window, const char *arg_title, const char *arg_subtitle, const char *arg_body, GVariant *arg_options) { g_autoptr(Request) request = NULL; const char *sender; AccessDialogHandle *handle; g_autoptr(GError) error = NULL; g_autofree char *filename = NULL; gboolean modal; GtkWidget *dialog; GdkWindow *foreign_parent = NULL; const char *deny_label; const char *grant_label; const char *icon; g_autoptr(GVariant) choices = NULL; GtkWidget *area; GtkWidget *image; GHashTable *choice_table = NULL; sender = g_dbus_method_invocation_get_sender (invocation); request = request_new (sender, arg_app_id, arg_handle); if (!g_variant_lookup (arg_options, "modal", "b", &modal)) modal = TRUE; if (!g_variant_lookup (arg_options, "deny_label", "&s", &deny_label)) deny_label = _("Deny Access"); if (!g_variant_lookup (arg_options, "grant_label", "&s", &grant_label)) grant_label = _("Grant Access"); if (!g_variant_lookup (arg_options, "icon", "&s", &icon)) icon = NULL; choices = g_variant_lookup_value (arg_options, "choices", G_VARIANT_TYPE ("a(ssa(ss)s)")); dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, arg_title, NULL); gtk_window_set_modal (GTK_WINDOW (dialog), modal); gtk_dialog_add_button (GTK_DIALOG (dialog), deny_label, GTK_RESPONSE_CANCEL); gtk_dialog_add_button (GTK_DIALOG (dialog), grant_label, GTK_RESPONSE_OK); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", arg_subtitle); area = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog)); fix_up_label_alignment (area); if (choices) { int i; choice_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); for (i = 0; i < g_variant_n_children (choices); i++) add_choice (area, g_variant_get_child_value (choices, i), choice_table); } if (!g_str_equal (arg_body, "")) { GtkWidget *body_label; body_label = gtk_label_new (arg_body); gtk_widget_set_halign (body_label, GTK_ALIGN_START); g_object_set (body_label, "margin-top", 10, NULL); gtk_label_set_xalign (GTK_LABEL (body_label), 0); gtk_label_set_line_wrap (GTK_LABEL (body_label), TRUE); gtk_label_set_max_width_chars (GTK_LABEL (body_label), 50); gtk_widget_show (body_label); gtk_container_add (GTK_CONTAINER (area), body_label); } image = gtk_image_new_from_icon_name (icon ? icon : "image-missing", GTK_ICON_SIZE_DIALOG); gtk_widget_set_opacity (image, icon ? 1.0 : 0.0); gtk_widget_show (image); G_GNUC_BEGIN_IGNORE_DEPRECATIONS gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image); G_GNUC_END_IGNORE_DEPRECATIONS #ifdef GDK_WINDOWING_X11 if (g_str_has_prefix (arg_parent_window, "x11:")) { int xid; if (sscanf (arg_parent_window, "x11:%x", &xid) != 1) g_warning ("invalid xid"); else foreign_parent = gdk_x11_window_foreign_new_for_display (gtk_widget_get_display (dialog), xid); } #endif else g_warning ("Unhandled parent window type %s", arg_parent_window); handle = g_new0 (AccessDialogHandle, 1); handle->impl = object; handle->invocation = invocation; handle->request = g_object_ref (request); handle->dialog = g_object_ref (dialog); handle->choices = choice_table; g_signal_connect (request, "handle-close", G_CALLBACK (handle_close), handle); g_signal_connect (dialog, "response", G_CALLBACK (access_dialog_response), handle); gtk_widget_realize (dialog); if (foreign_parent) gdk_window_set_transient_for (gtk_widget_get_window (dialog), foreign_parent); gtk_widget_show (dialog); request_export (request, g_dbus_method_invocation_get_connection (invocation)); return TRUE; }
static void present_autorun_for_software_dialog (GMount *mount) { GIcon *icon; int icon_size; CajaIconInfo *icon_info; GdkPixbuf *pixbuf; GtkWidget *image; char *mount_name; GtkWidget *dialog; AutorunSoftwareDialogData *data; mount_name = g_mount_get_name (mount); dialog = gtk_message_dialog_new_with_markup (NULL, /* TODO: parent window? */ 0, GTK_MESSAGE_OTHER, GTK_BUTTONS_CANCEL, _("<big><b>This medium contains software intended to be automatically started. Would you like to run it?</b></big>")); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), _("The software will run directly from the medium \"%s\". " "You should never run software that you don't trust.\n" "\n" "If in doubt, press Cancel."), mount_name); /* TODO: in a star trek future add support for verifying * software on media (e.g. if it has a certificate, check it * etc.) */ icon = g_mount_get_icon (mount); icon_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_DIALOG); icon_info = caja_icon_info_lookup (icon, icon_size); pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info, icon_size); image = gtk_image_new_from_pixbuf (pixbuf); gtk_widget_set_halign (image, GTK_ALIGN_CENTER); gtk_widget_set_valign (image, GTK_ALIGN_START); gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image); gtk_window_set_title (GTK_WINDOW (dialog), mount_name); gtk_window_set_icon (GTK_WINDOW (dialog), pixbuf); data = g_new0 (AutorunSoftwareDialogData, 1); data->dialog = dialog; data->mount = g_object_ref (mount); g_signal_connect (G_OBJECT (mount), "unmounted", G_CALLBACK (autorun_software_dialog_mount_unmounted), data); gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Run"), GTK_RESPONSE_OK); gtk_widget_show_all (dialog); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) { gtk_widget_destroy (dialog); autorun (mount); } g_object_unref (icon_info); g_object_unref (pixbuf); g_free (mount_name); }
static void remmina_tp_channel_handler_get_contacts(TpConnection *connection, guint n_contacts, TpContact * const *contacts, guint n_failed, const TpHandle *failed, const GError *error, gpointer user_data, GObject *weak_object) { RemminaTpChannelHandler *chandler = (RemminaTpChannelHandler *) user_data; TpContact *contact; gchar *token; gchar *cm; gchar *protocol; gchar *filename; GdkPixbuf *pixbuf; GtkWidget *image; GtkWidget *dialog; if (error != NULL) { g_print("remmina_tp_channel_handler_get_contacts: %s", error->message); remmina_tp_channel_handler_free(chandler); return; } if (n_contacts <= 0) { g_print("remmina_tp_channel_handler_get_contacts: no contacts\n"); remmina_tp_channel_handler_free(chandler); return; } contact = contacts[0]; chandler->alias = g_strdup(tp_contact_get_alias(contact)); dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, _("%s wants to share his/her desktop.\nDo you accept the invitation?"), chandler->alias); g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(remmina_tp_channel_handler_on_response), chandler); g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(gtk_widget_destroy), NULL); gtk_window_set_title(GTK_WINDOW(dialog), _("Desktop sharing invitation")); remmina_plugin_telepathy_service->ui_register(dialog); gtk_widget_show(dialog); token = (gchar *) tp_contact_get_avatar_token(contact); if (token == NULL) { return; } if (!tp_connection_parse_object_path(chandler->connection, &protocol, &cm)) { g_print("tp_connection_parse_object_path: failed\n"); return; } token = tp_escape_as_identifier(token); filename = g_build_filename(g_get_user_cache_dir(), "telepathy", "avatars", cm, protocol, token, NULL); g_free(cm); g_free(protocol); g_free(token); if (g_file_test(filename, G_FILE_TEST_EXISTS)) { pixbuf = gdk_pixbuf_new_from_file(filename, NULL); if (pixbuf) { image = gtk_image_new_from_pixbuf(pixbuf); gtk_widget_show(image); g_object_unref(pixbuf); gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(dialog), image); } } g_free(filename); }
static void _properties_window(Camera * camera) { GtkWidget * dialog; GtkSizeGroup * group; GtkWidget * vbox; GtkWidget * hbox; char buf[64]; const struct { unsigned int capability; char const * name; } capabilities[] = { { V4L2_CAP_VIDEO_CAPTURE, "capture" }, { V4L2_CAP_VIDEO_OUTPUT, "output" }, { V4L2_CAP_VIDEO_OVERLAY, "overlay" }, { V4L2_CAP_TUNER, "tuner" }, { V4L2_CAP_AUDIO, "audio" }, { V4L2_CAP_STREAMING, "streaming" }, { 0, NULL } }; unsigned int i; char const * sep = ""; dialog = gtk_message_dialog_new(GTK_WINDOW(camera->window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, #if GTK_CHECK_VERSION(2, 6, 0) "%s", _("Properties")); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), #endif ""); camera->pp_window = dialog; #if GTK_CHECK_VERSION(2, 10, 0) gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(dialog), gtk_image_new_from_stock(GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_DIALOG)); #endif gtk_window_set_title(GTK_WINDOW(dialog), _("Properties")); g_signal_connect_swapped(dialog, "response", G_CALLBACK( _properties_on_response), camera); group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); #if GTK_CHECK_VERSION(2, 14, 0) vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); #else vbox = dialog->vbox; #endif /* driver */ snprintf(buf, sizeof(buf), "%-16s", (char *)camera->cap.driver); hbox = _properties_label(camera, group, _("Driver: "), buf); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* card */ snprintf(buf, sizeof(buf), "%-32s", (char *)camera->cap.card); hbox = _properties_label(camera, group, _("Card: "), buf); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* bus info */ snprintf(buf, sizeof(buf), "%-32s", (char *)camera->cap.bus_info); hbox = _properties_label(camera, group, _("Bus info: "), buf); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* version */ snprintf(buf, sizeof(buf), "0x%x", camera->cap.version); hbox = _properties_label(camera, group, _("Version: "), buf); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* capabilities */ buf[0] = '\0'; for(i = 0; capabilities[i].name != NULL; i++) if(camera->cap.capabilities & capabilities[i].capability) { strncat(buf, sep, sizeof(buf) - strlen(buf)); strncat(buf, capabilities[i].name, sizeof(buf) - strlen(buf)); sep = ", "; } buf[sizeof(buf) - 1] = '\0'; hbox = _properties_label(camera, group, _("Capabilities: "), buf); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); gtk_widget_show_all(vbox); }