Changeset 74 for mh-shot-tool
- Timestamp:
- 10/26/07 21:01:02 (1 year ago)
- Files:
-
- mh-shot-tool/trunk/Makefile (modified) (2 diffs)
- mh-shot-tool/trunk/debian/changelog (modified) (1 diff)
- mh-shot-tool/trunk/debian/mh-shot-tool.postinst (added)
- mh-shot-tool/trunk/debian/mh-shot-tool.postrm (added)
- mh-shot-tool/trunk/shot.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
mh-shot-tool/trunk/Makefile
r73 r74 48 48 else pkg-config gtk+-2.0 --cflags; fi) 49 49 mh_shot_tool_LDFLAGS += $(shell if pkg-config hildon-1 --exists; then pkg-config hildon-1 --libs; elif pkg-config hildon-libs --exists; then pkg-config hildon-libs --libs; else pkg-config gtk+-2.0 --libs; fi) 50 mh_shot_tool_CFLAGS += $(shell if pkg-config dbus-1 mce --exists; then \ 51 pkg-config dbus-1 mce --cflags; echo -DMCE; fi) 52 mh_shot_tool_LDFLAGS += $(shell if pkg-config dbus-1 mce --exists; then \ 53 pkg-config dbus-1 mce --libs; fi) 50 54 51 55 mh_shot_tool_CFLAGS += `pkg-config gtk+-2.0 libsoup-2.2 libosso gconf-2.0 --cflags` \ … … 74 78 @$(MAKE) LIBDIR="$(LIBDIR)" PLUGINDIR="$(PLUGINDIR)" -s PART="$(patsubst %.build,%,$@)" $(patsubst %.build,%,$@) 75 79 76 %.lo: %.c $($(call CLEAN,${PART})_HEADERS) 80 %.lo: %.c $($(call CLEAN,${PART})_HEADERS) Makefile 77 81 @echo -n " Building $@..." 78 82 @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) $($(call CLEAN,${PART})_CFLAGS) -c $< -o $@ mh-shot-tool/trunk/debian/changelog
r73 r74 1 mh-shot-tool (0.0.5) mistral; urgency=low 2 3 * Blink the led while waiting for re-grab. 4 5 -- Santtu Lakkala <inz@inz.fi> Fri, 26 Oct 2007 21:00:30 +0300 6 1 7 mh-shot-tool (0.0.4) mistral; urgency=low 2 8 mh-shot-tool/trunk/shot.c
r73 r74 25 25 #else 26 26 # define HILDON_MARGIN_DEFAULT 5 27 #endif 28 #ifdef MCE 29 # include <mce/dbus-names.h> 27 30 #endif 28 31 … … 311 314 }; 312 315 316 static void _quit_loop(SoupMessage *message, gpointer loop) 317 { 318 (void)message; 319 g_main_loop_quit(loop); 320 } 321 322 static gboolean _pulse(gpointer data) 323 { 324 gtk_progress_bar_pulse(data); 325 return TRUE; 326 } 327 313 328 static gboolean flickr_save(GdkPixbuf *buf, GtkWindow *parent, 314 329 osso_context_t *osso) … … 329 344 time_t now = time(NULL); 330 345 struct tm times; 346 GMainLoop *loop; 347 GtkWidget *banner; 348 GtkWidget *pbar; 349 guint timer; 331 350 332 351 localtime_r(&now, ×); 333 352 strftime(buffer, 1023, "shot-%Y-%m-%d-%H-%M-%S.png", ×); 334 353 335 session = soup_session_ sync_new();354 session = soup_session_async_new(); 336 355 msg = flickr_soup_call("flickr.auth.getFrob", 337 356 API_SECRET, … … 420 439 form_multipart_builder_to_message(builder, message); 421 440 422 soup_session_send_message(session, message); 441 loop = g_main_loop_new(NULL, FALSE); 442 pbar = gtk_progress_bar_new(); 443 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(pbar)); 444 banner = hildon_banner_show_progress(GTK_WIDGET(parent), 445 GTK_PROGRESS_BAR(pbar), 446 "Uploading..."); 447 timer = g_timeout_add(200, _pulse, pbar); 448 soup_session_queue_message(session, message, _quit_loop, loop); 449 g_main_loop_run(loop); 450 g_main_loop_unref(loop); 451 g_source_remove(timer); 452 gtk_widget_destroy(banner); 423 453 return TRUE; 424 454 } … … 508 538 GtkWidget *window; 509 539 GtkWidget *spinner; 540 GConfClient *gc; 541 #ifdef MCE_ACTIVATE_LED_PATTERN 542 GtkWidget *cbox; 543 DBusConnection *conn; 544 #endif 510 545 }; 511 546 … … 513 548 { 514 549 GdkPixbuf *thumb; 550 551 #ifdef MCE_ACTIVATE_LED_PATTERN 552 const gchar *pattern_name = "PatternCaptureFast"; 553 DBusMessage *msg; 554 if (grab->conn) { 555 msg = dbus_message_new_method_call(MCE_SERVICE, 556 MCE_REQUEST_PATH, 557 MCE_REQUEST_IF, 558 MCE_DEACTIVATE_LED_PATTERN); 559 560 dbus_message_append_args(msg, 561 DBUS_TYPE_STRING, &pattern_name, 562 DBUS_TYPE_INVALID); 563 dbus_connection_send(grab->conn, msg, NULL); 564 dbus_message_unref(msg); 565 dbus_connection_flush(grab->conn); 566 dbus_connection_unref(grab->conn); 567 grab->conn = NULL; 568 } 569 #endif 570 515 571 grab->buf = gdk_pixbuf_get_from_drawable(NULL, 516 572 GDK_DRAWABLE(gdk_get_default_root_window()), … … 534 590 } 535 591 592 #ifdef MCE_ACTIVATE_LED_PATTERN 593 static gboolean _enable_slow_pattern(gpointer connection) 594 { 595 const gchar *pattern_name = "PatternCaptureSlow"; 596 DBusMessage *msg; 597 msg = dbus_message_new_method_call(MCE_SERVICE, 598 MCE_REQUEST_PATH, 599 MCE_REQUEST_IF, 600 MCE_ACTIVATE_LED_PATTERN); 601 602 dbus_message_append_args(msg, 603 DBUS_TYPE_STRING, &pattern_name, 604 DBUS_TYPE_INVALID); 605 dbus_connection_send(connection, msg, NULL); 606 dbus_message_unref(msg); 607 dbus_connection_flush(connection); 608 609 return FALSE; 610 } 611 612 static gboolean _enable_fast_pattern(gpointer connection) 613 { 614 const gchar *pattern_name = "PatternCaptureSlow"; 615 DBusMessage *msg; 616 msg = dbus_message_new_method_call(MCE_SERVICE, 617 MCE_REQUEST_PATH, 618 MCE_REQUEST_IF, 619 MCE_DEACTIVATE_LED_PATTERN); 620 621 dbus_message_append_args(msg, 622 DBUS_TYPE_STRING, &pattern_name, 623 DBUS_TYPE_INVALID); 624 dbus_connection_send(connection, msg, NULL); 625 dbus_message_unref(msg); 626 dbus_connection_flush(connection); 627 628 msg = dbus_message_new_method_call(MCE_SERVICE, 629 MCE_REQUEST_PATH, 630 MCE_REQUEST_IF, 631 MCE_ACTIVATE_LED_PATTERN); 632 pattern_name = "PatternCaptureFast"; 633 634 dbus_message_append_args(msg, 635 DBUS_TYPE_STRING, &pattern_name, 636 DBUS_TYPE_INVALID); 637 dbus_connection_send(connection, msg, NULL); 638 dbus_message_unref(msg); 639 dbus_connection_flush(connection); 640 641 return FALSE; 642 } 643 #endif 644 536 645 static void _regrab(GtkWidget *button, struct GrabbedData *grab) 537 646 { 647 gdouble t = gtk_spin_button_get_value(GTK_SPIN_BUTTON(grab->spinner)); 648 #ifdef MCE_ACTIVATE_LED_PATTERN 649 gint secs = t; 650 gboolean use_led; 651 grab->conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); 652 #endif 538 653 (void)button; 539 654 540 655 g_object_unref(grab->buf); 541 g_timeout_add(gtk_spin_button_get_value(GTK_SPIN_BUTTON(grab->spinner)) * 1000, 656 #ifdef MCE_ACTIVATE_LED_PATTERN 657 use_led = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(grab->cbox)); 658 gconf_client_set_bool(grab->gc, 659 "/system/osso/dsm/leds/PatternCaptureSlow", 660 use_led, 661 NULL); 662 gconf_client_set_bool(grab->gc, 663 "/system/osso/dsm/leds/PatternCaptureFast", 664 use_led, 665 NULL); 666 if (t >= 2) { 667 g_timeout_add((t - secs) * 1000, 668 _enable_slow_pattern, 669 grab->conn); 670 } 671 g_timeout_add((t - 1) * 1000, 672 _enable_fast_pattern, 673 grab->conn); 674 #endif 675 g_timeout_add(t * 1000, 542 676 (GSourceFunc)do_grab, 543 677 grab); … … 547 681 int main(int argc, char **argv) 548 682 { 549 GConfClient *gc;550 683 struct GrabbedData grab; 551 684 GtkWidget *combo; … … 557 690 gint ret = GTK_RESPONSE_NONE; 558 691 gchar *last_handler; 692 #ifdef MCE_ACTIVATE_LED_PATTERN 693 gboolean use_led; 694 #endif 559 695 560 696 g_set_application_name("MH Shot Tool"); 561 697 g_thread_init(NULL); 562 698 gtk_init(&argc, &argv); 699 700 memset(&grab, 0, sizeof(grab)); 563 701 564 702 osso = osso_initialize("org.MaemoHackers.MhShotTool", "0.0.1", … … 586 724 gtk_box_pack_start(GTK_BOX(hbox), grab.spinner, FALSE, FALSE, 0); 587 725 gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new("second interval"), FALSE, FALSE, 0); 588 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); 726 727 grab.gc = gconf_client_get_default(); 728 #ifdef MCE_ACTIVATE_LED_PATTERN 729 use_led = gconf_client_get_bool(grab.gc, 730 "/system/osso/dsm/leds/PatternCaptureSlow", 731 NULL); 732 grab.cbox = gtk_check_button_new_with_label("Use led"); 733 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(grab.cbox), use_led); 734 gtk_box_pack_start(GTK_BOX(hbox), grab.cbox, FALSE, FALSE, 0); 735 #endif 736 gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0); 589 737 590 738 hbox = gtk_hbutton_box_new(); … … 600 748 gtk_container_add(GTK_CONTAINER(hbox), button); 601 749 602 gc = gconf_client_get_default(); 603 last_handler = gconf_client_get_string(gc, 750 last_handler = gconf_client_get_string(grab.gc, 604 751 "/apps/mh-shot-tool/handler", 605 752 NULL); … … 616 763 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); 617 764 618 gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, TRUE, 0);765 gtk_box_pack_start(GTK_BOX(vbox), combo, TRUE, TRUE, 0); 619 766 gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, TRUE, 0); 620 767 gtk_container_add(GTK_CONTAINER(grab.window), vbox); … … 629 776 i = gtk_combo_box_get_active(GTK_COMBO_BOX(combo)); 630 777 handlers[i].save(grab.buf, GTK_WINDOW(grab.window), osso); 631 gconf_client_set_string(g c,778 gconf_client_set_string(grab.gc, 632 779 "/apps/mh-shot-tool/handler", 633 780 handlers[i].name, … … 639 786 } 640 787 g_object_unref(grab.buf); 641 g_object_unref(g c);788 g_object_unref(grab.gc); 642 789 g_free(last_handler); 643 790 osso_deinitialize(osso);
