void scroller::draw_first(image *screen) { if (sx >= t) sx = t - 1; draw(0, screen); screen->widget_bar(b1x(), b1y(), b1x() + bw() - 1, b1y() + bh() - 1, wm->bright_color(), wm->medium_color(), wm->dark_color()); screen->widget_bar(b2x(), b2y(), b2x() + bw() - 1, b2y() + bh() - 1, wm->bright_color(), wm->medium_color(), wm->dark_color()); show_icon(screen, b1x() + 2, b1y() + 2, bw() - 4, bh() - 4, b1()); show_icon(screen, b2x() + 2, b2y() + 2, bw() - 4, bh() - 4, b2()); int x1, y1, x2, y2; dragger_area(x1, y1, x2, y2); screen->bar(x1, y1, x2, y2, wm->black()); screen->bar(x1 + 1, y1 + 1, x2 - 1, y2 - 1, wm->medium_color()); draw_widget(screen, 0); scroll_event(sx, screen); }
static void on_configure_response(G_GNUC_UNUSED GtkDialog *dialog, gint response, G_GNUC_UNUSED gpointer user_data) { if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) { GKeyFile *config = g_key_file_new(); gchar *config_dir = g_path_get_dirname(config_file); gboolean configure_toogle_status; g_free(mailer); mailer = g_strdup(gtk_entry_get_text(GTK_ENTRY(pref_widgets.entry))); configure_toogle_status = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pref_widgets.checkbox_icon_to_toolbar)); if (icon_in_toolbar ^ configure_toogle_status) /* Only do anything if a status change is needed */ { if (icon_in_toolbar == TRUE) { /* We need to remove the toolbar icon */ cleanup_icon(); } else { /* We need to show the toolbar icon */ show_icon(); } } if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(pref_widgets.checkbox_use_addressdialog)) == TRUE) use_address_dialog = TRUE; else use_address_dialog = FALSE; g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL); g_key_file_set_string(config, "tools", "mailer", mailer); g_key_file_set_boolean(config, "tools", "address_usage", use_address_dialog); g_key_file_set_boolean(config, "icon", "show_icon", icon_in_toolbar); if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0) { dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Plugin configuration directory could not be created.")); } else { /* write config to file */ gchar *data = g_key_file_to_data(config, NULL, NULL); utils_write_file(config_file, data); g_free(data); } g_key_file_free(config); g_free(config_dir); } }
static void update_icon_visibility (void) { if (num_adapters_powered == 0) set_icon (FALSE); else set_icon (TRUE); if (show_icon_pref != FALSE) { if (num_adapters_present > 0 || bluetooth_killswitch_has_killswitches (killswitch) != FALSE) { show_icon (); return; } } hide_icon (); }
static void update_icon_visibility (void) { gboolean state = bluetooth_applet_get_killswitch_state (applet); if (state != BLUETOOTH_KILLSWITCH_STATE_UNBLOCKED) set_icon (FALSE); else set_icon (TRUE); if (state == BLUETOOTH_KILLSWITCH_STATE_NO_ADAPTER) hide_icon (); #ifdef HAVE_APP_INDICATOR else if (!g_settings_get_boolean (gsettings, GSETTINGS_VISIBLE_KEY)) hide_icon (); #endif else show_icon (); }
static void QuotaExceeded(DBusMessage* signal) { int r; DBusMessageIter in_iter; dbus_message_iter_init(signal, &in_iter); const char* str = NULL; r = load_charp(&in_iter, &str); if (r != ABRT_DBUS_LAST_FIELD) { error_msg("dbus signal %s: parameter type mismatch", __func__); return; } //if (m_pSessionDBus->has_name("com.redhat.abrt.gui")) // return; init_applet(); show_icon(applet); show_msg_notification(applet, "%s", str); }
/* Called by Geany to initialize the plugin */ void plugin_init(GeanyData G_GNUC_UNUSED *data) { GKeyFile *config = g_key_file_new(); gchar *kb_label = _("Send file by mail"); GtkWidget *menu_mail = NULL; GeanyKeyGroup *key_group; config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "geanysendmail", G_DIR_SEPARATOR_S, "mail.conf", NULL); /* Initialising options from config file */ g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL); mailer = g_key_file_get_string(config, "tools", "mailer", NULL); address = g_key_file_get_string(config, "tools", "address", NULL); use_address_dialog = g_key_file_get_boolean(config, "tools", "address_usage", NULL); icon_in_toolbar = g_key_file_get_boolean(config, "icon", "show_icon", NULL); g_key_file_free(config); add_stock_item(); if (icon_in_toolbar == TRUE) { show_icon(); } /* Build up menu entry */ menu_mail = gtk_menu_item_new_with_mnemonic(_("_Mail document")); gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_mail); gtk_widget_set_tooltip_text(menu_mail, _("Sends the opened file as unzipped attachment by any mailer from your $PATH")); g_signal_connect(G_OBJECT(menu_mail), "activate", G_CALLBACK(send_as_attachment), NULL); /* setup keybindings */ key_group = plugin_set_key_group(geany_plugin, "sendmail", COUNT_KB, NULL); keybindings_set_item(key_group, SENDMAIL_KB, key_send_as_attachment, 0, 0, "send_file_as_attachment", kb_label, menu_mail); gtk_widget_show_all(menu_mail); ui_add_document_sensitive(menu_mail); main_menu_item = menu_mail; }
/* Called by Geany to initialize the plugin */ void plugin_init(GeanyData G_GNUC_UNUSED *data) { GKeyFile *config = g_key_file_new(); gchar *config_file_old = NULL; gchar *config_dir = NULL; gchar *config_dir_old = NULL; gchar *kb_label = _("Send file by mail"); GtkWidget *menu_mail = NULL; GeanyKeyGroup *key_group; config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "sendmail", G_DIR_SEPARATOR_S, "mail.conf", NULL); #ifndef G_OS_WIN32 /* We try only to move if we are on not Windows platform */ config_file_old = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "geanysendmail", G_DIR_SEPARATOR_S, "mail.conf", NULL); config_dir = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "sendmail", NULL); config_dir_old = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "geanysendmail", NULL); if (g_file_test(config_file_old, G_FILE_TEST_EXISTS)) { if (dialogs_show_question( _("Renamed plugin detected!\n" "\n" "GeanySendMail has been renamed to sendmail -- you surely have " "already recognised it. \n" "Geany is able to migrate your old plugin configuration by " "moving the old configuration file to new location.\n" "Move now?"))) { if (g_rename(config_dir_old, config_dir) == 0) { dialogs_show_msgbox(GTK_MESSAGE_INFO, _("Your configuration directory has been " "successfully moved from \"%s\" to \"%s\"."), config_dir_old, config_dir); } else { /* If there was an error on migrating we need * to load from original one. * When saving new configuration it will go to * new folder so migration should * be implicit. */ g_free(config_file); config_file = g_strdup(config_file_old); dialogs_show_msgbox( GTK_MESSAGE_WARNING, _("Your old configuration directory \"%s\" could " "not be moved to \"%s\" (%s). " "Please move manually the directory to the new location."), config_dir_old, config_dir, g_strerror(errno)); } } } g_free(config_dir_old); g_free(config_dir); g_free(config_file_old); #endif /* Initialising options from config file */ g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL); mailer = g_key_file_get_string(config, "tools", "mailer", NULL); address = g_key_file_get_string(config, "tools", "address", NULL); use_address_dialog = g_key_file_get_boolean(config, "tools", "address_usage", NULL); icon_in_toolbar = g_key_file_get_boolean(config, "icon", "show_icon", NULL); g_key_file_free(config); add_stock_item(); if (icon_in_toolbar == TRUE) { show_icon(); } /* Build up menu entry */ menu_mail = gtk_menu_item_new_with_mnemonic(_("_Mail document")); gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_mail); gtk_widget_set_tooltip_text(menu_mail, _("Sends the opened file as unzipped attachment by any mailer from your $PATH")); g_signal_connect(G_OBJECT(menu_mail), "activate", G_CALLBACK(send_as_attachment), NULL); /* setup keybindings */ key_group = plugin_set_key_group(geany_plugin, "sendmail", COUNT_KB, NULL); keybindings_set_item(key_group, SENDMAIL_KB, key_send_as_attachment, 0, 0, "send_file_as_attachment", kb_label, menu_mail); gtk_widget_show_all(menu_mail); ui_add_document_sensitive(menu_mail); main_menu_item = menu_mail; }
static void Crash(DBusMessage* signal) { int r; DBusMessageIter in_iter; dbus_message_iter_init(signal, &in_iter); /* 1st param: package */ const char* package_name = NULL; r = load_charp(&in_iter, &package_name); /* 2nd param: dir */ //dir parameter is not used for now, use is planned in the future if (r != ABRT_DBUS_MORE_FIELDS) { error_msg("dbus signal %s: parameter type mismatch", __func__); return; } const char* dir = NULL; r = load_charp(&in_iter, &dir); /* Optional 3rd param: uid */ const char* uid_str = NULL; if (r == ABRT_DBUS_MORE_FIELDS) { r = load_charp(&in_iter, &uid_str); } if (r != ABRT_DBUS_LAST_FIELD) { error_msg("dbus signal %s: parameter type mismatch", __func__); return; } if (uid_str != NULL) { char *end; errno = 0; unsigned long uid_num = strtoul(uid_str, &end, 10); if (errno || *end != '\0' || uid_num != getuid()) { return; } } const char* message = _("A crash in the %s package has been detected"); if (package_name[0] == '\0') message = _("A crash has been detected"); init_applet(); //applet->AddEvent(uid, package_name); set_icon_tooltip(applet, message, package_name); show_icon(applet); /* If this crash seems to be repeating, do not annoy user with popup dialog. * (The icon in the tray is not suppressed) */ static time_t last_time = 0; static char* last_package_name = NULL; static char* last_dir = NULL; time_t cur_time = time(NULL); if (last_package_name && strcmp(last_package_name, package_name) == 0 && last_dir && strcmp(last_dir, dir) == 0 && (unsigned)(cur_time - last_time) < 2 * 60 * 60 ) { log_msg("repeated crash in %s, not showing the notification", package_name); return; } last_time = cur_time; free(last_package_name); last_package_name = xstrdup(package_name); free(last_dir); last_dir = xstrdup(dir); show_crash_notification(applet, dir, message, package_name); }
// Move the player void PLAYER::move() { #ifndef EDITOR int who = (this == &p1) ? 1 : 2; int who2 = who-1; // Used for array indices // Reduce the icon alpha if(p_icon_alpha[who2]) { p_icon_alpha[who2] -= 0.005f; if(p_icon_alpha[who2] < 0.0f) p_icon_alpha[who2] = 0.0f; } // If we're dead, reduce the death counter and respawn if(!alive) { death_counter--; if(death_counter == 0) { // Respawn to a block int ox, oy; get_respawn_position((int)get_real_x(), (int)get_real_y(), ox, oy); int odir = dir; //clear(); alive = true; x = ox; y = oy; dir = odir; nextdir = dir; tx = x; ty = y; walking = false; jumping = false; dying = false; offset = 0.0f; create_teleport_effect(x, y); show_icon(who2); // Play the appear sound play_sound(SND_APPEAR, false); } return; } // Advance the dying animation if we're actually dying if(dying) { die_anim -= 0.03f; // Create the blue "burning down" effect float px = get_real_x(); float py = get_real_y(); for(int f=0; f < RAND(2,10); f++) { float rnd = RANDF(-0.3f, 0.3f); VECT pos(px, 2*size - 0.05f - (2.5f*size*(1-die_anim)), py); pos.x += rnd; pos.z -= rnd; if(pos.y < 0.0f) pos.y = 0.0f; VECT dir = 0.0f; float c1[4] = { 0.1f, 0.7f, 1, 1 }; float c2[4] = { 0.1f, 0.7f, 1, 0 }; add_particle(pos, dir, RAND(20,35), 0.1f, 0.4f, c1, c2, part_star); } if(die_anim < 0.0f) { die_anim = 0.0f; alive = false; // Explode the player bombs if(num_bombs > 0) { list<BOMB>::iterator b; for(b = bomblist.begin(); b != bomblist.end(); ++b) if((*b).owner == who && (*b).time > 1) (*b).time = 1; // Makes the bomb explode on the next cycle } } return; } // Jumping stuff if(jumping) { jump_pos += jump_speed; if(jump_pos >= 1.0f) { jump_pos = 1.0f; // We're now on the target tile x = jump_tx; y = jump_ty; tx = x; ty = y; offset = 0.0f; jumping = false; } // Create some particles if we're teleporting if(in_teleport && jumping) { VECT pos(get_real_x(), 0.25f, get_real_y()); pos += jump_dir * jump_pos * jump_dist; pos.y += jump_height * SIN(180.0f * jump_pos); VECT dir; for(int f=0; f<5; f++) { VECT ppos = pos + VECT(RANDF(-0.5f,0.5f),RANDF(-0.5f,0.5f),RANDF(-0.5f,0.5f)); dir.x = dir.y = dir.z = 0.0f; float c1[4] = { 0.3, 0.7f, 1, 1 }; float c2[4] = { 0, 0, 1, 0 }; add_particle(ppos, dir, RAND(10,30), 0.1f, 0.3f, c1, c2, part_teleport); } } // This is a dirty hack. Read the comments from the beginning of this file. if(map[jump_tx][jump_ty][1] && jump_pos > 0.9f) { players_on_block_x[who2] = jump_tx; players_on_block_y[who2] = jump_ty; } return; } // This is a dirty hack. Read the comments from the beginning of this file. if(map[x][y][1]) { players_on_block_x[who2] = x; players_on_block_y[who2] = y; //return; } else { players_on_block_x[who2] = -1; } // Don't move if we're using the napalm or the teleport power if(using_special_power && (which_special_power == RED_POWER_NAPALM)) return; if(using_special_power == who && (which_special_power == BLUE_POWER_TELEPORT)) return; // Don't move if the level is finished if(level_pause) return; // Advance the animation anim += 0.20f; if((int)anim > 3) anim = 0.0f; // Advance the turning animation if(turning) { turning_counter++; if(turning_counter == 5) { dir = nextdir; nextdir = dir + 1; if(nextdir > DIR_W) nextdir = DIR_N; } else if(turning_counter == 10) { dir = nextdir; turning = false; } } if(!walking && ((config.moving_style[who2] == MOV_RELATIVE && !key[config.key_up[who2]]) || (config.moving_style[who2] == MOV_ABSOLUTE && !key[config.key_up[who2]] && !key[config.key_down[who2]] && !key[config.key_left[who2]] && !key[config.key_right[who2]]))) anim = 0.0f; // Check if we're on a block bool on_block = false; if(map_solid(x,y)) on_block = true; // Don't move if we're using the flower power (absolute) if(on_block && config.moving_style[who2] == MOV_ABSOLUTE && (p1.num_flower_bombs > 0 || p2.num_flower_bombs > 0)) return; // Check for turning input if(key[config.key_left[who2]]) { if(config.moving_style[who2] == MOV_RELATIVE) { // Relative moving if(!turn_key_down[0] && !turning) { // Turn left nextdir = dir - 1; if(nextdir < DIR_N) nextdir = DIR_W; if(!walking) dir = nextdir; turn_key_down[0] = true; } } else if(config.moving_style[who2] == MOV_ABSOLUTE && !walking) { // Absolute moving dir = DIR_W; walking = true; offset = 0.0f; tx = x - 1; ty = y; // Check if the target is passable? if(map_solid(tx, ty)) { tx = x; ty = y; walking = false; } if(on_block) { // We're on a block, jump down from it jump(tx, ty, 2.0f, 0.05f); tx = x; ty = y; anim = 0; on_block = true; // Play the jumping sound if(jumping) play_sound(SND_JUMP, false); } } } else turn_key_down[0] = false; if(key[config.key_right[who2]]) { if(config.moving_style[who2] == MOV_RELATIVE) { // Relative moving if(!turn_key_down[1] && !turning) { // Turn right nextdir = dir + 1; if(nextdir > DIR_W) nextdir = DIR_N; if(!walking) dir = nextdir; turn_key_down[1] = true; } } else if(config.moving_style[who2] == MOV_ABSOLUTE && !walking) { // Absolute moving dir = DIR_E; walking = true; offset = 0.0f; tx = x + 1; ty = y; // Check if the target is passable? if(map_solid(tx, ty)) { tx = x; ty = y; walking = false; } if(on_block) { // We're on a block, jump down from it jump(tx, ty, 2.0f, 0.05f); tx = x; ty = y; anim = 0; on_block = true; // Play the jumping sound if(jumping) play_sound(SND_JUMP, false); } } } else turn_key_down[1] = false; // Check for 180 degree turning if(key[config.key_down[who2]]) { if(config.moving_style[who2] == MOV_RELATIVE) { // Relative moving if(!turn_key_down[2] && !turning && !walking && !key[config.key_up[who2]]) { nextdir = dir + 1; if(nextdir > DIR_W) nextdir = DIR_N; turning = true; turning_counter = 0; turn_key_down[2] = true; } } else if(config.moving_style[who2] == MOV_ABSOLUTE && !walking) { // Absolute moving dir = DIR_S; walking = true; offset = 0.0f; tx = x; ty = y + 1; // Check if the target is passable? if(map_solid(tx, ty)) { tx = x; ty = y; walking = false; } if(on_block) { // We're on a block, jump down from it jump(tx, ty, 2.0f, 0.05f); tx = x; ty = y; anim = 0; on_block = true; // Play the jumping sound if(jumping) play_sound(SND_JUMP, false); } } } else turn_key_down[2] = false; // Don't move if we're using the flower power (relative) if(on_block && config.moving_style[who2] == MOV_RELATIVE && (p1.num_flower_bombs > 0 || p2.num_flower_bombs > 0)) return; // Check for walking input if(key[config.key_up[who2]] && !walking && !turning) { if(config.moving_style[who2] == MOV_RELATIVE) { // Relative moving walking = true; offset = 0.0f; dir = nextdir; switch(dir) { default: case DIR_N: tx = x; ty = y - 1; break; case DIR_E: tx = x + 1; ty = y; break; case DIR_S: tx = x; ty = y + 1; break; case DIR_W: tx = x - 1; ty = y; break; } // Check if the target is passable? if(map_solid(tx, ty)) { tx = x; ty = y; walking = false; } if(on_block) { // We're on a block, jump down from it jump(tx, ty, 2.0f, 0.05f); tx = x; ty = y; anim = 0; on_block = true; // Play the jumping sound if(jumping) play_sound(SND_JUMP, false); } } else { // Absolute moving dir = DIR_N; walking = true; offset = 0.0f; tx = x; ty = y - 1; // Check if the target is passable? if(map_solid(tx, ty)) { tx = x; ty = y; walking = false; } if(on_block) { // We're on a block, jump down from it jump(tx, ty, 2.0f, 0.05f); tx = x; ty = y; anim = 0; on_block = true; // Play the jumping sound if(jumping) play_sound(SND_JUMP, false); } } } // Move towards the target tile if(offset < 1.0f && (tx != x || ty != y)) { offset += 0.1f; // If we're reached the target tile, move again if(offset >= 1.0f) { x = tx; y = ty; offset = 0.0f; walking = false; in_teleport = 0; } } // Reload the weapons if(reload > 0) reload--; // Dropping bombs if(key[config.key_shoot[who2]] && reload == 0 && num_bombs < 3 && !on_block && !icon_menu.wait) { reload = 30; // Plant the bomb add_bomb(x, y, BTYP_NORMAL, who); num_bombs++; // Play the sound play_sound(SND_BOMB, false); } // Invoke the special powers if(key[config.key_special[who2]]) { open_icon_menu(who, on_block); show_icon(0); show_icon(1); } #endif }