static void create_canvas_items (GooCanvasGroup *group, LibraryPart *library_part) { GooCanvasItem *item; GooCanvasPoints *points; GSList *objects; LibrarySymbol *symbol; SymbolObject *object; gdouble height, width; GooCanvasBounds bounds, group_bounds = {0,0,0,0}; g_return_if_fail (group != NULL); g_return_if_fail (library_part != NULL); symbol = library_get_symbol (library_part->symbol_name); if (symbol == NULL) { g_warning ("Couldn't find the requested symbol %s for part %s in " "library.\n", library_part->symbol_name, library_part->name); return; } for (objects = symbol->symbol_objects; objects; objects = objects->next) { object = (SymbolObject *)(objects->data); switch (object->type) { case SYMBOL_OBJECT_LINE: points = object->u.uline.line; item = goo_canvas_polyline_new (GOO_CANVAS_ITEM (group), FALSE, 0, "points", points, "stroke-color", NORMAL_COLOR, "line-width", 0.5, NULL); if (object->u.uline.spline) { g_object_set (item, "smooth", TRUE, "spline_steps", 5, NULL); } break; case SYMBOL_OBJECT_ARC: item = goo_canvas_ellipse_new (GOO_CANVAS_ITEM (group), (object->u.arc.x2 + object->u.arc.x1) / 2.0, (object->u.arc.y1 + object->u.arc.y2) / 2.0, (object->u.arc.x2 - object->u.arc.x1) / 2.0, (object->u.arc.y1 - object->u.arc.y2) / 2.0, "stroke-color", NORMAL_COLOR, "line_width", 1.0, NULL); break; case SYMBOL_OBJECT_TEXT: item = goo_canvas_text_new (GOO_CANVAS_ITEM (group), object->u.text.str, (double) object->u.text.x, (double) object->u.text.y, -1, GOO_CANVAS_ANCHOR_NORTH_EAST, "fill_color", LABEL_COLOR, "font", "Sans 8", NULL); break; default: g_warning ("Unknown symbol object.\n"); continue; } goo_canvas_item_get_bounds (item, &bounds); if (group_bounds.x1 > bounds.x1) group_bounds.x1 = bounds.x1; if (group_bounds.x2 < bounds.x2) group_bounds.x2 = bounds.x2; if (group_bounds.y1 > bounds.y1) group_bounds.y1 = bounds.y1; if (group_bounds.y2 < bounds.y2) group_bounds.y2 = bounds.y2; } g_object_get (group, "width", &width, "height", &height, NULL); width = group_bounds.x2 - group_bounds.x1; height = group_bounds.y2 - group_bounds.y1; g_object_set (group, "width", width, "height", height, NULL); g_slist_free_full (objects, g_object_unref); }
static void write_network_to_xml (const gchar *id, EmpathyIrcNetwork *network, xmlNodePtr root) { xmlNodePtr network_node, servers_node; GSList *servers, *l; gchar *name, *charset; if (!network->user_defined) /* no need to write this network to the XML */ return; network_node = xmlNewChild (root, NULL, "network", NULL); xmlNewProp (network_node, "id", id); if (network->dropped) { xmlNewProp (network_node, "dropped", "1"); return; } g_object_get (network, "name", &name, "charset", &charset, NULL); xmlNewProp (network_node, "name", name); xmlNewProp (network_node, "network_charset", charset); g_free (name); g_free (charset); servers = empathy_irc_network_get_servers (network); servers_node = xmlNewChild (network_node, NULL, "servers", NULL); for (l = servers; l != NULL; l = g_slist_next (l)) { EmpathyIrcServer *server; xmlNodePtr server_node; gchar *address, *tmp; guint port; gboolean ssl; server = l->data; server_node = xmlNewChild (servers_node, NULL, "server", NULL); g_object_get (server, "address", &address, "port", &port, "ssl", &ssl, NULL); xmlNewProp (server_node, "address", address); tmp = g_strdup_printf ("%u", port); xmlNewProp (server_node, "port", tmp); g_free (tmp); xmlNewProp (server_node, "ssl", ssl ? "TRUE": "FALSE"); g_free (address); } /* free the list */ g_slist_foreach (servers, (GFunc) g_object_unref, NULL); g_slist_free (servers); }
/** * glade_cursor_set: * @window: a #GdkWindow * @type: a #GladeCursorType * * Sets the cursor for @window to something appropriate based on @type. * (also sets the cursor on all visible project widgets) */ void glade_cursor_set (GladeProject *project, GdkWindow *window, GladeCursorType type) { GladeWidgetAdaptor *adaptor; GdkCursor *the_cursor = NULL; g_return_if_fail (cursor != NULL); switch (type) { case GLADE_CURSOR_SELECTOR: the_cursor = cursor->selector; break; case GLADE_CURSOR_ADD_WIDGET: if ((adaptor = glade_project_get_add_item (project)) != NULL) { g_object_get (adaptor, "cursor", &the_cursor, NULL); if (the_cursor == NULL) the_cursor = cursor->add_widget; } else the_cursor = cursor->add_widget; break; case GLADE_CURSOR_RESIZE_TOP_LEFT: the_cursor = cursor->resize_top_left; break; case GLADE_CURSOR_RESIZE_TOP_RIGHT: the_cursor = cursor->resize_top_right; break; case GLADE_CURSOR_RESIZE_BOTTOM_LEFT: the_cursor = cursor->resize_bottom_left; break; case GLADE_CURSOR_RESIZE_BOTTOM_RIGHT: the_cursor = cursor->resize_bottom_right; break; case GLADE_CURSOR_RESIZE_LEFT: the_cursor = cursor->resize_left; break; case GLADE_CURSOR_RESIZE_RIGHT: the_cursor = cursor->resize_right; break; case GLADE_CURSOR_RESIZE_TOP: the_cursor = cursor->resize_top; break; case GLADE_CURSOR_RESIZE_BOTTOM: the_cursor = cursor->resize_bottom; break; case GLADE_CURSOR_DRAG: the_cursor = cursor->drag; break; default: break; } if (the_cursor != gdk_window_get_cursor (window)) { set_cursor (project, cursor->selector); gdk_window_set_cursor (window, the_cursor); } }
BalsaMimeWidget * balsa_mime_widget_new(BalsaMessage * bm, LibBalsaMessageBody * mime_body, gpointer data) { BalsaMimeWidget *mw = NULL; gchar *content_type; mime_delegate_t *delegate; g_return_val_if_fail(bm != NULL, NULL); g_return_val_if_fail(mime_body != NULL, NULL); /* determine the content type of the passed MIME body */ content_type = libbalsa_message_body_get_mime_type(mime_body); delegate = mime_delegate; while (delegate->handler && ((delegate->wildcard && g_ascii_strncasecmp(delegate->mime_type, content_type, strlen(delegate->mime_type))) || (!delegate->wildcard && g_ascii_strcasecmp(delegate->mime_type, content_type)))) delegate++; if (delegate->handler) mw = (delegate->handler) (bm, mime_body, content_type, data); /* fall back to default if no handler is present */ if (!mw) mw = balsa_mime_widget_new_unknown(bm, mime_body, content_type); if (mw) { if (mw->widget) { g_signal_connect(G_OBJECT(mw->widget), "focus_in_event", G_CALLBACK(balsa_mime_widget_limit_focus), (gpointer) bm); g_signal_connect(G_OBJECT(mw->widget), "focus_out_event", G_CALLBACK(balsa_mime_widget_unlimit_focus), (gpointer) bm); #ifdef HAVE_GPGME if (mime_body->sig_info && g_ascii_strcasecmp("application/pgp-signature", content_type) && g_ascii_strcasecmp("application/pkcs7-signature", content_type) && g_ascii_strcasecmp("application/x-pkcs7-signature", content_type)) { GtkWidget * signature = balsa_mime_widget_signature_widget(mime_body, content_type); mw->widget = balsa_mime_widget_crypto_frame(mime_body, mw->widget, mime_body->was_encrypted, FALSE, signature); } else if (mime_body->was_encrypted && g_ascii_strcasecmp("multipart/signed", content_type)) { mw->widget = balsa_mime_widget_crypto_frame(mime_body, mw->widget, TRUE, TRUE, NULL); } #endif g_object_ref_sink(mw->widget); if (GTK_IS_LAYOUT(mw->widget)) { GtkAdjustment *vadj; g_object_get(G_OBJECT(mw->widget), "vadjustment", &vadj, NULL); g_signal_connect(vadj, "changed", G_CALLBACK(vadj_change_cb), mw->widget); } gtk_widget_show_all(mw->widget); } } g_free(content_type); return mw; }
static PanelPropertiesDialog * panel_properties_dialog_new (PanelToplevel *toplevel, GtkBuilder *gui) { PanelPropertiesDialog *dialog; char *toplevel_settings_path; dialog = g_new0 (PanelPropertiesDialog, 1); g_object_set_qdata_full (G_OBJECT (toplevel), panel_properties_dialog_quark, dialog, (GDestroyNotify) panel_properties_dialog_free); dialog->toplevel = toplevel; dialog->properties_dialog = PANEL_GTK_BUILDER_GET (gui, "panel_properties_dialog"); g_signal_connect_swapped (dialog->properties_dialog, "response", G_CALLBACK (panel_properties_dialog_response), dialog); g_signal_connect_swapped (dialog->properties_dialog, "destroy", G_CALLBACK (panel_properties_dialog_destroy), dialog); gtk_window_set_screen (GTK_WINDOW (dialog->properties_dialog), gtk_window_get_screen (GTK_WINDOW (toplevel))); dialog->writability_warn_general = PANEL_GTK_BUILDER_GET (gui, "writability_warn_general"); dialog->writability_warn_background = PANEL_GTK_BUILDER_GET (gui, "writability_warn_background"); dialog->general_vbox = PANEL_GTK_BUILDER_GET (gui, "general_vbox"); dialog->general_table = PANEL_GTK_BUILDER_GET (gui, "general_table"); panel_properties_dialog_setup_orientation_combo (dialog, gui); panel_properties_dialog_setup_size_spin (dialog, gui); panel_properties_dialog_setup_icon_chooser (dialog, gui); panel_properties_dialog_setup_expand_toggle (dialog, gui); panel_properties_dialog_setup_autohide_toggle (dialog, gui); panel_properties_dialog_setup_hidebuttons_toggle (dialog, gui); panel_properties_dialog_setup_arrows_toggle (dialog, gui); g_signal_connect_swapped (dialog->expand_toggle, "toggled", G_CALLBACK (panel_properties_dialog_setup_orientation_combo_sensitivty), dialog); panel_properties_update_arrows_toggle_visible ( dialog, GTK_TOGGLE_BUTTON (dialog->hidebuttons_toggle)); g_signal_connect_swapped (dialog->hidebuttons_toggle, "toggled", G_CALLBACK (panel_properties_update_arrows_toggle_visible), dialog); g_object_get (toplevel, "settings-path", &toplevel_settings_path, NULL); dialog->settings = g_settings_new_with_path (PANEL_TOPLEVEL_SCHEMA, toplevel_settings_path); gchar *toplevel_background_path; toplevel_background_path = g_strdup_printf ("%sbackground/", toplevel_settings_path); dialog->background_settings = g_settings_new_with_path (PANEL_TOPLEVEL_BACKGROUND_SCHEMA, toplevel_background_path); g_free (toplevel_background_path); g_signal_connect (dialog->settings, "changed", G_CALLBACK (panel_properties_dialog_toplevel_notify), dialog); panel_properties_dialog_setup_color_button (dialog, gui); panel_properties_dialog_setup_image_chooser (dialog, gui); panel_properties_dialog_setup_opacity_scale (dialog, gui); panel_properties_dialog_setup_background_radios (dialog, gui); g_signal_connect (dialog->background_settings, "changed", G_CALLBACK (panel_properties_dialog_background_notify), dialog); panel_properties_dialog_update_for_attached (dialog, panel_toplevel_get_is_attached (dialog->toplevel)); panel_toplevel_push_autohide_disabler (dialog->toplevel); panel_widget_register_open_dialog (panel_toplevel_get_panel_widget (dialog->toplevel), dialog->properties_dialog); #if !GTK_CHECK_VERSION (3, 0, 0) /* FIXME re-add once GTK3 support is fixed */ g_signal_connect (dialog->properties_dialog, "event", G_CALLBACK (config_event), PANEL_GTK_BUILDER_GET (gui, "notebook")); #endif gtk_widget_show (dialog->properties_dialog); return dialog; }
void ags_audio_preferences_reset(AgsApplicable *applicable) { AgsWindow *window; AgsPreferences *preferences; AgsAudioPreferences *audio_preferences; AgsSoundcard *soundcard; GtkListStore *model; GtkTreeIter iter; GList *card_id, *card_name; char *device; int card_num; guint channels, channels_min, channels_max; guint rate, rate_min, rate_max; guint buffer_size, buffer_size_min, buffer_size_max; GError *error; audio_preferences = AGS_AUDIO_PREFERENCES(applicable); /* */ preferences = (AgsPreferences *) gtk_widget_get_ancestor(GTK_WIDGET(audio_preferences), AGS_TYPE_PREFERENCES); window = AGS_WINDOW(preferences->parent); soundcard = AGS_SOUNDCARD(window->soundcard); /* refresh */ ags_soundcard_list_cards(AGS_SOUNDCARD(soundcard), &card_id, &card_name); model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); while(card_id != NULL){ gtk_list_store_append(model, &iter); gtk_list_store_set(model, &iter, 0, card_id->data, 1, card_name->data, -1); card_id = card_id->next; card_name = card_name->next; } g_list_free(card_id); g_list_free(card_name); gtk_combo_box_set_model(audio_preferences->card, GTK_TREE_MODEL(model)); /* */ g_object_get(G_OBJECT(soundcard), "device\0", &device, "pcm-channels\0", &channels, "frequency\0", &rate, "buffer-size\0", &buffer_size, NULL); error = NULL; /* */ sscanf(device, "hw:%i\0", &card_num); // gtk_combo_box_set_active(audio_preferences->card, // card_num); gtk_spin_button_set_value(audio_preferences->audio_channels, (gdouble) channels); gtk_spin_button_set_value(audio_preferences->samplerate, (gdouble) rate); gtk_spin_button_set_value(audio_preferences->buffer_size, (gdouble) buffer_size); /* */ ags_soundcard_pcm_info(soundcard, gtk_combo_box_get_active_text(audio_preferences->card), &channels_min, &channels_max, &rate_min, &rate_max, &buffer_size_min, &buffer_size_max, &error); if(error != NULL){ GtkMessageDialog *dialog; dialog = (GtkMessageDialog *) gtk_message_dialog_new((GtkWindow *) gtk_widget_get_ancestor(GTK_WIDGET(audio_preferences), AGS_TYPE_PREFERENCES), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, error->message); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(GTK_WIDGET(dialog)); gtk_spin_button_set_range(audio_preferences->audio_channels, 0.0, 24.0); gtk_spin_button_set_range(audio_preferences->samplerate, 1.0, 192000.0); gtk_spin_button_set_range(audio_preferences->buffer_size, 1.0, 65535.0); return; } gtk_spin_button_set_range(audio_preferences->audio_channels, channels_min, channels_max); gtk_spin_button_set_range(audio_preferences->samplerate, rate_min, rate_max); gtk_spin_button_set_range(audio_preferences->buffer_size, buffer_size_min, buffer_size_max); }
static void update_device_resources (struct device_resources* res) { tcam::CaptureDevice* dev = nullptr; g_object_get(G_OBJECT(res->source_element), "camera", &dev, NULL); if (dev == nullptr) { GST_ERROR("Could not retrieve device. Aborting"); return; } tcam::Property* prop = dev->get_property(TCAM_PROPERTY_EXPOSURE); if (prop == nullptr) { GST_ERROR("Exposure could not be found!"); } else { struct tcam_device_property p = prop->get_struct(); res->exposure.min = p.value.i.min; res->exposure.max = p.value.i.max; res->exposure.value = p.value.i.value; } prop = dev->get_property(TCAM_PROPERTY_GAIN); if (prop == nullptr) { GST_ERROR("Gain could not be found!"); } else { struct tcam_device_property p = prop->get_struct(); res->gain.min = p.value.i.min; res->gain.max = p.value.i.max; res->gain.value = p.value.i.value; } prop = dev->get_property(TCAM_PROPERTY_GAIN_RED); if (prop == nullptr) { GST_INFO("Gain Red could not be found!"); } else { struct tcam_device_property p = prop->get_struct(); res->color.rgb.R = p.value.i.value; res->exposure.max = p.value.i.max; // hardcoded from dfk72 res->color.default_value = 36; } prop = dev->get_property(TCAM_PROPERTY_GAIN_GREEN); if (prop == nullptr) { GST_INFO("Gain Green could not be found!"); } else { struct tcam_device_property p = prop->get_struct(); res->color.rgb.G = p.value.i.value; res->exposure.max = p.value.i.max; // hardcoded from dfk72 res->color.default_value = 36; } prop = dev->get_property(TCAM_PROPERTY_GAIN_BLUE); if (prop == nullptr) { GST_INFO("Gain Blue could not be found!"); } else { struct tcam_device_property p = prop->get_struct(); res->color.rgb.B = p.value.i.value; res->exposure.max = p.value.i.max; // hardcoded from dfk72 res->color.default_value = 36; } }
int main (int argc, char **argv) { GdaReportEngine *eng; GdaConnection *cnc; GdaHolder *param; GdaReportDocument *doc; gda_init (); /* Doc object */ doc = gda_report_docbook_document_new (NULL); g_object_get (G_OBJECT (doc), "engine", &eng, NULL); gda_report_document_set_template (doc, "customers-report-spec.xml"); g_object_set (G_OBJECT (doc), "fo-stylesheet", "/usr/share/xml/docbook/stylesheet/nwalsh/fo/docbook.xsl", NULL); /* GdaConnection */ cnc = open_connection (); gda_report_engine_declare_object (eng, G_OBJECT (cnc), "main_cnc"); /* define parameters */ param = gda_holder_new_string ("abstract", "-- This text is from a parameter set in the code, not in the spec. file --"); gda_report_engine_declare_object (eng, G_OBJECT (param), "abstract"); g_object_unref (param); /* create queries */ GSList *queries, *list; queries = create_queries (cnc); for (list = queries; list; list = list->next) { gda_report_engine_declare_object (eng, G_OBJECT (list->data), g_object_get_data (G_OBJECT (list->data), "name")); g_object_unref (G_OBJECT (list->data)); } g_slist_free (queries); g_object_unref (eng); /* use the doc object */ GError *error = NULL; gchar *outfile = "customers-report-docbook.pdf"; if (! (gda_report_document_run_as_pdf (doc, outfile, &error))) { g_print ("gda_report_document_run_as_pdf error: %s\n", error && error->message ? error->message : "No detail"); exit (1); } else g_print ("%s file generated\n", outfile); #ifdef HTML outfile = "customers-report-docbook.html"; if (! (gda_report_document_run_as_html (doc, outfile, &error))) { g_print ("gda_report_document_run_as_html error: %s\n", error && error->message ? error->message : "No detail"); exit (1); } else g_print ("%s file generated\n", outfile); #endif g_object_unref (cnc); g_object_unref (doc); return 0; }
GStreamerFilterImpl::GStreamerFilterImpl (const boost::property_tree::ptree &conf, std::shared_ptr<MediaPipeline> mediaPipeline, const std::string &command, std::shared_ptr<FilterType> filterType) : FilterImpl (conf, std::dynamic_pointer_cast<MediaObjectImpl> ( mediaPipeline) ) { GstElement *filter, *filter_check; GError *error = NULL; this->cmd = command; GST_DEBUG ("Command %s", command.c_str() ); switch (filterType->getValue() ) { case FilterType::VIDEO: g_object_set (element, "type", 2, NULL); break; case FilterType::AUDIO: g_object_set (element, "type", 1, NULL); break; case FilterType::AUTODETECT: g_object_set (element, "type", 0, NULL); break; default: break; } filter = gst_parse_launch (command.c_str(), &error); if (filter == NULL || error != NULL) { std::string error_str = "GStreamer filter cannot be created"; if (filter) { g_object_unref (filter); } if (error != NULL) { if (error->message != NULL) { error_str += ": " + std::string (error->message); } g_error_free (error); } throw KurentoException (MARSHALL_ERROR, error_str); } else if (GST_IS_BIN (filter) ) { g_object_unref (filter); throw KurentoException (MARSHALL_ERROR, "Given command is not valid, just one element can be created"); } g_object_set (element, "filter", filter, NULL); g_object_get (element, "filter", &filter_check, NULL); if (filter_check != filter) { g_object_unref (filter); g_object_unref (filter_check); throw KurentoException (MARSHALL_ERROR, "Given command is not valid, pad templates does not match"); } g_object_unref (filter); g_object_unref (filter_check); }
int main (int argc, char *argv[]) { gtk_init (&argc, &argv); gdaui_init (); /* create data model */ GdaDataModel *model; model = data_model_errors_new (); gda_data_model_dump (model, NULL); /* create UI */ GtkWidget *window, *vbox, *button, *form, *grid; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW(window), 400, 200); g_signal_connect_swapped (window, "destroy", G_CALLBACK (destroy), window); gtk_container_set_border_width (GTK_CONTAINER (window), 10); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); gtk_container_add (GTK_CONTAINER (window), vbox); /* main form to list customers */ form = gdaui_form_new (model); gtk_box_pack_start (GTK_BOX (vbox), form, FALSE, FALSE, 0); GtkWidget *raw; g_object_get (form, "raw-form", &raw, NULL); g_timeout_add (80, (GSourceFunc) change_unknow_color, raw); g_object_unref (raw); g_object_set (G_OBJECT (form), "info-flags", GDAUI_DATA_PROXY_INFO_CURRENT_ROW | GDAUI_DATA_PROXY_INFO_ROW_MOVE_BUTTONS | GDAUI_DATA_PROXY_INFO_ROW_MODIFY_BUTTONS, NULL ); /* main grid to list customers */ grid = gdaui_grid_new (model); g_object_unref (model); gtk_box_pack_start (GTK_BOX (vbox), grid, TRUE, TRUE, 0); g_object_set (G_OBJECT (grid), "info-flags", GDAUI_DATA_PROXY_INFO_CURRENT_ROW | GDAUI_DATA_PROXY_INFO_ROW_MODIFY_BUTTONS, NULL ); /* button to quit */ button = gtk_button_new_with_label ("Quit"); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window); gtk_widget_show_all (window); gtk_main (); return 0; }
GstCaps * _owr_payload_create_rtp_caps(OwrPayload *payload) { OwrPayloadPrivate *priv; OwrMediaType media_type; GstCaps *caps = NULL; GEnumClass *enum_class; GEnumValue *enum_value; gchar *encoding_name; gboolean ccm_fir = FALSE, nack_pli = FALSE; g_return_val_if_fail(payload, NULL); priv = payload->priv; switch (priv->codec_type) { case OWR_CODEC_TYPE_PCMU: encoding_name = "PCMU"; break; case OWR_CODEC_TYPE_PCMA: encoding_name = "PCMA"; break; case OWR_CODEC_TYPE_OPUS: encoding_name = "X-GST-OPUS-DRAFT-SPITTKA-00"; break; case OWR_CODEC_TYPE_H264: encoding_name = "H264"; break; case OWR_CODEC_TYPE_VP8: encoding_name = "VP8-DRAFT-IETF-01"; break; default: g_return_val_if_reached(NULL); } caps = gst_caps_new_simple("application/x-rtp", "encoding-name", G_TYPE_STRING, encoding_name, "payload", G_TYPE_INT, priv->payload_type, "clock-rate", G_TYPE_INT, priv->clock_rate, NULL); g_object_get(payload, "media-type", &media_type, NULL); enum_class = G_ENUM_CLASS(g_type_class_ref(OWR_TYPE_MEDIA_TYPE)); enum_value = g_enum_get_value(enum_class, media_type); if (enum_value) gst_caps_set_simple(caps, "media", G_TYPE_STRING, enum_value->value_nick, NULL); g_type_class_unref(enum_class); if (OWR_IS_VIDEO_PAYLOAD(payload)) { g_object_get(OWR_VIDEO_PAYLOAD(payload), "ccm-fir", &ccm_fir, "nack-pli", &nack_pli, NULL); gst_caps_set_simple(caps, "rtcp-fb-ccm-fir", G_TYPE_BOOLEAN, ccm_fir, "rtcp-fb-nack-pli", G_TYPE_BOOLEAN, nack_pli, NULL); } else if (media_type == OWR_MEDIA_TYPE_AUDIO) { guint channels = 0; if (OWR_IS_AUDIO_PAYLOAD(payload)) g_object_get(OWR_AUDIO_PAYLOAD(payload), "channels", &channels, NULL); if (channels > 0) { gst_caps_set_simple(caps, "channels", G_TYPE_INT, channels, NULL); } } return caps; }
char *iupdrvGetGlobal(const char *name) { if (iupStrEqual(name, "VIRTUALSCREEN")) { GdkScreen *screen = gdk_screen_get_default(); GdkWindow *root = gdk_screen_get_root_window(gdk_screen_get_default()); int x = 0; int y = 0; int w = gdk_screen_get_width(screen); int h = gdk_screen_get_height(screen); gdk_window_get_root_origin(root, &x, &y); return iupStrReturnStrf("%d %d %d %d", x, y, w, h); } if (iupStrEqual(name, "MONITORSINFO")) { int i; #if GTK_CHECK_VERSION(3, 22, 0) GdkDisplay *display = gdk_display_get_default(); int monitors_count = gdk_display_get_n_monitors(display); #else GdkScreen *screen = gdk_screen_get_default(); int monitors_count = gdk_screen_get_n_monitors(screen); #endif char *str = iupStrGetMemory(monitors_count * 50); char* pstr = str; GdkRectangle rect; for (i = 0; i < monitors_count; i++) { #if GTK_CHECK_VERSION(3, 22, 0) GdkMonitor* monitor = gdk_display_get_monitor(display, i); gdk_monitor_get_geometry(monitor, &rect); #else gdk_screen_get_monitor_geometry(screen, i, &rect); #endif pstr += sprintf(pstr, "%d %d %d %d\n", rect.x, rect.y, rect.width, rect.height); } return str; } if (iupStrEqual(name, "MONITORSCOUNT")) { #if GTK_CHECK_VERSION(3, 22, 0) GdkDisplay *display = gdk_display_get_default(); int monitors_count = gdk_display_get_n_monitors(display); #else GdkScreen *screen = gdk_screen_get_default(); int monitors_count = gdk_screen_get_n_monitors(screen); #endif return iupStrReturnInt(monitors_count); } if (iupStrEqual(name, "TRUECOLORCANVAS")) { return iupStrReturnBoolean(gdk_visual_get_best_depth() > 8); } if (iupStrEqual(name, "UTF8MODE")) { return iupStrReturnBoolean(iupgtkStrGetUTF8Mode()); } if (iupStrEqual(name, "UTF8AUTOCONVERT")) { return iupStrReturnBoolean(!iupgtkStrGetUTF8Mode()); } #ifndef WIN32 if (iupStrEqual(name, "EXEFILENAME")) { char* argv0 = IupGetGlobal("ARGV0"); if (argv0) { char* exefilename = realpath(argv0, NULL); if (exefilename) { char* str = iupStrReturnStr(exefilename); free(exefilename); return str; } } } #endif if (iupStrEqual(name, "SHOWMENUIMAGES")) { gboolean menu_images; g_object_get (gtk_settings_get_default (), "gtk-menu-images", &menu_images, NULL); return iupStrReturnBoolean(menu_images); } return NULL; }
bool GStreamerGWorld::enterFullscreen() { if (m_dynamicPadName) return false; if (!m_videoWindow) m_videoWindow = PlatformVideoWindow::createWindow(); GstElement* platformVideoSink = gst_element_factory_make("autovideosink", "platformVideoSink"); GstElement* colorspace = gst_element_factory_make("ffmpegcolorspace", "colorspace"); GstElement* queue = gst_element_factory_make("queue", "queue"); GstElement* videoScale = gst_element_factory_make("videoscale", "videoScale"); // Get video sink bin and the tee inside. GRefPtr<GstElement> videoSink; GstElement* sinkPtr = 0; g_object_get(m_pipeline, "video-sink", &sinkPtr, NULL); videoSink = adoptGRef(sinkPtr); GRefPtr<GstElement> tee = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoTee")); // Add and link a queue, ffmpegcolorspace, videoscale and sink in the bin. gst_bin_add_many(GST_BIN(videoSink.get()), platformVideoSink, videoScale, colorspace, queue, NULL); // Faster elements linking. gst_element_link_pads_full(queue, "src", colorspace, "sink", GST_PAD_LINK_CHECK_NOTHING); gst_element_link_pads_full(colorspace, "src", videoScale, "sink", GST_PAD_LINK_CHECK_NOTHING); gst_element_link_pads_full(videoScale, "src", platformVideoSink, "sink", GST_PAD_LINK_CHECK_NOTHING); // Link a new src pad from tee to queue. GRefPtr<GstPad> srcPad = adoptGRef(gst_element_get_request_pad(tee.get(), "src%d")); GRefPtr<GstPad> sinkPad = adoptGRef(gst_element_get_static_pad(queue, "sink")); gst_pad_link(srcPad.get(), sinkPad.get()); m_dynamicPadName.set(gst_pad_get_name(srcPad.get())); // Synchronize the new elements with pipeline state. If it's // paused limit the state change to pre-rolling. GstState state; gst_element_get_state(m_pipeline, &state, 0, 0); if (state < GST_STATE_PLAYING) state = GST_STATE_READY; gst_element_set_state(platformVideoSink, state); gst_element_set_state(videoScale, state); gst_element_set_state(colorspace, state); gst_element_set_state(queue, state); // Query the current media segment informations and send them towards // the new tee branch downstream. GstQuery* query = gst_query_new_segment(GST_FORMAT_TIME); gboolean queryResult = gst_element_query(m_pipeline, query); if (!queryResult) { gst_query_unref(query); return true; } GstFormat format; gint64 position; if (!gst_element_query_position(m_pipeline, &format, &position)) position = 0; gdouble rate; gint64 startValue, stopValue; gst_query_parse_segment(query, &rate, &format, &startValue, &stopValue); GstEvent* event = gst_event_new_new_segment(FALSE, rate, format, startValue, stopValue, position); gst_pad_push_event(srcPad.get(), event); gst_query_unref(query); return true; }
static void st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect) { StScrollViewFade *self = ST_SCROLL_VIEW_FADE (effect); ClutterOffscreenEffectClass *parent; CoglHandle material; gdouble value, lower, upper, page_size; ClutterActor *vscroll = st_scroll_view_get_vscroll_bar (ST_SCROLL_VIEW (self->actor)); ClutterActor *hscroll = st_scroll_view_get_hscroll_bar (ST_SCROLL_VIEW (self->actor)); gboolean h_scroll_visible, v_scroll_visible; ClutterActorBox allocation, content_box, paint_box; /* * Used to pass the fade area to the shader * * [0][0] = x1 * [0][1] = y1 * [1][0] = x2 * [1][1] = y2 * */ float fade_area[2][2]; ClutterVertex verts[4]; if (self->program == COGL_INVALID_HANDLE) goto out; clutter_actor_get_paint_box (self->actor, &paint_box); clutter_actor_get_abs_allocation_vertices (self->actor, verts); clutter_actor_get_allocation_box (self->actor, &allocation); st_theme_node_get_content_box (st_widget_get_theme_node (ST_WIDGET (self->actor)), (const ClutterActorBox *)&allocation, &content_box); /* * The FBO is based on the paint_volume's size which can be larger then the actual * allocation, so we have to account for that when passing the positions */ fade_area[0][0] = content_box.x1 + (verts[0].x - paint_box.x1); fade_area[0][1] = content_box.y1 + (verts[0].y - paint_box.y1); fade_area[1][0] = content_box.x2 + (verts[3].x - paint_box.x2); fade_area[1][1] = content_box.y2 + (verts[3].y - paint_box.y2); g_object_get (ST_SCROLL_VIEW (self->actor), "hscrollbar-visible", &h_scroll_visible, "vscrollbar-visible", &v_scroll_visible, NULL); if (v_scroll_visible) { if (clutter_actor_get_text_direction (self->actor) == CLUTTER_TEXT_DIRECTION_RTL) fade_area[0][0] += clutter_actor_get_width (vscroll); fade_area[1][0] -= clutter_actor_get_width (vscroll); } if (h_scroll_visible) fade_area[1][1] -= clutter_actor_get_height (hscroll); st_adjustment_get_values (self->vadjustment, &value, &lower, &upper, NULL, NULL, &page_size); if (self->offset_top_uniform > -1) { if (value > lower + 0.1) cogl_program_set_uniform_1f (self->program, self->offset_top_uniform, self->vfade_offset); else cogl_program_set_uniform_1f (self->program, self->offset_top_uniform, 0.0f); } if (self->offset_bottom_uniform > -1) { if (value < upper - page_size - 0.1) cogl_program_set_uniform_1f (self->program, self->offset_bottom_uniform, self->vfade_offset); else cogl_program_set_uniform_1f (self->program, self->offset_bottom_uniform, 0.0f); } st_adjustment_get_values (self->hadjustment, &value, &lower, &upper, NULL, NULL, &page_size); if (self->offset_left_uniform > -1) { if (value > lower + 0.1) cogl_program_set_uniform_1f (self->program, self->offset_left_uniform, self->hfade_offset); else cogl_program_set_uniform_1f (self->program, self->offset_left_uniform, 0.0f); } if (self->offset_right_uniform > -1) { if (value < upper - page_size - 0.1) cogl_program_set_uniform_1f (self->program, self->offset_right_uniform, self->hfade_offset); else cogl_program_set_uniform_1f (self->program, self->offset_right_uniform, 0.0f); } if (self->tex_uniform > -1) cogl_program_set_uniform_1i (self->program, self->tex_uniform, 0); if (self->height_uniform > -1) cogl_program_set_uniform_1f (self->program, self->height_uniform, clutter_actor_get_height (self->actor)); if (self->width_uniform > -1) cogl_program_set_uniform_1f (self->program, self->width_uniform, clutter_actor_get_width (self->actor)); if (self->fade_area_uniform > -1) cogl_program_set_uniform_matrix (self->program, self->fade_area_uniform, 2, 1, FALSE, (const float *)fade_area); material = clutter_offscreen_effect_get_target (effect); cogl_material_set_user_program (material, self->program); out: parent = CLUTTER_OFFSCREEN_EFFECT_CLASS (st_scroll_view_fade_parent_class); parent->paint_target (effect); }
gboolean download_cb(WebKitWebView *web_view, WebKitDownload *download, gpointer user_data) { (void) web_view; (void) user_data; /* get the URI being downloaded */ const gchar *uri = webkit_download_get_uri(download); /* get the destination path, if specified. * this is only intended to be set when this function is trigger by an * explicit download using uzbl's 'download' action. */ const gchar *destination = user_data; if (uzbl.state.verbose) printf("Download requested -> %s\n", uri); if (!uzbl.behave.download_handler) { webkit_download_cancel(download); return FALSE; /* reject downloads when there's no download handler */ } /* get a reasonable suggestion for a filename */ const gchar *suggested_filename; g_object_get(download, "suggested-filename", &suggested_filename, NULL); /* get the mimetype of the download */ const gchar *content_type = NULL; WebKitNetworkResponse *r = webkit_download_get_network_response(download); /* downloads can be initiated from the context menu, in that case there is no network response yet and trying to get one would crash. */ if(WEBKIT_IS_NETWORK_RESPONSE(r)) { SoupMessage *m = webkit_network_response_get_message(r); SoupMessageHeaders *h = NULL; g_object_get(m, "response-headers", &h, NULL); if(h) /* some versions of libsoup don't have "response-headers" here */ content_type = soup_message_headers_get_one(h, "Content-Type"); } if(!content_type) content_type = "application/octet-stream"; /* get the filesize of the download, as given by the server. (this may be inaccurate, there's nothing we can do about that.) */ unsigned int total_size = webkit_download_get_total_size(download); GArray *a = g_array_new (TRUE, FALSE, sizeof(gchar*)); const CommandInfo *c = parse_command_parts(uzbl.behave.download_handler, a); if(!c) { webkit_download_cancel(download); g_array_free(a, TRUE); return FALSE; } g_array_append_val(a, uri); g_array_append_val(a, suggested_filename); g_array_append_val(a, content_type); gchar *total_size_s = g_strdup_printf("%d", total_size); g_array_append_val(a, total_size_s); if(destination) g_array_append_val(a, destination); GString *result = g_string_new (""); run_parsed_command(c, a, result); g_free(total_size_s); g_array_free(a, TRUE); /* no response, cancel the download */ if(result->len == 0) { webkit_download_cancel(download); return FALSE; } /* we got a response, it's the path we should download the file to */ gchar *destination_path = result->str; g_string_free(result, FALSE); /* presumably people don't need newlines in their filenames. */ char *p = strchr(destination_path, '\n'); if ( p != NULL ) *p = '\0'; /* set up progress callbacks */ g_signal_connect(download, "notify::status", G_CALLBACK(download_status_cb), NULL); g_signal_connect(download, "notify::progress", G_CALLBACK(download_progress_cb), NULL); /* convert relative path to absolute path */ if(destination_path[0] != '/') { gchar *rel_path = destination_path; gchar *cwd = g_get_current_dir(); destination_path = g_strconcat(cwd, "/", destination_path, NULL); g_free(cwd); g_free(rel_path); } send_event(DOWNLOAD_STARTED, NULL, TYPE_STR, destination_path, NULL); /* convert absolute path to file:// URI */ gchar *destination_uri = g_strconcat("file://", destination_path, NULL); g_free(destination_path); webkit_download_set_destination_uri(download, destination_uri); g_free(destination_uri); return TRUE; }
static void st_icon_update (StIcon *icon) { StIconPrivate *priv = icon->priv; StThemeNode *theme_node; StTextureCache *cache; gint scale; ClutterActor *stage; StThemeContext *context; if (priv->pending_texture) { clutter_actor_destroy (priv->pending_texture); g_object_unref (priv->pending_texture); priv->pending_texture = NULL; priv->opacity_handler_id = 0; } theme_node = st_widget_peek_theme_node (ST_WIDGET (icon)); if (theme_node == NULL) return; stage = clutter_actor_get_stage (CLUTTER_ACTOR (icon)); context = st_theme_context_get_for_stage (CLUTTER_STAGE (stage)); g_object_get (context, "scale-factor", &scale, NULL); cache = st_texture_cache_get_default (); if (priv->gicon != NULL) priv->pending_texture = st_texture_cache_load_gicon (cache, theme_node, priv->gicon, priv->icon_size, scale); if (priv->pending_texture == NULL && priv->fallback_gicon != NULL) priv->pending_texture = st_texture_cache_load_gicon (cache, theme_node, priv->fallback_gicon, priv->icon_size, scale); if (priv->pending_texture) { g_object_ref_sink (priv->pending_texture); if (clutter_actor_get_opacity (priv->pending_texture) != 0 || priv->icon_texture == NULL) { /* This icon is ready for showing, or nothing else is already showing */ st_icon_finish_update (icon); } else { /* Will be shown when fully loaded */ priv->opacity_handler_id = g_signal_connect_object (priv->pending_texture, "notify::opacity", G_CALLBACK (opacity_changed_cb), icon, 0); } } else if (priv->icon_texture) { clutter_actor_destroy (priv->icon_texture); priv->icon_texture = NULL; } }
static gboolean run_pipeline (gpointer user_data) { GstCaps *preview_caps = NULL; gchar *filename_str = NULL; GstElement *video_source = NULL; const gchar *filename_suffix; g_object_set (camera_bin, "mode", mode, NULL); if (preview_caps_name != NULL) { preview_caps = gst_caps_from_string (preview_caps_name); if (preview_caps) { g_object_set (camera_bin, "preview-caps", preview_caps, NULL); GST_DEBUG ("Preview caps set"); } else GST_DEBUG ("Preview caps set but could not create caps from string"); } set_metadata (camera_bin); /* Construct filename */ if (mode == 1) filename_suffix = ".mp4"; else filename_suffix = ".jpg"; filename_str = g_strdup_printf ("%s/test_%04u%s", filename->str, capture_count, filename_suffix); GST_DEBUG ("Setting filename: %s", filename_str); g_object_set (camera_bin, "filename", filename_str, NULL); g_free (filename_str); g_object_get (camera_bin, "video-source", &video_source, NULL); if (video_source) { if (GST_IS_ELEMENT (video_source) && gst_element_implements_interface (video_source, GST_TYPE_PHOTOGRAPHY)) { /* Set GstPhotography interface options. If option not given as command-line parameter use default of the source element. */ if (scene_mode != SCENE_MODE_NONE) g_object_set (video_source, "scene-mode", scene_mode, NULL); if (ev_compensation != EV_COMPENSATION_NONE) g_object_set (video_source, "ev-compensation", ev_compensation, NULL); if (aperture != APERTURE_NONE) g_object_set (video_source, "aperture", aperture, NULL); if (flash_mode != FLASH_MODE_NONE) g_object_set (video_source, "flash-mode", flash_mode, NULL); if (exposure != EXPOSURE_NONE) g_object_set (video_source, "exposure", exposure, NULL); if (iso_speed != ISO_SPEED_NONE) g_object_set (video_source, "iso-speed", iso_speed, NULL); if (wb_mode != WHITE_BALANCE_MODE_NONE) g_object_set (video_source, "white-balance-mode", wb_mode, NULL); if (color_mode != COLOR_TONE_MODE_NONE) g_object_set (video_source, "colour-tone-mode", color_mode, NULL); } g_object_unref (video_source); } g_object_set (camera_bin, "mute", mute, NULL); g_object_set (camera_bin, "zoom", zoom / 100.0f, NULL); capture_count++; g_timer_start (timer); g_signal_emit_by_name (camera_bin, "capture-start", 0); if (mode == 1) { g_timeout_add ((capture_time * 1000), (GSourceFunc) stop_capture, NULL); } return FALSE; }
static void gimp_tag_popup_handle_scrolling (GimpTagPopup *popup, gint x, gint y, gboolean enter, gboolean motion) { GdkRectangle rect; gboolean in_arrow; gboolean scroll_fast = FALSE; gboolean touchscreen_mode; g_object_get (gtk_widget_get_settings (GTK_WIDGET (popup)), "gtk-touchscreen-mode", &touchscreen_mode, NULL); /* upper arrow handling */ get_arrows_sensitive_area (popup, &rect, NULL); in_arrow = FALSE; if (popup->arrows_visible && x >= rect.x && x < rect.x + rect.width && y >= rect.y && y < rect.y + rect.height) { in_arrow = TRUE; } if (touchscreen_mode) popup->upper_arrow_prelight = in_arrow; if (popup->upper_arrow_state != GTK_STATE_INSENSITIVE) { gboolean arrow_pressed = FALSE; if (popup->arrows_visible) { if (touchscreen_mode) { if (enter && popup->upper_arrow_prelight) { if (popup->scroll_timeout_id == 0) { gimp_tag_popup_remove_scroll_timeout (popup); popup->scroll_step = -MENU_SCROLL_STEP2; /* always fast */ if (! motion) { /* Only do stuff on click. */ gimp_tag_popup_start_scrolling (popup); arrow_pressed = TRUE; } } else { arrow_pressed = TRUE; } } else if (! enter) { gimp_tag_popup_stop_scrolling (popup); } } else /* !touchscreen_mode */ { scroll_fast = (y < rect.y + MENU_SCROLL_FAST_ZONE); if (enter && in_arrow && (! popup->upper_arrow_prelight || popup->scroll_fast != scroll_fast)) { popup->upper_arrow_prelight = TRUE; popup->scroll_fast = scroll_fast; gimp_tag_popup_remove_scroll_timeout (popup); popup->scroll_step = (scroll_fast ? -MENU_SCROLL_STEP2 : -MENU_SCROLL_STEP1); popup->scroll_timeout_id = gdk_threads_add_timeout (scroll_fast ? MENU_SCROLL_TIMEOUT2 : MENU_SCROLL_TIMEOUT1, gimp_tag_popup_scroll_timeout, popup); } else if (! enter && ! in_arrow && popup->upper_arrow_prelight) { gimp_tag_popup_stop_scrolling (popup); } } } /* gimp_tag_popup_start_scrolling() might have hit the top of the * tag_popup, so check if the button isn't insensitive before * changing it to something else. */ if (popup->upper_arrow_state != GTK_STATE_INSENSITIVE) { GtkStateType arrow_state = GTK_STATE_NORMAL; if (arrow_pressed) arrow_state = GTK_STATE_ACTIVE; else if (popup->upper_arrow_prelight) arrow_state = GTK_STATE_PRELIGHT; if (arrow_state != popup->upper_arrow_state) { popup->upper_arrow_state = arrow_state; gdk_window_invalidate_rect (gtk_widget_get_window (GTK_WIDGET (popup)), &rect, FALSE); } } } /* lower arrow handling */ get_arrows_sensitive_area (popup, NULL, &rect); in_arrow = FALSE; if (popup->arrows_visible && x >= rect.x && x < rect.x + rect.width && y >= rect.y && y < rect.y + rect.height) { in_arrow = TRUE; } if (touchscreen_mode) popup->lower_arrow_prelight = in_arrow; if (popup->lower_arrow_state != GTK_STATE_INSENSITIVE) { gboolean arrow_pressed = FALSE; if (popup->arrows_visible) { if (touchscreen_mode) { if (enter && popup->lower_arrow_prelight) { if (popup->scroll_timeout_id == 0) { gimp_tag_popup_remove_scroll_timeout (popup); popup->scroll_step = MENU_SCROLL_STEP2; /* always fast */ if (! motion) { /* Only do stuff on click. */ gimp_tag_popup_start_scrolling (popup); arrow_pressed = TRUE; } } else { arrow_pressed = TRUE; } } else if (! enter) { gimp_tag_popup_stop_scrolling (popup); } } else /* !touchscreen_mode */ { scroll_fast = (y > rect.y + rect.height - MENU_SCROLL_FAST_ZONE); if (enter && in_arrow && (! popup->lower_arrow_prelight || popup->scroll_fast != scroll_fast)) { popup->lower_arrow_prelight = TRUE; popup->scroll_fast = scroll_fast; gimp_tag_popup_remove_scroll_timeout (popup); popup->scroll_step = (scroll_fast ? MENU_SCROLL_STEP2 : MENU_SCROLL_STEP1); popup->scroll_timeout_id = gdk_threads_add_timeout (scroll_fast ? MENU_SCROLL_TIMEOUT2 : MENU_SCROLL_TIMEOUT1, gimp_tag_popup_scroll_timeout, popup); } else if (! enter && ! in_arrow && popup->lower_arrow_prelight) { gimp_tag_popup_stop_scrolling (popup); } } } /* gimp_tag_popup_start_scrolling() might have hit the bottom of the * popup, so check if the button isn't insensitive before * changing it to something else. */ if (popup->lower_arrow_state != GTK_STATE_INSENSITIVE) { GtkStateType arrow_state = GTK_STATE_NORMAL; if (arrow_pressed) arrow_state = GTK_STATE_ACTIVE; else if (popup->lower_arrow_prelight) arrow_state = GTK_STATE_PRELIGHT; if (arrow_state != popup->lower_arrow_state) { popup->lower_arrow_state = arrow_state; gdk_window_invalidate_rect (gtk_widget_get_window (GTK_WIDGET (popup)), &rect, FALSE); } } } }
static gboolean gimp_window_key_press_event (GtkWidget *widget, GdkEventKey *event) { GtkWindow *window = GTK_WINDOW (widget); GtkWidget *focus = gtk_window_get_focus (window); GdkModifierType accel_mods; gboolean enable_mnemonics; gboolean handled = FALSE; /* we're overriding the GtkWindow implementation here to give * the focus widget precedence over unmodified accelerators * before the accelerator activation scheme. */ /* text widgets get all key events first */ if (GTK_IS_EDITABLE (focus) || GTK_IS_TEXT_VIEW (focus) || GIMP_IS_CANVAS (focus)) { handled = gtk_window_propagate_key_event (window, event); if (handled) GIMP_LOG (KEY_EVENTS, "handled by gtk_window_propagate_key_event(text_widget)"); } accel_mods = gtk_widget_get_modifier_mask (widget, GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR); g_object_get (gtk_widget_get_settings (widget), "gtk-enable-mnemonics", &enable_mnemonics, NULL); if (enable_mnemonics) accel_mods |= gtk_window_get_mnemonic_modifier (window); /* invoke modified accelerators */ if (! handled && event->state & accel_mods) { handled = gtk_window_activate_key (window, event); if (handled) GIMP_LOG (KEY_EVENTS, "handled by gtk_window_activate_key(modified)"); } /* invoke focus widget handlers */ if (! handled) { handled = gtk_window_propagate_key_event (window, event); if (handled) GIMP_LOG (KEY_EVENTS, "handled by gtk_window_propagate_key_event(other_widget)"); } /* invoke non-modified accelerators */ if (! handled && ! (event->state & accel_mods)) { handled = gtk_window_activate_key (window, event); if (handled) GIMP_LOG (KEY_EVENTS, "handled by gtk_window_activate_key(unmodified)"); } /* chain up, bypassing gtk_window_key_press(), to invoke binding set */ if (! handled) { GtkWidgetClass *widget_class; widget_class = g_type_class_peek_static (g_type_parent (GTK_TYPE_WINDOW)); handled = widget_class->key_press_event (widget, event); if (handled) GIMP_LOG (KEY_EVENTS, "handled by widget_class->key_press_event()"); } return handled; }
gboolean thrift_test_handler_test_insanity (TTestThriftTestIf *iface, GHashTable **_return, const TTestInsanity *argument, GError **error) { TTestXtruct *xtruct_in; gchar *string_thing = NULL; gint byte_thing; gint i32_thing; gint64 i64_thing; GPtrArray *xtructs; TTestInsanity *looney; GHashTable *user_map; GHashTable *first_map; GHashTable *second_map; GHashTableIter hash_table_iter; GHashTableIter inner_hash_table_iter; GHashTableIter user_map_iter; gpointer key; gpointer value; TTestUserId *user_id; guint i; THRIFT_UNUSED_VAR (iface); THRIFT_UNUSED_VAR (error); printf ("testInsanity()\n"); first_map = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref); second_map = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref); g_hash_table_insert (first_map, GINT_TO_POINTER (T_TEST_NUMBERZ_TWO), argument); g_hash_table_insert (first_map, GINT_TO_POINTER (T_TEST_NUMBERZ_THREE), argument); /* Increment argument's ref count since first_map now holds two references to it and would otherwise attempt to deallocate it twice during destruction. We do this instead of creating a copy of argument in order to mimic the C++ implementation (and since, frankly, the world needs less argument, not more). */ g_object_ref (argument); looney = g_object_new (T_TEST_TYPE_INSANITY, NULL); g_hash_table_insert (second_map, GINT_TO_POINTER (T_TEST_NUMBERZ_SIX), looney); user_id = g_malloc (sizeof *user_id); *user_id = 1; g_hash_table_insert (*_return, user_id, first_map); user_id = g_malloc (sizeof *user_id); *user_id = 2; g_hash_table_insert (*_return, user_id, second_map); printf ("return"); printf (" = {"); g_hash_table_iter_init (&hash_table_iter, *_return); while (g_hash_table_iter_next (&hash_table_iter, &key, &value)) { printf ("%" PRId64 " => {", *(TTestUserId *)key); g_hash_table_iter_init (&inner_hash_table_iter, (GHashTable *)value); while (g_hash_table_iter_next (&inner_hash_table_iter, &key, &value)) { printf ("%d => {", (TTestNumberz)key); g_object_get ((TTestInsanity *)value, "userMap", &user_map, "xtructs", &xtructs, NULL); printf ("{"); g_hash_table_iter_init (&user_map_iter, user_map); while (g_hash_table_iter_next (&user_map_iter, &key, &value)) { printf ("%d => %" PRId64 ", ", (TTestNumberz)key, *(TTestUserId *)value); } printf ("}, "); g_hash_table_unref (user_map); printf ("{"); for (i = 0; i < xtructs->len; ++i) { xtruct_in = g_ptr_array_index (xtructs, i); g_object_get (xtruct_in, "string_thing", &string_thing, "byte_thing", &byte_thing, "i32_thing", &i32_thing, "i64_thing", &i64_thing, NULL); printf ("{\"%s\", %d, %d, %" PRId64 "}, ", string_thing, byte_thing, i32_thing, i64_thing); } printf ("}"); g_ptr_array_unref (xtructs); printf ("}, "); } printf ("}, "); } printf ("}\n"); return TRUE; }
static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data) { __android_log_write(6, "android-spice", "channel_new"); SpiceDisplay *display = data; SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display); int id; g_object_get(channel, "channel-id", &id, NULL); if (SPICE_IS_MAIN_CHANNEL(channel)) { d->main = SPICE_MAIN_CHANNEL(channel); spice_g_signal_connect_object(channel, "main-mouse-update", G_CALLBACK(update_mouse_mode), display, 0); update_mouse_mode(channel, display); // TODO: For now, connect to this signal with a callback that disables // any secondary displays that crop up. g_signal_connect(channel, "main-agent-update", G_CALLBACK(disable_secondary_displays), display); return; } if (SPICE_IS_DISPLAY_CHANNEL(channel)) { if (id != d->channel_id) return; d->display = channel; g_signal_connect(channel, "display-primary-create", G_CALLBACK(primary_create), display); g_signal_connect(channel, "display-primary-destroy", G_CALLBACK(primary_destroy), display); g_signal_connect(channel, "display-invalidate", G_CALLBACK(invalidate), display); g_signal_connect(channel, "display-mark", G_CALLBACK(mark), display); spice_channel_connect(channel); return; } //if (SPICE_IS_CURSOR_CHANNEL(channel)) { // if (id != d->channel_id) // return; // d->cursor = SPICE_CURSOR_CHANNEL(channel); // g_signal_connect(channel, "cursor-set", // G_CALLBACK(cursor_set), display); // g_signal_connect(channel, "cursor-move", // G_CALLBACK(cursor_move), display); // g_signal_connect(channel, "cursor-hide", // G_CALLBACK(cursor_hide), display); // g_signal_connect(channel, "cursor-reset", // G_CALLBACK(cursor_reset), display); // spice_channel_connect(channel); // return; //} if (SPICE_IS_INPUTS_CHANNEL(channel)) { d->inputs = SPICE_INPUTS_CHANNEL(channel); spice_channel_connect(channel); //sync_keyboard_lock_modifiers(display); return; } #ifdef USE_SMARTCARD if (SPICE_IS_SMARTCARD_CHANNEL(channel)) { d->smartcard = SPICE_SMARTCARD_CHANNEL(channel); spice_channel_connect(channel); return; } #endif return; }
/** * pk_package_sack_get_update_detail_cb: **/ static void pk_package_sack_get_update_detail_cb (GObject *source_object, GAsyncResult *res, PkPackageSackState *state) { PkClient *client = PK_CLIENT (source_object); PkUpdateDetail *item; guint i; PkPackage *package; g_autoptr(GError) error = NULL; g_autoptr(PkResults) results = NULL; g_autoptr(GPtrArray) update_details = NULL; /* get the results */ results = pk_client_generic_finish (client, res, &error); if (results == NULL) { g_warning ("failed to update_detail: %s", error->message); pk_package_sack_merge_bool_state_finish (state, error); return; } /* get the update_details */ update_details = pk_results_get_update_detail_array (results); if (update_details->len == 0) { error = g_error_new (1, 0, "no update details found!"); pk_package_sack_merge_bool_state_finish (state, error); return; } /* set data on each item */ for (i = 0; i < update_details->len; i++) { PkRestartEnum restart; PkUpdateStateEnum state_enum; g_autofree gchar *changelog = NULL; g_autofree gchar *issued = NULL; g_autofree gchar *obsoletes = NULL; g_autofree gchar *package_id = NULL; g_autofree gchar *updated = NULL; g_autofree gchar *updates = NULL; g_autofree gchar *update_text = NULL; g_auto(GStrv) bugzilla_urls = NULL; g_auto(GStrv) cve_urls = NULL; g_auto(GStrv) vendor_urls = NULL; item = g_ptr_array_index (update_details, i); g_object_get (item, "package-id", &package_id, "updates", &updates, "obsoletes", &obsoletes, "vendor-urls", &vendor_urls, "bugzilla-urls", &bugzilla_urls, "cve-urls", &cve_urls, "restart", &restart, "update-text", &update_text, "changelog", &changelog, "state", &state_enum, "issued", &issued, "updated", &updated, NULL); /* get package, and set data */ package = pk_package_sack_find_by_id (state->sack, package_id); if (package == NULL) { g_warning ("failed to find %s", package_id); continue; } /* set data */ g_object_set (package, "update-updates", updates, "update-obsoletes", obsoletes, "update-vendor-urls", vendor_urls, "update-bugzilla-urls", bugzilla_urls, "update-cve-urls", cve_urls, "update-restart", restart, "update-text", update_text, "update-changelog", changelog, "update-state", state_enum, "update-issued", issued, "update-updated", updated, NULL); g_object_unref (package); } /* all okay */ state->ret = TRUE; /* we're done */ pk_package_sack_merge_bool_state_finish (state, error); }
/* TODO remove redundant code */ static void i7_cell_renderer_transcript_render(GtkCellRenderer *self, GdkWindow *window, GtkWidget *widget, GdkRectangle *background_area, GdkRectangle *cell_area, GdkRectangle *expose_area, GtkCellRendererState flags) { I7_CELL_RENDERER_TRANSCRIPT_USE_PRIVATE; int x, y, width, height; unsigned xpad, ypad, transcript_width; GtkStateType state; cairo_t *cr; PangoRectangle command_rect; PangoLayout *layout; GtkStyle *style = gtk_widget_get_style(widget); /* Get the size we calculated earlier and then take the padding into account */ g_object_get(self, "xpad", &xpad, "ypad", &ypad, NULL); gtk_cell_renderer_get_size(self, widget, cell_area, &x, &y, &width, &height); x += cell_area->x + (int)xpad; y += cell_area->y + (int)ypad; width -= (int)xpad * 2; height -= (int)ypad * 2; /* Decide what state to draw the widget components in */ switch(flags) { case GTK_CELL_RENDERER_PRELIT: state = GTK_STATE_PRELIGHT; break; case GTK_CELL_RENDERER_INSENSITIVE: state = GTK_STATE_INSENSITIVE; break; default: state = GTK_STATE_NORMAL; } /* Get a cairo context to draw the rectangles on directly; use GTK themed drawing to draw everything else */ cr = gdk_cairo_create(GDK_DRAWABLE(window)); /* Draw the command */ layout = gtk_widget_create_pango_layout(widget, priv->command); pango_layout_get_pixel_extents(layout, NULL, &command_rect); set_rgb_style(cr, STYLE_COMMAND); cairo_rectangle(cr, (double)x, (double)y, (double)width, (double)(command_rect.height + priv->text_padding * 2)); cairo_fill(cr); gtk_paint_layout(style, window, state, TRUE, cell_area, widget, NULL, x + priv->text_padding, y + priv->text_padding, layout); g_object_unref(layout); /* Draw the transcript text */ transcript_width = priv->default_width / 2 - xpad; if(priv->changed) set_rgb_style(cr, STYLE_CHANGED); else set_rgb_style(cr, STYLE_UNCHANGED); cairo_rectangle(cr, (double)x, (double)(y + command_rect.height + priv->text_padding * 2), (double)(width / 2), (double)(height - command_rect.height - priv->text_padding * 2)); cairo_fill(cr); layout = gtk_widget_create_pango_layout(widget, NULL); pango_layout_set_markup(layout, priv->transcript_text, -1); pango_layout_set_width(layout, (int)(transcript_width - priv->text_padding * 2) * PANGO_SCALE); pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); gtk_paint_layout(style, window, state, TRUE, cell_area, widget, NULL, x + (int)priv->text_padding, y + command_rect.height + (int)priv->text_padding * 3, layout); g_object_unref(layout); /* Draw the expected text */ switch(priv->match_type) { case CANT_COMPARE: set_rgb_style(cr, STYLE_NO_EXPECTED); break; case NO_MATCH: set_rgb_style(cr, STYLE_NO_MATCH); break; case NEAR_MATCH: set_rgb_style(cr, STYLE_NEAR_MATCH); break; case EXACT_MATCH: default: set_rgb_style(cr, STYLE_EXACT_MATCH); break; } cairo_rectangle(cr, (double)(x + width / 2), (double)(y + command_rect.height + priv->text_padding * 2), (double)(width / 2), (double)(height - command_rect.height - priv->text_padding * 2)); cairo_fill(cr); layout = gtk_widget_create_pango_layout(widget, NULL); pango_layout_set_markup(layout, priv->expected_text, -1); pango_layout_set_width(layout, (int)(transcript_width - priv->text_padding * 2) * PANGO_SCALE); pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); gtk_paint_layout(style, window, state, TRUE, cell_area, widget, NULL, x + width / 2 + (int)priv->text_padding, y + command_rect.height + (int)priv->text_padding * 3, layout); g_object_unref(layout); /* Draw some lines */ gtk_paint_hline(style, window, state, cell_area, widget, NULL, x, x + width, y + command_rect.height + priv->text_padding * 2); gtk_paint_vline(style, window, state, cell_area, widget, NULL, y + command_rect.height + priv->text_padding * 2, y + height, x + width / 2); /* Draw a border around the highlighted node */ if(priv->current) { cairo_set_line_width(cr, 4.0); set_rgb_style(cr, STYLE_HIGHLIGHT); cairo_rectangle(cr, (double)x + 2.0, (double)y + 2.0, (double)width - 4.0, (double)height - 4.0); cairo_stroke(cr); } /* Draw a border around the active node */ if(priv->played) { cairo_set_line_width(cr, 2.0); set_rgb_style(cr, STYLE_ACTIVE); cairo_rectangle(cr, (double)x + 1.0, (double)y + 1.0, (double)width - 2.0, (double)height - 2.0); cairo_stroke(cr); } cairo_destroy(cr); }
void dialog_data_slicer (WBCGtk *wbcg, gboolean create) { static GtkTargetEntry row_targets[] = { { (char *)"GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_APP, 0 } }; DialogDataSlicer *state; GtkBuilder *gui; GtkWidget *w; g_return_if_fail (wbcg != NULL); if (gnm_dialog_raise_if_exists (wbcg, DIALOG_KEY)) return; gui = gnm_gtk_builder_load ("data-slicer.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (NULL == gui) return; state = g_new0 (DialogDataSlicer, 1); state->wbcg = wbcg; state->sv = wb_control_cur_sheet_view (GNM_WBC (wbcg)); state->dialog = go_gtk_builder_get_widget (gui, "dialog_data_slicer"); state->notebook = go_gtk_builder_get_widget (gui, "notebook"); state->slicer = create ? NULL : sv_editpos_in_slicer (state->sv); state->cache = NULL; state->source = NULL; if (NULL == state->slicer) { state->slicer = g_object_new (GNM_SHEET_SLICER_TYPE, NULL); } else { g_object_ref (state->slicer); g_object_get (G_OBJECT (state->slicer), "cache", &state->cache, NULL); if (NULL != state->cache && NULL != (state->source = go_data_cache_get_source (state->cache))) g_object_ref (state->source); } state->source_expr = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->source_expr, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); g_signal_connect_swapped (G_OBJECT (state->source_expr), "changed", G_CALLBACK (cb_source_expr_changed), state); w = go_gtk_builder_get_widget (gui, "source_vbox"); gtk_box_pack_start (GTK_BOX (w), GTK_WIDGET (state->source_expr), FALSE, FALSE, 0); gtk_widget_show (GTK_WIDGET (state->source_expr)); w = go_gtk_builder_get_widget (gui, "ok_button"); g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (cb_dialog_data_slicer_ok), state); w = go_gtk_builder_get_widget (gui, "cancel_button"); g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (cb_dialog_data_slicer_cancel), state); state->treeview = GTK_TREE_VIEW (go_gtk_builder_get_widget (gui, "field_tree")); gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (state->treeview), GDK_BUTTON1_MASK, row_targets, G_N_ELEMENTS (row_targets), GDK_ACTION_MOVE); gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (state->treeview), row_targets, G_N_ELEMENTS (row_targets), GDK_ACTION_MOVE); state->selection = gtk_tree_view_get_selection (state->treeview); gtk_tree_selection_set_mode (state->selection, GTK_SELECTION_SINGLE); g_signal_connect (state->selection, "changed", G_CALLBACK (cb_dialog_data_slicer_selection_changed), state); gtk_tree_view_append_column (state->treeview, gtk_tree_view_column_new_with_attributes ("", gtk_cell_renderer_text_new (), "text", FIELD_NAME, NULL)); cb_dialog_data_slicer_create_model (state); g_signal_connect (state->treeview, "realize", G_CALLBACK (gtk_tree_view_expand_all), NULL); gtk_notebook_set_current_page (GTK_NOTEBOOK (state->notebook), create ? 0 : 1); /* a candidate for merging into attach guru */ gnm_init_help_button (go_gtk_builder_get_widget (gui, "help_button"), GNUMERIC_HELP_LINK_DATA_SLICER); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify)cb_dialog_data_slicer_destroy); wbc_gtk_attach_guru (state->wbcg, state->dialog); gnm_keyed_dialog (wbcg, GTK_WINDOW (state->dialog), DIALOG_KEY); gtk_widget_show (state->dialog); g_object_unref (gui); }
gint gnc_dialog_run (GtkDialog *dialog, const gchar *pref_name) { GtkWidget *perm, *temp; gboolean ask = TRUE; gint response; /* Does the user want to see this question? If not, return the * previous answer. */ response = gnc_prefs_get_int(GNC_PREFS_GROUP_WARNINGS_PERM, pref_name); if (response != 0) return response; response = gnc_prefs_get_int(GNC_PREFS_GROUP_WARNINGS_TEMP, pref_name); if (response != 0) return response; /* Add in the checkboxes to find out if the answer should be remembered. */ #if 0 if (GTK_IS_MESSAGE_DIALOG(dialog)) { GtkMessageType type; g_object_get(dialog, "message-type", &type, (gchar*)NULL); ask = (type == GTK_MESSAGE_QUESTION); } else { ask = FALSE; } #endif perm = gtk_check_button_new_with_mnemonic (ask ? _("Remember and don't _ask me again.") : _("Don't _tell me again.")); temp = gtk_check_button_new_with_mnemonic (ask ? _("Remember and don't ask me again this _session.") : _("Don't tell me again this _session.")); gtk_widget_show(perm); gtk_widget_show(temp); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (dialog)), perm, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (dialog)), temp, TRUE, TRUE, 0); g_signal_connect(perm, "clicked", G_CALLBACK(gnc_perm_button_cb), temp); /* OK. Present the dialog. */ response = gtk_dialog_run(dialog); if ((response == GTK_RESPONSE_NONE) || (response == GTK_RESPONSE_DELETE_EVENT)) { return GTK_RESPONSE_CANCEL; } if (response != GTK_RESPONSE_CANCEL) { /* Save the answer? */ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(perm))) { gnc_prefs_set_int(GNC_PREFS_GROUP_WARNINGS_PERM, pref_name, response); } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(temp))) { gnc_prefs_set_int(GNC_PREFS_GROUP_WARNINGS_TEMP, pref_name, response); } } return response; }
void budgie_popover_present(BudgiePopover *self, GtkWidget *parent, GdkEvent *event) { GtkWidget *real_parent; GdkWindow *parent_window; gint x, y, tx, ty, rx, margin; GdkScreen *screen; GtkAllocation alloc, our_alloc; GdkDeviceManager *manager; gint32 time; if (event && event->type == GDK_BUTTON_PRESS) { x = event->button.x; y = event->button.y; } else if (event && event->type == GDK_TOUCH_END) { x = event->touch.x; y = event->touch.y; } if (gtk_widget_get_visible(GTK_WIDGET(self))) { budgie_popover_hide(self); return; } if (!gtk_widget_get_realized(GTK_WIDGET(self))) gtk_widget_realize(GTK_WIDGET(self)); /* Get position of parent widget on screen */ real_parent = gtk_widget_get_toplevel(parent); parent_window = gtk_widget_get_window(real_parent); gdk_window_get_position(parent_window, &x, &y); gtk_widget_translate_coordinates(parent, real_parent, x, y, &tx, &ty); gtk_widget_get_allocation(parent, &alloc); gtk_widget_get_allocation(GTK_WIDGET(self), &our_alloc); screen = gtk_widget_get_screen(GTK_WIDGET(self)); /* Ensure we're in a sensible position (under/over) */ if (ty + our_alloc.height + 11 < gdk_screen_get_height(screen)) { self->top = TRUE; ty = y+alloc.y+alloc.height; } else { ty = (y+alloc.y)-our_alloc.height; self->top = FALSE; } /* Ensure widg_x is within bounds */ if (event) { /* Point tip to mouse x,y */ rx = x; } else { /* Center the tip when there is no event */ rx = alloc.x + (alloc.width/2); } /* ensure margin is accounted for */ g_object_get(parent, "margin", &margin, NULL); tx -= margin; rx -= margin; if (rx >= our_alloc.width) rx = our_alloc.width - 14; if (rx <= 14) rx = 14; self->widg_x = rx; gtk_window_move(GTK_WINDOW(self), tx-11, ty); gtk_widget_show_all(GTK_WIDGET(self)); if (event) { if (event->type == GDK_BUTTON_PRESS) { self->pointer = event->button.device; time = event->button.time; } else { self->pointer = event->touch.device; time = event->touch.time; } } else { manager = gdk_display_get_device_manager(gdk_screen_get_display(screen)); self->pointer = gdk_device_manager_get_client_pointer(manager); time = GDK_CURRENT_TIME; } self->parent_widget = real_parent; self->con_id = g_signal_connect(real_parent, "button-press-event", G_CALLBACK(button_press), self); self->con_id = 0; /* TODO: Handle keyboard grab too */ popup_grab_on_window(gtk_widget_get_window(GTK_WIDGET(real_parent)), NULL, self->pointer, time); }
static gboolean ovirt_collection_refresh_from_xml(OvirtCollection *collection, RestXmlNode *root_node, GError **error) { RestXmlNode *resources_node; RestXmlNode *node; GHashTable *resources; const char *resource_key; g_return_val_if_fail(OVIRT_IS_COLLECTION(collection), FALSE); g_return_val_if_fail(root_node != NULL, FALSE); g_return_val_if_fail((error == NULL) || (*error == NULL), FALSE); if (strcmp(root_node->name, collection->priv->collection_xml_name) != 0) { g_set_error(error, OVIRT_ERROR, OVIRT_ERROR_PARSING_FAILED, _("Got '%s' node, expected '%s'"), root_node->name, collection->priv->collection_xml_name); return FALSE; } resource_key = g_intern_string(collection->priv->resource_xml_name); resources = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_object_unref); resources_node = g_hash_table_lookup(root_node->children, resource_key); for (node = resources_node; node != NULL; node = node->next) { OvirtResource *resource; gchar *name; resource = ovirt_collection_new_resource_from_xml(collection, node, error); if (resource == NULL) { if ((error != NULL) && (*error != NULL)) { g_message("Failed to parse '%s' node: %s", collection->priv->resource_xml_name, (*error)->message); } else { g_message("Failed to parse '%s' node", collection->priv->resource_xml_name); } g_clear_error(error); continue; } g_object_get(G_OBJECT(resource), "name", &name, NULL); if (name == NULL) { g_message("'%s' resource had no name in its XML description", collection->priv->resource_xml_name); g_object_unref(G_OBJECT(resource)); continue; } if (g_hash_table_lookup(resources, name) != NULL) { g_message("'%s' resource with the same name ('%s') already exists", collection->priv->resource_xml_name, name); g_object_unref(G_OBJECT(resource)); g_free(name); continue; } g_hash_table_insert(resources, name, resource); } ovirt_collection_set_resources(OVIRT_COLLECTION(collection), resources); g_hash_table_unref(resources); return TRUE; }
static ClutterActor * create_track_info (RBShell *shell) { RBShellPlayer *player; RhythmDB *db; ClutterActor *box; ClutterActor *box2; ClutterActor *widget; ClutterActor *frame; RhythmDBEntry *entry; GValue *value; guint elapsed; g_object_get (shell, "shell-player", &player, "db", &db, NULL); entry = rb_shell_player_get_playing_entry (player); box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_HORIZONTAL); mx_box_layout_set_spacing (MX_BOX_LAYOUT (box), 16); mx_stylable_set_style_class (MX_STYLABLE (box), "TrackInfoBox"); mx_stylable_set_style (MX_STYLABLE (box), style); /* XXX rtl? */ /* image container */ frame = mx_frame_new (); mx_stylable_set_style_class (MX_STYLABLE (frame), "TrackInfoImage"); mx_stylable_set_style (MX_STYLABLE (frame), style); mx_box_layout_add_actor (MX_BOX_LAYOUT (box), frame, 0); clutter_container_child_set (CLUTTER_CONTAINER (box), frame, "expand", FALSE, NULL); set_blank_image (MX_FRAME (frame)); clutter_actor_show_all (CLUTTER_ACTOR (frame)); g_signal_connect_object (player, "playing-song-changed", G_CALLBACK (cover_art_entry_changed_cb), frame, 0); request_cover_art (MX_FRAME (frame), entry); box2 = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box2), MX_ORIENTATION_VERTICAL); mx_box_layout_set_spacing (MX_BOX_LAYOUT (box2), 16); mx_stylable_set_style (MX_STYLABLE (box2), style); mx_box_layout_add_actor (MX_BOX_LAYOUT (box), box2, 1); clutter_container_child_set (CLUTTER_CONTAINER (box), box2, "expand", TRUE, "x-fill", TRUE, "y-fill", TRUE, "y-align", MX_ALIGN_MIDDLE, NULL); /* track info */ widget = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (widget), "TrackInfoText"); mx_stylable_set_style (MX_STYLABLE (widget), style); mx_box_layout_add_actor (MX_BOX_LAYOUT (box2), widget, 1); clutter_container_child_set (CLUTTER_CONTAINER (box2), widget, "expand", FALSE, "x-fill", TRUE, "y-fill", TRUE, "y-align", MX_ALIGN_MIDDLE, NULL); g_signal_connect_object (player, "playing-song-changed", G_CALLBACK (playing_song_changed_cb), widget, 0); g_signal_connect_object (db, "entry-changed", G_CALLBACK (entry_changed_cb), widget, 0); g_signal_connect_object (db, "entry-extra-metadata-notify::" RHYTHMDB_PROP_STREAM_SONG_TITLE, G_CALLBACK (streaming_title_notify_cb), widget, 0); value = rhythmdb_entry_request_extra_metadata (db, entry, RHYTHMDB_PROP_STREAM_SONG_TITLE); if (value != NULL) { update_track_info (MX_LABEL (widget), db, entry, g_value_get_string (value)); g_value_unset (value); g_free (value); } else { update_track_info (MX_LABEL (widget), db, entry, NULL); } /* elapsed/duration */ widget = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (widget), "TrackTimeText"); mx_stylable_set_style (MX_STYLABLE (widget), style); mx_box_layout_add_actor (MX_BOX_LAYOUT (box2), widget, 2); clutter_container_child_set (CLUTTER_CONTAINER (box2), widget, "expand", FALSE, "x-fill", TRUE, "y-fill", TRUE, "y-align", MX_ALIGN_MIDDLE, NULL); g_signal_connect_object (player, "elapsed-changed", G_CALLBACK (elapsed_changed_cb), widget, 0); if (rb_shell_player_get_playing_time (player, &elapsed, NULL)) { update_elapsed (widget, player, elapsed); } rhythmdb_entry_unref (entry); g_object_unref (player); g_object_unref (db); return box; }
bool Pipeline::isIdle() { gboolean result = FALSE; g_object_get(camerabin, "idle", &result, NULL); return (TRUE == result); }
static void bt_settings_page_interaction_controller_init_ui (const BtSettingsPageInteractionController * self, GtkWidget * pages) { GtkWidget *label, *widget, *scrolled_window; GtkCellRenderer *renderer; GtkTreeViewColumn *tree_col; GtkTreeSelection *tree_sel; BtIcRegistry *ic_registry; gchar *str; gtk_widget_set_name (GTK_WIDGET (self), "interaction controller settings"); // create the widget already so that we can set the initial text self->priv->message = GTK_LABEL (gtk_label_new (NULL)); g_object_set (GTK_WIDGET (self->priv->message), "hexpand", TRUE, NULL); // add setting widgets label = gtk_label_new (NULL); str = g_strdup_printf ("<big><b>%s</b></big>", _("Interaction Controller")); gtk_label_set_markup (GTK_LABEL (label), str); g_free (str); g_object_set (label, "xalign", 0.0, NULL); gtk_grid_attach (GTK_GRID (self), label, 0, 0, 3, 1); gtk_grid_attach (GTK_GRID (self), gtk_label_new (" "), 0, 1, 1, 3); label = gtk_label_new (_("Device")); g_object_set (label, "xalign", 1.0, NULL); gtk_grid_attach (GTK_GRID (self), label, 1, 1, 1, 1); widget = gtk_combo_box_new (); self->priv->device_menu = GTK_COMBO_BOX (widget); renderer = gtk_cell_renderer_text_new (); gtk_cell_renderer_set_fixed_size (renderer, 1, -1); gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self->priv->device_menu), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self->priv->device_menu), renderer, "text", DEVICE_MENU_LABEL, NULL); // get list of devices from libbtic and listen to changes g_object_get (self->priv->app, "ic-registry", &ic_registry, NULL); g_signal_connect_object (ic_registry, "notify::devices", G_CALLBACK (on_ic_registry_devices_changed), (gpointer) self, 0); g_object_unref (ic_registry); g_object_set (widget, "hexpand", TRUE, "margin-left", LABEL_PADDING, NULL); gtk_grid_attach (GTK_GRID (self), widget, 2, 1, 1, 1); g_signal_connect (widget, "changed", G_CALLBACK (on_device_menu_changed), (gpointer) self); // add list of controllers (updated when selecting a device) scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_ETCHED_IN); self->priv->controller_list = GTK_TREE_VIEW (gtk_tree_view_new ()); g_object_set (self->priv->controller_list, "enable-search", FALSE, "rules-hint", TRUE, NULL); // have this first as the last column gets the remaining space (always :/) renderer = gtk_cell_renderer_toggle_new (); gtk_tree_view_insert_column_with_attributes (self->priv->controller_list, -1, _("In use"), renderer, "active", CONTROLLER_LIST_USED, NULL); self->priv->id_renderer = renderer = gtk_cell_renderer_text_new (); //gtk_cell_renderer_set_fixed_size (renderer, 1, -1); gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1); g_signal_connect (renderer, "edited", G_CALLBACK (on_control_name_edited), (gpointer) self); if ((tree_col = gtk_tree_view_column_new_with_attributes (_("Controller"), renderer, "text", CONTROLLER_LIST_LABEL, NULL)) ) { g_object_set (tree_col, "expand", TRUE, NULL); gtk_tree_view_insert_column (self->priv->controller_list, tree_col, -1); } else GST_WARNING ("can't create treeview column"); tree_sel = gtk_tree_view_get_selection (self->priv->controller_list); gtk_tree_selection_set_mode (tree_sel, GTK_SELECTION_BROWSE); g_signal_connect (tree_sel, "changed", G_CALLBACK (on_control_selected), (gpointer) self); gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (self->priv->controller_list)); g_object_set (GTK_WIDGET (scrolled_window), "hexpand", TRUE, "vexpand", TRUE, "margin-left", LABEL_PADDING, NULL); gtk_grid_attach (GTK_GRID (self), GTK_WIDGET (scrolled_window), 1, 2, 2, 1); // add a message pane #if ! defined(USE_GUDEV) && ! defined(USE_ALSA) gtk_label_set_text (self->priv->message, _("This package has been built without GUdev and Alsa support and thus " "supports no interaction controllers.")); #endif gtk_grid_attach (GTK_GRID (self), GTK_WIDGET (self->priv->message), 0, 3, 3, 1); // listen to page changes g_signal_connect ((gpointer) pages, "notify::page", G_CALLBACK (on_page_switched), (gpointer) self); // initial refresh on_ic_registry_devices_changed (ic_registry, NULL, (gpointer) self); }