/** * totem_interface_error_with_link: * @title: the error title * @reason: the error reason (secondary text) * @uri: the URI to open * @label: a label for the URI's button, or %NULL to use @uri as the label * @parent: the error dialogue's parent #GtkWindow * * Display a modal error dialogue like totem_interface_error(), * but add a button which will open @uri in a browser window. **/ void totem_interface_error_with_link (const char *title, const char *reason, const char *uri, const char *label, GtkWindow *parent) { GtkWidget *error_dialog, *link_button, *hbox; if (label == NULL) label = uri; error_dialog = totem_interface_error_dialog (title, reason, parent); link_button = gtk_link_button_new_with_label (uri, label); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE); gtk_box_pack_start (GTK_BOX (hbox), link_button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (error_dialog))), hbox, TRUE, FALSE, 0); gtk_widget_show_all (hbox); gtk_dialog_set_default_response (GTK_DIALOG (error_dialog), GTK_RESPONSE_OK); g_signal_connect (G_OBJECT (error_dialog), "response", G_CALLBACK (gtk_widget_destroy), error_dialog); gtk_window_present (GTK_WINDOW (error_dialog)); }
void lmplayer_interface_error_with_link (const char *title, const char *reason, const char *uri, const char *label, GtkWindow *parent, LmplayerObject *lmplayer) { GtkWidget *error_dialog, *link_button, *hbox; if (label == NULL) label = uri; error_dialog = lmplayer_interface_error_dialog (title, reason, parent); link_button = gtk_link_button_new_with_label (uri, label); g_signal_connect (G_OBJECT (link_button), "clicked", G_CALLBACK (link_button_clicked_cb), lmplayer); hbox = gtk_hbox_new (TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), link_button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (error_dialog)->vbox), hbox, TRUE, FALSE, 0); gtk_dialog_set_default_response (GTK_DIALOG (error_dialog), GTK_RESPONSE_OK); g_signal_connect (G_OBJECT (error_dialog), "destroy", G_CALLBACK (gtk_widget_destroy), error_dialog); g_signal_connect (G_OBJECT (error_dialog), "response", G_CALLBACK (gtk_widget_destroy), error_dialog); gtk_window_set_modal (GTK_WINDOW (error_dialog), TRUE); gtk_widget_show_all (error_dialog); }
GtkWidget* title_formatting_help_link_create (gchar *widget_name, gchar *string1, gchar *string2, gint int1, gint int2) { GtkWidget *link = gtk_link_button_new_with_label ("http://github.com/Alexey-Yakovenko/deadbeef/wiki/Title-formatting-2.0", "Help"); return link; }
GtkWidget* title_formatting_help_link_create (gchar *widget_name, gchar *string1, gchar *string2, gint int1, gint int2) { GtkWidget *link = gtk_link_button_new_with_label ("http://github.com/DeaDBeeF-Player/deadbeef/wiki/Title-formatting-2.0", _("Help")); return link; }
GtkWidget* create_plugin_weblink (gchar *widget_name, gchar *string1, gchar *string2, gint int1, gint int2) { GtkWidget *link = gtk_link_button_new_with_label ("", "WWW"); gtk_widget_set_sensitive (link, FALSE); return link; }
static WidgetInfo * create_link_button (void) { GtkWidget *widget; widget = gtk_link_button_new_with_label ("http://www.gtk.org", "Link Button"); gtk_widget_set_halign (widget, GTK_ALIGN_CENTER); gtk_widget_set_valign (widget, GTK_ALIGN_CENTER); return new_widget_info ("link-button", widget, SMALL); }
static WidgetInfo * create_link_button (void) { GtkWidget *widget; GtkWidget *align; widget = gtk_link_button_new_with_label ("http://www.gtk.org", "Link Button"); align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); gtk_container_add (GTK_CONTAINER (align), widget); return new_widget_info ("link-button", align, SMALL); }
static VALUE rg_initialize(int argc, VALUE *argv, VALUE self) { VALUE uri, label; GtkWidget *widget = NULL; rb_scan_args(argc, argv, "11", &uri, &label); if (NIL_P(label)){ widget = gtk_link_button_new(RVAL2CSTR(uri)); } else { widget = gtk_link_button_new_with_label(RVAL2CSTR(uri), RVAL2CSTR(label)); } RBGTK_INITIALIZE(self, widget); return Qnil; }
int main(int argc, char *argv[]) { gtk_init(&argc, &argv); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(window, "destroy", G_CALLBACK(destroy), NULL); GtkWidget *linkbutton = gtk_link_button_new_with_label("http://learngtk.org/", "Link Button"); gtk_container_add(GTK_CONTAINER(window), linkbutton); gtk_widget_show_all(window); gtk_main(); return 0; }
GtkWidget * blog_add_widget () { gchar *url; GtkWidget *wid, *button; wid = gtk_vbox_new (TRUE, TRUE); url = g_strdup_printf ("https://graph.renren.com/oauth/authorize?client_id=%s&scope=publish_blog&response_type=token&redirect_uri=http://graph.renren.com/oauth/login_success.html", renren_api_key); button = gtk_link_button_new_with_label (url, _ ("Get renren token")); g_free (url); g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (renren_get_token_cb), wid); gtk_box_pack_start (GTK_BOX (wid), button, FALSE, FALSE, 2); return wid; }
static void fit_contents_list (OGDObject *obj, gpointer container) { GtkWidget *contents; GtkWidget *link; OGDContent *con; contents = (GtkWidget*) container; if (obj == NULL) { gtk_statusbar_pop (GTK_STATUSBAR (mainStatus), 2); return; } con = OGD_CONTENT (obj); link = gtk_link_button_new_with_label (ogd_content_get_homepage (con), ogd_content_get_name (con)); gtk_box_pack_end_defaults (GTK_BOX (contents), link); gtk_widget_show (link); }
static void gt_settings_dlg_init(GtSettingsDlg* self) { GtSettingsDlgPrivate* priv = gt_settings_dlg_get_instance_private(self); //So it's not optimised away volatile gpointer type = (gpointer) PEAS_GTK_TYPE_PLUGIN_MANAGER; gtk_widget_init_template(GTK_WIDGET(self)); gtk_widget_show_all(priv->players_view); GtkWidget* header_bar = gtk_dialog_get_header_bar(GTK_DIALOG(self)); gtk_header_bar_set_custom_title(GTK_HEADER_BAR(header_bar), priv->settings_switcher); /* NOTE: This is a hack to show a label at the bottom of the dialogue*/ GList* children = gtk_container_get_children(GTK_CONTAINER(priv->players_view)); GtkToolbar* toolbar = GTK_TOOLBAR(g_list_nth(children, 1)->data); GtkToolItem* item = gtk_tool_item_new(); gtk_container_add(GTK_CONTAINER(item), gtk_link_button_new_with_label( "https://github.com/vinszent/gnome-twitch/wiki/How-to-install-player-backends", _("How to install player backends"))); gtk_widget_show_all(GTK_WIDGET(item)); gtk_toolbar_insert(toolbar, item, 0); g_list_free(children); g_settings_bind(main_app->settings, "prefer-dark-theme", priv->prefer_dark_theme_button, "active", G_SETTINGS_BIND_DEFAULT); g_settings_bind(main_app->settings, "default-quality", priv->quality_combo, "active-id", G_SETTINGS_BIND_DEFAULT); g_settings_bind(main_app->settings, "language-filter", priv->language_filter_combo, "active-id", G_SETTINGS_BIND_DEFAULT); g_settings_bind(main_app->settings, "show-notifications", priv->notifications_switch, "active", G_SETTINGS_BIND_DEFAULT); }
static void refresh_widget (NemoExtensionConfigWidget *widget) { if (widget->current_extensions != NULL) { g_list_free_full (widget->current_extensions, (GDestroyNotify) extension_proxy_free); widget->current_extensions = NULL; } nemo_config_base_widget_clear_list (NEMO_CONFIG_BASE_WIDGET (widget)); detect_extensions (widget); if (widget->current_extensions == NULL) { GtkWidget *empty_label = gtk_label_new (NULL); gchar *markup = NULL; markup = g_strdup_printf ("<i>%s</i>", _("No extensions found")); gtk_label_set_markup (GTK_LABEL (empty_label), markup); g_free (markup); GtkWidget *empty_row = gtk_list_box_row_new (); gtk_container_add (GTK_CONTAINER (empty_row), empty_label); gtk_widget_show_all (empty_row); gtk_container_add (GTK_CONTAINER (NEMO_CONFIG_BASE_WIDGET (widget)->listbox), empty_row); gtk_widget_set_sensitive (GTK_WIDGET (NEMO_CONFIG_BASE_WIDGET (widget)->listbox), FALSE); } else { GtkSizeGroup *row_group, *name_group; GList *l; gchar **blacklist = g_settings_get_strv (nemo_plugin_preferences, NEMO_PLUGIN_PREFERENCES_DISABLED_EXTENSIONS); row_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); name_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); for (l = widget->current_extensions; l != NULL; l=l->next) { gchar *markup; ExtensionProxy *proxy = l->data; gboolean active = TRUE; guint i = 0; for (i = 0; i < g_strv_length (blacklist); i++) { if (g_strcmp0 (blacklist[i], proxy->name) == 0) { active = FALSE; break; } } GtkWidget *w; GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); GtkWidget *button = gtk_check_button_new (); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), active); g_signal_connect (button, "toggled", G_CALLBACK (on_check_toggled), proxy); gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 2); w = gtk_label_new (NULL); markup = NULL; if (proxy->display_name == NULL) markup = g_strdup_printf ("<b>%s</b>", proxy->name); else markup = g_strdup_printf ("<b>%s</b>", proxy->display_name); gtk_label_set_markup (GTK_LABEL (w), markup); gtk_label_set_xalign (GTK_LABEL (w), 0.0); g_clear_pointer (&markup, g_free); gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0); gtk_size_group_add_widget (name_group, w); w = gtk_label_new (NULL); if (proxy->display_name == NULL) markup = g_strdup (_("no information available")); else markup = g_strdup_printf ("%s", proxy->desc); gtk_label_set_markup (GTK_LABEL (w), markup); g_clear_pointer (&markup, g_free); gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 6); if (proxy->config_exec != NULL) { button = gtk_link_button_new_with_label ("uri://dummy", _("Configure")); g_signal_connect (button, "activate-link", G_CALLBACK (on_config_clicked), proxy); gtk_box_pack_end (GTK_BOX (box), button, FALSE, FALSE, 2); gtk_widget_set_tooltip_text (button, ""); } GtkWidget *row = gtk_list_box_row_new (); gtk_container_add (GTK_CONTAINER (row), box); gtk_size_group_add_widget (row_group, row); gtk_widget_show_all (row); gtk_container_add (GTK_CONTAINER (NEMO_CONFIG_BASE_WIDGET (widget)->listbox), row); } g_strfreev (blacklist); } update_restart_visiblity (widget); nemo_config_base_widget_set_default_buttons_sensitive (NEMO_CONFIG_BASE_WIDGET (widget), widget->current_extensions != NULL); }
void cd_rssreader_show_dialog (GldiModuleInstance *myApplet) { if (myData.pDialog != NULL) // on detruit le dialogue actuel. { gldi_object_unref (GLDI_OBJECT(myData.pDialog)); myData.pDialog = NULL; return; } gldi_dialogs_remove_on_icon (myIcon); // on enleve tout autre dialogue (message d'erreur). if (myData.pItemList != NULL && myData.pItemList->next != NULL && (myData.pItemList->next->next != NULL || ! myData.bError)) // on construit le dialogue contenant toutes les infos. { // On construit le widget GTK qui contient les lignes avec les liens. GtkWidget *pVBox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); // le widget qu'on va inserer dans le dialogue. GtkWidget *pScrolledWindow = gtk_scrolled_window_new (NULL, NULL); g_object_set (pScrolledWindow, "height-request", 250, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (pScrolledWindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); #if GTK_CHECK_VERSION (3, 8, 0) gtk_container_add (GTK_CONTAINER (pScrolledWindow), pVBox); #else gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (pScrolledWindow), pVBox); #endif PangoLayout *pLayout = pango_cairo_create_layout (myDrawContext); PangoFontDescription *fd = pango_font_description_from_string (""); pango_layout_set_font_description (pLayout, fd); int w = MIN (600, g_desktopGeometry.Xscreen.width / g_desktopGeometry.iNbScreens / 2); // we don't know on which screen is place the container... gchar *cLine; GtkWidget *pLinkButton, *pAlign; CDRssItem *pItem; GList *it; for (it = myData.pItemList->next; it != NULL; it = it->next) { pItem = it->data; if (pItem->cTitle == NULL) continue; cLine = g_strdup (pItem->cTitle); cd_rssreader_cut_line (cLine, pLayout, w); if (pItem->cLink != NULL) pLinkButton = gtk_link_button_new_with_label (pItem->cLink, cLine); else pLinkButton = gtk_label_new (cLine); g_free (cLine); pAlign = gtk_alignment_new (0., 0.5, 0., 0.); gtk_container_add (GTK_CONTAINER (pAlign), pLinkButton); gtk_box_pack_start (GTK_BOX (pVBox), pAlign, FALSE, FALSE, 0); if (pItem->cDescription != NULL) { cLine = g_strdup (pItem->cDescription); cd_rssreader_cut_line (cLine, pLayout, w); pLinkButton = gtk_label_new (cLine); gtk_label_set_selectable (GTK_LABEL (pLinkButton), TRUE); g_free (cLine); pAlign = gtk_alignment_new (0., 0.5, 0., 0.); gtk_alignment_set_padding (GTK_ALIGNMENT (pAlign), 0, 0, 20, 0); gtk_container_add (GTK_CONTAINER (pAlign), pLinkButton); gtk_box_pack_start (GTK_BOX (pVBox), pAlign, FALSE, FALSE, 0); } if (pItem->cAuthor != NULL) { gchar *by = g_strdup_printf (" [by %s]", pItem->cAuthor); pLinkButton = gtk_label_new (by); g_free (by); pAlign = gtk_alignment_new (0., 0.5, 0., 0.); gtk_alignment_set_padding (GTK_ALIGNMENT (pAlign), 0, 0, 40, 0); gtk_container_add (GTK_CONTAINER (pAlign), pLinkButton); gtk_box_pack_start (GTK_BOX (pVBox), pAlign, FALSE, FALSE, 0); } if (pItem->cDate != NULL) { pLinkButton = gtk_label_new (pItem->cDate); pAlign = gtk_alignment_new (1., 0.5, 0., 0.); gtk_alignment_set_padding (GTK_ALIGNMENT (pAlign), 0, 0, 40, 0); gtk_container_add (GTK_CONTAINER (pAlign), pLinkButton); gtk_box_pack_start (GTK_BOX (pVBox), pAlign, FALSE, FALSE, 0); } } pango_font_description_free (fd); pItem = myData.pItemList->data; // le nom du flux en titre du dialogue. // on affiche le dialogue. myData.pDialog = gldi_dialog_show (pItem->cTitle, myIcon, myContainer, 0, myDock ? "same icon" : MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE, pScrolledWindow, NULL, myApplet, (GFreeFunc)_on_dialog_destroyed); /**g_signal_connect (G_OBJECT (myData.pDialog->container.pWidget), "button-press-event", G_CALLBACK (on_button_press_dialog), myApplet);*/ } else // on affiche un message clair a l'utilisateur. { if (myConfig.cUrl == NULL) gldi_dialog_show_temporary_with_icon (D_("No URL is defined\nYou can define one by copying the URL in the clipboard,\n and selecting \"Paste the URL\" in the menu."), myIcon, myContainer, 1000*myConfig.iNotificationDuration, myDock ? "same icon" : MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE); else gldi_dialog_show_temporary_with_icon (D_("No data\nDid you set a valid RSS feed?\nIs your connection alive?"), myIcon, myContainer, 1000*myConfig.iNotificationDuration, myDock ? "same icon" : MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE); } }
static void photos_properties_dialog_constructed (GObject *object) { PhotosPropertiesDialog *self = PHOTOS_PROPERTIES_DIALOG (object); PhotosPropertiesDialogPrivate *priv = self->priv; GDateTime *date_modified; GtkStyleContext *context; GtkWidget *author_w = NULL; GtkWidget *content_area; GtkWidget *date_created_w = NULL; GtkWidget *date_modified_data; GtkWidget *date_modified_w; GtkWidget *exposure_time_w = NULL; GtkWidget *flash_w = NULL; GtkWidget *fnumber_w = NULL; GtkWidget *focal_length_w = NULL; GtkWidget *height_w = NULL; GtkWidget *iso_speed_w = NULL; GtkWidget *item_type; GtkWidget *item_type_data; GtkWidget *source; GtkWidget *source_data; GtkWidget *title; GtkWidget *width_w = NULL; GQuark equipment; GQuark flash; PhotosBaseItem *item; const gchar *author; const gchar *name; const gchar *type_description; gchar *date_created_str = NULL; gchar *date_modified_str; gdouble exposure_time; gdouble fnumber; gdouble focal_length; gdouble iso_speed; gint64 ctime; gint64 height; gint64 mtime; gint64 width; G_OBJECT_CLASS (photos_properties_dialog_parent_class)->constructed (object); item = PHOTOS_BASE_ITEM (photos_base_manager_get_object_by_id (priv->item_mngr, priv->urn)); mtime = photos_base_item_get_mtime (item); date_modified = g_date_time_new_from_unix_local (mtime); date_modified_str = g_date_time_format (date_modified, "%c"); g_date_time_unref (date_modified); ctime = photos_base_item_get_date_created (item); if (ctime != -1) { GDateTime *date_created; date_created = g_date_time_new_from_unix_local (ctime); date_created_str = g_date_time_format (date_created, "%c"); g_date_time_unref (date_created); } priv->grid = gtk_grid_new (); gtk_widget_set_halign (priv->grid, GTK_ALIGN_CENTER); gtk_widget_set_margin_start (priv->grid, 24); gtk_widget_set_margin_end (priv->grid, 24); gtk_widget_set_margin_bottom (priv->grid, 12); gtk_widget_set_margin_top (priv->grid, 12); gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->grid), GTK_ORIENTATION_VERTICAL); gtk_grid_set_column_homogeneous (GTK_GRID (priv->grid), TRUE); gtk_grid_set_column_spacing (GTK_GRID (priv->grid), 24); gtk_grid_set_row_homogeneous (GTK_GRID (priv->grid), TRUE); gtk_grid_set_row_spacing (GTK_GRID (priv->grid), 6); content_area = gtk_dialog_get_content_area (GTK_DIALOG (self)); gtk_box_pack_start (GTK_BOX (content_area), priv->grid, TRUE, TRUE, 2); /* Translators: this is the label next to the photo title in the * properties dialog */ title = gtk_label_new (C_("Document Title", "Title")); gtk_widget_set_halign (title, GTK_ALIGN_END); context = gtk_widget_get_style_context (title); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), title); author = photos_base_item_get_author (item); if (author != NULL && author[0] != '\0') { /* Translators: this is the label next to the photo author in * the properties dialog */ author_w = gtk_label_new (C_("Document Author", "Author")); gtk_widget_set_halign (author_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (author_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), author_w); } source = gtk_label_new (_("Source")); gtk_widget_set_halign (source, GTK_ALIGN_END); context = gtk_widget_get_style_context (source); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), source); date_modified_w = gtk_label_new (_("Date Modified")); gtk_widget_set_halign (date_modified_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (date_modified_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), date_modified_w); if (date_created_str != NULL) { date_created_w = gtk_label_new (_("Date Created")); gtk_widget_set_halign (date_created_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (date_created_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), date_created_w); } /* Translators: this is the label next to the photo type in the * properties dialog */ item_type = gtk_label_new (C_("Document Type", "Type")); gtk_widget_set_halign (item_type, GTK_ALIGN_END); context = gtk_widget_get_style_context (item_type); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), item_type); width = photos_base_item_get_width (item); if (width > 0) { width_w = gtk_label_new (_("Width")); gtk_widget_set_halign (width_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (width_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), width_w); } height = photos_base_item_get_height (item); if (height > 0) { height_w = gtk_label_new (_("Height")); gtk_widget_set_halign (height_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (height_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), height_w); } equipment = photos_base_item_get_equipment (item); photos_camera_cache_get_camera_async (priv->camera_cache, equipment, priv->cancellable, photos_properties_dialog_get_camera, self); if (equipment != 0) { priv->camera_w = gtk_label_new (_("Camera")); gtk_widget_set_halign (priv->camera_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (priv->camera_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), priv->camera_w); } exposure_time = photos_base_item_get_exposure_time (item); if (exposure_time > 0.0) { exposure_time_w = gtk_label_new (_("Exposure")); gtk_widget_set_halign (exposure_time_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (exposure_time_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), exposure_time_w); } fnumber = photos_base_item_get_fnumber (item); if (fnumber > 0.0) { fnumber_w = gtk_label_new (_("Aperture")); gtk_widget_set_halign (fnumber_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (fnumber_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), fnumber_w); } focal_length = photos_base_item_get_focal_length (item); if (focal_length > 0.0) { focal_length_w = gtk_label_new (_("Focal Length")); gtk_widget_set_halign (focal_length_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (focal_length_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), focal_length_w); } iso_speed = photos_base_item_get_iso_speed (item); if (iso_speed > 0.0) { iso_speed_w = gtk_label_new (_("ISO Speed")); gtk_widget_set_halign (iso_speed_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (iso_speed_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), iso_speed_w); } flash = photos_base_item_get_flash (item); if (flash != 0) { flash_w = gtk_label_new (_("Flash")); gtk_widget_set_halign (flash_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (flash_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), flash_w); } name = photos_base_item_get_name (item); if (PHOTOS_IS_LOCAL_ITEM (item)) { priv->title_entry = gtk_entry_new (); gtk_widget_set_halign (priv->title_entry, GTK_ALIGN_START); gtk_widget_set_hexpand (priv->title_entry, TRUE); gtk_entry_set_activates_default (GTK_ENTRY (priv->title_entry), TRUE); gtk_entry_set_text (GTK_ENTRY (priv->title_entry), name); gtk_entry_set_width_chars (GTK_ENTRY (priv->title_entry), 40); gtk_editable_set_editable (GTK_EDITABLE (priv->title_entry), TRUE); g_signal_connect (priv->title_entry, "changed", G_CALLBACK (photos_properties_dialog_title_entry_changed), self); } else { priv->title_entry = gtk_label_new (name); gtk_widget_set_halign (priv->title_entry, GTK_ALIGN_START); } gtk_grid_attach_next_to (GTK_GRID (priv->grid), priv->title_entry, title, GTK_POS_RIGHT, 2, 1); if (author_w != NULL) { GtkWidget *author_data; author_data = gtk_label_new (author); gtk_widget_set_halign (author_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), author_data, author_w, GTK_POS_RIGHT, 2, 1); } if (PHOTOS_IS_FACEBOOK_ITEM (item)) { const gchar *source_name; source_name = photos_base_item_get_source_name (item); source_data = gtk_link_button_new_with_label ("https://www.facebook.com/", source_name); gtk_widget_set_halign (source_data, GTK_ALIGN_START); } else if (PHOTOS_IS_FLICKR_ITEM (item)) { const gchar *source_name; source_name = photos_base_item_get_source_name (item); source_data = gtk_link_button_new_with_label ("https://www.flickr.com/", source_name); gtk_widget_set_halign (source_data, GTK_ALIGN_START); } else /* local item */ { if (photos_base_item_is_collection (item)) { const gchar *source_name; source_name = photos_base_item_get_source_name (item); source_data = gtk_label_new (source_name); gtk_widget_set_halign (source_data, GTK_ALIGN_START); } else { GFile *file; GFile *source_link; GtkWidget *label; const gchar *uri; gchar *source_path; gchar *source_uri; uri = photos_base_item_get_uri (item); file = g_file_new_for_uri (uri); source_link = g_file_get_parent (file); source_path = g_file_get_path (source_link); source_uri = g_file_get_uri (source_link); source_data = gtk_link_button_new_with_label (source_uri, source_path); gtk_widget_set_halign (source_data, GTK_ALIGN_START); label = gtk_bin_get_child (GTK_BIN (source_data)); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); g_object_unref (source_link); g_object_unref (file); } } gtk_grid_attach_next_to (GTK_GRID (priv->grid), source_data, source, GTK_POS_RIGHT, 2, 1); date_modified_data = gtk_label_new (date_modified_str); gtk_widget_set_halign (date_modified_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), date_modified_data, date_modified_w, GTK_POS_RIGHT, 2, 1); if (date_created_w != NULL) { GtkWidget *date_created_data; date_created_data = gtk_label_new (date_created_str); gtk_widget_set_halign (date_created_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), date_created_data, date_created_w, GTK_POS_RIGHT, 2, 1); } type_description = photos_base_item_get_type_description (item); item_type_data = gtk_label_new (type_description); gtk_widget_set_halign (item_type_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), item_type_data, item_type, GTK_POS_RIGHT, 2, 1); if (width_w != NULL) { GtkWidget *width_data; gchar *width_str; width_str = g_strdup_printf ("%"G_GINT64_FORMAT" pixels", width); width_data = gtk_label_new (width_str); gtk_widget_set_halign (width_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), width_data, width_w, GTK_POS_RIGHT, 2, 1); g_free (width_str); } if (height_w != NULL) { GtkWidget *height_data; gchar *height_str; height_str = g_strdup_printf ("%"G_GINT64_FORMAT" pixels", height); height_data = gtk_label_new (height_str); gtk_widget_set_halign (height_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), height_data, height_w, GTK_POS_RIGHT, 2, 1); g_free (height_str); } if (exposure_time_w != NULL) { GtkWidget *exposure_time_data; gchar *exposure_time_str; exposure_time_str = g_strdup_printf ("%.3lf sec", exposure_time); exposure_time_data = gtk_label_new (exposure_time_str); gtk_widget_set_halign (exposure_time_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), exposure_time_data, exposure_time_w, GTK_POS_RIGHT, 2, 1); g_free (exposure_time_str); } if (fnumber_w != NULL) { GtkWidget *fnumber_data; gchar *fnumber_str; fnumber_str = g_strdup_printf ("f/%.1lf", fnumber); fnumber_data = gtk_label_new (fnumber_str); gtk_widget_set_halign (fnumber_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), fnumber_data, fnumber_w, GTK_POS_RIGHT, 2, 1); g_free (fnumber_str); } if (focal_length_w != NULL) { GtkWidget *focal_length_data; gchar *focal_length_str; focal_length_str = g_strdup_printf ("%.0lf mm", focal_length); focal_length_data = gtk_label_new (focal_length_str); gtk_widget_set_halign (focal_length_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), focal_length_data, focal_length_w, GTK_POS_RIGHT, 2, 1); g_free (focal_length_str); } if (iso_speed_w != NULL) { GtkWidget *iso_speed_data; gchar *iso_speed_str; iso_speed_str = g_strdup_printf ("%.0lf", iso_speed); iso_speed_data = gtk_label_new (iso_speed_str); gtk_widget_set_halign (iso_speed_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), iso_speed_data, iso_speed_w, GTK_POS_RIGHT, 2, 1); g_free (iso_speed_str); } if (flash_w != NULL) { GtkWidget *flash_data; gchar *flash_str; if (flash == PHOTOS_FLASH_OFF) flash_str = g_strdup (_("Off, did not fire")); else if (flash == PHOTOS_FLASH_ON) flash_str = g_strdup (_("On, fired")); else g_assert_not_reached (); flash_data = gtk_label_new (flash_str); gtk_widget_set_halign (flash_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), flash_data, flash_w, GTK_POS_RIGHT, 2, 1); g_free (flash_str); } g_free (date_created_str); g_free (date_modified_str); }
GtkWidget *gui_create_about_trans(void) { GtkWidget *dialog_about_trans; GtkWidget *dialog_vbox; GtkWidget *vbox; GtkWidget *pixmap; GtkWidget *scrolledwindow; GtkWidget *label; GtkWidget *textview; GtkWidget *href; GtkWidget *dialog_action_area; GtkWidget *hbuttonbox; GtkWidget *button; gchar *about = _("Do you like using Xiphos to study the Bible? " "Would you like to see its user interface in your native language? " "You could translate Xiphos! " "\n\n" "We are always looking for contributions of new " "translations of Xiphos into other languages. " "If you are able to translate for us, please see the link " "below, contact us, and get involved with our efforts. Your help will " "be much appreciated!"); dialog_about_trans = gtk_dialog_new(); g_object_set_data(G_OBJECT(dialog_about_trans), "dialog_about_trans", dialog_about_trans); gtk_window_set_title(GTK_WINDOW(dialog_about_trans), _("About Xiphos Translation")); set_window_icon(GTK_WINDOW(dialog_about_trans)); gtk_window_set_resizable(GTK_WINDOW(dialog_about_trans), FALSE); dialog_vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog_about_trans)); g_object_set_data(G_OBJECT(dialog_about_trans), "dialog_vbox", dialog_vbox); gtk_widget_show(dialog_vbox); UI_VBOX(vbox, FALSE, 0); gtk_widget_show(vbox); gtk_box_pack_start(GTK_BOX(dialog_vbox), vbox, TRUE, TRUE, 0); pixmap = pixmap_finder("logo.png"); gtk_widget_show(pixmap); gtk_box_pack_start(GTK_BOX(vbox), pixmap, FALSE, FALSE, 4); scrolledwindow = gtk_scrolled_window_new(NULL, NULL); gtk_widget_show(scrolledwindow); gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 4); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_widget_set_size_request(scrolledwindow, 400, 150); gtk_container_set_border_width(GTK_CONTAINER(scrolledwindow), 4); gtk_scrolled_window_set_shadow_type((GtkScrolledWindow *) scrolledwindow, settings.shadow_type); textview = gtk_text_view_new(); gtk_widget_show(textview); gtk_container_add(GTK_CONTAINER(scrolledwindow), textview); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_WORD); gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE); gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)), about, -1); gtk_widget_set_sensitive(textview, FALSE); label = gtk_label_new(_("See TRANSLATION-HOWTO in Xiphos source")); gtk_widget_show(label); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); gtk_widget_set_size_request(label, -2, 24); href = gtk_link_button_new_with_label("http://xiphos.org/development/", _("Xiphos development")); gtk_widget_show(href); gtk_box_pack_start(GTK_BOX(vbox), href, FALSE, FALSE, 0); dialog_action_area = #ifdef HAVE_GTK_312 gtk_dialog_get_content_area(GTK_DIALOG(dialog_about_trans)); #else gtk_dialog_get_action_area(GTK_DIALOG(dialog_about_trans)); #endif g_object_set_data(G_OBJECT(dialog_about_trans), "dialog_action_area", dialog_action_area); gtk_widget_show(dialog_action_area); gtk_container_set_border_width(GTK_CONTAINER(dialog_action_area), 10); #ifdef USE_GTK_3 hbuttonbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); #else hbuttonbox = gtk_hbutton_box_new(); #endif gtk_widget_show(hbuttonbox); gtk_box_pack_start(GTK_BOX(dialog_action_area), hbuttonbox, TRUE, TRUE, 0); gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox), GTK_BUTTONBOX_END); button = #ifdef HAVE_GTK_310 gtk_button_new_with_mnemonic(_("Close")); #else gtk_button_new_from_stock(GTK_STOCK_CLOSE); #endif gtk_widget_show(button); gtk_container_add(GTK_CONTAINER(hbuttonbox), button); #ifdef HAVE_GTK_218 gtk_widget_set_can_default(button, TRUE); #elif defined(USE_GTK_3) gtk_widget_set_can_default(button, 1); #else GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); #endif g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(about_trans_ok), NULL); return dialog_about_trans; }
static gboolean info_area_draw(struct wcam_win *c, GtkWidget *box) { GtkWidget *frame; GtkWidget *table; GtkWidget *label; GtkWidget *align; GtkWidget *separator; gchar buf[256]; frame = gtk_frame_new("信息区"); c->info_area = frame; gtk_box_pack_start_defaults(GTK_BOX(box), frame); table = gtk_table_new(9, 2, FALSE); gtk_container_add(GTK_CONTAINER(frame), table); /* VERSION & HOMEPAGE */ label = gtk_label_new("主页:"); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, GTK_SHRINK, 1, 1); label = gtk_link_button_new_with_label(WCAM_HOMEPAGE, "www.enjoylinux.cn"); align = gtk_alignment_new(0, 0, 0, 0); /* 左对齐 */ gtk_container_add(GTK_CONTAINER(align), label); gtk_table_attach(GTK_TABLE(table), align, 1, 2, 0, 1, GTK_FILL, GTK_SHRINK, 1, 1); label = gtk_label_new("版本:"); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, GTK_SHRINK, 1, 1); label = gtk_label_new(WCAM_VERSION); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 1, 2, 1, 2, GTK_FILL, GTK_SHRINK, 8, 1); /* IP & PORT */ label = gtk_label_new("服务器:"); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, GTK_FILL, GTK_SHRINK, 1, 1); label = gtk_label_new(c->ipaddr); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 1, 2, 2, 3, GTK_FILL, GTK_SHRINK, 8, 1); separator = gtk_hseparator_new(); gtk_table_attach(GTK_TABLE(table), separator, 0, 1, 3, 4, GTK_FILL, GTK_SHRINK, 1, 1); separator = gtk_hseparator_new(); gtk_table_attach(GTK_TABLE(table), separator, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 1, 1); /* Frame Format */ label = gtk_label_new("帧格式:"); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, GTK_FILL, GTK_SHRINK, 1, 1); sprintf(buf, "%c%c%c%c", (c->video_format)&0xFF, (c->video_format>>8)&0xFF, (c->video_format>>16)&0xFF, (c->video_format>>24)&0xFF); label = gtk_label_new(buf); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 1, 2, 4, 5, GTK_FILL, GTK_SHRINK, 8, 1); /* Frame width x height */ label = gtk_label_new("帧尺寸:"); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6, GTK_FILL, GTK_SHRINK, 1, 1); sprintf(buf, "%d x %d", c->video_width, c->video_height); label = gtk_label_new(buf); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 1, 2, 5, 6, GTK_FILL, GTK_SHRINK, 8, 1); /* Frame Size */ label = gtk_label_new("帧大小:"); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 6, 7, GTK_FILL, GTK_SHRINK, 1, 1); label = gtk_label_new("0"); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 1, 2, 6, 7, GTK_FILL, GTK_SHRINK, 8, 1); c->frmsize_label = label; /* FPS */ label = gtk_label_new("帧速率:"); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 7, 8, GTK_FILL, GTK_SHRINK, 1, 1); label = gtk_label_new("0"); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(table), label, 1, 2, 7, 8, GTK_FILL, GTK_SHRINK, 8, 1); c->fps_label = label; /* hseparator */ separator = gtk_hseparator_new(); gtk_table_attach(GTK_TABLE(table), separator, 0, 1, 8, 9, GTK_FILL, GTK_SHRINK, 1, 1); separator = gtk_hseparator_new(); gtk_table_attach(GTK_TABLE(table), separator, 1, 2, 8, 9, GTK_FILL, GTK_SHRINK, 1, 1); return TRUE; }
/* todo: less on this side, like add track */ gchar *a_dialog_waypoint ( GtkWindow *parent, gchar *default_name, VikTrwLayer *vtl, VikWaypoint *wp, VikCoordMode coord_mode, gboolean is_new, gboolean *updated ) { GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Waypoint Properties"), parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); struct LatLon ll; GtkWidget *latlabel, *lonlabel, *namelabel, *latentry, *lonentry, *altentry, *altlabel, *nameentry=NULL; GtkWidget *commentlabel, *commententry, *descriptionlabel, *descriptionentry, *imagelabel, *imageentry, *symbollabel, *symbolentry; GtkWidget *sourcelabel = NULL, *sourceentry = NULL; GtkWidget *typelabel = NULL, *typeentry = NULL; GtkWidget *timelabel = NULL; GtkWidget *timevaluebutton = NULL; GtkWidget *hasGeotagCB = NULL; GtkWidget *consistentGeotagCB = NULL; GtkWidget *direction_sb = NULL; GtkWidget *direction_hb = NULL; GtkListStore *store; gchar *lat, *lon, *alt; vik_coord_to_latlon ( &(wp->coord), &ll ); lat = g_strdup_printf ( "%f", ll.lat ); lon = g_strdup_printf ( "%f", ll.lon ); vik_units_height_t height_units = a_vik_get_units_height (); switch (height_units) { case VIK_UNITS_HEIGHT_METRES: alt = g_strdup_printf ( "%f", wp->altitude ); break; case VIK_UNITS_HEIGHT_FEET: alt = g_strdup_printf ( "%f", VIK_METERS_TO_FEET(wp->altitude) ); break; default: alt = g_strdup_printf ( "%f", wp->altitude ); g_critical("Houston, we've had a problem. height=%d", height_units); } *updated = FALSE; namelabel = gtk_label_new (_("Name:")); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), namelabel, FALSE, FALSE, 0); // Name is now always changeable nameentry = gtk_entry_new (); if ( default_name ) gtk_entry_set_text( GTK_ENTRY(nameentry), default_name ); g_signal_connect_swapped ( nameentry, "activate", G_CALLBACK(a_dialog_response_accept), GTK_DIALOG(dialog) ); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), nameentry, FALSE, FALSE, 0); latlabel = gtk_label_new (_("Latitude:")); latentry = gtk_entry_new (); gtk_entry_set_text ( GTK_ENTRY(latentry), lat ); g_free ( lat ); lonlabel = gtk_label_new (_("Longitude:")); lonentry = gtk_entry_new (); gtk_entry_set_text ( GTK_ENTRY(lonentry), lon ); g_free ( lon ); altlabel = gtk_label_new (_("Altitude:")); altentry = gtk_entry_new (); gtk_entry_set_text ( GTK_ENTRY(altentry), alt ); g_free ( alt ); if ( wp->comment && !strncmp(wp->comment, "http", 4) ) commentlabel = gtk_link_button_new_with_label (wp->comment, _("Comment:") ); else commentlabel = gtk_label_new (_("Comment:")); commententry = gtk_entry_new (); gchar *cmt = NULL; // Auto put in some kind of 'name' as a comment if one previously 'goto'ed this exact location cmt = a_vik_goto_get_search_string_for_this_place(VIK_WINDOW(parent)); if (cmt) gtk_entry_set_text(GTK_ENTRY(commententry), cmt); if ( wp->description && !strncmp(wp->description, "http", 4) ) descriptionlabel = gtk_link_button_new_with_label (wp->description, _("Description:") ); else descriptionlabel = gtk_label_new (_("Description:")); descriptionentry = gtk_entry_new (); sourcelabel = gtk_label_new (_("Source:")); if ( wp->source ) { sourceentry = gtk_entry_new (); gtk_entry_set_text(GTK_ENTRY(sourceentry), wp->source); } typelabel = gtk_label_new (_("Type:")); if ( wp->type ) { typeentry = gtk_entry_new (); gtk_entry_set_text(GTK_ENTRY(typeentry), wp->type); } imagelabel = gtk_label_new (_("Image:")); imageentry = vik_file_entry_new (GTK_FILE_CHOOSER_ACTION_OPEN, VF_FILTER_IMAGE, NULL, NULL); { GtkCellRenderer *r; symbollabel = gtk_label_new (_("Symbol:")); GtkTreeIter iter; store = gtk_list_store_new(3, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING); symbolentry = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(symbolentry), 6); g_signal_connect(symbolentry, "changed", G_CALLBACK(symbol_entry_changed_cb), store); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, NULL, 1, NULL, 2, _("(none)"), -1); a_populate_sym_list(store); r = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (symbolentry), r, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (symbolentry), r, "pixbuf", 1, NULL); r = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (symbolentry), r, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (symbolentry), r, "text", 2, NULL); if ( !is_new && wp->symbol ) { gboolean ok; gchar *sym; for (ok = gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(store), &iter ); ok; ok = gtk_tree_model_iter_next ( GTK_TREE_MODEL(store), &iter)) { gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 ); if (sym && !strcmp(sym, wp->symbol)) { g_free(sym); break; } else { g_free(sym); } } // Ensure is it a valid symbol in the given symbol set (large vs small) // Not all symbols are available in both // The check prevents a Gtk Critical message if ( iter.stamp ) gtk_combo_box_set_active_iter(GTK_COMBO_BOX(symbolentry), &iter); } } if ( !is_new && wp->comment ) gtk_entry_set_text ( GTK_ENTRY(commententry), wp->comment ); if ( !is_new && wp->description ) gtk_entry_set_text ( GTK_ENTRY(descriptionentry), wp->description ); if ( !edit_wp ) edit_wp = vik_waypoint_new (); edit_wp = vik_waypoint_copy ( wp ); if ( !is_new && wp->image ) { vik_file_entry_set_filename ( VIK_FILE_ENTRY(imageentry), wp->image ); #ifdef VIK_CONFIG_GEOTAG // Geotag Info [readonly] hasGeotagCB = gtk_check_button_new_with_label ( _("Has Geotag") ); gtk_widget_set_sensitive ( hasGeotagCB, FALSE ); gboolean hasGeotag; gchar *ignore = a_geotag_get_exif_date_from_file ( wp->image, &hasGeotag ); g_free ( ignore ); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(hasGeotagCB), hasGeotag ); consistentGeotagCB = gtk_check_button_new_with_label ( _("Consistent Position") ); gtk_widget_set_sensitive ( consistentGeotagCB, FALSE ); if ( hasGeotag ) { struct LatLon ll = a_geotag_get_position ( wp->image ); VikCoord coord; vik_coord_load_from_latlon ( &coord, coord_mode, &ll ); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(consistentGeotagCB), vik_coord_equalish(&coord, &wp->coord) ); } // ATM the direction value box is always shown, even when there is no information. // It would be nice to be able to hide it until the 'Add' has been performed, // however I've not been able to achieve this. // Thus simply sensistizing it instead. GtkWidget *direction_label = gtk_label_new ( _("Image Direction:") ); direction_hb = gtk_hbox_new ( FALSE, 0 ); gtk_box_pack_start (GTK_BOX(direction_hb), direction_label, FALSE, FALSE, 0); direction_sb = gtk_spin_button_new ( (GtkAdjustment*)gtk_adjustment_new (0, 0.0, 359.9, 5.0, 1, 0 ), 1, 1 ); if ( !is_new && !isnan(wp->image_direction) ) { GtkWidget *direction_ref = gtk_label_new ( NULL ); if ( wp->image_direction_ref == WP_IMAGE_DIRECTION_REF_MAGNETIC ) gtk_label_set_label ( GTK_LABEL(direction_ref), _("Magnetic") ); else gtk_label_set_label ( GTK_LABEL(direction_ref), _("True") ); gtk_box_pack_start (GTK_BOX(direction_hb), direction_ref, TRUE, FALSE, 0); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(direction_sb), wp->image_direction ); } else { GtkWidget *direction_ref_button = gtk_button_new (); gtk_button_set_relief ( GTK_BUTTON(direction_ref_button), GTK_RELIEF_NONE ); GtkWidget *img = gtk_image_new_from_stock ( GTK_STOCK_ADD, GTK_ICON_SIZE_MENU ); gtk_button_set_image ( GTK_BUTTON(direction_ref_button), img ); gtk_box_pack_start (GTK_BOX(direction_hb), direction_ref_button, TRUE, FALSE, 0); gtk_widget_set_sensitive ( direction_sb, FALSE ); direction_signal_id = g_signal_connect ( G_OBJECT(direction_ref_button), "button-release-event", G_CALLBACK(direction_add_click), direction_sb ); } #endif } timelabel = gtk_label_new ( _("Time:") ); timevaluebutton = gtk_button_new(); gtk_button_set_relief ( GTK_BUTTON(timevaluebutton), GTK_RELIEF_NONE ); // TODO: Consider if there should be a remove time button... if ( !is_new && wp->has_timestamp ) { update_time ( timevaluebutton, wp ); } else { GtkWidget *img = gtk_image_new_from_stock ( GTK_STOCK_ADD, GTK_ICON_SIZE_MENU ); gtk_button_set_image ( GTK_BUTTON(timevaluebutton), img ); // Initially use current time or otherwise whatever the last value used was if ( edit_wp->timestamp == 0 ) { time ( &edit_wp->timestamp ); } } g_signal_connect ( G_OBJECT(timevaluebutton), "button-release-event", G_CALLBACK(time_edit_click), edit_wp ); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), latlabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), latentry, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), lonlabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), lonentry, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), timelabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), timevaluebutton, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), altlabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), altentry, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), commentlabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), commententry, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), descriptionlabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), descriptionentry, FALSE, FALSE, 0); if ( wp->source ) { gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), sourcelabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), sourceentry, FALSE, FALSE, 0); } if ( wp->type ) { gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), typelabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), typeentry, FALSE, FALSE, 0); } gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), imagelabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), imageentry, FALSE, FALSE, 0); if ( hasGeotagCB ) { GtkWidget *hbox = gtk_hbox_new ( FALSE, 0 ); gtk_box_pack_start (GTK_BOX(hbox), hasGeotagCB, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(hbox), consistentGeotagCB, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox, FALSE, FALSE, 0); } if ( direction_hb ) gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), direction_hb, FALSE, FALSE, 0); if ( direction_sb ) gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), direction_sb, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), symbollabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), GTK_WIDGET(symbolentry), FALSE, FALSE, 0); gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT ); gtk_widget_show_all ( gtk_dialog_get_content_area(GTK_DIALOG(dialog)) ); if ( !is_new ) { // Shift left<->right to try not to obscure the waypoint. trw_layer_dialog_shift ( vtl, GTK_WINDOW(dialog), &(wp->coord), FALSE ); } while ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT ) { if ( strlen((gchar*)gtk_entry_get_text ( GTK_ENTRY(nameentry) )) == 0 ) /* TODO: other checks (isalpha or whatever ) */ a_dialog_info_msg ( parent, _("Please enter a name for the waypoint.") ); else { // NB: No check for unique names - this allows generation of same named entries. gchar *entered_name = g_strdup ( (gchar*)gtk_entry_get_text ( GTK_ENTRY(nameentry) ) ); /* Do It */ ll.lat = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(latentry) ) ); ll.lon = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(lonentry) ) ); vik_coord_load_from_latlon ( &(wp->coord), coord_mode, &ll ); // Always store in metres switch (height_units) { case VIK_UNITS_HEIGHT_METRES: wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) ); break; case VIK_UNITS_HEIGHT_FEET: wp->altitude = VIK_FEET_TO_METERS(atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) )); break; default: wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) ); g_critical("Houston, we've had a problem. height=%d", height_units); } if ( g_strcmp0 ( wp->comment, gtk_entry_get_text ( GTK_ENTRY(commententry) ) ) ) vik_waypoint_set_comment ( wp, gtk_entry_get_text ( GTK_ENTRY(commententry) ) ); if ( g_strcmp0 ( wp->description, gtk_entry_get_text ( GTK_ENTRY(descriptionentry) ) ) ) vik_waypoint_set_description ( wp, gtk_entry_get_text ( GTK_ENTRY(descriptionentry) ) ); if ( g_strcmp0 ( wp->image, vik_file_entry_get_filename ( VIK_FILE_ENTRY(imageentry) ) ) ) vik_waypoint_set_image ( wp, vik_file_entry_get_filename ( VIK_FILE_ENTRY(imageentry) ) ); if ( sourceentry && g_strcmp0 ( wp->source, gtk_entry_get_text ( GTK_ENTRY(sourceentry) ) ) ) vik_waypoint_set_source ( wp, gtk_entry_get_text ( GTK_ENTRY(sourceentry) ) ); if ( typeentry && g_strcmp0 ( wp->type, gtk_entry_get_text ( GTK_ENTRY(typeentry) ) ) ) vik_waypoint_set_type ( wp, gtk_entry_get_text ( GTK_ENTRY(typeentry) ) ); if ( wp->image && *(wp->image) && (!a_thumbnails_exists(wp->image)) ) a_thumbnails_create ( wp->image ); if ( edit_wp->timestamp ) { wp->timestamp = edit_wp->timestamp; wp->has_timestamp = TRUE; } if ( direction_sb ) { if ( gtk_widget_get_sensitive (direction_sb) ) { wp->image_direction = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(direction_sb) ); if ( wp->image_direction != edit_wp->image_direction ) a_geotag_write_exif_gps ( wp->image, wp->coord, wp->altitude, wp->image_direction, wp->image_direction_ref, TRUE ); } } GtkTreeIter iter, first; gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(store), &first ); if ( !gtk_combo_box_get_active_iter ( GTK_COMBO_BOX(symbolentry), &iter ) || !memcmp(&iter, &first, sizeof(GtkTreeIter)) ) { vik_waypoint_set_symbol ( wp, NULL ); } else { gchar *sym; gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 ); vik_waypoint_set_symbol ( wp, sym ); g_free(sym); } gtk_widget_destroy ( dialog ); if ( is_new ) return entered_name; else { *updated = TRUE; // See if name has been changed if ( g_strcmp0 (default_name, entered_name ) ) return entered_name; else return NULL; } } } gtk_widget_destroy ( dialog ); return NULL; }
/****f* widget/gnoclLinkButtonCmd * AUTHOR * PGB * SOURCE */ int gnoclLinkButtonCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { int ret; GtkWidget *widget; int k, a, b; GnoclOption *pop; char *str_label, *str_uri ; /* determine which type of linkButton to create... */ /* * Do some pre-checking on the options set. * The gtk library has two forms of linkbutton, on with a label or one that simply shows the uri * these values are set at initialisation and so the argument line needs to be parsed so * that a decision can be made as to which type of widget to create. * */ /* * Parse all Options * Picking out individual options from the active script command line. */ for ( k = 1; k < objc; k += 2 ) { int idx; if ( gnoclGetIndexFromObjStruct ( interp, objv[k], ( char ** ) &linkButtonOptions[0].optName, sizeof ( GnoclOption ), "option", TCL_EXACT, &idx ) != TCL_OK ) { return -1; } /* originally, commented out */ /* printf( "parsing %s -> %s\n", Tcl_GetString( objv[k] ), linkButtonOptions[idx].optName); */ if ( strcmp ( Tcl_GetString ( objv[k] ), "-text" ) == 0 ) { str_label = Tcl_GetString ( objv[k+1] ); a = 1; } if ( strcmp ( Tcl_GetString ( objv[k] ), "-uri" ) == 0 ) { str_uri = Tcl_GetString ( objv[k+1] ); b = 1; } } /* decide what to do based on above values in step 2*/ /* STEP 1) -check validity of switches */ if ( gnoclParseOptions ( interp, objc, objv, linkButtonOptions ) != TCL_OK ) { gnoclClearOptions ( linkButtonOptions ); return TCL_ERROR; } /* STEP 2) -create widget, configure it, then clear memory */ /* * a== 1 and b == 1, then create a button with a label. * if a!= 1 and b == 1, then create a button with the URI as label * if b != 1, then this is an error. -uri is a mandatory option. */ if ( a == 1 && b == 1 ) { //printf ("label %s and URI %s\n", str_label, str_uri ); widget = GTK_WIDGET ( gtk_link_button_new_with_label ( str_uri, str_label ) ); } else if ( b == 1 ) { //printf ("URI %s\n", str_uri ); widget = gtk_link_button_new ( str_uri ); } else { //printf ("error\n" ); } a = 0; b = 0; gtk_widget_show ( GTK_WIDGET ( widget ) ); ret = gnoclSetOptions ( interp, linkButtonOptions, G_OBJECT ( widget ), -1 ); if ( ret == TCL_OK ) { ret = configure ( interp, G_OBJECT ( widget ), linkButtonOptions ); } gnoclClearOptions ( linkButtonOptions ); /* STEP 3) -show the widget */ if ( ret != TCL_OK ) { gtk_widget_destroy ( GTK_WIDGET ( widget ) ); return TCL_ERROR; } /* STEP 4) -everything has worked, register the widget with the Tcl interpretor. */ return gnoclRegisterWidget ( interp, GTK_WIDGET ( widget ), linkButtonFunc ); }
GtkWidget * tips_dialog_create (Gimp *gimp) { GimpGuiConfig *config; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *button; GtkWidget *image; gint tips_count; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); if (!tips) { GError *error = NULL; gchar *filename; filename = g_build_filename (gimp_data_directory (), "tips", "gimp-tips.xml", NULL); tips = gimp_tips_from_file (filename, &error); if (! tips) { GimpTip *tip; if (! error) { tip = gimp_tip_new (_("The GIMP tips file is empty!"), NULL); } else if (error->code == G_FILE_ERROR_NOENT) { tip = gimp_tip_new (_("The GIMP tips file appears to be " "missing!"), _("There should be a file called '%s'. " "Please check your installation."), gimp_filename_to_utf8 (filename)); } else { tip = gimp_tip_new (_("The GIMP tips file could not be parsed!"), "%s", error->message); } tips = g_list_prepend (tips, tip); } else if (error) { g_printerr ("Error while parsing '%s': %s\n", filename, error->message); } g_clear_error (&error); g_free (filename); } tips_count = g_list_length (tips); config = GIMP_GUI_CONFIG (gimp->config); if (config->last_tip_shown >= tips_count || config->last_tip_shown < 0) config->last_tip_shown = 0; current_tip = g_list_nth (tips, config->last_tip_shown); if (tips_dialog) return tips_dialog; tips_dialog = gimp_dialog_new (_("GIMP Tip of the Day"), "gimp-tip-of-the-day", NULL, 0, NULL, NULL, NULL); button = gtk_dialog_add_button (GTK_DIALOG (tips_dialog), _("_Previous Tip"), RESPONSE_PREVIOUS); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name ("go-previous", GTK_ICON_SIZE_BUTTON)); button = gtk_dialog_add_button (GTK_DIALOG (tips_dialog), _("_Next Tip"), RESPONSE_NEXT); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name ("go-next", GTK_ICON_SIZE_BUTTON)); gtk_dialog_set_response_sensitive (GTK_DIALOG (tips_dialog), RESPONSE_NEXT, tips_count > 1); gtk_dialog_set_response_sensitive (GTK_DIALOG (tips_dialog), RESPONSE_PREVIOUS, tips_count > 1); g_signal_connect (tips_dialog, "response", G_CALLBACK (tips_dialog_response), NULL); g_signal_connect (tips_dialog, "destroy", G_CALLBACK (tips_dialog_destroy), config); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (tips_dialog))), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); gtk_widget_show (hbox); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); image = gtk_image_new_from_icon_name (GIMP_STOCK_INFO, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); gtk_widget_show (image); gtk_container_set_focus_chain (GTK_CONTAINER (hbox), NULL); tip_label = gtk_label_new (NULL); gtk_label_set_selectable (GTK_LABEL (tip_label), TRUE); gtk_label_set_justify (GTK_LABEL (tip_label), GTK_JUSTIFY_LEFT); gtk_label_set_line_wrap (GTK_LABEL (tip_label), TRUE); gtk_misc_set_alignment (GTK_MISC (tip_label), 0.5, 0.0); gtk_box_pack_start (GTK_BOX (vbox), tip_label, TRUE, TRUE, 0); gtk_widget_show (tip_label); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); more_button = gtk_link_button_new_with_label ("http://docs.gimp.org/", /* a link to the related section in the user manual */ _("Learn more")); gtk_widget_show (more_button); gtk_box_pack_start (GTK_BOX (hbox), more_button, FALSE, FALSE, 0); g_signal_connect (more_button, "clicked", G_CALLBACK (more_button_clicked), gimp); tips_dialog_set_tip (current_tip->data); return tips_dialog; }